1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| import sys, os
D = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'rdp_decrypted', 'client_decrypted.bin')
SC = {
0x02:('1','!'),0x03:('2','@'),0x04:('3','#'),0x05:('4','$'),0x06:('5','%'),
0x07:('6','^'),0x08:('7','&'),0x09:('8','*'),0x0A:('9','('),0x0B:('0',')'),
0x0C:('-','_'),0x0D:('=','+'),0x0E:('\b','\b'),0x0F:('\t','\t'),
0x10:('q','Q'),0x11:('w','W'),0x12:('e','E'),0x13:('r','R'),0x14:('t','T'),
0x15:('y','Y'),0x16:('u','U'),0x17:('i','I'),0x18:('o','O'),0x19:('p','P'),
0x1A:('[','{'),0x1B:(']','}'),0x1C:('\n','\n'),
0x1E:('a','A'),0x1F:('s','S'),0x20:('d','D'),0x21:('f','F'),0x22:('g','G'),
0x23:('h','H'),0x24:('j','J'),0x25:('k','K'),0x26:('l','L'),
0x27:(';',':'),0x28:("'",'"'),0x29:('`','~'),0x2B:('\\','|'),
0x2C:('z','Z'),0x2D:('x','X'),0x2E:('c','C'),0x2F:('v','V'),0x30:('b','B'),
0x31:('n','N'),0x32:('m','M'),0x33:(',','<'),0x34:('.','>'),0x35:('/','?'),
0x39:(' ',' '),
}
data = open(sys.argv[1] if len(sys.argv)>1 else D,'rb').read()
shift = caps = False
out = []
for i in range(len(data)-3):
if data[i]!=0x04 or data[i+3]!=0x44 or data[i+2]==0x44: continue #0x04开始 0x44结束
fl, sc, dn = data[i+1], data[i+2], (data[i+1]==0x00)
if fl not in (0,1): continue
if sc in (0x2A,0x36): shift = dn; continue
if sc == 0x3A and dn: caps = not caps; continue
if sc in (0x1D,0x38): continue
if not dn: continue
if sc not in SC: continue
ch = SC[sc][1] if (shift ^ caps) else SC[sc][0]
if ch == '\b' and out: out.pop() #出栈
else: out.append(ch)
print(''.join(out))
|