Lib for CrackMe Xchat2 Plugin


SUBMITTED BY: Guest

DATE: Sept. 18, 2012, 5:40 p.m.

FORMAT: Python

SIZE: 7.6 kB

HITS: 1784

  1. # -*- coding: utf-8 -*-
  2. #
  3. # NOTE : Library for CrackMe 0.3 Beta (http://www.bitbin.it/PUt0h7ZN)
  4. # paste in a file with the name "crypto.py" and put in your
  5. # /home/user/.xchat2/
  6. #
  7. # crypto.py
  8. #
  9. # Copyright (c) 2010 - Kalkulators Knights
  10. #
  11. # This file is part of Kalkb0t.
  12. # Kalkb0t is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; either version 2 of the License, or
  15. # (at your option) any later version.
  16. #
  17. # This program is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. # GNU General Public License for more details.
  21. #
  22. # You should have received a copy of the GNU General Public License
  23. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. #
  25. from Crypto.Cipher import DES
  26. import mhash
  27. __all__ = ['HashMaker']
  28. class SambaPass(object):
  29. """Generate lm and ntlm hashes - Thanks to sanguinarius for this class
  30. """
  31. def lmhash(self, password):
  32. """generate lm hash"""
  33. secret = r'KGS!@#$%'
  34. password = password.upper()[:14]
  35. k1 = self.SMB_Key(password[:7])
  36. k2 = self.SMB_Key(password[7:])
  37. d1 = DES.new(k1, DES.MODE_CBC)
  38. d2 = DES.new(k2, DES.MODE_CBC)
  39. h1 = d1.encrypt(secret).encode('hex').upper()
  40. h2 = d2.encrypt(secret).encode('hex').upper()
  41. if len(password) > 7:
  42. return h1+h2
  43. else:
  44. return h1
  45. def SMB_Key(self, string):
  46. """convert the string the way samba does
  47. """
  48. key7bits = [0] * 8
  49. key8bits = [0] * 8
  50. for i in range(0, len(string)):
  51. key7bits[i] = ord(string[i])
  52. key8bits[0] = ((key7bits[0] >> 1) & 0xff)
  53. key8bits[1] = ((((key7bits[0] & 0x01) << 6) | (((key7bits[1] & 0xff)>>2) & 0xff)) & 0xff)
  54. key8bits[2] = ((((key7bits[1] & 0x03) << 5) | (((key7bits[2] & 0xff)>>3) & 0xff)) & 0xff)
  55. key8bits[3] = ((((key7bits[2] & 0x07) << 4) | (((key7bits[3] & 0xff)>>4) & 0xff)) & 0xff)
  56. key8bits[4] = ((((key7bits[3] & 0x0F) << 3) | (((key7bits[4] & 0xff)>>5) & 0xff)) & 0xff)
  57. key8bits[5] = ((((key7bits[4] & 0x1F) << 2) | (((key7bits[5] & 0xff)>>6) & 0xff)) & 0xff)
  58. key8bits[6] = ((((key7bits[5] & 0x3F) << 1) | (((key7bits[6] & 0xff)>>7) & 0xff)) & 0xff)
  59. key8bits[7] = (key7bits[6] & 0x7F)
  60. for i in range(0,8):
  61. key8bits[i] = (key8bits[i] << 1)
  62. result = ''
  63. for i in range(0, 8):
  64. result += chr(key8bits[i])
  65. return result
  66. class HashMaker(object):
  67. """Multi-algorithms hash generation class
  68. """
  69. @staticmethod
  70. def adler32(plaintext):
  71. return get_digest('adler32', plaintext).encode('hex')
  72. @staticmethod
  73. def crc32(plaintext):
  74. return get_digest('crc32', plaintext).encode('hex')
  75. @staticmethod
  76. def crc32b(plaintext):
  77. return get_digest('crc32b', plaintext).encode('hex')
  78. @staticmethod
  79. def gost(plaintext):
  80. return get_digest('gost', plaintext).encode('hex')
  81. @staticmethod
  82. def haval128(plaintext):
  83. return get_digest('haval128', plaintext).encode('hex')
  84. @staticmethod
  85. def haval160(plaintext):
  86. return get_digest('haval160', plaintext).encode('hex')
  87. @staticmethod
  88. def haval192(plaintext):
  89. return get_digest('haval192', plaintext).encode('hex')
  90. @staticmethod
  91. def haval224(plaintext):
  92. return get_digest('haval224', plaintext).encode('hex')
  93. @staticmethod
  94. def haval256(plaintext):
  95. return get_digest('haval256', plaintext).encode('hex')
  96. @staticmethod
  97. def md2(plaintext):
  98. return get_digest('md2', plaintext).encode('hex')
  99. @staticmethod
  100. def md4(plaintext):
  101. return get_digest('md4', plaintext).encode('hex')
  102. @staticmethod
  103. def md5(plaintext):
  104. return get_digest('md5', plaintext).encode('hex')
  105. @staticmethod
  106. def ripemd128(plaintext):
  107. return get_digest('ripemd128', plaintext).encode('hex')
  108. @staticmethod
  109. def ripemd160(plaintext):
  110. return get_digest('ripemd160', plaintext).encode('hex')
  111. @staticmethod
  112. def ripemd256(plaintext):
  113. return get_digest('ripemd256', plaintext).encode('hex')
  114. @staticmethod
  115. def ripemd320(plaintext):
  116. return get_digest('ripemd320', plaintext).encode('hex')
  117. @staticmethod
  118. def sha1(plaintext):
  119. return get_digest('sha1', plaintext).encode('hex')
  120. @staticmethod
  121. def sha224(plaintext):
  122. return get_digest('sha224', plaintext).encode('hex')
  123. @staticmethod
  124. def sha256(plaintext):
  125. return get_digest('sha256', plaintext).encode('hex')
  126. @staticmethod
  127. def sha384(plaintext):
  128. return get_digest('sha384', plaintext).encode('hex')
  129. @staticmethod
  130. def sha512(plaintext):
  131. return get_digest('sha512', plaintext).encode('hex')
  132. @staticmethod
  133. def snefru128(plaintext):
  134. return get_digest('snefru128', plaintext).encode('hex')
  135. @staticmethod
  136. def snefru256(plaintext):
  137. return get_digest('snefru256', plaintext).encode('hex')
  138. @staticmethod
  139. def tiger(plaintext):
  140. return get_digest('tiger', plaintext).encode('hex')
  141. @staticmethod
  142. def tiger128(plaintext):
  143. return get_digest('tiger128', plaintext).encode('hex')
  144. @staticmethod
  145. def tiger160(plaintext):
  146. return get_digest('tiger160', plaintext).encode('hex')
  147. @staticmethod
  148. def whirlpool(plaintext):
  149. return get_digest('whirlpool', plaintext).encode('hex')
  150. @staticmethod
  151. def mysql3(plaintext):
  152. nr = 1345345333
  153. add = 7
  154. nr2 = 0x12345671
  155. for char in plaintext:
  156. if char in ' \t':
  157. continue
  158. tmp = ord(char)
  159. nr ^= (((nr & 63)+add)*tmp) + (nr << 8)
  160. nr &= 0xffffffff
  161. nr2 += (nr2 << 8) ^ nr
  162. nr2 &= 0xffffffff
  163. add += tmp
  164. ints = (
  165. nr & ((1 << 31)-1),
  166. nr2 & ((1 << 31)-1)
  167. )
  168. return "%08lx%08lx" % ints
  169. @staticmethod
  170. def mysql5(plaintext):
  171. sha1 = get_digest('sha1', plaintext)
  172. mysql5 = get_digest('sha1', sha1)
  173. return mysql5.encode('hex')
  174. @staticmethod
  175. def lm(plaintext):
  176. return SambaPass().lmhash(plaintext)
  177. def get_digest(algo, plaintext):
  178. md = mhash.MHASH(getattr(mhash, 'MHASH_%s' % algo.upper()))
  179. md.update(plaintext)
  180. return md.digest()

comments powered by Disqus