Skip to content

Instantly share code, notes, and snippets.

@rdymc
Created March 14, 2022 15:24
Show Gist options
  • Select an option

  • Save rdymc/ed3588e1128488868c243a432b4bcfb4 to your computer and use it in GitHub Desktop.

Select an option

Save rdymc/ed3588e1128488868c243a432b4bcfb4 to your computer and use it in GitHub Desktop.
CiscoIOUKeygen
#! /usr/bin/python
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 = b'\x4B\x58\x21\x81\x56\x7B\x0D\xF3\x21\x43\x9B\x7E\xAC\x1D\xE6\x8A'
iouPad2 = b'\x80' + 39*b'\0'
md5input=iouPad1 + iouPad2 + struct.pack('!L', ioukey) + iouPad1
iouLicense=hashlib.md5(md5input).hexdigest()[:16]
print("\nAdd the following text to ~/.iourc:")
print("[license]\n" + hostname + " = " + iouLicense + ";\n")
print("You can disable the phone home feature with something like:")
print(" echo '127.0.0.127 xml.cisco.com' >> /etc/hosts\n")
@aliyeheaa2-lang
Copy link

#! /usr/bin/python
مطبعة("*********************************************************************")
print("مولد ترخيص Cisco IOU - Kal 2011، منفذ Python لإصدار C 2006")
print("تم تعديله للعمل مع بايثون 3 بواسطة c_d 2014")
استيراد نظام التشغيل
مقبس الاستيراد
استيراد هاشليب
هيكل الاستيراد

احصل على معرف المضيف واسم المضيف لحساب مفتاح المضيف

معرف المضيف=os.popen("معرف المضيف").read().strip()
اسم المضيف = socket.gethostname()
ioukey=int(معرف المضيف، 16)
بالنسبة لـ x في اسم المضيف:
ioukey = ioukey + ord(x)
اطبع ("معرف المضيف=" + معرف المضيف +"، اسم المضيف=" + اسم المضيف + "، ioukey=" + hex(ioukey)[2:])

إنشاء الترخيص باستخدام md5sum

iouPad1 = b'\x4B\x58\x21\x81\x56\x7B\x0D\xF3\x21\x43\x9B\x7E\xAC\x1D\xE6\x8A'
iouPad2 = b'\x80' + 39*b'\0'
md5input=iouPad1 + iouPad2 + struct.pack('!L', ioukey) + iouPad1
ترخيص iou=hashlib.md5(md5input).hexdigest()[:16]

print("\nأضف النص التالي إلى ~/.iourc:")
طباعة ("[رخصة]\n" + اسم المضيف + " = " + iouLicense + "؛\n")
print("يمكنك تعطيل ميزة الاتصال بالمنزل باستخدام شيء مثل:")
اطبع ("صدى '127.0.0.127 xml.cisco.com' >> /etc/hosts\n

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment