Cenzic 232 Patent
Paid Advertising
sla.ckers.org is
ha.ckers sla.cking
Whether this is about ha.ckers.org, sla.ckers.org or some other project you are interested in or want to talk about, throw it in here to get feedback. 
Go to Topic: PreviousNext
Go to: Forum ListMessage ListNew TopicSearchLog In
Unknown Hash/Encryption Function
Posted by: icehawk78
Date: February 26, 2010 05:43PM

Unsure if this is the correct location to ask - please move/redirect if it's not.

I have some code that is doing something like this:

Device sends a request to http://site.com?id=12345
Site returns 'a87gbihya9749a87gbihya9749j39slw' (random 32-byte length alphanumeric string)
Device runs some sort of hashing function, and appends all further calls with ?id=12345&hash=1284674ba937173749ab1284674ba937173749ab (40-byte length hex hash).

What I would like to do is be able to emulate the device, but I don't know how to figure out what function is generating the hash from the returned string. I ran hashmaster on a few input/output pairs, and it didn't come up with anything.

I can post a few string/hash pairs, and I have the ability to send custom strings to the device to see what hash is generated from them. However, the device crashes if you try sending anything other than a 32-byte alphanumeric string.

00000000000000000000000000000000 -> b267b3896a52f79c99510ff92af27b67e0aaf148
00000000000000000000000000000001 -> f24f009084f957aabef62b69b099db52aaa94162
11111111111111111111111111111111 -> 03bb6090660035fcae0b3aabd052de92765ca63c
ge4mcncu2MfBvadgxFd4Xu6byp4EIaV9 -> afe8b758b24324d725cd74c58370093c4cdddc6e
WftZakLoSREhcUuD488rerzySv4V5vJL -> b02d6707e53fb7727900aaf11ba11f13e8ebd58f
LJvxoIpeSq5EAeU5sB4R1LaLl9vdTtrs -> 67a376d36a40b8cdbf5e564709707c1cd8552566
DXHigrnbxeMQqQS4bpKxf29ZPEPpbcG4 -> f5ee24b88c0b5827657c1d0267940dbb11867ec1
9nMIelu60Jy2C2Wey3EzCooNUIONaXGR -> f7d058913e8fb65286c5d4d548ba5b43de629d37
mPJt7CDtTZDuORot2TUagQaNMJtqy0Hn -> f855988be61d5d9084cd712d9d2fed59f3aa0ccc
Py1D1a8lnl4TKgTs19SnIbvhkApOTR61 -> 61557219204624f05fce83b3dccfddfd3090ba23
DtBrxVGBrLbHiT6eGfs9WWRTxdX9Hg4f -> fcc63f4d0c10bbf26e834ac2bb3742c93086c29a
W8RxZmMwurQkxEyt0gCTTPGmkuD7QAAS -> 65fbe53250c1813048a7f2b14909ec76619caed3
XUWV3wdtNd9ADX10MvPVVzLn6qf2Lq6r -> aa1f2f75112f8ec893250634234d5a4ae3e845ff

(I have a file of about 100 naturally generated pairs, as well, if that would be useful.)

Options: ReplyQuote
Re: Unknown Hash/Encryption Function
Posted by: SAS
Date: March 01, 2010 04:17PM

Short answer (since I'm going to bed in a moment) did you try to race the hash? i.e. by getting at least 5 to 10 pairs per seconds and try to find discrepancies? If you can trigger 5-10 requests per second with no difference, but in every Nth second, it could be that they use a UNIX time-stamp, micro-time is somewhat harder to race against, but not impossible. That's what I would do first in such situation.

Options: ReplyQuote
Re: Unknown Hash/Encryption Function
Posted by: digi7al64
Date: March 01, 2010 10:19PM

wow - thats look identical to something i wrote for a bank...

'Just because you got the bacon, lettuce, and tomato don't mean I'm gonna give you my toast.'

Options: ReplyQuote
Re: Unknown Hash/Encryption Function
Posted by: cykyc
Date: March 02, 2010 07:42AM

My wild ass guess is HMAC-SHA1 since straight SHA1 did not work. Can you power cycle the device? If so, does it shoot out different hashes for the same input? Do you have access to multiple devices? If so, do they have the same outputs for the same inputs?

Here's a cheesy script that ran through the ~ 3000 passwords in the included john password.lst file:



cat $PW_FILE | while read secret
output_p=`echo $INPUT | $OPENSSL sha1 -hmac "$secret"`
if [ "$output_p" == "$OUTPUT" ]; then
echo "Found input! Input:$secret"
exit 0

Maybe try a bigger password file? Or, see if you can get circuit board access to the device and check for debugging points...


Options: ReplyQuote
Re: Unknown Hash/Encryption Function
Posted by: cykyc
Date: March 02, 2010 08:14AM

Typo above... the echo will append a newline

Change this line:
output_p=`echo $INPUT | $OPENSSL sha1 -hmac "$secret"`

To this:
output_p=`printf "%s" "$INPUT" | $OPENSSL sha1 -hmac "$secret"`

But, really, there's no way on telling what's going on. We're just guessing...

Options: ReplyQuote
Re: Unknown Hash/Encryption Function
Posted by: icehawk78
Date: March 02, 2010 09:14AM

SAS: I haven't yet tried that, but I can. I would be slightly surprised, seeing as the device is a Nintendo DS. However, I do know that sending the same string through the hashing function at any given time will still return the same hash value.

cykyc: Checked both of those - I have access to multiple devices, and even between devices, the same input will always produce the same outputted hash.

Options: ReplyQuote
Re: Unknown Hash/Encryption Function
Posted by: cykyc
Date: March 02, 2010 01:34PM

@icehawk78 - Nintendo DS :-) If it's static, it's more than likely written somewhere that you can access. Is this w/ a specific program on the DS or something you're seeing across programs? If it's a program, can you run it on the DSemu? - http://www.ndsemulator.com/nintendo-ds/dsemu.htm

Options: ReplyQuote
Re: Unknown Hash/Encryption Function
Posted by: SAS
Date: March 08, 2010 07:09PM

Oh, if it's on a console you might try to dig up the schematics, or some published cracks of it, assuming others are looking for weaknesses in devices too.

Options: ReplyQuote

Sorry, only registered users may post in this forum.