SecureCRT密码破解(实验环境:win10,SecureCRT Version 9.1.0 (x64 build 2579))

news2025/2/12 8:23:04

实验环境:win10,

SecureCRT:Version 9.1.0 (x64 build 2579)

1. SecureCRTCipher.py 文件

#!/usr/bin/env python3
import os
from Crypto.Hash import SHA256
from Crypto.Cipher import AES, Blowfish

class SecureCRTCrypto:

    def __init__(self):
        '''
        Initialize SecureCRTCrypto object.
        '''
        self.IV = b'\x00' * Blowfish.block_size
        self.Key1 = b'\x24\xA6\x3D\xDE\x5B\xD3\xB3\x82\x9C\x7E\x06\xF4\x08\x16\xAA\x07'
        self.Key2 = b'\x5F\xB0\x45\xA2\x94\x17\xD9\x16\xC6\xC6\xA2\xFF\x06\x41\x82\xB7'

    def Encrypt(self, Plaintext : str):
        '''
        Encrypt plaintext and return corresponding ciphertext.

        Args:
            Plaintext: A string that will be encrypted.

        Returns:
            Hexlified ciphertext string.
        '''
        plain_bytes = Plaintext.encode('utf-16-le')
        plain_bytes += b'\x00\x00'
        padded_plain_bytes = plain_bytes + os.urandom(Blowfish.block_size - len(plain_bytes) % Blowfish.block_size)

        cipher1 = Blowfish.new(self.Key1, Blowfish.MODE_CBC, iv = self.IV)
        cipher2 = Blowfish.new(self.Key2, Blowfish.MODE_CBC, iv = self.IV)
        return cipher1.encrypt(os.urandom(4) + cipher2.encrypt(padded_plain_bytes) + os.urandom(4)).hex()

    def Decrypt(self, Ciphertext : str):
        '''
        Decrypt ciphertext and return corresponding plaintext.

        Args:
            Ciphertext: A hex string that will be decrypted.

        Returns:
            Plaintext string.
        '''

        cipher1 = Blowfish.new(self.Key1, Blowfish.MODE_CBC, iv = self.IV)
        cipher2 = Blowfish.new(self.Key2, Blowfish.MODE_CBC, iv = self.IV)
        ciphered_bytes = bytes.fromhex(Ciphertext)
        if len(ciphered_bytes) <= 8:
            raise ValueError('Invalid Ciphertext.')
        
        padded_plain_bytes = cipher2.decrypt(cipher1.decrypt(ciphered_bytes)[4:-4])
        
        i = 0
        for i in range(0, len(padded_plain_bytes), 2):
            if padded_plain_bytes[i] == 0 and padded_plain_bytes[i + 1] == 0:
                break
        plain_bytes = padded_plain_bytes[0:i]

        try:
            return plain_bytes.decode('utf-16-le')
        except UnicodeDecodeError:
            raise(ValueError('Invalid Ciphertext.'))

class SecureCRTCryptoV2:

    def __init__(self, ConfigPassphrase : str = ''):
        '''
        Initialize SecureCRTCryptoV2 object.

        Args:
            ConfigPassphrase: The config passphrase that SecureCRT uses. Leave it empty if config passphrase is not set.
        '''
        self.IV = b'\x00' * AES.block_size
        self.Key = SHA256.new(ConfigPassphrase.encode('utf-8')).digest()

    def Encrypt(self, Plaintext : str):
        '''
        Encrypt plaintext and return corresponding ciphertext.

        Args:
            Plaintext: A string that will be encrypted.

        Returns:
            Hexlified ciphertext string.
        '''
        plain_bytes = Plaintext.encode('utf-8')
        if len(plain_bytes) > 0xffffffff:
            raise OverflowError('Plaintext is too long.')
        
        plain_bytes = \
            len(plain_bytes).to_bytes(4, 'little') + \
            plain_bytes + \
            SHA256.new(plain_bytes).digest()
        padded_plain_bytes = \
            plain_bytes + \
            os.urandom(AES.block_size - len(plain_bytes) % AES.block_size)
        cipher = AES.new(self.Key, AES.MODE_CBC, iv = self.IV)
        return cipher.encrypt(padded_plain_bytes).hex()

    def Decrypt(self, Ciphertext : str):
        '''
        Decrypt ciphertext and return corresponding plaintext.

        Args:
            Ciphertext: A hex string that will be decrypted.

        Returns:
            Plaintext string.
        '''
        cipher = AES.new(self.Key, AES.MODE_CBC, iv = self.IV)
        padded_plain_bytes = cipher.decrypt(bytes.fromhex(Ciphertext))
        
        plain_bytes_length = int.from_bytes(padded_plain_bytes[0:4], 'little')
        plain_bytes = padded_plain_bytes[4:4 + plain_bytes_length]
        if len(plain_bytes) != plain_bytes_length:
            raise ValueError('Invalid Ciphertext.')

        plain_bytes_digest = padded_plain_bytes[4 + plain_bytes_length:4 + plain_bytes_length + SHA256.digest_size]
        if len(plain_bytes_digest) != SHA256.digest_size:
            raise ValueError('Invalid Ciphertext.')

        if SHA256.new(plain_bytes).digest() != plain_bytes_digest:
            raise ValueError('Invalid Ciphertext.')

        return plain_bytes.decode('utf-8')

