Page 3 of 3

Posted: Tue Jul 31, 2012 7:31 pm
by timothy48342
I had sat on the "file mystery" challenge for a few days. It was also a compressed file, but I never would have guessed it. Then when I looked at the first few bytes of this, I saw it was the same and that made me think to do an internet search for the hex of the bytes themselves and found out they both were compressed.

That was the hardest part. Up till then I had tried opening it as a graphic and all sorts of stuff like that. I had tried various guesses with the other one, too.(Even used a ROTXX program I had written on that one. No such luck.)

Anyway past figuring out that it's compressed, and that 7-Zip can open it up without trouble, I started to peal back the layers manually until that got tedious.

So I made a batch file. 7-zip's command line version was easy to use and the docs were in the help file, so I lucked out with that.

do.bat:
@copy *.zip ..
@erase *.zip
@rename *. *.zip
@7z x *.zip

Than after running that about 20 times made another bat file
dox10.bat
@call do.bat
@call do.bat
@call do.bat
@call do.bat
...etc
Then after that got tedious, made a dox100.bat

I think this thing was about 500 levels deep or more.

So, I learned 2 things. When you don't know what kind of file you have, type the first few bytes into a search engine. And scrips are so much better than typing and clicking.
(Also learned that "IF EXISTS filename" does not work in a .bat file on my installation of winXP. I wonder if they have done away with that or disabled it some versions. *shrug*)

Fun, fun.
On to the next.
--timothy48342

Posted: Wed Aug 21, 2013 1:32 am
by strongdrink
Simple on *nix!

Code: Select all

mv doll.bin doll
while true; do mv doll doll.gz; gunzip doll.gz;done
It will just start outputting a bunch of gunzip errors when it is done :)

Posted: Wed Aug 21, 2013 3:31 am
by CodeX
If you give it a good bash the answer will simply fall out :D

Code: Select all

wget -qO a.z http://www.hacker.org/challenge/misc/doll.bin
while true
do
    (gzip -d a.z 2>/dev/null && mv a a.z) || break
done
cat a.z
rm a.z

bash solution with a counter

Posted: Tue Oct 01, 2013 7:48 pm
by viaken
Here's how I did mine. Infinite loops make me itch, so I try to avoid "while true", even knowing I can break.

Also, looks like it was nested 999 times.

Code: Select all

wget -qO doll.gz http://www.hacker.org/challenge/misc/doll.bin
export i=0
while gunzip doll.gz
  do let i++ ; mv doll doll.gz
done
echo "Took $i iterations"
cat doll
[/code]

Posted: Tue Apr 01, 2014 10:11 pm
by Hippo
My 5 cents:

Code: Select all

:loop
dell bak
copy [Content] bak
ren [Content] doll.zip
7z e doll.zip
del doll.zip
goto :loop

Posted: Sun Jun 08, 2014 9:33 pm
by snoopy1alpha
It is always interesting to see other peoples solutions. I always wonder why I am solving my problems in Java, if other languages can do the job in fewer lines of code. However, the neat thing about the Java solution is that Java supports gzip without additional tools. In combination with ByteArray(Input|Output)Streams, we have a very efficient way to work in memory, without writing the interim data back to the HDD. I will not post my code, but I want to share my solution strategy:
- read the gzip file into a byte array
- check the magic number for gzip
- deflate the data (new array, same reference) and check again
- repeat this until the magic number check fails
- the last byte array is written as file back to the HDD (and contains the solution text).

Python solution with help of file signature

Posted: Thu Jan 08, 2015 10:17 am
by totick

Code: Select all

import gzip

f = open(r"c:\doll.bin", "rb")
doll = f.read()
i = 1
r = gzip.decompress(doll)
while r.startswith(b"\x1f\x8b\x08"): # b"\x1f\x8b\x08"  = Hex Signature for gzip file
    r = gzip.decompress(r)
    i += 1

print(r) # result
print(i) # iteration count
List of file signatures http://garykessler.net/library/file_sigs.html

Posted: Fri Jan 09, 2015 2:11 am
by Valar_Dragon
I just used 7zip File Manager (The GUI) and an auto clicker and would just go through 200+ files deep, rename the file so 7zip didn't get an error due to the string taking too much memory, and repeated. It took less than 5 minutes to do this way.

Posted: Mon Jun 20, 2016 4:47 pm
by stask
Did it on MATLAB. Very simple.
Just ran a for-loop on the following code:

Code: Select all

 ! ren doll doll.gz
 gunzip('doll.gz')
 ! del doll.gz
The code run automatically stops when it reaches a doll.gz file which is not valid.

Posted: Thu Jun 23, 2016 6:42 pm
by evan_yeyeye
I wrote an extremely simple shell script.

Code: Select all

#!/bin/bash

while (true)
do	
	mv doll doll.gz
	gunzip doll.gz
done

Posted: Wed Nov 30, 2016 9:09 am
by Mad Mike
Boring part first: I wrote a bash one-liner

Code: Select all

while [ /bin/true ] ; do mv doll doll.gz; gunzip doll; done
and waited for errors to occur. But I really love how the first posts are like "took me over five minutes" and nowadays it's mere seconds (I'd guess ten?) until one hits the bottom.

Also tried to do it manually (Windows machine…) but when I got to the bottom the filename was too long to read or unpack the file. Such shame!