Tag Archive for 'obfuscation'

04
Sep

The Chinese Radio Station Problem

The other day I was on a support call with a techie from a vendor that will remain nameless (go ahead… guess!).  We were watching some HTTP packets fly by with tcpdump when he suddenly said, “WTF is that?

“That” was along the lines of this:

http://72.246.30.118/idle/Ga0mdz02wSLOaQ5Q/250
http://72.246.30.118/idle/Gx0mdz02xSLWq-NW/44
http://72.246.30.118/idle/Gx0mdz02xSLWq-NW/121
http://72.246.30.118/idle/Gx0mdz02xSLWq-NW/200
http://72.246.30.118/idle/Gx0mdz02xSLWq-NW/251
http://72.246.30.118/idle/Gx0mdz02xSLWq-NW/310
http://72.246.30.118/idle/Gx0mdz02xSLWq-NW/359
http://72.246.30.118/idle/Gx0mdz02xSLWq-NW/422
http://72.246.30.118/idle/Gx0mdz02xSLWq-NW/481

More or less.  Lots of these suckers.  I see millions of them in my proxy logs every day.

This fellow had never seen these URLs before.  Odd because his company deals with URLs every day.  I just told him to add “not host 72.246.30.118″ to his tcpdump command line and that got rid of it.

Well, the support call eventually ended.  Nothing was resolved, as usual.  But this article is not about him anyway.

That crap is Flash.  The URL never has a hostname.  It’s always an IP address and that address usually belongs to a CDN (Content Distribution Network).  The address above belongs to Akamai.  The second part of the URL is one of open/send/idle.  The third is some sort of content or user or session identifier.  The last part is obviously a sequence number.

If you frequent some sort of Internet Radio station while you’re at work and you play it all day and you leave work with your browser open to that site, you will generate tens of thousands of these URLs.  I’ve seen a single user drop a half a million of these a day.

Now, all you blackhat spooks out there listen up, because this is important.  If you don’t get it already, I’m going to spell it out.

This is a perfect covert channel.

Just faking these URLs offers excellent cover.  The “idle” URLs are all http POSTs.    You can send data out without raising red flags as long as you keep the packet size down.  A single /idle/ URL packs about 215 bytes, but the user will hit a single /idle/ URL 600-700 times, for a total of ~150K.  In the logs, looking for that kind of crap in a multi-user environment boils down to the “needle in a needlestack” problem.

You get the picture.

It gets better if you can do it over a CDN.  This is what I like to call “The Chinese Radio Station Problem”.  It’s a deep pockets hack, because you have to control the server.  The CDN serves to mask the real destination. In my small little mind I see it as something an adversarial government has the resources to do.  Hence, Chinese.

Think about it.  It’s Flash, so there are plenty of known, unknown, and, shall we say,  ”private label” vectors that can be leveraged to add a little some-some to an end-user’s PC.

What that some-some is, is up to you.  You are only limited by your imagination.

If you control the server, the user can still listen to Internet Radio while he sends you his company’s intellectual property.  Logged or not, it still looks like streaming media.

I would conjecture that most companies that block streaming media leave it open for CxOs, which is even better because they get the juiciest details on intellectual property.  You just need to know what kind of media they like.

And for employers who don’t block streaming media, there’s people like Shirley in Accounts Payable, who has all the bank passwords and likes to listen to Christian music all day long.  Double cover.  Anything with “Christian” in it is above suspicion, right?

And what about that Asian dude in Engineering, Tony Lee?  What is he listening to?

Endless opportunity.

09
Aug

More Annoying JavaSHIT Obfuscation!

Time and time again the bozos who run proxy lists try to come up with silly JavaSHIT schemes to prevent their pages from getting scraped by list raiders like me.

Consider the following stupidity (click for a larger view):

This is silly on a number of levels.

First, anyone remotely concerned about online security (there’s a couple of us) has JavaSHIT disabled 24×7 and the last place they’d want to enable it would be on a freakin’ proxy list site.

