Skip to content

Instantly share code, notes, and snippets.

@MikuAuahDark
Last active September 4, 2019 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikuAuahDark/886fc56592d76731df247a1f9e9b6c03 to your computer and use it in GitHub Desktop.
Save MikuAuahDark/886fc56592d76731df247a1f9e9b6c03 to your computer and use it in GitHub Desktop.
SIF Decrypter Benchmark
-- Benchmarh test
if jit then jit.off() end
local ITERATION = 200
local commands = {
-- First is HonokaMiku, second is libhonoka
{"HonokaMiku -w1 ww_v1_test nul 2> nul", "libhonoka -w1 ww_v1_test nul 2> nul"},
{"HonokaMiku ww_v2_test nul 2> nul", "libhonoka ww_v2_test nul 2> nul"},
{"HonokaMiku ww_v3_test nul 2> nul", "libhonoka ww_v3_test nul 2> nul"},
{"HonokaMiku ww_v4_test nul 2> nul", "libhonoka ww_v4_test nul 2> nul"},
{"HonokaMiku ww_v5_test nul 2> nul", "libhonoka ww_v5_test nul 2> nul"},
{"HonokaMiku ww_v6_test nul 2> nul", "libhonoka ww_v6_test nul 2> nul"}
}
print("Running decrypter test")
for i, v in ipairs(commands) do
print("==== DECRYPT VERSION", i)
print(ITERATION.." iteration of HonokaMiku")
local a = os.clock()
for j = 1, ITERATION do
assert(os.execute(v[1]) == 0, "Command exited with nonzero error code")
end
print("Performance HonokaMiku", (os.clock() - a) * 1000, "ms")
print(ITERATION.." iteration of libhonoka")
local a = os.clock()
for j = 1, ITERATION do
assert(os.execute(v[2]) == 0, "Command exited with nonzero error code")
end
print("Performance libhonoka", (os.clock() - a) * 1000, "ms")
end

Decrypter Benchmark

Test comparison of HonokaMiku v6.0.3 vs libhonoka v2.1.0 (both are not open source program)

Executable is 32-bit, compiled with Visual Studio 2010, with /Ox /Ot /Oi optimization.
HonokaMiku also additionally compiled with /EHsc option.

CPU: Intel Core i5-7200u 2.5GHz (up to 3.1GHz) OS: Windows 10 64-bit

All decrypt runs 500 times and WW gamefile is used.

HonokaMiku libhonoka
File size 100352 bytes 79360 bytes
Version 1 5629 ms 5480 ms
Version 2 7114 ms 7065 ms
Version 3 6737 ms 6589 ms
Version 4 6637 ms 6685 ms
Version 5 6850 ms 6844 ms
Version 6 7008 ms 6936 ms

Additionally, when compiled under GCC 7.2.0 64-bit (MSYS), -O3, libhonoka wins all the tests by ~1 second difference

@MikuAuahDark
Copy link
Author

GrygrFlzr created better benchmark script written in bash, so you should check it out https://gist.github.com/GrygrFlzr/764c8330aed214d00dc973a7cad28961

@NyaMisty
Copy link

NyaMisty commented Sep 4, 2019

Sorry to bother, is there any way to download these two projects' executable?

@MikuAuahDark
Copy link
Author

MikuAuahDark commented Sep 4, 2019 via email

@NyaMisty
Copy link

NyaMisty commented Sep 4, 2019

Oh that's a pity :(
Even the compiled executable is not available?
If not, could you please giving me some hints about where I could find the encryption assembly code? I found the approximate location by searching the constant left in your old version HonokaMiku. But I failed to understand some critical code due to the lack of a debugger :(

@MikuAuahDark
Copy link
Author

No, not even compiled executable is available due to above reason I stated above. It was used for cheating (making modded APKs) and I don't want that game-breaking thing to exist so I decide not to release anything beyond that.

The decryption code is a C++ virtual method. C++ virtual method is very hard to track even with IDA so good luck with it.

@NyaMisty
Copy link

NyaMisty commented Sep 4, 2019 via email

@MikuAuahDark
Copy link
Author

You can find a particular constant 2531011 and 214013 which will lead you to version 3 decryption (or key tables). The next function should be the other version.

@NyaMisty
Copy link

NyaMisty commented Sep 4, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment