Skip to content

Commit 95a4065

Browse files
committed
Adding APT-29 Graphical Proton stack strings algorithm
1 parent d568247 commit 95a4065

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python
2+
3+
DESCRIPTION = "Graphical Proton string hashing algorithm"
4+
TYPE = 'unsigned_int'
5+
TEST_1 = "2194288283"
6+
7+
ROTATE_BITMASK = {
8+
8 : 0xff,
9+
16 : 0xffff,
10+
32 : 0xffffffff,
11+
64 : 0xffffffffffffffff,
12+
}
13+
14+
def ror(inVal, numShifts, dataSize=32):
15+
'''rotate right instruction emulation'''
16+
if numShifts == 0:
17+
return inVal
18+
if (numShifts < 0) or (numShifts > dataSize):
19+
raise ValueError('Bad numShifts')
20+
if (dataSize != 8) and (dataSize != 16) and (dataSize != 32) and (dataSize != 64):
21+
raise ValueError('Bad dataSize')
22+
bitMask = ROTATE_BITMASK[dataSize]
23+
return bitMask & ((inVal >> numShifts) | (inVal << (dataSize-numShifts)))
24+
25+
def hash(data):
26+
out = 0x3ddfb511
27+
for c in data:
28+
temp = ror(out, 8)
29+
out = (ord(c) + temp) ^ out
30+
return out

0 commit comments

Comments
 (0)