Second, that “eval(unescape(…” bullshit screams “HAXX!!!”

Third, this code simply unescapes to the html that would have been displayed had they not obfuscated it in the first place.  What is the point?

And since it’s JavaSHIT, it’s easy to pull off the page and de-obfuscate.

I bring this up because I have been throwing out the unproductive sites I’ve been pulling data from.  Some have disappeared, including my very last, solid gold Russian proxy site.

Those are some big shoes to fill, so to replace it I Googled “proxy list” to see who’s getting all the hits these days.  For the most part it was the usual suspects, but there were a few new names so I looked into them.

And sure enough, most of them were using JavaSHIT obfuscation.  Even some of the old standby sites have been re-written to leverage JavaSHIT.

And I was surprised to find that I could actually get some good proxies from these sites.  THAT in itself is very unusual.  Typically you go through the hassle of unobfuscating this crap and it’s seldom worth the effort.

As usual, you’re the WINNER!

12
Apr

Obfuscated Updates for 04/12/10

You may notice the “PoTTY” link above. There’s nothing there yet. That is/was a test for the “Visit Web site” button on the PoTTY “About” box. Right now I’m mulling over where to put the files. I think they’ll end up on www.mrhinkydink.com (not the BlogSpot redirect), if only for “branding” purposes.

Today I obfuscated PLINK and PSFTP (I did PSCP over the weekend), but I haven’t tested them yet, so the entire PoTTY Suite is almost ready to rock’n'roll.  As far as the source code goes, I could zip the entire directory structure up as is, but I need to do something about my idiosyncratic, highly non-standard search paths so you can just import it into VCE 2008 with minimum hassle.  I agree VC6 would be a better format, but I don’t have VC6.

I have had a few hiccups using my own obfuscated-openssh server (Debian 4.0r0).  I have four instances of ObfuscatedPort in sshd_config, but only two of the ports are working.  This is probably something unique to this system (i.e., something I screwed up) since I also have it installed and running on four ports on my CentOS laptop (long story – it’s the only distro that works on a SONY Vaio PCG-K27) with zero problems.

The simple Cyqwin fix continues to shine.  Right now I have Cygwin oossh running in a loop back at my office in the Salt Mine, back-tunneling RDP.  There have been a few connection drops due to proxy issues – it goes out through a very busy proxy – but it reconnects fine.

If you use a proxy with Cygwin oossh (or any ssh client), be sure to set the ServerAliveInterval to something less than a minute.  In my case, the Microsoft ISA proxy back at the office drops all TCP connections after two minutes of inactivity, so you have to keep that pipe flowing if you want to stay connected.  Be it SOCKS or HTTP, it doesn’t matter.  You get two minutes.  Shit or get off the pot.

This is usually not an issue if you can get out through a firewall hole, but YMMV.

I don’t recommend using oossh through a proxy, but sometimes you have no choice.  I have a choice, but I use a proxy because I have this… obsession with proxies.

Did I ever mention that?

10
Apr

RDP Back-Tunneling NAILED

WTF!

All this time I’ve been using PuTTY (great program, BTW.  Ever heard of it?) to make the tunnel.

Cygwin ssh worked just fine, which means that Cygwin obfuscated-openssh should work just fine.

Well, I’ll be dipped in shit!

The thing is, I know I’ve tried this with Cygwin before, with the same, exact Black Screen ‘O’ FAIL results.

I did upgrade to v1.7 within the last couple of weeks, though.  Hmmm…

Maybe it’s time to take back all those nasty things I said about Cygwin.

08
Apr

Hinky Gets Props For Patch!

I had a question about the copyright of obfuscated-openssh so I dropped the author a note.  He wrote back saying since it was a patch to OpenSSH, the same copyright applied.

I thanked him and added a BTW about the fix I made to oossh to get it to work with proxies.

He posted it to github with a thanks!

Aw shucks, folks, ’tweren’t nuthin!

On the PoTTY front, my first attempt at static linking to the OpenSSL libs taught me more than I ever wanted to know about Microsoft C compilers.  In other words, it was a Total Fail.  And it made my dinky little brain hurt.  I’m not sure if I can pull it off but I’m going to dick around with the compiler flags and rebuild OpenSSL to see if that helps.  Another option would be yanking the RC4 code out completely and shoving it down the PoTTY, so to speak.  Either way, it looks like tough hack.

Otherwise, testing is going well.  I built a private version with my Secret Sauce and tested against my workplace firewall/IDS.  It worked beautifully.

07
Apr

PoTTY: Tidying Things Up

I moved the obfuscation settings to Connection/SSH/Kex because that’s where they belong.  The settings disappear if you’re in mid-session, because, well… there would be no point in doing that.  Obfuscation only happens at the beginning of a connection.

The password box offers no option for verification, so you have to get it right the first time.  It gets stored in the Windows user’s registry in clear text, which bothers me for obvious reasons.  Ideally, I think there should be two checkboxes, one to enable obfuscation and one to “Use password”.  Then, PoTTY would prompt for the password just before the connection is attempted.

But… heh… I don’t want to deal with that right now.

At the moment I believe “obfuscation is enough” and I don’t have any passwords on any of the oossh servers I have deployed so far (having said that, maybe I should).  But in The Future, if oossh gets deployed widely enough that hackers and brute-forcers add obfuscation to their standard repertoire, it will probably become a “best practice”, since without a password the server trusts any old connection at all (at least for the key exchange).

Until that time, clear text password storage can be tolerated.  Or, you could simply choose never to save the password in the first place.

This is looking better every day.  Now I need to get this thing statically linked with OpenSSL.

06
Apr

Obfuscated PuTTY LIVES!!!!

As it turns out, Obfuscated PuTTY was a three-day weekend hack.

Last night I was banging away and things were looking good.  I got past the “corrupt packet” errors and I was getting all the way through the obfuscated key exchange when I realized my problem was that I wasn’t turning off obfuscation in the right place.  At that moment everything that needed to be done was all clear to me.

I had an epiphany!!!!

Right then, at that Stunning Moment of Clarity, there was a bright flash, a clap of thunder, and the fucking power went out!

It was as if my efforts had enraged the Gods Themselves.

It lasted all of five seconds, but Visual C++ Express blinked out and suddenly I was staring at a power-on self test on my monitor.  I couldn’t help but wonder if I had saved my work recently.  I didn’t want to deal with that possibility (they call it “denial”) or the possibility that the power would go out again, so I did other stuff for a couple of hours and hit the sack early.

I woke up at 4AM (my own personal “Magic Hour” these days) and loaded up the code to see what I had lost.  But it was all there!  I made the changes and after a few tests and a couple cups of coffee, the damned thing worked!

Now, the clean-up phase begins.  I still have some unfinished business:

  • Statically link OpenSSL to make PoTTY a standalone executable.
  • Fix up and test the obfuscated-openssh password stuff
  • Add some spit and polish
  • Test!  Test!  Test!
04
Apr

Another Victory

I may just hammer this sucker yet…

The circled part is the start of the obfuscated handshake.  Normally, that’s in clear text.

Maybe it could be a weekend hack after all, but right now I’m kind of burnt out on the whole thing.

04
Apr

Small Victories

As you can see, I haven’t given up on PoTTY yet.

This morning I woke up at about 4AM and decided to go at it.  I have found the spot in the PuTTY code where (I think) the obfuscated handshake should go, but at the moment I’m not sure how to implement it.  But with that insight I cut the network routines out of  obfuscate.c and set about to just getting it to compile.

With that issue on the back burner, the only piece that had to be hacked out of nowhere was the arc4random() function.  I was lucky enough to find that, and other WIN32 goodies, here.

I shoehorned it all in and compiled it with VCE 2008 and it worked.

Or, rather, it “worked”.

Even though obfuscate.c is dead code (there’s nothing calling it right now), PoTTY choked because it couldn’t find the OpenSSL DLLs (libeay32.dll & ssleay32.dll).  I put them in the system PATH and PoTTY fired up.  Since nothing but the obfuscation code and arc4random() includes the OpenSSL headers that error was an obvious sign that the code was in there.

I’d prefer it if all the OpenSSL routines were statically linked, but at this point I’ll take what I can get.

The primary reason I want to statically link the code is that there are quite a few vendors in the non-FOSS world who have their own, proprietary versions of these two DLLs for Windows.  That’s not a problem when there’s only one of these vendors in your system, but when you have two of them the incompatibles DLLs start causing problems.

I discovered that years ago after compiling my own SSL-enabled WIN32 version of wget.  Somewhere along the line I installed a McAfee product of some sort and it stomped on my SSL DLLs (McAfee also has a version of wpcap.dll that will ruin your day sooner or later).

So that will be the next step.  I have all the OpenSSL static libs but I can’t get VCE to link them.  Not sure what the issue is there.

Another small victory…

The options are in there, ready to rock’n'roll whenever I finally figure out how to use them!

03
Apr

Epic Hinky FAIL

Going over the PuTTY code I got a strange feeling of déjà vu.  And indeed I had been here before, in November of 2005 when I last tried hacking it.  That particular trick was successful.  I needed to make a “secure-er” version for a vendor who was remoting into one of our *ix servers through a Windows box (via telnet).  All I did was remove the right-click context menu so he couldn’t get into a box we didn’t want him to get into (of course, nothing prevented him from doing that from the command line once he was inside PuTTY but at least that would leave an audit trail on both *ix boxes).

Yes… I had seen this all before and it wasn’t pretty.

In typical Hinky Dink fashion I hacked around for hours and hours until, defeated and crestfallen, I decided it was probably a good idea to read the docs.

Oh, yeah… definitely been there before.  The repressed memories came flooding back.

You have to hand it to Simon Tatham, PuTTY’s author.  He has the free Windows SSH client “market” all to himself.  Sure, Cygwin’s client does work quite well, and they have a server to boot (there’s no PuTTYd yet) but it’s still… ugh… Cygwin.

Not that there’s anything wrong with Cygwin… just don’t get me started.

Then there’s SSHWindows, the “minimal Cygwin” variant.  Based on an ancient version of OpenSSH and an equally decrepit version of Cygwin, it’s an accident waiting to happen.  Oddly, this is quite widely deployed.  I practically crapped my pance when I found it flourishing in my work environment (when reported to management all I got in return were blank stares.  I get that a lot).

There are a few PuTTY derivatives out there, but none that are in active development.  And most of them seem to be dedicated to features that no one really cares about (like “minimize to the system tray”, PuTTY-in-a-DLL, support for Active Directory Group Policy, et cetera – Big Fucking Deal).

It leads you to wonder out load, “Why doesn’t someone just sit down and port the OpenSSH code to Windows?”  Well, it’s been done but the developers went insane doing it and never released the code.  You can read about that here.

With OpenSSH being so maddening to port to Windows it’s no wonder Mr. Tatham decided to trash it all and do it his way.  And looking at “his way” you have to wonder if he wasn’t insane in the first place (just kidding, Simon!).

So I have come to the conclusion this is not going to be a weekend hack, but I will not go so far as to say it can’t be done.  It probably just can’t be done by me.

That opens up some other options:

  • Send the PuTTY Team a wishlist request
  • Start an obfuscated-openssh movement and get OpenSSH to mainline the extensions.  Wait a couple of years for Simon to play catch up.
  • Pay some starving Indian/Chinese programmer US$200 to program it for me

The first option is likely a dead-end.  They have this thing about “standards”.  However, no one has suggested it yet, which surprised me.  It could be worth a shot, but again, who takes email from “MrHinkyDink” seriously?

As for the second, I’ve never had any luck rallying troops of any sort.  I’m not what you’d call a charismatic leader (unlike my namesake).  Plus, it would take too long.

I like the third option and I have the two hundred bucks!  Drop me a note!

In the meantime I will meditate on Simon’s code and see what I can do, but I value what little sanity I have left so nothing may come of it.