if __name__ == '__main__':
    import sys

    def Help():
        print('Usage:')
        print('    SecureCRTCipher.py <enc|dec> [-v2] [-p ConfigPassphrase] <plaintext|ciphertext>')
        print('')
        print('    <enc|dec>              "enc" for encryption, "dec" for decryption.')
        print('                           This parameter must be specified.')
        print('')
        print('    [-v2]                  Encrypt/Decrypt with "Password V2" algorithm.')
        print('                           This parameter is optional.')
        print('')
        print('    [-p ConfigPassphrase]  The config passphrase that SecureCRT uses.')
        print('                           This parameter is optional.')
        print('')
        print('    <plaintext|ciphertext> Plaintext string or ciphertext string.')
        print('                           NOTICE: Ciphertext string must be a hex string.')
        print('                           This parameter must be specified.')
        print('')
    
    def EncryptionRoutine(UseV2 : bool, ConfigPassphrase : str, Plaintext : str):
        try:
            if UseV2:
                print(SecureCRTCryptoV2(ConfigPassphrase).Encrypt(Plaintext))
            else:
                print(SecureCRTCrypto().Encrypt(Plaintext))
            return True
        except:
            print('Error: Failed to encrypt.')
            return False

    def DecryptionRoutine(UseV2 : bool, ConfigPassphrase : str, Ciphertext : str):
        try:
            if UseV2:
                print(SecureCRTCryptoV2(ConfigPassphrase).Decrypt(Ciphertext))
            else:
                print(SecureCRTCrypto().Decrypt(Ciphertext))
            return True
        except:
            print('Error: Failed to decrypt.')
            return False

    def Main(argc : int, argv : list):
        if 3 <= argc and argc <= 6:
            bUseV2 = False
            ConfigPassphrase = ''

            if argv[1].lower() == 'enc':
                bEncrypt = True
            elif argv[1].lower() == 'dec':
                bEncrypt = False
            else:
                Help()
                return -1
            
            i = 2
            while i < argc - 1:
                if argv[i].lower() == '-v2':
                    bUseV2 = True
                    i += 1
                elif argv[i].lower() == '-p' and i + 1 < argc - 1:
                    ConfigPassphrase = argv[i + 1]
                    i += 2
                else:
                    Help()
                    return -1

            if bUseV2 == False and len(ConfigPassphrase) != 0:
                print('Error: ConfigPassphrase is not supported if "-v2" is not specified')
                return -1

            if bEncrypt:
                return 0 if EncryptionRoutine(bUseV2, ConfigPassphrase, argv[-1]) else -1
            else:
                return 0 if DecryptionRoutine(bUseV2, ConfigPassphrase, argv[-1]) else -1
        else:
            Help()

    exit(Main(len(sys.argv), sys.argv))


2. 安装 python3

【https://www.python.org/ftp/python/3.10.9/python-3.10.9-amd64.exe】(不要安装2)
3. 配置环境变量

【一个是 python.exe 所在目录,另一个是 pip.exe 所在目录】

我的目录是在

C:\Users\admin\AppData\Local\Programs\Python\Python310

C:\Users\admin\AppData\Local\Programs\Python\Python310\Scripts

可按照实际安装情况自行配置


4. 安装 三方库 (不是pyCrypto )
    pip install pycryptodome


5. 找到 SecureCRT 配置文件密码

 C:\Users\admin\AppData\Roaming\VanDyke\Config\Sessions\192.168.1.1.ini

6. 执行解密

    在 cmd 下,执行 
    python SecureCRTCipher.py dec -v2 这里写加密的 02:后面的那串码(下面的截图换行是因为密文太长了,自动换行了,不是分两行执行)
    
