-
-
Save Jinmo/b35f97be6bbfc9025de79e59479d0e95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pprint | |
yy_meta = [0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x03, 0x01, 0x01, 0x03, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] | |
yy_accept = [0x0000, 0x0000, 0x0000, 0x001C, 0x001A, 0x0018, 0x0018, 0x001A, 0x000E, 0x000F, 0x0015, 0x0013, 0x0017, 0x0014, 0x0019, 0x0016, 0x0012, 0x000D, 0x000D, 0x000D, 0x000D, 0x000D, 0x000D, 0x000D, 0x000D, 0x000D, 0x0010, 0x0011, 0x000C, 0x0000, 0x0019, 0x000D, 0x000D, 0x000D, 0x000D, 0x000D, 0x000D, 0x000D, 0x000D, | |
0x000D, 0x000D, 0x000B, 0x000D, 0x0003, 0x000D, 0x000D, 0x0006, 0x000D, 0x000D, 0x000D, 0x000D, 0x000D, 0x0001, 0x0004, 0x000D, 0x0002, 0x000D, 0x0005, 0x000D, 0x000A, 0x000D, 0x000D, 0x0008, 0x000D, 0x0000, 0x0009, 0x0000, 0x0000, 0x0000, 0x0007, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000] | |
yy_base = [0x0000, 0x0000, 0x0000, 0x0050, 0x0051, 0x0051, 0x0051, 0x004B, 0x0051, 0x0051, 0x0051, 0x0051, 0x0051, 0x0051, 0x0042, 0x0051, 0x0051, 0x0000, 0x0039, 0x0032, 0x0012, 0x002E, 0x002E, 0x002F, 0x0034, 0x0033, 0x0051, 0x0051, 0x0051, 0x0042, 0x0039, 0x0000, 0x002D, 0x0012, 0x002D, 0x002F, 0x002A, 0x002A, 0x0025, | |
0x0022, 0x001D, 0x0000, 0x002B, 0x0000, 0x0022, 0x0026, 0x0000, 0x0020, 0x001A, 0x0018, 0x0018, 0x0017, 0x0000, 0x0000, 0x0016, 0x0000, 0x001F, 0x0000, 0x001C, 0x0000, 0x0015, 0x0016, 0x001F, 0x0012, 0x0011, 0x0000, 0x0018, 0x0010, 0x0012, 0x0051, 0x0051, 0x002B, 0x0022, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000] | |
yy_def = [0x0000, 0x0046, 0x0001, 0x0046, 0x0046, 0x0046, 0x0046, 0x0047, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0046, 0x0046, 0x0046, 0x0047, 0x0046, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, | |
0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0046, 0x0048, 0x0046, 0x0046, 0x0046, 0x0046, 0x0000, 0x0046, 0x0046, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000] | |
yy_nxt = [0x0000, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x0004, 0x000E, 0x000F, 0x0010, 0x0011, 0x0004, 0x0011, 0x0011, 0x0012, 0x0011, 0x0011, 0x0011, 0x0013, 0x0014, 0x0011, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x0011, 0x0011, 0x001A, 0x001B, 0x0022, 0x002A, 0x001F, 0x0045, 0x002B, 0x0044, 0x0043, 0x0042, 0x0041, 0x0023, 0x001D, 0x001D, 0x0040, 0x003F, 0x003E, 0x003D, 0x003C, 0x003B, 0x003A, 0x0039, 0x0038, 0x0037, 0x0036, 0x0035, 0x0034, 0x0033, 0x0032, 0x0031, | |
0x0030, 0x002F, 0x002E, 0x002D, 0x002C, 0x0029, 0x001E, 0x001C, 0x0028, 0x0027, 0x0026, 0x0025, 0x0024, 0x0021, 0x0020, 0x001E, 0x001C, 0x0046, 0x0003, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000] | |
yy_chk = [0x0000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0014, 0x0021, 0x0048, 0x0044, 0x0021, 0x0043, 0x0042, 0x0040, 0x003F, 0x0014, 0x0047, 0x0047, 0x003E, 0x003D, 0x003C, 0x003A, 0x0038, 0x0036, 0x0033, 0x0032, 0x0031, 0x0030, 0x002F, 0x002D, 0x002C, 0x002A, 0x0028, 0x0027, | |
0x0026, 0x0025, 0x0024, 0x0023, 0x0022, 0x0020, 0x001E, 0x001D, 0x0019, 0x0018, 0x0017, 0x0016, 0x0015, 0x0013, 0x0012, 0x000E, 0x0007, 0x0003, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0046, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000] | |
yy_ec=lol = [0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x01, 0x0D, 0x01, 0x0E, 0x01, 0x01, 0x01, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x01, 0x0B, 0x01, 0x01, 0x10, 0x01, 0x11, 0x0F, 0x12, 0x13, 0x14, 0x0F, 0x15, 0x0F, 0x16, 0x0F, 0x0F, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x0F, 0x1C, 0x1D, 0x1E, 0x0F, 0x1F, 0x0F, 0x20, 0x0F, 0x0F, 0x21, 0x01, 0x22, 0x01, 0x01, | |
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01] | |
yo = ([(x, c) for x, c in enumerate(lol) if c != 1 and x]) | |
state = 8 | |
ll = {4: ['.', '/', '\\', '_'], | |
5: ['\t', ' '], | |
6: ['\n'], | |
8: ['('], | |
9: [')'], | |
10: ['*'], | |
11: ['+'], | |
12: [','], | |
13: ['-'], | |
15: [';'], | |
16: ['='], | |
17: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'n', 'q', 'u', 'v', 'w', 'x', 'y', 'z'], | |
14: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], | |
7: ['"'], | |
18: ['d'], | |
19: ['l'], | |
20: ['m'], | |
21: ['o'], | |
22: ['p'], | |
23: ['r'], | |
24: ['s'], | |
25: ['t'], | |
26: ['{'], | |
27: ['}']} | |
count = 0 | |
def ks(a, ptr): | |
global count | |
yy_current_state = a | |
ptr=list(bytearray(ptr)) | |
# print a, | |
while ptr: | |
v4 = ptr[0] | |
yy_c = yy_ec[v4] | |
assert yy_c | |
v6 = yy_current_state | |
while True: | |
v7 = yy_c + yy_base[v6] | |
if (yy_chk[v7] == yy_current_state): | |
break | |
yy_current_state = yy_def[v6] | |
if (yy_current_state > 70): # max status | |
yy_c = yy_meta[yy_c] | |
# print bytearray(ptr), yy_c, | |
count += 1 | |
v6 = yy_def[v6] | |
yy_current_state = yy_nxt[v7] | |
ptr.pop(0) | |
return yy_current_state | |
import string | |
for i in [1]: | |
print 'state', i | |
key=string.lowercase+string.uppercase+'_{}$=' | |
queue=list(key) | |
# queue=['server_'] | |
while queue: | |
text=queue.pop() | |
for a in key: | |
count = 0 | |
res = ks(i, text+a) | |
if yy_accept[res] not in (13, 0): | |
print (text+a, res, yy_accept[res]) | |
if res == 70: | |
count += 1 | |
if count == 0: | |
print 'found', text + a, res | |
queue.append(text+a) | |
exit() | |
# print [(i,yy_accept[i]) for i,x in enumerate(yy_base) if x == 81] | |
for _state in range(len(yy_base)): | |
res = [] | |
for x, yy_c in yo: | |
l = yy_base[_state]+yy_c | |
if l >= len(yy_chk): | |
continue | |
if yy_chk[l] == _state: | |
res.append(chr(x)) | |
if res: | |
for x in ll.items(): | |
if x[0] == _state: | |
print x[1], res | |
# print _state,res | |
exit() | |
# print zip(yy_accept, yy_base) | |
yy_meta = [0x0100, 0x0101, 0x0102, 0x0201, 0x0101, 0x0201, 0x0103, 0x0301, 0x0301, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, 0x0303, | |
0x0303, 0x0103, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000] | |
nexts = {} | |
for x, yy_c in yo: | |
# yy_c: translated character | |
# translate state using base | |
base = yy_base[state] | |
next = base+yy_c | |
_state = state | |
nxt = state | |
while not yy_chk[next] == state: | |
ey | |
__yy_current_state = yy_def[nxt] | |
if (__yy_current_state > 70): # lastdfa + 2 | |
# lastdfa: 69 | |
yy_c = yy_meta[yy_c] | |
nxt = yy_def[nxt] | |
# total states: 79 print x, yy_nxt[next] | |
base = yy_base[__yy_current_state] | |
nxt = yy_nxt[next] | |
if nxt not in nexts: | |
nexts[nxt] = [] | |
nexts[nxt].append(chr(x)) | |
pprint.pprint(nexts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment