Skip Links

Network World

Jimmy Ray Purser

Safe HEX

By JimmyRay on Wed, 04/15/09 - 12:21pm.

I was mainly raised by my Grandmother as punk kid growing up in the hills of Tennessee. Of course she had a ton of catchy sayings that probably would have made her a bumper sticker or refrigerator magnet millionaire. One of my favs is: "Knowledge is no good unless it is shared" I have tried to live my life as close to that as possible. I teach an Internet Safety class to parents to help get them to not be afraid of the Internet for their kids and their use. One of the Dudes came up to me and asked if it is possible to see what imagines their employees are actually looking at online. Possible sure, but you have enjoy hex. He thought I was a perv and ran out of there faster then crap though a goose.

In forensic terms we always go back to the hex. And no I am not going to do any cheesy Hex--Sex double entendres like a goober newscaster, I PROMISE! Hex is the key data reassembly just like the software interrupter would do. The trick is getting in the middle of that transmission to intercept the stream without breaking the flow from source to destination. So this gives me a few options:
- ARP spoof MiTM (good for old school and on paper)
- SPAN port/TAP
- Install WinPCap, a Netcat listener and a lightweight sniffer like WinDump (on a Windows target, TCPDump on a Linux target) on the target machine.
Each of these options depends on my autonomous control of each sector of the network. Certainly the most complicated of the three options is the third one since it requires either physical access or skulduggery to trick a client to download a trojan which is very rare to hold up in Federal Court. Trust me on that one, I am still looking for a piece of my tail in one such case...

I am positive there are as many ways to recover a graphic out of a hex stream as there is to making good chili. This is how I normally do it. Lets use a jpg for reference but this could easily apply to gifs, bmps, etc...
- Activate my preferred intercept method. For me, I use a passive TAP connected to a modified wireless travel router velco'ed to the bottom a desk. A hub also would work IF it is a TRUE hub and lightweight-small. Most are not.
- I fire up Wireshark to look at the traffic from the target. Now typically, I do not want all of the other stuff on the Ether, so I write a http capture filter: tcp[0:2]==80 this tells Wireshark to start looking at position 0 and end with position 2 for any TCP packet equal to 80.
- Typically I can see a HTTP GET request fetching a jpg file but really depends how fast the stream is scrolling-n-rolling.
- After I capture the data needed, I use one the coolest features in Wireshark; Follow the stream. To make it simple, I search for a HTTP GET where a graphic was fetched. It should display something like: HTTP GET /somegraphic.jpg HTTP/1.1
Now I right click on this frame and select: Follow TCP Stream
- This will open up another window with the actual stream itself. Now I just select the radio button at the bottom the states: RAW Hey kinda like WWE Raw on Monday Night! Any Wrestling fans in the house! Now select: Save As and give a easy to remember file name.
- I need to go to my hex editor and strip away all of the HTTP headers and mess that goes along with it to get to the good stuff. Personally, I like the editor Neo Pro from the folks at HHD Software: http://www.hhdsoftware.com/Family/hex-editor.html they also have a free version that works great and can do this operation as well. I also give some high props to XVI32 which is another cool hex editor at http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm I use the pro version of Neo Hex for other forensic stuff I need to do, but I'll save that for another blog.
- I am looking for either the hex string value: FFD8FFE000104A464946 or the ASCII string value:ÿØÿà..JFIF The majority of time, you will see the ASCII string first. This indicates the START of the jpg file and if this is a large capture the hex FFD9... indicates the end of a jpg. Now I just highlight all of the crap before the start of the jpg and I delete it. Now I am just left with the actual raw jpg decode itself. Now I just save this file with another name.
- I open up this newly saved file with my web browser and would you look at that! There's the graphic!

It is important to understand how to reassemble and manipulate code in a hex editor. Communication MUST play be certain rules on the wire. We can use those rules to our favor to uncover the hidden network all around us. I will be discussing more about this in upcoming blogs.

Jimmy Ray Purser

Trivia File Transfer Protocol
If you are looking to get into movies; think twice if you get offered a part in the movie: "The Incomparable Atuk" All the leading Dudes offered the role have died. Sam Kinison, John Belushi, Chris Farley and John Candy where offered the role. Heck Farley just showed the script to Phil Hartman and he was murdered that same year.

on wireshark and hex editors

0

Wireshark supports normal BPF filters, so simply "tcp and src port 80" will do the same thing as your tcp offset syntax (and is slightly more readable).

For hex editors, the best out there is UltraEdit (for Win32). Though it's not free software, I used it for years back when I was on Windows a lot more often. (Now I use gvim and some plugins, but it all sucks compared to UltraEdit). The 010 editor is also popular (again, Windows only), and probably more useful for the kind of tasks you're describing here -- namely, creating binary templates with offsets into data.

Anyway, just so's you know.

Very cool!

0

Awesome!!! Thank you for the post!

Try pcapr for stream reassembly

0

Have you tried http://www.pcapr.net? It lets you reassemble streams and look at images in the browser with a couple of clicks.
http://www.pcapr.net/browse?q=ecard-for-packet-geeks

PCAPR

0

I have used PCAPR and still do! I even follow them on twitter as well. PCAPR is a fantastic site for tons of packet captures. But I must admit I have only used it as a repository and not really as a tool. I will take a look at this. Although, it is really hard to beat the rush of decoding the hex!

Thank you for the recommendation

Jimmy Ray

Hi Jimmy, Thanks for your

0

Hi Jimmy,
Thanks for your blog! Reading it for the half year, but commenting here for the first time.

Simpliest way to see the web-content your users are transfering is to my view setting up (transparent) proxy, and surfing through the cache.

As for HEX editors - my personal choise for 'patching' software and looking for structures in datafiles is HIEW (http://www.hiew.ru/) - I bet you'll love it.

Quick Fix

0

After saving out the raw data to a file, you can just point bitmaprip at the dump and it will extract gif's, png's, jpg's, etc. IF you don't want to wade through the hex.

http://mark0.net/soft-bitmaprip-e.html

Tom

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You can use BBCode tags in the text.
  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <p> <strong> <i> <br /> <br> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Welcome, visitor. Register Log in
About Networking Geek to Geek

Jimmy Ray Purser is the technical co-host for Cisco's TechWise and BizWise TV. Jimmy Ray also conducts advanced training for engineers across North America and Europe and regularly speaks at industry conferences such as VON, CeBIT, N+I, and Networkers. As a field engineer, Jimmy Ray experiences networking first hand behind the console or in the rack. He is an active member in the IEEE and the Ethernet Alliance and has designed, installed and tested numerous networks for Fortune 500 companies, the United States military and other institutions worldwide. He holds 3 U.S. patents for Ethernet security algorithms with two others pending and one defensive publication, as well as numerous other vendor certifications in networking and security.

Purser holds a Bachelor of Science degree in electrical engineering from Southern Illinois University is currently pursuing a master of science degree in electrical engineering.