Lxn-Chan!

(~ ̄▽ ̄)→))* ̄▽ ̄*)o

在 SecureCRT 中保存的终端密码是不可以直接被查看的,本文提供了一个Python脚本用于解密该密码。仅对 SecureCRT 7.x 版本有效,8.x版本目前好像是没有有效方案。

经过查找发现获取SecureCRT明文密码中提供了一种解密的方法,但仅限Python2,我又嫌麻烦没重装Python,于是重写了脚本使其能够在Python3下运行:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from Crypto.Cipher import Blowfish
import argparse
import re

def decrypt(password_hex: str) -> str:
key1 = bytes.fromhex('5F B0 45 A2 94 17 D9 16 C6 C6 A2 FF 06 41 82 B7')
key2 = bytes.fromhex('24 A6 3D DE 5B D3 B3 82 9C 7E 06 F4 08 16 AA 07')
iv = b'\x00' * 8

c1 = Blowfish.new(key1, Blowfish.MODE_CBC, iv)
c2 = Blowfish.new(key2, Blowfish.MODE_CBC, iv)

raw = bytes.fromhex(password_hex)

padded = c1.decrypt(c2.decrypt(raw)[4:-4])

p = b''
while not padded.startswith(b'\x00\x00'):
p += padded[:2]
padded = padded[2:]

return p.decode('utf-16')

REGEX_HOSTNAME = re.compile(r'S:"Hostname"=([^\r\n]*)')
REGEX_PASWORD = re.compile(r'S:"Password"=u([0-9a-f]+)')
REGEX_PORT = re.compile(r'D:"\[SSH2\] Port"=([0-9a-f]{8})')
REGEX_USERNAME = re.compile(r'S:"Username"=([^\r\n]*)')

def hostname(x): return REGEX_HOSTNAME.search(x).group(1) if REGEX_HOSTNAME.search(x) else '???'
def password(x): return decrypt(REGEX_PASWORD.search(x).group(1)) if REGEX_PASWORD.search(x) else '???'
def port(x): return '-p %d ' % int(REGEX_PORT.search(x).group(1), 16) if REGEX_PORT.search(x) else ''
def username(x): return REGEX_USERNAME.search(x).group(1) + '@' if REGEX_USERNAME.search(x) else ''

parser = argparse.ArgumentParser(description='Decrypt SSHv2 passwords in VanDyke SecureCRT session files')
parser.add_argument('files', type=argparse.FileType('r', encoding='utf-8', errors='ignore'), nargs='+',
help='session file(s)')
args = parser.parse_args()

for f in args.files:
c = f.read().replace('\x00', '')
print(f.name)
print("ssh %s%s%s # %s" % (port(c), username(c), hostname(c), password(c)))

依赖要求不变:

1
pip install pycryptodome pywin32

解密效果:

1
2
3
D:\UserData\Desktop>python recovery.py 172.16.254.253.ini
172.16.254.253.ini
ssh admin@172.16.254.253 # Pa88w0rc1

 简单说两句



联系站长 | 服务状态 | 友情链接

备案号:辽ICP备19013963号

津公网安备12011602300394号

中国互联网违法和不良信息举报中心

架构版本号:8.1.7 | 本站已全面支持IPv6

正在载入运行数据(1/2)请稍后...
正在载入运行数据(2/2)请稍后...

♥stand with innovative technologies of all kinds♥

Copyright 2024 LingXuanNing, All rights reserved.