生活随笔
收集整理的這篇文章主要介紹了
BugkuCTF-WEB题速度要快
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
此題小結(jié):
用python腳本獲取網(wǎng)頁(yè)內(nèi)容以及post數(shù)據(jù)
主要函數(shù):
s= requests.session()
url=’’
return= s.get(url). # 可以獲取header等信息
data={}
最后傳值:s.post(data=data)
解題流程
打開(kāi)網(wǎng)頁(yè),只看到一句話:我感覺(jué)你得快點(diǎn)!!!
F12查看源代碼
發(fā)現(xiàn)了提示:OK ,now you have to post the margin what you find
需要以POST方式傳參,先用BrupSuite抓包看一下
1、使用BrupSuite抓包并重新發(fā)送
發(fā)送后看到flag
2、使用base64解碼
跑的還不錯(cuò),給你flag吧: MTMyOTIx
3、繼續(xù)進(jìn)行一次base64解碼
4、通過(guò)post方法上傳margin=132921
還要再快點(diǎn),看來(lái)有時(shí)間限制,不過(guò)已經(jīng)有了思路,可以編寫python腳本了
5、編寫python腳本并執(zhí)行
import requests
import base64url
= "http://114.67.246.176:13069"
r
= requests
.session
()
header
= r
.get
(url
).headers mid
= base64
.b64decode
(header
['flag'])
mid
= mid
.decode
() flag
= base64
.b64decode
(mid
.split
(':')[1])
data
= {'margin':flag
}
print(r
.post
(url
,data
).text
)
import requests
import base64url
= "http://120.24.86.145:8002/web6/"
s
= requests
.Session
()
headers
= s
.get
(url
).headers str1
= base64
.b64decode
(headers
['flag'])
str2
= base64
.b64decode
(repr(str1
).split
(':')[1]) key
= {'margin':str2
}
flag
= s
.post
(url
,data
=key
) """
知識(shí)補(bǔ)充:python里的字符串有byte型和str型,有時(shí)操作數(shù)類型和操作類型不匹配就會(huì)報(bào)錯(cuò)
b64decode()結(jié)果是byte型字符串,而split()函數(shù)要為str型字符串
repr()函數(shù)可以將byte型字符串轉(zhuǎn)換成str型字符串
另外,還有一個(gè)簡(jiǎn)單的方法:1、byte型轉(zhuǎn)str型_str=_byte.decode()2、str型轉(zhuǎn)byte型_byte=_str.encode()""""""知識(shí)點(diǎn)
import base64
st = 'hello world!'.encode() #默認(rèn)以u(píng)tf8編碼
res = base64.b64encode(st)
print(res.decode()) #默認(rèn)以u(píng)tf8解碼
res = base64.b64decode(res)
print(res.decode()) #默認(rèn)以u(píng)tf8解碼
輸出
aGVsbG8gd29ybGQh
hello world!""""""
split() 通過(guò)指定分隔符對(duì)字符串進(jìn)行切片,如果第二個(gè)參數(shù) num 有指定值,則分割為 num+1 個(gè)子字符串。
實(shí)例
以下實(shí)例展示了 split() 函數(shù)的使用方法:
str = "this is string example....wow!!!"
print (str.split( )) # 以空格為分隔符
print (str.split('i',1)) # 以 i 為分隔符
print (str.split('w')) # 以 w 為分隔符
以上實(shí)例輸出結(jié)果如下:
['this', 'is', 'string', 'example....wow!!!']
['th', 's is string example....wow!!!']
['this is string example....', 'o', '!!!']以下實(shí)例以 # 號(hào)為分隔符,指定第二個(gè)參數(shù)為 1,返回兩個(gè)參數(shù)列表。
txt = "Google#Runoob#Taobao#Facebook"
# 第二個(gè)參數(shù)為 1,返回兩個(gè)參數(shù)列表
x = txt.split("#", 1)
print(x)
以上實(shí)例輸出結(jié)果如下:
['Google', 'Runoob#Taobao#Facebook']
"""
6、得到flag:flag{dfba848a692f67f6982657e50a13d42e}
總結(jié)
以上是生活随笔為你收集整理的BugkuCTF-WEB题速度要快的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。