SecureCRTSecure7.0查看连接密码的步骤

整体分为两步:

第一步:查看系统保存的连接的ini文件(大概位置:F:\SecureCRTSecureFX_HH_x64_7.0.0.326\Data\Settings\Config\Sessions)

ini文件的格式样例:

  1. ip地址
  2. S:“Hostname”=192.168.0.145
  3. –登录用户
  4. S:“Username”=root
  5. –端口,加密
  6. D:“[SSH2] 端口”=00000016
  7. –密码,加密,解密需要u之后的字符串
  8. S:“Password”=u2c7d50aae53e14eb94ef0cb377c247a77c2dbcea95333365

第二步:破解加密之后的密码,这个使用python3,具体脚本如下:

  1. #!/usr/bin/env python3
  2. import os
  3. from Crypto.Hash import SHA256
  4. from Crypto.Cipher import AES, Blowfish
  5.  
  6. class SecureCRTCrypto:
  7.  
  8. def __init__(self):
  9. ”’
  10. Initialize SecureCRTCrypto object.
  11. ”’
  12. self.IV = b‘\x00’ * Blowfish.block_size
  13. self.Key1 = b‘\x24\xA6\x3D\xDE\x5B\xD3\xB3\x82\x9C\x7E\x06\xF4\x08\x16\xAA\x07’
  14. self.Key2 = b‘\x5F\xB0\x45\xA2\x94\x17\xD9\x16\xC6\xC6\xA2\xFF\x06\x41\x82\xB7’
  15.  
  16. def Encrypt(self, Plaintext : str):
  17. ”’
  18. Encrypt plaintext and return corresponding ciphertext.
  19. Args:
  20. Plaintext: A string that will be encrypted.
  21. Returns:
  22. Hexlified ciphertext string.
  23. ”’
  24. plain_bytes = Plaintext.encode(‘utf-16-le’)
  25. plain_bytes += b‘\x00\x00’
  26. padded_plain_bytes = plain_bytes + os.urandom(Blowfish.block_size len(plain_bytes) % Blowfish.block_size)
  27.  
  28. cipher1 = Blowfish.new(self.Key1, Blowfish.MODE_CBC, iv = self.IV)
  29. cipher2 = Blowfish.new(self.Key2, Blowfish.MODE_CBC, iv = self.IV)
  30. return cipher1.encrypt(os.urandom(4) + cipher2.encrypt(padded_plain_bytes) + os.urandom(4)).hex()
  31.  
  32. def Decrypt(self, Ciphertext : str):
  33. ”’
  34. Decrypt ciphertext and return corresponding plaintext.
  35. Args:
  36. Ciphertext: A hex string that will be decrypted.
  37. Returns:
  38. Plaintext string.
  39. ”’
  40.  
  41. cipher1 = Blowfish.new(self.Key1, Blowfish.MODE_CBC, iv = self.IV)
  42. cipher2 = Blowfish.new(self.Key2, Blowfish.MODE_CBC, iv = self.IV)
  43. ciphered_bytes = bytes.fromhex(Ciphertext)
  44. if len(ciphered_bytes) <= 8:
  45. raise ValueError(‘Invalid Ciphertext.’)
  46.  
  47. padded_plain_bytes = cipher2.decrypt(cipher1.decrypt(ciphered_bytes)[4:-4])
  48.  
  49. i = 0
  50. for i in range(0, len(padded_plain_bytes), 2):
  51. if padded_plain_bytes[i] == 0 and padded_plain_bytes[i + 1] == 0:
  52. break
  53. plain_bytes = padded_plain_bytes[0:i]
  54.  
  55. try:
  56. return plain_bytes.decode(‘utf-16-le’)
  57. except UnicodeDecodeError:
  58. raise(ValueError(‘Invalid Ciphertext.’))
  59.  
  60. class SecureCRTCryptoV2:
  61.  
  62. def __init__(self, ConfigPassphrase : str = ):
  63. ”’
  64. Initialize SecureCRTCryptoV2 object.
  65. Args:
  66. ConfigPassphrase: The config passphrase that SecureCRT uses. Leave it empty if config passphrase is not set.
  67. ”’
  68. self.IV = b‘\x00’ * AES.block_size
  69. self.Key = SHA256.new(ConfigPassphrase.encode(‘utf-8’)).digest()
  70.  
  71. def Encrypt(self, Plaintext : str):
  72. ”’
  73. Encrypt plaintext and return corresponding ciphertext.
  74. Args:
  75. Plaintext: A string that will be encrypted.
  76. Returns:
  77. Hexlified ciphertext string.
  78. ”’
  79. plain_bytes = Plaintext.encode(‘utf-8’)
  80. if len(plain_bytes) > 0xffffffff:
  81. raise OverflowError(‘Plaintext is too long.’)
  82.  
  83. plain_bytes = \
  84. len(plain_bytes).to_bytes(4, ‘little’) + \
  85. plain_bytes + \
  86. SHA256.new(plain_bytes).digest()
  87. padded_plain_bytes = \
  88. plain_bytes + \
  89. os.urandom(AES.block_size len(plain_bytes) % AES.block_size)
  90. cipher = AES.new(self.Key, AES.MODE_CBC, iv = self.IV)
  91. return cipher.encrypt(padded_plain_bytes).hex()
  92.  
  93. def Decrypt(self, Ciphertext : str):
  94. ”’
  95. Decrypt ciphertext and return corresponding plaintext.
  96. Args:
  97. Ciphertext: A hex string that will be decrypted.
  98. Returns:
  99. Plaintext string.
  100. ”’
  101. cipher = AES.new(self.Key, AES.MODE_CBC, iv = self.IV)
  102. padded_plain_bytes = cipher.decrypt(bytes.fromhex(Ciphertext))
  103.  
  104. plain_bytes_length = int.from_bytes(padded_plain_bytes[0:4], ‘little’)
  105. plain_bytes = padded_plain_bytes[4:4 + plain_bytes_length]
  106. if len(plain_bytes) != plain_bytes_length:
  107. raise ValueError(‘Invalid Ciphertext.’)
  108.  
  109. plain_bytes_digest = padded_plain_bytes[4 + plain_bytes_length:4 + plain_bytes_length + SHA256.digest_size]
  110. if len(plain_bytes_digest) != SHA256.digest_size:
  111. raise ValueError(‘Invalid Ciphertext.’)
  112.  
  113. if SHA256.new(plain_bytes).digest() != plain_bytes_digest:
  114. raise ValueError(‘Invalid Ciphertext.’)
  115.  
  116. return plain_bytes.decode(‘utf-8’)
  117.  
  118. if __name__ == ‘__main__’:
  119. import sys
  120.  
  121. def Help():
  122. print(‘Usage:’)
  123. print(‘ SecureCRTCipher.py <enc|dec> [-v2] [-p ConfigPassphrase] <plaintext|ciphertext>’)
  124. print()
  125. print(‘ <enc|dec> “enc” for encryption, “dec” for decryption.’)
  126. print(‘ This parameter must be specified.’)
  127. print()
  128. print(‘ [-v2] Encrypt/Decrypt with “Password V2” algorithm.’)
  129. print(‘ This parameter is optional.’)
  130. print()
  131. print(‘ [-p ConfigPassphrase] The config passphrase that SecureCRT uses.’)
  132. print(‘ This parameter is optional.’)
  133. print()
  134. print(‘ <plaintext|ciphertext> Plaintext string or ciphertext string.’)
  135. print(‘ NOTICE: Ciphertext string must be a hex string.’)
  136. print(‘ This parameter must be specified.’)
  137. print()
  138.  
  139. def EncryptionRoutine(UseV2 : bool, ConfigPassphrase : str, Plaintext : str):
  140. try:
  141. if UseV2:
  142. print(SecureCRTCryptoV2(ConfigPassphrase).Encrypt(Plaintext))
  143. else:
  144. print(SecureCRTCrypto().Encrypt(Plaintext))
  145. return True
  146. except:
  147. print(‘Error: Failed to encrypt.’)
  148. return False
  149.  
  150. def DecryptionRoutine(UseV2 : bool, ConfigPassphrase : str, Ciphertext : str):
  151. try:
  152. if UseV2:
  153. print(SecureCRTCryptoV2(ConfigPassphrase).Decrypt(Ciphertext))
  154. else:
  155. print(SecureCRTCrypto().Decrypt(Ciphertext))
  156. return True
  157. except:
  158. print(‘Error: Failed to decrypt.’)
  159. return False
  160.  
  161. def Main(argc : int, argv : list):
  162. if 3 <= argc and argc <= 6:
  163. bUseV2 = False
  164. ConfigPassphrase =
  165.  
  166. if argv[1].lower() == ‘enc’:
  167. bEncrypt = True
  168. elif argv[1].lower() == ‘dec’:
  169. bEncrypt = False
  170. else:
  171. Help()
  172. return 1
  173.  
  174. i = 2
  175. while i < argc 1:
  176. if argv[i].lower() == ‘-v2’:
  177. bUseV2 = True
  178. i += 1
  179. elif argv[i].lower() == ‘-p’ and i + 1 < argc 1:
  180. ConfigPassphrase = argv[i + 1]
  181. i += 2
  182. else:
  183. Help()
  184. return 1
  185.  
  186. if bUseV2 == False and len(ConfigPassphrase) != 0:
  187. print(‘Error: ConfigPassphrase is not supported if “-v2” is not specified’)
  188. return 1
  189.  
  190. if bEncrypt:
  191. return 0 if EncryptionRoutine(bUseV2, ConfigPassphrase, argv[-1]) else 1
  192. else:
  193. return 0 if DecryptionRoutine(bUseV2, ConfigPassphrase, argv[-1]) else 1
  194. else:
  195. Help()
  196.  
  197. exit(Main(len(sys.argv), sys.argv))

