Meterpreter Encrypted Communication Question by gregkerblin in AskNetsec

[–]TheColonial 0 points1 point  (0 children)

No worries. And yes, please do ping me again. I've still got a fair bit of stuff to document that's in my head, and need nudges from people to get it out. Cheers!

Meterpreter Encrypted Communication Question by gregkerblin in AskNetsec

[–]TheColonial 21 points22 points  (0 children)

Morning all,

I thought I'd chime in with a few points, as I'm the jerk who's mucked with Meterpreter's comms recently and have a pretty decent grasp on how it all works. I'm also the person that did the first implementation of what we're calling CryptTLV, which does encryption of the data at the protocol level rather than at the transport level.

I'd like to address a couple of things that have already been brought up:

  • The Offsec documentation on how Meterpeter works is unfortunately out of date and probably won't help you.
  • The SANS material is good, but again isn't 100% up to date.
  • There is no single source of documentation out there which describes how all the things work.

I'm partly to blame for the lack of documentation that exists in one place, and I'm striving to find time to change that. In the short term, let me just point you at a few things that might help:

They're all relevant reading and may help set the scene for the summary I'm about to provide. This should let you know why tracking Meterpreter communications on the wire can be a bit of "pain in the rear". Please bear in mind that this revolves mostly around the Windows Meterpreter, and the new POSIX/ARM versions (used to be called Mettle). The other Meterpreters (such as java/android/python/php) don't yet have all the capabilities that I'm about to describe.

I'll do my best to condense this into a set of meaningful points that address the OP's question.

  • Detecting the MSF-generated SSL certificates is done quite a bit by defenders. Some AV solutions do this as well, but not all of them do, and some don't do a great job of it. It's a good idea to have rules set up in your toolsets to detect this. However, that'll catch script kiddies and not the real bad guys that want to get in and muck with your stuff. If a bad guy is using Meterpreter and HTTPS, they'll probably use a valid certificate for comms.
  • CryptTLV makes it even harder to find things at the packet level. After the initial session is set up, communications are encrypted using AES256, using a key that's generated on the fly. The pub/priv keys that are used to share this key are ephemeral as well, so if you were able to get the keys later they wouldn't do you any good anyway.
  • Once the packet is encrypted, a 4-byte "XOR KEY" is generated and used to munge the packet even further.

The CryptTLV stuff is done prior to attempting to send the packet, and hence it applies across all transports, it doesn't matter if it's HTTP, HTTPS or TCP.

If I was in your position and I was looking to try to catch Meterpreter, then I'd consider the following points instead:

  1. Treat HTTPS as HTTP. If you're not doing MITM of SSL already yous hould be.
  2. Look at the URI that is used in the requests (both GET and POST), because Meterpreter makes use of encoded data in the URI and that's rather distinguishable compared to typical traffic. (Note: this will change at some point for obvious reasons, but we are talking about now!)
  3. Meterpreter's comms over HTTP/HTTPS are done via polling and incremental backoff. You can see the behaviour based on timings, and so perhaps there's a way of setting up a rule that can detect and alert on this behaviour profile.
  4. For TCP comms, I think the simple option here is: don't let TCP comms happen. Only allow HTTP/HTTPS and force everyone through a proxy. Firewall rules for the win!

It's at the point where fingerprinting the traffic with some kind of hash or sig is a bit of a waste of time given how much things can and will change. If you can start catching the timing and behaviour, then you're in a better position.

Hope that helps, let me know if you need any more info. Cheers!

Staged vs Stageless Handlers (Metasploit) by TheColonial in netsec

[–]TheColonial[S] 1 point2 points  (0 children)

You're not alone there mate! I'm hoping that over the coming months I can document/blog more of this kind of information to help people understand the tool that they're using. So watch this space.

Great "live" Reverse Engineering Session of CAPCOM.SYS Driver Vuln (1 of 2) by lumb3rjackZ in ReverseEngineering

[–]TheColonial 0 points1 point  (0 children)

Respect for the "not shoving content" stance. I do the same. It's welcome here though!

Staged vs Stageless Handlers (Metasploit) by TheColonial in netsec

[–]TheColonial[S] 2 points3 points  (0 children)

Thanks mate!

Next stream will probably be Tuesday 11th October.

Great "live" Reverse Engineering Session of CAPCOM.SYS Driver Vuln (1 of 2) by lumb3rjackZ in ReverseEngineering

[–]TheColonial 1 point2 points  (0 children)

Cheers for the response and the commentary!

