Cisco_IOU_Crack

Posted zenosblog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cisco_IOU_Crack相关的知识,希望对你有一定的参考价值。

附源码:
#! /usr/bin/python3
print("*********************************************************************")
print("Cisco IOU License Generator - Kal 2011, python port of 2006 C version")
print("Modified to work with python3 by c_d 2014")
import os
import socket
import hashlib
import struct

# get the host id and host name to calculate the hostkey
hostid=os.popen("hostid").read().strip()
hostname = socket.gethostname()
ioukey=int(hostid,16)
for x in hostname:
 ioukey = ioukey + ord(x)
print("hostid=" + hostid +", hostname="+ hostname + ", ioukey=" + hex(ioukey)[2:])

# create the license using md5sum
iouPad1 = bx4Bx58x21x81x56x7Bx0DxF3x21x43x9Bx7ExACx1DxE6x8A
iouPad2 = bx80 + 39*b
md5input=iouPad1 + iouPad2 + struct.pack(!L, ioukey) + iouPad1
iouLicense=hashlib.md5(md5input).hexdigest()[:16]

print("
Add the following text to ~/.iourc:")
print("[license]
" + hostname + " = " + iouLicense + ";
")
print("You can disable the phone home feature with something like:")
print(" echo ‘127.0.0.127 xml.cisco.com‘ >> /etc/hosts
")

 

问题现象:生成IOU License的时候出现struct.error

#./CiscoIOUkeygen.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可能就行了。

原先第21行是这样的:

  1. md5input=iouPad1 + iouPad2 + struct.pack(‘!i‘, ioukey) + iouPad1

现在将i改成L

  1. md5input=iouPad1 + iouPad2 + struct.pack(‘!L‘, ioukey) + iouPad1

测试成功:
# ./CiscoIOUkeygen.py

  1.     *********************************************************************
  2.     Cisco IOU License Generator - Kal 2011, python port of 2006 C version
  3.     hostid=a8c0caa0, hostname=192_168_160_202, ioukey=a8c0ce23L
  4.     Add the following text to ~/.iourc:
  5.     [license]
  6.     GNS3 = 0c3838fa36b12ed4;
  7.     You can disable the phone home feature with something like:
  8.      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改短一点也能成功,但不推荐。


































以上是关于Cisco_IOU_Crack的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数