各种失败情况及原因:
    1. 不要看他们说的安装 python2版本,安装 3 版本。否则报错   File "SecureCRTCipher.py", line 16 def Encrypt(self, Plaintext : str):


    2. 没有 pip 命令,要将 python 安装目录下的 Scripts 目录也加入到环境变量中
    3. pip install pyCrypto 命令执行失败【原因可能是已经弃用 pyCrypto 包,现在使用 pycryptodome 包】


    4. 其他小问题,打开命令行执行了 SeicureCRTCipher.py 结果报错 python: can't open file 'C:\\Users\\admin\\SecureCRTCipher.py': [Errno 2] No such file or directory
因为我把 SeicureCRTCipher.py 放到了桌面,所以先把 cmd 切换目录到 C:\Users\admin>cd Desktop

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/864311.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

如何选择适合自己的文件传输工具

随着互联网的发展&#xff0c;人们处理文件的需求也随之增加。不管是工作还是生活中&#xff0c;文件传输都是一个非常常见的问题。因此&#xff0c;如何选择适合自己的文件传输工具也越来越重要。在本文中&#xff0c;我将从以下几个方面进行分析和总结&#xff0c;希望能为大…

springboot文件上传和下载接口的简单思路

springboot文件上传和下载的简单思路 文件上传文件下载 文件上传 在springboot中&#xff0c;上传文件只需要在接口中通过 MultipartFile 对象来获取前端传递的数据&#xff0c;然后将数据存储&#xff0c;并且返回一个对外访问路径即可。一般对于上传文件的文件名&#xff0c…

【立创EDA】【0】基本概念

原理图库设计 符号设计 当在元件库中没有找到需要的元件原理图符号时&#xff0c;需要自己手动绘制点击文件-新建-符号进行新建符号 封装库设计 原理图符号对应焊盘 绘制封装时&#xff0c;可以在立创商城寻找元器件对应的数据手册进行参考 PCB绘制 晶振需要包地&#xf…

【STM32RT-Thread零基础入门】 1. 搭建开发环境

文章目录 一、RT-Thread Studio 集成开发环境安装1. 下载2. 安装3. 下载SDK 二、STM32CubeMX 图形化配置工具安装1. 获取安装包2. 安装3. 安装固件库 总结 一、RT-Thread Studio 集成开发环境安装 1. 下载 可以从RT-Thread 官网上获取 RT-Thread studio 最新的安装包&#xf…

解决:django设置DEBUG=false时出现的问题

首先&#xff0c;我用的是django4.2&#xff0c;python3.10版本 本来&#xff0c;如果在settings.py中使用 DEBUG True&#xff0c;那么什么问题也没有&#xff0c;当然&#xff0c;这属于调试模式。 DEBUG True TEMPLATE_DEBUG DEBUGSTATIC_URL /static/ STATICFILES_DI…

计算机视觉的应用10-图片中的表格结构识别与提取实战

大家好&#xff0c;我是微学AI&#xff0c;今天给大家介绍一下计算机视觉的应用10-图片中的表格结构识别与提取实战&#xff0c;表格结构识别在信息处理领域中具有广泛应用&#xff0c;但由于表格的多样性和复杂性&#xff0c;以及难以准确解析的布局和格式&#xff0c;传统的方…

如何消除谐波对医疗设备的影响? 安科瑞 顾语欢

1.概述 谐波的危害十分严重&#xff0c;尤其在医院这种医疗设备和化验设备较多的场合。大部分大型医疗设备都是谐波源&#xff0c;比如X光机、CT机等都会产生大量谐波&#xff0c;谐波使电能的生产、传输和利用的效率降低&#xff0c;使电气设备过热、产生振动和噪声&#xff…

opencv进阶01-直方图的应用及示例cv2.calcHist()

直方图是什么&#xff1f; 直方图是一种图形表示方法&#xff0c;用于显示数据中各个数值或数值范围的分布情况。它将数据划分为一系列的区间&#xff08;也称为“箱子”或“bin”&#xff09;&#xff0c;然后统计每个区间中数据出现的频次&#xff08;或频率&#xff09;。直…

supervisor常见错误场景

项目场景&#xff1a; python虚拟环境venv启动supervisor服务 一、类型一 unix:///var/run/supervisor.sock no such file error: <class ‘FileNotFoundError’>, [Errno 2] No such file or directory: file: /home/zhaon/miniconda3/envs/abio_filesvr/lib/python3.…

Stable Diffusion Webui源码剖析