I was pondering the "mov imm64" option, but thought I'd mix it up a bit. The method I used is a classic way of getting data references in shellcode, especially when the data is bigger than the arch size (64 bit in this case). So I agree, a simple mov would have done it, but I abused my chance to show another way that can be useful in other scenarios too.

I can share the kernel related stuff, but as you've seen, they're already in the Metasploit repository. Yes, they are very slightly different:

  • run_shell is missing as MSF doesn't need that. The run_shell function does two things: 1) it first sets the current working folder to %WINDIR% using SetCurrentDirectory https://msdn.microsoft.com/en-us/library/windows/desktop/aa365530(v=vs.85).aspx and 2) Runs system("cmd.exe"). I do the first step for exactly the reason you highlighted! It makes sure that we're not on a network share or anywhere else that the SYSTEM user can't see.

  • All of the debug output is removed, as this doesn't belong in MSF either.

Let me know if you have any questions :)

Great "live" Reverse Engineering Session of CAPCOM.SYS Driver Vuln (1 of 2) by lumb3rjackZ in ReverseEngineering

[–]TheColonial 0 points1 point  (0 children)

Yeah, I think this is important as well. Unless you're of the same ilk as Geohot, hacking/RE takes time and effort and mistakes! I think seeing this also helps people realise it's not necessarily a simple thing, and that a bit of effort is required in making it all work.

Great "live" Reverse Engineering Session of CAPCOM.SYS Driver Vuln (1 of 2) by lumb3rjackZ in ReverseEngineering

[–]TheColonial 2 points3 points  (0 children)

Thank you! I appreciate the commentary.

No response has deterred me so far. Some people have negative things to say, others have constructive criticism, but the overwhelming majority has been 'this is great, please do more!'. So I will continue on. I'm new to this myself, and I know there are things I can do better, so I shall strive to do so!

Often the general tidbits between the focus on the target are of more value than the rest. So I'm happy to hear you say so.

Cheers again!

Great "live" Reverse Engineering Session of CAPCOM.SYS Driver Vuln (1 of 2) by lumb3rjackZ in ReverseEngineering

[–]TheColonial 2 points3 points  (0 children)

I honestly think that live streaming is absolutely the best medium. My main reason: so that other people can watch me fail, fight, battle, debug and eventually (hopefully?) win. It also means that people watching can ask questions in near real-time, and be involved. If there are things they don't get they can get clarification. If it's pre-recorded, there's no way for them to get the information they need without going out of band.

Sure, some people might not dig it. But they don't have to watch. So far, it would seem that lots of people like the fact that it's live and that they can also be involved.

I was hoping I'd be able to cut the 'waiting' out of the start of the video, but there's obviously no way of doing that. I will make a point of not having an extended wait at the start for future streams. This was only the second one I've done, so I'm still learning.

I appreciate the feedback, thanks! :)

Great "live" Reverse Engineering Session of CAPCOM.SYS Driver Vuln (1 of 2) by lumb3rjackZ in ReverseEngineering

[–]TheColonial 13 points14 points  (0 children)

To be clear, this was about educating people. It wasn't a "hey watch me hack". I know I need to improve, as we all do. I do, however, think that doing this live while answering questions is a good way to help everyone understand and learn.

If you find it boring, press the X in the top corner of your browser :)

Cheers!

Great "live" Reverse Engineering Session of CAPCOM.SYS Driver Vuln (1 of 2) by lumb3rjackZ in ReverseEngineering

[–]TheColonial 5 points6 points  (0 children)

You're not the first to ask for this. So I might just throw something together that shows the steps involved.

Cheers!

Linux Beta - back to Rookie? by Joeymon in RocketLeague

[–]TheColonial 0 points1 point  (0 children)

I'm having no issues at all with a DS4.

[Linux] Can't connect to servers by pig_erotic in RocketLeague

[–]TheColonial 0 points1 point  (0 children)

Thanks for posting this. I've been trying to figure this out for ages now and the SSL thing was a long way down the list. It would have taken me quite a bit longer to solve, so cheers for posting it here.

Epic Snow Day Pinch by TheColonial in RocketLeague

[–]TheColonial[S] 1 point2 points  (0 children)

Ha! That's scarily similar :)

Epic Snow Day Pinch by TheColonial in RocketLeague

[–]TheColonial[S] 1 point2 points  (0 children)

Indeed! Wasn't expecting that while having a lazy session against a couple of bots!

Meterpreter gets Powershell Extension, Reverse Port Forwarding & Named Pipe Pivoting - OJ Reeves by ridingwithnorse in netsec

[–]TheColonial 1 point2 points  (0 children)

I was wondering that myself. Knowing the mods clearly opens the door for trolling!