将上面的python代码保存为:SecureCRTCipher.py,使用分为两种情况:

第一种:

密码的格式如下:

S:”PasswordV2″=02:7b9f594a1f39bb36bbaa0d9688ee38b3d233c67b338e20e2113f2ba4d328b6fc8c804e3c02324b1eaad57a5b96ac1fc5cc1ae0ee2930e6af2e5e644a28ebe3fc

执行脚本:

python SecureCRTCipher.py dec -v2 7b9f594a1f39bb36bbaa0d9688ee38b3d233c67b338e20e2113f2ba4d328b6fc8c804e3c02324b1eaad57a5b96ac1fc5cc1ae0ee2930e6af2e5e644a28ebe3fc

第二种:

密码的格式如下:

S:”Password”=uc71bd1c86f3b804e42432f53247c50d9287f410c7e59166969acab69daa6eaadbe15c0c54c0e076e945a6d82f9e13df2

执行脚本:注意密码的字符串去掉u

python SecureCRTCipher.py dec c71bd1c86f3b804e42432f53247c50d9287f410c7e59166969acab69daa6eaadbe15c0c54c0e076e945a6d82f9e13df2

执行上述脚本,python需要安装pycryptodome模块,安装脚本:

  1. pip install pycryptodome

以上就是SecureCRTSecure7.0连接密码查看的详细内容,更多关于SecureCRTSecure7密码查看的资料请关注我们其它相关文章!

支持本站请点击我们的赞助商广告!我们将不断更新精品!

评论0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
没有账号? 忘记密码?