靶場:
http://hackinglab.cn/ShowQues.php?type=scripts
其中題目很有意思:
http://lab1.xseclab.com/xss2_0d557e6d2a4ac08b749b61473a075be1/index.php
payload:
很簡單,就是寫一個小爬蟲,爬下來裏面數字內容,然後使用eval函數將其計算出來,不過可能很多簡單題目中會使用到這種爬蟲:
import re
from bs4 import BeautifulSoup
import requests
import json
x = "http://lab1.xseclab.com/xss2_0d557e6d2a4ac08b749b61473a075be1/index.php"
session = requests.session() #設置session連接,能保證連接的穩定性
line = session.get(x)
new2 = re.findall(' .+\)',line.text) #提取html流中數據的內容
new3 = new2[0]
new = new3.lstrip() #去掉前面的空格
p = eval(new)
d = dict(v=p) #將要提交的計算結果提交
exp = session.post(x,data=d) #data代表了post傳參
print(exp.text)
踩坑:
其中這種題目要首先看看存不存在session,這個平臺題目都帶有session,所以要使用session方式來建立連接,這樣才能保持連接的穩定性。
另外,進行傳參的時候可以直接傳入字典,不一定非要json化,有的時候甚至會報錯,另外就是re庫正則表達式的使用,要總結一下,最好是用beautifulsoup庫來進行解析,不過沒有正則更加精準一些。