Simple Analysis of an upload function Upload Vulnerability

Source: Internet
Author: User

 

Function fnUploadImg (ByVal upFile As HttpPostedFile, ByVal uploadPath As String) As String Dim result As String = "" Dim intImgSize As Int32 intImgSize = upFile. contentLength If intImgSize <> 0 Then If intImgSize> 500000 Then result = "the image is too large" Return result Exit Function End If Dim strImgType As String = upFile. contentType 'only accepts images in .jpg format: Dim filesplit () As String = Split (strImgType, "/") strImgType = filesplit (filesplit. length-1) If strImgType = "jpg" Or strImgType = "jpeg" Then Else result = "incorrect image format" Return result Exit Function End If filesplit = Split (upFile. fileName, "\") Dim filename As String = filesplit (filesplit. length-1) upFile. saveAs (Server. mapPath ("upload \ location \" & uploadPath) & "\" & filename) dim imgpath As String = "upload/location/" & uploadPath & "/" & filename result = imgpath Return result End If End Function




Breakthrough method: upload arbitrary files, capture packets, and modify Content-Type to: image/jpeg

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.