iT邦幫忙

2025 iThome 鐵人賽

DAY 18
0
Security

資安小白—30天學習滲透測試with OWASP ZAP (Zed Attack Proxy)系列 第 18

Day18—自動化登入(JWT / Token-Based Auth)

  • 分享至 

  • xImage
  •  

大家好!我目前正在就讀資訊類科系,平常以接觸程式撰寫居多,對於資安領域的技術沒有太多了解/images/emoticon/emoticon16.gif因此希望藉由這30天的機會,以OWASP ZAP作為主要工具,從實際操作和分析,從環境架設、基本掃描到進階弱點發掘,一步步建立資安思維。
  我將學習如何利用ZAP自動化及主動/被動掃描常見的資安漏洞,並理解其背後的原理,以及該如何修復,例如SQL Injection、XSS等,讓我從「資安小白」進化成具備基本滲透測試技能的「資安入門者」。


今日內容概要:

  1. 安裝juice-shop
  2. 對Juice Shop設定Token-based驗證
  3. 在API腳本中自動附加Token

安裝juice-shop(用nvm安裝)

(Juice Shop 19版需要Node.js版本大於22)
在終端機依序輸入下列指令:
sudo apt install curl -y curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash source ~/.bashrc nvm install 22 nvm use 22 cd ~ git clone https://github.com/juice-shop/juice-shop.git cd juice-shop npm install npm run build npm start
最後有顯示info: Server listening on port 3000
就可以打開瀏覽器,輸入juice-shop網址:http://localhost:3000 ,沒意外的話會看到juice-shop的官網!
https://ithelp.ithome.com.tw/upload/images/20251014/201690228KFMMXuNuu.png

對Juice Shop設定Token-based驗證

  1. 首先先在juice shop註冊自己的帳號。
  2. 在終端機輸入:sudo apt install jq
  3. 在終端機輸入:curl -s -X POST 'http://localhost:3000/rest/user/login' -H 'Content-Type: application/json' -d '{"email":"YourEmail","password":"YourPW"}' | jq .
    (localhost、YourEmail、YourPW的部分需要換成自己的)
  4. 成功的話,可以看到系統回傳下列格式的token(如附圖):
    { "authentication": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } }
    https://ithelp.ithome.com.tw/upload/images/20251014/201690226buw6rPqr2.png
  5. 接著,把token存到變數、檔案中,可供ZAP、後續腳本作使用。
    (依序在終端機輸入)
    `TOKEN=$(curl -s -X POST 'http://127.0.0.1:3000/rest/user/login' -H 'Content-Type: application/json' -d '{"email":"admin@juice-sh.op","password":"admin123"}' | jq -r '.authentication.token')

echo $TOKEN
echo "$TOKEN" > /tmp/juice_token.txt
`
6.

在ZAP中建立HTTP Sender Script

在API腳本中自動附加Token


上一篇
Day17—自動化登入流程(Form-Based Auth)
下一篇
Day19—多靶場交叉掃描(bWAPP)
系列文
資安小白—30天學習滲透測試with OWASP ZAP (Zed Attack Proxy)30
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言