Here are some helpers for solving the RSA 2012 challenge, RSA 2012 #sophospuzzle. Compile the posted code with C++ compiler, I used GCC in Mingw package. I did clean up the code for easier reading, plus the newer GCC was complaining about VOID used instead of INT. If you look at the code, it won’t do anything unless the passed argument is equal to 8; a 8 character password. So pass any 8 character password as the argument to your exe and it will generate a response. Now adjust your password starting from left to right until you get a response that you should recognize as a web url. The url is encrypted in a modified Vigenere cipher. When the puzzle was first posted the source code was corrupt or incomplete. So I solved it as a plain Vigenere but the source code for the exe will give you a different password to the same link. Put ‘noncen.ceh/alu/puyps.hrhb’ in a Vigenere solver with passkey ‘vayvqvaq’ and you get sophos.com/anz/zzyzx.html That password won’t work on the exe though. Easy to solve though, plug in chug the letters.
The 2nd part of the clue refers to taking text of some RFC files appended together with the password. This is the real time consuming portion of the challenge. If you append the correct text with password the resulting md5sum is ’01b9e8adf4dd660c7e4cb6dd8a304691′. When I first read the challenge I thought (was hoping) that just taking the numerical number of the RFC with the password was the trick. ’1234password6543′ The RFC format is 4 numbers and even if the number had been 1 digit (1 vs 0001) breaking the md5 with the given information would be very easy. I created a dictionary file for a hybrid attack and also ran a mask attack for every possible variation. Everything failed. This means grabbing the entire RFC collection of txt files is the next place to start. Probably the most bandwidth traffic to that site in awhile, the zip file collection is 140MB. RFC Request for Comments
I wrote a python script (my first one) to combine the files one by one. There are over 6400 RFC txt files in that zip. It’s going to take a while for every solution with this script. I experimented with different methods of merging the files but this way seems to be the fastest. On my notebook the script will run 1 set (6400 files) of RFCs through every possibility in 6 sec, so 9-12 sets every minute. Disabling or excluding the directory from AV scanner will speed up the process because this script creates and overwrites a temp text file for every test of md5sum. AV scanner is constantly scanning every new file… As is, this script will merge 3 files in a stream, write to the hard drive as temp file, close the file, open the file for md5 check, compare md5 then exit or continue to next file in list.
# python 2.72 script for brute force a md5sum from three files.
# run from same folder as RFC files are located with a file 'password.txt' containing only the password from step 1
# make sure password file does not contain any extra spaces or special codes for line feed, eof, cr etc.
# As is, no guarantee and use at your own risk. Modify as needed.
# Rev 0.92 Works
# Rev 0.92a Minor Changed variable names rsa Was using rsa as var linking contest name not for hashing.
def mergeFiles():
fileSet1 = glob.glob('RFC*.txt')
fileSet2 = fileSet1
# for file1 in sorted(fileSet1,reverse=True): #For running sets on another PC files in reverse
for file1 in fileSet1:# [1000:2500] for specific positions
print "Current file = " + file1
for file2 in fileSet2:
destination = open('0tempfile.txt', 'wb')
shutil.copyfileobj(open(file1, 'rb'), destination)
shutil.copyfileobj(open('password.txt', 'rb'), destination)
shutil.copyfileobj(open(file2, 'rb'), destination)
destination.close()# if skip close here the buffer is not readable and results corrupt file:9hrs wasted
destination = open('0tempfile.txt', 'rb')
m = hashlib.md5()
while True:
data = destination.read(8192)
if not data:
break
m.update(data)
md5Sum2=m.hexdigest()
md5Sum1='01b9e8adf4dd660c7e4cb6dd8a304691'
# md5SumTest='99a5cbf1379d6937333fedc817a2e1f2' #test file md5 to make sure script is working
if md5Sum2 == md5Sum1:
print 'Success - ' + file1 + '_' + file2 + ' = ' + md5Sum2
destination.close()
sys.exit(1)
else:
# print 'Fail - ' + file1 + '_' + file2 + ' = ' + md5Sum2
destination.close()
return
def main():
print "Brute forcing md5 for RSA2012"
mergeFiles()
if __name__ == '__main__':
main()
So assuming the password is correct, all the RFC files are present and this script is working correctly; the two needed numbers for rest of the puzzle will be found. I wasted too much time working the script for this. This was my first attempt of doing a python script that wasn’t part of some class. First attempt was using direct call to shell commands to combine the files. Way slower opening a cmd line every file. Thought about creating new files and run a 3rd party md5 tool against all the files. That would’ve been a lot of drive space but with RAID this would probably been faster. Python has a library to create and delete a temp file on the fly. This seemed like the best option to go with. Well 9 hours later after running every possible combination no md5sum was correct. I had tested in cmd line python but in the script it was failing. Seems something with read write buffer of the binary stream and then reading chunks for hashing somehow conflicts. Tried to correct it but decided I was spending too much time on it. Too much, missing the dead line for the contest… Changed the script to create a static temp file, close the stream and then hash the file. This way the file is constantly being overwritten and seems to be the same speed as tempfile library. It may be possible to send the stream directly to the md5 library in memory, this would speed up the process.
Factoring the numbers. There are websites and scripts available for this. Prime Number Gen This shouldn’t be that hard for anyone. There will probably be a proper solution posted on the Nakedsecurity Sophos blog Good luck – CDaze
Addon
A video solution was posted on Sophos. RSA 2012 Solution


Recent Comments
Don’t Buy It*update 2 – Solution*Don’t Buy It*update 2 – Solution*Don’t Buy It*update 2 – Solution*Don’t Buy It*update 2 – Solution*Don’t Buy It*update 2 – Solution*Don’t Buy It*update 2 – Solution*