AdSense

Friday, June 10, 2016

METASPLOIT - Windows 7 - Reverse TCP Shell


WINDOWS 7 - REVERSE TCP SHELL


- Layout for this exercise:





- As seen in previous case bind_tcp.exe is detected by Windows Firewall, and its action blocked unless the victim allows it to be run. It happens that firewalls are usually more aware watching INBOUND than OUTBOUND connections. So, for real world scenarios, using payloads working on OUTBOUND connections would be more successful, for instance creating reverse shells from the victim to the attacker. 

- The procedure would be similar than before, with the only difference that now the reverse_tcp would be used:












- As done with previous case, for this example the Windows Firewall is also connected at the victim computer, because the goal is to show how reverse_tcp.exe is not detected and blocked by the normal inbound firewall:






The attacker Kali sets up a web server on port 8000:






- The victim Windows 7 downloads the executable reverse_tcp.exe:













Then, the attacker uses a multihandler exploit and a meterpreter payload, waiting until the victim executes the reverse backdoor. It is important to notice than LHOST option corresponds to the attacker's IP:






- The victim runs reverse_tcp.exe:




















Though the executable is running on the victim, no sign of firewall detection appears:




- At the Kali attacker side a meterpreter session is succesfully achieved, allowing post exploitation of the victim Windows 7:






- However, Windows 7 has also a so called Windows Firewall with Advanced Security, whichs allows to create special rules for OUTBOUND connections. In this specific case, it would be possible to create a rule to block the action of reverse_tcp.exe, because the advanced firewall would detect the executable.

- Let's create a rule which blocks OUTBOUND connections to the remote port 4444 (generally used by Metasploit):









The new rule takes the port as a parameter to be controlled:







- The rule applies to port TCP 4444, remote port used by the attacker Kali with Metasploit:






- The action to be taken by the new rule would be to block the OUTBOUND connection to remote port TCP 4444:






- The rule applies to any type of domain or network location:






- The name for the rule is "Blocking reverse_tcp.exe":













- From the attacker side, a handler is waiting for the client connection:




The victim runs the executable reverse_tcp.exe:









- However, nothing happens in this case because of the presence of the new rule created by the Windows Firewall with Advanced Security, and the attack is unsuccessful:








- Anyway, it is not very usual that System Administrators create OUTBOUND rules on firewalls, so this late case of an specific rule blocking a reverse shell connection is not very common, although desirable, of course.








METASPLOIT - Windows 7 - Bind TCP Shell


WINDOWS 7 - BIND TCP SHELL

- Layout for this exercise:



msfvenom converts Metasploit payloads into executable or binary files. In this case, the 
windows/meterpreter/bind_tcp payload is converted into a Microsoft executable file (.exe) with these options:

-a x86 = architecture x86
-f exe = format executable





- The command file checks that bind_tcp.exe is of PE32 type. PE (Portable Executable) is a file format for executables, object code, DLLs, Font files, and others used in 32 and 64 bits versions of Windows operating systems. 



From the Kali attacker side, a SimpleHTTPServer is run, accepting connections on port 8000:



- The victim Windows 7 connects to the attacker's web server and downloads bind_tcp.exe:







- The client or victim Windows 7 has downloaded bind_tcp.exe, a backdoor that in case of being executed will trigger an undesired Internet connection between attacker and victim.

The attacker detects that bind_tcp.exe has been downloaded on the client side, from IP 192.168.1.14:









Then, the attacker sets up a handler exploit with the payload meterpreter, waiting until the victim runs the executable. The RHOST is the IP 192.168.1.14, corresponding to the victim: 




- On the client side, the victim executes bind_tcp.exe:





- Now, Windows 7 is running bind_tcp.exe:





- As a consequence, on the attacker side a meterpreter session is automatically created by the handler:





- Running netstat on both Windows 7 and Kali shows how a connection has been established between the victim and the attacker:








- However, the bind_tcp.exe executable would be stopped in case of presence of firewall. Let's see what happens if Windows Firewall is "on":






- If the victim runs bind_tcp.exe Windows Firewall immediately detects and blocks its execution:





- Only if the victim clicked Allow access option (which would be unwise) , the executable would be run.

-  The conclusion is that Bind Shell payloads don't work with firewalls, because these programs or devices are usually configured to detect INBOUND connections. The solution would be to use OUTBOUND connections, like those provided by Reverse Shell payloads.







METASPLOIT - Windows 7 - Bypassing User Account Control


WINDOWS 7 - BYPASSING USER ACCOUNT CONTROL



- Layout for this exercise:




- Let's suppose we have a Windows 7 system already exploited:




- From Control Panel -> User Accounts and Family Safety -> User Accounts -> Change User Account Control Settings:




In this case Windows 7 has got the User Account Control (UAC) set to Default level:








- Let's exploit the system with badblue_passthru:




- However, it is not possible to get total control over the system, due to the presence of the UAC:




- Post explotaition cannot be performed:




- To perform good exploitation of UAC, it is recommendable to use processes as much stable as possible. For instance, the current process is badblue.exe:










- It would be a good idea to migrate to a more stable process like explorer.exe:







- To start the process of bypassing UAC, in order to get total control over the victim, the current meterpreter session is put into background mode:





- At the moment, there is only 1 meterpreter session active:




- There is a good exploit to bypass the User Account Control:





- For this exploit, the active meterpreter session is a required option:




- So, session is set to 1:




- Also, reverse_tcp payload is used, with local host the attacker's IP:




- The exploit is launched, and a second meterpreter session is achieved as a result:




- Now, from this second meterpreter session Privilege Escalation is done with no problem. Getting control over the system with authority credentials:





- A good example of post exploitation is the command hashdump, which provides hashes of the passwords:




- Also, smart_hashdump dumps hashes on a file text, for further treatment for instance with John the Ripper:

















METASPLOIT - Windows 7 - Exploitation


WINDOWS 7 - EXPLOITATION


- Layout for this exercise:





- Bad Blue es is File Sharing web service application available for Windows systems that allows users to share files.  

http://www.badblue.com/down.htm


- However, this application suffers from a vulnerability that can be exploited with a stack buffer overflow, affecting the PassThru functionality in ext.dll, for versions 2.72b and earlier:

https://www.exploit-db.com/exploits/16806/


- Once BadBlue downloaded, installed and accepted the License agreement, finally it is working on Windows 7, running on port TCP 80:





- The attacker detects that Bad Blue web server is running on victim's port 80:



















- Searching exploits for BadBlue into the Metasploit Framework:




- Let's try this exploit:






- Options for this exploit are simple:






















- The remote host is set to the victim's IP:





- The exploitation is successful: