首先,感谢xee发表的爆破教程,http://bbs.pediy.com/showthread.php?t=138599,省去了许多前期工作。
友情提示,本文需要一点python基础。
【准备】
xee同学已经说过,用unpyclib能得到.pyc .pyo的op code,而一个op code的文本基本上有几百K,
怎么查看、分析这些op code呢?
正所谓,工欲善其事,必先利其器。要浏览如烟似海的代码,一个能高亮代码的编辑器是必不可少的。
我用了notepad++,利用自定义语言功能,简单定义了python opcode的高亮语法。
相信我,花半个小时做这点事,是绝对值得的。
光看静态的代码很吃力,要让代码跑起来,才能更好的理解和分析。
注册模块运行的是python 2.5,所以得先安装一个python 2.5。
然后,将目标程序安装目录下 bin\2.5的src.zip解压到c:\ide 下面,把所有的.pyo文件改名成.pyc。
编辑一个test.py,里面只用写一句
from process import abstract
import sys
sys.path += ("c:/ide", "c:/ide/pygtk")
import tempfile
tempfile.tempdir = "c:/windows/temp"
import os
os.environ["WINGHOME"] = "c:/ide"
from process import abstract
0000245A CODE:
argcount:
0000245B LONG: 1L (01 00 00 00)
nlocals:
0000245F LONG: 8L (08 00 00 00)
stacksize:
00002463 LONG: 4L (04 00 00 00)
flags:
00002467 LONG: 67L (43 00 00 00)
(OPTIMIZED, NEWLOCALS, NOFREE)
code:
0000246B STR: 't\x00\x00|\x00\x00\x83\x01\x00\\\x02\x00}\x01\x00}\x02\x00t\x01\x00|\x02\x00\x83\x01\x00d\x01\x00j\x04\x00o2...' (B0 01 00 00 74 00 00 7C 00 00 83 01...)
00000000 74 - LOAD_GLOBAL '__ValidateAndNormalize'
00000003 7C - LOAD_FAST 'id'
00000006 83 - CALL_FUNCTION
00000009 5C - UNPACK_SEQUENCE
0000000C 7D - STORE_FAST 'errs'
0000000F 7D - STORE_FAST 'id2'
00000012 74 - LOAD_GLOBAL 'len'
00000015 7C - LOAD_FAST 'id2'
00000018 83 - CALL_FUNCTION
0000001B 64 - LOAD_CONST 0
0000001E 6A - COMPARE_OP ">"
00000021 6F - JUMP_IF_FALSE -> 00000056
00000024 01 - POP_TOP
00000025 7C - LOAD_FAST 'id2'
00000028 64 - LOAD_CONST 0
0000002B 19 - BINARY_SUBSCR
0000002C 74 - LOAD_GLOBAL 'kLicenseUseCodes'
0000002F 6A - COMPARE_OP "not in"
00000032 6F - JUMP_IF_FALSE -> 00000056
00000035 01 - POP_TOP
00000036 7C - LOAD_FAST 'errs'
00000039 69 - LOAD_ATTR 'append'
0000003C 74 - LOAD_GLOBAL '_'
0000003F 64 - LOAD_CONST 'Invalid first character: Should be one of %s'
00000042 83 - CALL_FUNCTION
00000045 74 - LOAD_GLOBAL 'str'
00000048 74 - LOAD_GLOBAL 'kLicenseUseCodes'
0000004B 83 - CALL_FUNCTION
0000004E 16 - BINARY_MODULO
0000004F 83 - CALL_FUNCTION
00000052 01 - POP_TOP
00000053 6E - JUMP_FORWARD -> 00000057
00000056 01 - POP_TOP
00000057 74 - LOAD_GLOBAL 'len'
0000005A 7C - LOAD_FAST 'id2'
0000005D 83 - CALL_FUNCTION
00000060 64 - LOAD_CONST 1
00000063 6A - COMPARE_OP ">"
00000066 6F - JUMP_IF_FALSE -> 000000EC
00000069 01 - POP_TOP
0000006A 7C - LOAD_FAST 'id2'
0000006D 64 - LOAD_CONST 1
00000070 19 - BINARY_SUBSCR
00000071 74 - LOAD_GLOBAL 'kLicenseProdCode'
00000074 6A - COMPARE_OP "!="
00000077 6F - JUMP_IF_FALSE -> 000000EC
0000007A 01 - POP_TOP
0000007B 64 - LOAD_CONST 'Wing IDE %s'
0000007E 74 - LOAD_GLOBAL 'config'
00000081 69 - LOAD_ATTR 'kProduct'
00000084 16 - BINARY_MODULO
00000085 7D - STORE_FAST 'cur_product'
00000088 74 - LOAD_GLOBAL 'kLicenseProdForCode'
0000008B 69 - LOAD_ATTR 'get'
0000008E 7C - LOAD_FAST 'id2'
00000091 64 - LOAD_CONST 1
00000094 19 - BINARY_SUBSCR
00000095 64 - LOAD_CONST None
00000098 83 - CALL_FUNCTION
0000009B 7D - STORE_FAST 'lic_product'
0000009E 7C - LOAD_FAST 'lic_product'
000000A1 64 - LOAD_CONST None
000000A4 6A - COMPARE_OP "is"
000000A7 6F - JUMP_IF_FALSE -> 000000BA
000000AA 01 - POP_TOP
000000AB 74 - LOAD_GLOBAL '_'
000000AE 64 - LOAD_CONST 'an unknown product'
000000B1 83 - CALL_FUNCTION
000000B4 7D - STORE_FAST 'lic_product'
000000B7 6E - JUMP_FORWARD -> 000000CC
000000BA 01 - POP_TOP
000000BB 64 - LOAD_CONST 'Wing IDE %s'
000000BE 74 - LOAD_GLOBAL 'config'
000000C1 69 - LOAD_ATTR 'k_ProductNames'
000000C4 7C - LOAD_FAST 'lic_product'
000000C7 19 - BINARY_SUBSCR
000000C8 16 - BINARY_MODULO
000000C9 7D - STORE_FAST 'lic_product'
000000CC 7C - LOAD_FAST 'errs'
000000CF 69 - LOAD_ATTR 'append'
000000D2 74 - LOAD_GLOBAL '_'
000000D5 64 - LOAD_CONST 'Your license is for %s, but you are currently running %s. Please download the correct product from http://wingware.com/downloads or upgrade your license at https://wingware.com/store/upgrade'
000000D8 83 - CALL_FUNCTION
000000DB 7C - LOAD_FAST 'lic_product'
000000DE 7C - LOAD_FAST 'cur_product'
000000E1 66 - BUILD_TUPLE
000000E4 16 - BINARY_MODULO
000000E5 83 - CALL_FUNCTION
000000E8 01 - POP_TOP
000000E9 6E - JUMP_FORWARD -> 000000ED
000000EC 01 - POP_TOP
000000ED 74 - LOAD_GLOBAL 'len'
000000F0 7C - LOAD_FAST 'errs'
000000F3 83 - CALL_FUNCTION
000000F6 64 - LOAD_CONST 0
000000F9 6A - COMPARE_OP ">"
000000FC 6F - JUMP_IF_FALSE -> 00000180
000000FF 01 - POP_TOP
00000100 7C - LOAD_FAST 'id'
00000103 69 - LOAD_ATTR 'strip'
00000106 83 - CALL_FUNCTION
00000109 69 - LOAD_ATTR 'upper'
0000010C 83 - CALL_FUNCTION
0000010F 69 - LOAD_ATTR 'replace'
00000112 64 - LOAD_CONST '-'
00000115 64 - LOAD_CONST ''
00000118 83 - CALL_FUNCTION
0000011B 7D - STORE_FAST 'check_code'
0000011E 74 - LOAD_GLOBAL 'len'
00000121 7C - LOAD_FAST 'check_code'
00000124 83 - CALL_FUNCTION
00000127 64 - LOAD_CONST 16
0000012A 6A - COMPARE_OP "=="
0000012D 6F - JUMP_IF_FALSE -> 0000017C
00000130 01 - POP_TOP
00000131 74 - LOAD_GLOBAL 'True'
00000134 7D - STORE_FAST 'looks_like_11'
00000137 78 - SETUP_LOOP -> 0000015F
0000013A 7C - LOAD_FAST 'check_code'
0000013D 44 - GET_ITER
0000013E 5D - FOR_ITER -> 0000015E
00000141 7D - STORE_FAST 'c'
00000144 7C - LOAD_FAST 'c'
00000147 64 - LOAD_CONST '0123456789ABCDEF'
0000014A 6A - COMPARE_OP "not in"
0000014D 6F - JUMP_IF_FALSE -> 0000015A
00000150 01 - POP_TOP
00000151 74 - LOAD_GLOBAL 'False'
00000154 7D - STORE_FAST 'looks_like_11'
00000157 71 - JUMP_ABSOLUTE -> 0000013E
0000015A 01 - POP_TOP
0000015B 71 - JUMP_ABSOLUTE -> 0000013E
0000015E 57 - POP_BLOCK
0000015F 7C - LOAD_FAST 'looks_like_11'
00000162 6F - JUMP_IF_FALSE -> 00000178
00000165 01 - POP_TOP
00000166 74 - LOAD_GLOBAL '_'
00000169 64 - LOAD_CONST 'You cannot activate using a Wing IDE 1.1 license: Please use a trial license or upgrade your license at http://wingware.com/store/upgrade'
0000016C 83 - CALL_FUNCTION
0000016F 67 - BUILD_LIST
00000172 7D - STORE_FAST 'errs'
00000175 71 - JUMP_ABSOLUTE -> 0000017D
00000178 01 - POP_TOP
00000179 71 - JUMP_ABSOLUTE -> 00000181
0000017C 01 - POP_TOP
0000017D 6E - JUMP_FORWARD -> 00000181
00000180 01 - POP_TOP
00000181 74 - LOAD_GLOBAL 'len'
00000184 7C - LOAD_FAST 'errs'
00000187 83 - CALL_FUNCTION
0000018A 64 - LOAD_CONST 0
0000018D 6A - COMPARE_OP ">"
00000190 6F - JUMP_IF_FALSE -> 000001A1
00000193 01 - POP_TOP
00000194 7C - LOAD_FAST 'errs'
00000197 64 - LOAD_CONST None
0000019A 66 - BUILD_TUPLE
0000019D 53 - RETURN_VALUE
0000019E 6E - JUMP_FORWARD -> 000001AC
000001A1 01 - POP_TOP
000001A2 67 - BUILD_LIST
000001A5 7C - LOAD_FAST 'id2'
000001A8 66 - BUILD_TUPLE
000001AB 53 - RETURN_VALUE
000001AC 64 - LOAD_CONST None
000001AF 53 - RETURN_VALUE
consts:
00002620 TUPLE: (
00002625 None (4E),
00002626 INT: 0 (00 00 00 00),
0000262B STR: 'Invalid first character: Should be ...' (2C 00 00 00 49 6E 76 61 6C 69 64 20...),
0000265C INT: 1 (01 00 00 00),
00002661 STR: 'Wing IDE %s' (0B 00 00 00 57 69 6E 67 20 49 44 45...),
00002671 STR: 'an unknown product' (12 00 00 00 61 6E 20 75 6E 6B 6E 6F...),
00002688 STR: 'Your license is for %s, but you are...' (BF 00 00 00 59 6F 75 72 20 6C 69 63...),
0000274C STR: '-' (92 00 00 00),
00002751 STR: '' (48 00 00 00),
00002756 INT: 16 (10 00 00 00),
0000275B STR: '0123456789ABCDEF' (10 00 00 00 30 31 32 33 34 35 36 37...),
00002770 STR: 'You cannot activate using a Wing ID...' (8A 00 00 00 59 6F 75 20 63 61 6E 6E...)
)
names:
000027FF TUPLE: (
00002804 STR: '__ValidateAndNormalize' (A6 00 00 00),
00002809 STR: 'len' (69 00 00 00),
0000280E STR: 'kLicenseUseCodes' (10 00 00 00 6B 4C 69 63 65 6E 73 65...),
00002823 STR: 'append' (7C 00 00 00),
00002828 STR: '_' (7D 00 00 00),
0000282D STR: 'str' (97 00 00 00),
00002832 STR: 'kLicenseProdCode' (50 00 00 00),
00002837 STR: 'config' (57 00 00 00),
0000283C STR: 'kProduct' (08 00 00 00 6B 50 72 6F 64 75 63 74),
00002849 STR: 'kLicenseProdForCode' (13 00 00 00 6B 4C 69 63 65 6E 73 65...),
00002861 STR: 'get' (38 00 00 00),
00002866 STR: 'None' (3B 00 00 00),
0000286B STR: 'k_ProductNames' (0E 00 00 00 6B 5F 50 72 6F 64 75 63...),
0000287E STR: 'strip' (A0 00 00 00),
00002883 STR: 'upper' (81 00 00 00),
00002888 STR: 'replace' (4B 00 00 00),
0000288D STR: 'True' (04 00 00 00 54 72 75 65),
00002896 STR: 'False' (05 00 00 00 46 61 6C 73 65)
)
varnames:
000028A0 TUPLE: (
000028A5 STR: 'id' (02 00 00 00 69 64),
000028AC STR: 'errs' (8A 00 00 00),
000028B1 STR: 'id2' (03 00 00 00 69 64 32),
000028B9 STR: 'cur_product' (0B 00 00 00 63 75 72 5F 70 72 6F 64...),
000028C9 STR: 'lic_product' (0B 00 00 00 6C 69 63 5F 70 72 6F 64...),
000028D9 STR: 'check_code' (0A 00 00 00 63 68 65 63 6B 5F 63 6F...),
000028E8 STR: 'looks_like_11' (0D 00 00 00 6C 6F 6F 6B 73 5F 6C 69...),
000028FA STR: 'c' (A5 00 00 00)
)
freevars:
000028FF TUPLE: ()
cellvars:
00002904 TUPLE: ()
filename:
00002909 STR: 'C:\\src\\ide\\bin\\2.5\\src\\process\\abst...' (2B 00 00 00 43 3A 5C 73 72 63 5C 69...)
name:
00002939 STR: 'ValidateAndNormalizeLicenseID' (1D 00 00 00 56 61 6C 69 64 61 74 65...)
firslineno:
0000295B LONG: 392L (88 01 00 00)
lnotab:
0000295F STR: '\x00\x02\x12\x02$\x01!\x02$\x01\r\x01\x16\x01\r\x01\x10\x02\x11\x01\x0f\x02\x12\x02\x13\x01\x1e\x01\x13\x01\x06\x01\x07\x00\x06...' (30 00 00 00 00 02 12 02 24 01 21 02...),
print abstract.ValidateAndNormalizeLicenseID("123456789A123456789A")
([u'Contains invalid characters: 0', u'Your license is for an unknown product, but you are currently running Wing IDE Professional. Please download the correct product from http://wingware.com/downloads or upgrade your license at https://wingware.com/store/upgrade'], None)
00000000 74 - LOAD_GLOBAL '__ValidateAndNormalize'
00000003 7C - LOAD_FAST 'id'
00000006 83 - CALL_FUNCTION
print abstract.__ValidateAndNormalize("123456789A123456789A")
([], '12345-6789A-12345-6789A')
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!