问题现象:生成IOU License的时候出现struct.error
- [root@192_168_160_202 IOU]# ./crack.py
- *********************************************************************
- Cisco IOU License Generator - Kal 2011, python port of 2006 C version
- hostid=a8c0caa0, hostname=192_168_160_202, ioukey=a8c0ce23L
- Traceback (most recent call last):
- File "./crack.py", line 18, in <module>
- md5input=iouPad1 + iouPad2 + struct.pack('!i', ioukey) + iouPad1
- struct.error: integer out of range for 'i' format code
分析:可能是由于不同机器算出来的值不一样,转换整数的时候溢出。超出'i'的范围那就换类型,用I,l或L可能就行了(具体见后面说明)。
原先第18行是这样的:
- md5input=iouPad1 + iouPad2 + struct.pack('!i', ioukey) + iouPad1
现在将i改成L
- md5input=iouPad1 + iouPad2 + struct.pack('!L', ioukey) + iouPad1
测试成功:
- [root@192_168_160_202 IOU]# ./crack.py
- *********************************************************************
- Cisco IOU License Generator - Kal 2011, python port of 2006 C version
- hostid=a8c0caa0, hostname=192_168_160_202, ioukey=a8c0ce23L
- Add the following text to ~/.iourc:
- [license]
- 192_168_160_202 = 0c3838fa36b12ed4;
- You can disable the phone home feature with something like:
- echo '127.0.0.127 xml.cisco.com' >> /etc/hosts
说明:
函数的用法是这样的:struct.pack(format, data)
The optional first format char indicates byte order, size and alignment:
@: native order, size & alignment (default)
=: native order, std. size & alignment
<: little-endian, std. size & alignment
>: big-endian, std. size & alignment
!: same as >
The remaining chars indicate types of args and must match exactly;
these can be preceded by a decimal repeat count:
x: pad byte (no data); c:char; b:signed byte; B:unsigned byte;
h:short; H:unsigned short; i:int; I:unsigned int;
l:long; L:unsigned long; f:float; d:double.
Special cases (preceding decimal count indicates length):
s:string (array of char); p: pascal string (with count byte).
Special case (only available in native format):
P:an integer type that is wide enough to hold a pointer.
Special case (not in native mode unless 'long long' in platform C):
q:long long; Q:unsigned long long
Whitespace between formats is ignored.
有时将hostname改短一点也能成功,但不推荐。
阅读(5837) | 评论(0) | 转发(0) |