Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

Problem getting SHA-1 hash to work

Featured Replies

  • Author
  • Localization

HenryEx, posted Wed Aug 13, 2014 6:55 pm (139)


I worked around my substitution table problem for Monster Hunter saves. :)

Now i'm trying to verify it. The game's using a 160bit SHA hash to verify data integrity. When i try to hash the memory file containing the data with QuickBMS, i don't get the correct hash though.

This is basically my test script to check the hash QuickBMS produces.
Code:
  log MEMORY_FILE3 0 0x40
  Encryption sha1 MEMORY_FILE3
  print "SHA-1 hash: %QUICKBMS_HEXHASH%"


I'm trying to attach a small (40 byte) file, but the forums won't let me and always says "extension not allowed". I tried .bin, .txt, .bmp, .dat, .jpg....

Anyway, with the script above i'm geting a different hash than with every other program (i tried 3, they gave identical hashes). Am I doing something wrong?
  • Author
  • Localization

aluigi, posted Wed Aug 13, 2014 9:23 pm (140)


Hi.
I guess that your problem with Monster Hunter was the missing key size field at the end of the Encryption command, otherwise when it finds a NULL byte it truncates the key.

Here the problem is that you have used the Encryption command after the Log one, place it before so that it will calculate the hash while doing the reading of the file.

For the attachments, simply make a zip.
But images are accepted (probably it checks if it's a valid image).
  • Author
  • Localization

HenryEx, posted Thu Aug 14, 2014 3:02 pm (157)


I did it like that because i copied it from what i'm supposed to do. I log the save to MEMORY_FILE, then i have to append a 14-character string as salt to the end of the save / memory file, which is specific to the region the save file is from.
I guess i could log them completed mem file into another mem file.

Nevertheless, i just tried this short script on my little tohash.bin test file, which i attached.
Code:
  Encryption sha1 ""
  log MEMORY_FILE3 0 0x40
  Encryption "" ""
  print "SHA-1 hash: %QUICKBMS_HEXHASH%"

The QuickBMS result was a hash of F6934BB884F1748550AA93CFF917F0500AACA45F.

This is what other programs say about the file:
Image
Am i still missing something?

#edit: As an aside, say i need to cancel a for loop on some condition. Would this work?
Code:
for i = 0   goto 0x6800  # file name position
  getdstring NAME 0x10
  if NAME = ""
    next i
  endif
  ...
  [ code to execute if name is valid ]
  ...
next i
  • Author
  • Localization

aluigi, posted Thu Aug 14, 2014 4:05 pm (161)


The problem is the size you specify, the file is 80 bytes (0x50) and you specified 0x40.
You can just do a:
Code:
Encryption sha1 ""
get SIZE asize
log MEMORY_FILE3 0 SIZE

Regarding the loop I guess you want a "continue" like in C, unfortunately that's not implemented because gave some troubles in Quickbms.

So you can just use an "if" "else" "endif" to perform the appropriate operation.

Instead if you want to "break" the loop there is just the Break command.
Only note about this command is that in particular conditions it may not work correctly, but if you use something like the following you will not have problems:
Code:
for i = 0 < FILES
    get TMP line
    if TMP == ""
        break
    endif
next i
  • Author
  • Localization

HenryEx, posted Mon Aug 18, 2014 3:21 pm (209)


Oh yeah, i forgot to report back. :D

I got it to work, finally, with Encryption sha1 "" and the log command. Of course it was such a dumb mistake! Thanks for your time. Still, specifying just the encryption command with a memory file as key and a fixed width got me all kinds of various hashes, but not the right one. Oh well, log works. I got two working scripts to de- and encrypt a Monster Hunter save now. :)

This is beyond the SHA issue now, but: If i want to distribute QuickBMS with the scripts (and the neccessary cipher tables), i'm guessing i need to include the src folder?
  • Author
  • Localization

aluigi, posted Mon Aug 18, 2014 3:41 pm (210)


You can distribute just the quickbms.exe file, no need of the src folder or the other files.


Ah, a little tip: if you want to calculate the hash of a string you can specify it in the encryption command and the hash will be calculated immediately.
It's a shortcut I added to avoid to make useless operations.

Try this:
Code:
set VAR string "hellohello"
encryption md5 VAR "" 0 4
print "%quickbms_hexhash%"
Useful, eh? :)

It works also with MEMORY_FILE:
Code:
set MEMORY_FILE string "hellohello"
encryption md5 MEMORY_FILE "" 0 4
print "%quickbms_hexhash%"
This feature has been introduced only recently.
  • Author
  • Localization

HenryEx, posted Wed Aug 20, 2014 3:07 pm (225)


Cool. :)


By the way, is there a method to make a string filename-save? I'm thinking of taking filenames from within the archive, but some of the potential names contain question marks and the like.
  • Author
  • Localization

aluigi, posted Wed Aug 20, 2014 3:33 pm (226)


quickbms has an internal function to clean the filenames when it dumps the file so the file is created without problems, but there is nothing similar exposed to the script.
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.