Chinaunix首页 | 论坛 | 博客
  • 博客访问: 172571
  • 博文数量: 47
  • 博客积分: 3053
  • 博客等级: 少校
  • 技术积分: 451
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-01 04:33
个人简介

malware/APT detection, silicon valley, entrepreneur, CTO, start-up operation, team build, Nanjing/Beijing, if you want to do creative things, join the adventure.

文章分类

全部博文(47)

分类: Python/Ruby

2016-11-27 18:03:09



ENX27-HWM6G-XYVFA-165PG




  1. # -*- coding: utf-8 -*-
  2. #先安装程序,安装完成后打开注册界面,输入下面的License ID 后得到RequestCode,将RequestCode替换掉本文件的RequestCode,运行代码,得到激活码
  3. import sha
  4. import string
  5. import sys
  6. reload(sys)
  7. sys.setdefaultencoding('utf-8')
  8. BASE2 = '01'
  9. BASE10 = '0123456789'
  10. BASE16 = '0123456789ABCDEF'
  11. BASE30 = '123456789ABCDEFGHJKLMNPQRTVWXY'
  12. BASE36 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  13. BASE62 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'
  14. BASEMAX = string.printable
  15. def BaseConvert(number, fromdigits, todigits, ignore_negative = True):
  16.     """ converts a "number" between two bases of arbitrary digits
  17.     
  18.     The input number is assumed to be a string of digits from the
  19.     fromdigits string (which is in order of smallest to largest
  20.     digit). The return value is a string of elements from todigits
  21.     (ordered in the same way). The input and output bases are
  22.     determined from the lengths of the digit strings. Negative
  23.     signs are passed through.
  24.     
  25.     decimal to binary
  26.     >>> baseconvert(555,BASE10,BASE2)
  27.     '1000101011'
  28.     
  29.     binary to decimal
  30.     >>> baseconvert('1000101011',BASE2,BASE10)
  31.     '555'
  32.     
  33.     integer interpreted as binary and converted to decimal (!)
  34.     >>> baseconvert(1000101011,BASE2,BASE10)
  35.     '555'
  36.     
  37.     base10 to base4
  38.     >>> baseconvert(99,BASE10,"0123")
  39.     '1203'
  40.     
  41.     base4 to base5 (with alphabetic digits)
  42.     >>> baseconvert(1203,"0123","abcde")
  43.     'dee'
  44.     
  45.     base5, alpha digits back to base 10
  46.     >>> baseconvert('dee',"abcde",BASE10)
  47.     '99'
  48.     
  49.     decimal to a base that uses A-Z0-9a-z for its digits
  50.     >>> baseconvert(257938572394L,BASE10,BASE62)
  51.     'E78Lxik'
  52.     
  53.     ..convert back
  54.     >>> baseconvert('E78Lxik',BASE62,BASE10)
  55.     '257938572394'
  56.     
  57.     binary to a base with words for digits (the function cannot convert this back)
  58.     >>> baseconvert('1101',BASE2,('Zero','One'))
  59.     'OneOneZeroOne'
  60.     
  61.     """
  62.     if not ignore_negative and str(number)[0] == '-':
  63.         number = str(number)[1:]
  64.         neg = 1
  65.     else:
  66.         neg = 0
  67.     x = long(0)
  68.     for digit in str(number):
  69.         x = x * len(fromdigits) + fromdigits.index(digit)

  70.     res = ''
  71.     while x > 0:
  72.         digit = x % len(todigits)
  73.         res = todigits[digit] + res
  74.         x /= len(todigits)

  75.     if neg:
  76.         res = '-' + res
  77.     return res

  78. def SHAToBase30(digest):
  79.     """Convert from a hexdigest form SHA hash into a more compact and
  80.     ergonomic BASE30 representation. This results in a 17 'digit'
  81.     number."""
  82.     tdigest = ''.join([ c for i, c in enumerate(digest) if i / 2 * 2 == i ])
  83.     result = BaseConvert(tdigest, BASE16, BASE30)
  84.     while len(result) < 17:
  85.         result = '1' + result

  86.     return result
  87. def AddHyphens(code):
  88.     """Insert hyphens into given license id or activation request to
  89.     make it easier to read"""
  90.     return code[:5] + '-' + code[5:10] + '-' + code[10:15] + '-' + code[15:]

  91. LicenseID='ENX27-HWM6G-XYVFA-165PG'
  92. #Copy the Request Code from the dialog
  93. RequestCode='RW537-V6NXW-GCLPK-7RE16'
  94. hasher = sha.new()
  95. hasher.update(RequestCode)
  96. hasher.update(LicenseID)
  97. digest = hasher.hexdigest().upper()
  98. lichash = RequestCode[:3] + SHAToBase30(digest)
  99. lichash=AddHyphens(lichash)

  100. #Calculate the Activation Code
  101. data=[7,123,23,87]
  102. tmp=0
  103. realcode=''
  104. for i in data:
  105.     for j in lichash:
  106.         tmp=(tmp*i+ord(j))&0xFFFFF
  107.     realcode+=format(tmp,'=05X')
  108.     tmp=0

  109. act30=BaseConvert(realcode,BASE16,BASE30)
  110. while len(act30) < 17:
  111.     act30 = '1' + act30
  112. act30='AXX'+act30
  113. act30=AddHyphens(act30)
  114. print "The Activation Code is: "+act30

  115. raw_input()



阅读(1143) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~