1、关键python依赖 &#xff08;1&#xff09;xformers&#xff1a;优化加速方案。它可以对模型进行适当的优化来加速图片生成并降低显存占用。缺点是输出图像不稳定&#xff0c;有可能比不开Xformers略差。 &#xff08;2&#xff09;GFPGAN&#xff1a;它是腾讯开源的人脸修…

出于网络安全考虑,印度启用本土操作系统”玛雅“取代Windows

据《印度教徒报》报道&#xff0c;印度将放弃微软系统&#xff0c;选择新的操作系统和端点检测与保护系统。 备受期待的 "玛雅操作系统 "将很快用于印度国防部的数字领域&#xff0c;而新的端点检测和保护系统 "Chakravyuh "也将一起面世。 不过&#xf…

Sharding-JDBC概述

前言 ​ 随着业务数据量的增加&#xff0c;原来所有的数据都是在一个数据库上的&#xff0c;网络IO及文件IO都集中在一个数据库上的&#xff0c;因此CPU、内存、文件IO、网络IO都可能会成为系统瓶颈。当业务系统的数据容量接近或超过单台服务器的容量、QPS/TPS接近或超过单个数…

分布式作业调度框架——ElasticJob

1、简介 ElasticJob 是面向互联网生态和海量任务的分布式调度解决方案&#xff0c;由两个相互独立的子项目 ElasticJob-Lite 和 ElasticJob-Cloud 组成。 它通过弹性调度、资源管控、以及作业治理的功能&#xff0c;打造一个适用于互联网场景的分布式调度解决方案&#xff0c;…

c语言进阶部分详解(数据在内存中的存储)

大家好&#xff0c;今天要进行梳理的内容是数据在内存中的存储相关内容。 在C语言中&#xff0c;数据在内存中的存储是一个非常重要的概念。了解数据在内存中的存储方式可以帮助我们更好地理解程序的执行过程&#xff0c;优化内存使用&#xff0c;提高程序的性能。 目录 一.数…

5.0SMDJ24CA 瞬态抑制TVS二极管 可过4kV 2Ω测试

瞬态概述 浪涌描述的是存在于电源或信号线上uS级以上的脉冲。通常浪涌产生于雷击或开关瞬变能量。雷击能量可能是由于直击雷或感应雷作用于系统所产生的瞬变能量&#xff0c;开关瞬变能量通常由于配电系统的电源切换&#xff0c;或是负载的变化导致。 雷击浪涌测试目的 GB/T …

QT中的PRO文件怎么进行相关的信息的注释?

小白学开发之QT下的PRO文件怎么进行注释&#xff0c;以及Pro文件的作用 Hello大家好&#xff0c;这里是程序员小白学开发&#xff0c;我是一个刚入门QT的初学者&#xff0c;晕乎晕乎的&#xff01;希望能够随时随地将自己所学的知识分享给大家&#xff0c;带着大学从零基础开始…

测试设计规范:优秀实践的全面指南

测试设计规范是一个定义了与测试项目相关的测试条件、详细的测试方法和高级测试用例的文档。它确定了要运行哪些测试套件和测试用例&#xff0c;以及要跳过哪些。 使用测试设计规范&#xff0c;可以简化对当前测试周期的理解。这个文档回答了像“我们在做什么?”&#xff0c;…

springcloud3 springcloud stream的学习以及案例(了解)

一 springcloud stream的作用 1.1 springcloud stream作用 stream屏蔽底层消息中间件的差异&#xff0c;降低切换成本&#xff0c;统一消息的编程模型。 stream中的消息通信模式遵循了“发布-订阅”模式。 1.2 Binder作用 通过定义绑定器Binder作为中间层&#xff0c;实现…

基于DEM tif影像的插值平滑和tif纹理贴图构建方法

准备数据是一个10米分辨率的Tif影像&#xff0c;直接用于生成DEM会十分的不平滑。如下图所示&#xff0c;平滑前后的对比效果图差异&#xff1a; 基于ArcGIS的DEM平滑插值 等值线生成&#xff08;指定加密间距&#xff09; 平滑线&#xff08;指定平滑容差平滑等高线&#xff0…

jackson库收发json格式数据和ajax发送json格式的数据

一、jackson库收发json格式数据 jackson库是maven仓库中用来实现组织json数据功能的库。 json格式  json格式一个组织数据的字符文本格式&#xff0c;它用键值对的方式存贮数据&#xff0c;json数据都是有一对对键值对组成的&#xff0c;键只能是字符串&#xff0c;用双引号包…