liuyuqi-dellpc 4 years ago
commit
8e7349a933
4 changed files with 45 additions and 0 deletions
  1. 3 0
      .vscode/settings.json
  2. 4 0
      README.md
  3. 0 0
      python/requirements.txt
  4. 38 0
      python/xshell_tools.py

+ 3 - 0
.vscode/settings.json

@@ -0,0 +1,3 @@
+{
+    "python.pythonPath": "D:\\Program-Files\\Anaconda3\\python.exe"
+}

+ 4 - 0
README.md

@@ -0,0 +1,4 @@
+## DecryptPwd
+
+对密码已保存在 Windwos 系统上的部分程序进行解析,包括:Navicat,TeamViewer,FileZilla,WinSCP,Xmangager系列产品(Xshell,Xftp)。
+

+ 0 - 0
python/requirements.txt


+ 38 - 0
python/xshell_tools.py

@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+@Author  :   liuyuqi
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2019/10/14 12:05:11
+@Version :   1.0
+@License :   (C)Copyright 2019
+@Desc    :   xshell xsftp加密解密算法
+'''
+
+from base64 import b64encode, b64decode
+from Crypto.Hash import MD5, SHA256
+from Crypto.Cipher import ARC4
+
+UserSid = "RcoIlS-1-5-21-3990929841-153547143-3340509336-1001".encode("utf-8")
+Pass = "root".encode("utf-8")
+rawPass = "klSqckgTSU0TfhYxu6MB1ayrbnu3qnTOEYXUVlZe9R1zdney".encode("utf-8")
+
+def encode():
+    """
+    加密
+    """
+    cipher = ARC4.new(SHA256.new(UserSid).digest())
+    checksum = SHA256.new(Pass).digest()
+    ciphertext = cipher.encrypt(rawPass)
+    print(b64encode(ciphertext + checksum).decode())
+
+
+def decode():
+    data = b64decode(rawPass)
+    Cipher = ARC4.new(SHA256.new((UserSid)).digest())
+    ciphertext, checksum = data[:-SHA256.digest_size], data[-SHA256.digest_size:]
+    plaintext = Cipher.decrypt(ciphertext)
+    print(plaintext.decode())
+
+if __name__ == "__main__":
+    decode()