-2

What is the hash? Generated from ida pro

int __fastcall hash(_BYTE *a1)
{
  _BYTE *v1; // r4@1
  int v2; // r5@1
  int v3; // r6@1

  v1 = a1;
  v2 = 0;
  v3 = 1;
  while ( *v1 )
  {
    v3 = (*v1 + v3) % 51407;
    v2 = (v3 + v2) % 51407;
    ++v1;
  }
  return ~(v3 | (v2 << 16));
}
  • Ways to solve this on your own: 1. Research code for hash algorithms, compare to this decompilation 2. Run an input through this function, compare it to the output of the same input through known hash functions. – multithr3at3d Feb 19 at 18:26
  • It is important that you include in the question what you've already tried and the research you've done. – multithr3at3d Feb 19 at 18:27
0

for an array x[] whose count is n

the series for v3 without the mod() will be

n * (1 + x[0]) + (n-1) * x[1] + (n-2) * x[2] + (n-3) * x[3] + .... (n-r) * x[r] +...+ x[n]

the series for v2 without the mod() will be

1+x[0]+x[1]+x[2]+....x[r]+...x[n]

assuming "secret" is passed as input
then hash will be 0xf72efd78

redone in python

input = "secret"
l = len(input)
v2 = 0
v3 = 1
for i in range(0,l,1):
    v3 = (ord(input[i]) + v3)
    v2 = v3 + v2
    print(hex(v2),hex(v3))
print ("hash for input %s = %08x" %(input,(~(v2 << 16 | v3)) & 0xffffffff))

result

0x74 0x74  
0x14d 0xd9 
0x289 0x13c
conforming the series for v2
>>> hex( 3 * (1 + ord("secret"[0])) + 2 * ord("secret"[1]) + 1 * ord("secret"[2]))
'0x289'
0x437 0x1ae
0x64a 0x213
0x8d1 0x287
hash for input secret = f72efd78
|improve this answer|||||

Not the answer you're looking for? Browse other questions tagged or ask your own question.