当前位置: 首页 > news >正文

python破解密码·筛查和选择

破解密码时可能遇到的几种情况

① 已知密码字符,破排序
② 已知密码位数,破字符
③ 已知密码类型,破字位
④ 已知部分密码,破未知
⑤ 啥都不知道,盲破,玩完
⑥ 已知位数、字符、类型、部分密码中的几个,已知越多破解越易

① 已知密码字符,破排序

python破解字母已知但大小写未知密码

python穷举已知字符串中某个或多个字符为大写的所有情况,并把生成的所有结果写入result.txt

def generate_uppercase_combinations(s, index=0, current='', output_file='result.txt'):if index == len(s):with open(output_file, 'a') as file:file.write(current + '\n')returngenerate_uppercase_combinations(s, index + 1, current + s[index], output_file)if s[index].isalpha() and s[index].islower():generate_uppercase_combinations(s, index + 1, current + s[index].upper(), output_file)# 测试代码
s = "abc"
with open('result.txt', 'w') as file:file.write('')
generate_uppercase_combinations(s)

- - - -
后续 python密码筛查和选择

④ 已知部分密码

用于排除,减少可能的密码

在函数中添加一个条件来检查当前字符串是否以’C’结尾,如果是,则不将其写入到文件中。

# 跳过末尾为'C'的情况
def generate_uppercase_combinations(s, index=0, current='', output_file='result.txt'):if index == len(s):if current[-1] != 'C':  # 检查末尾是否为'C'with open(output_file, 'a') as file:file.write(current + '\n')returngenerate_uppercase_combinations(s, index + 1, current + s[index], output_file)if s[index].isalpha() and s[index].islower():generate_uppercase_combinations(s, index + 1, current + s[index].upper(), output_file)# 测试代码
s = "abc"
with open('result.txt', 'w') as file:file.write('')
generate_uppercase_combinations(s)

s="abcdefgh"已知第3-5位为cde,排除非cde的情况;已知第1-4位不是abdC,排除是abcd的情况;已知第第7-8位是gH,排除非gH的情况。

def generate_uppercase_combinations(s, index=0, current='', output_file='result.txt'):if index == len(s):if current[2:5] == 'cde' and current[0:4] != 'abcd' and current[6:8] == 'gH': # 添加条件限制with open(output_file, 'a') as file:file.write(current + '\n')returngenerate_uppercase_combinations(s, index + 1, current + s[index], output_file)if s[index].isalpha() and s[index].islower():generate_uppercase_combinations(s, index + 1, current + s[index].upper(), output_file)# 测试代码
s = "abcdefgh"
with open('result.txt', 'w') as file:file.write('')
generate_uppercase_combinations(s)

在Python中,字符串的索引是从0开始的,current[-1]表示字符串current的末尾位。

因此,在上面代码中:

  • current[-1]表示current的末尾位。
  • current[7]表示current的第8位的子字符串。
  • current[2:5]表示索引2-4,即current的第3位到第5位的子字符串。
  • current[0:4]表示索引0-3,即current的第1位到第4位的子字符串。
  • current[6:8]表示索引6-7,即current的第7位到第8位的子字符串。

第n位加入特殊符号

. + whitespace etc.

某位有一特殊字符,直接在上述代码的基础上在字符串s相应位置加特殊字符就好了,例如:

def generate_uppercase_combinations(s, index=0, current='', output_file='result.txt'):if index == len(s):with open(output_file, 'a') as file:file.write(current + '\n')returngenerate_uppercase_combinations(s, index + 1, current + s[index], output_file)if s[index].isalpha() and s[index].islower():generate_uppercase_combinations(s, index + 1, current + s[index].upper(), output_file)# 测试代码
s = "a b.c"
with open('result.txt', 'w') as file:file.write('')
generate_uppercase_combinations(s)

将全部行的某几位替换为另几位,同特殊字符。

② 已知密码位数,破字符

python穷举已知位数n=3,每位密码位0-9数字或者字母a,b,c的所有情况,并把生成的所有结果写入result.txt

import itertools# 定义可能的字符集
characters = '0123456789abc'# 生成所有可能的密码组合
combinations = itertools.product(characters, repeat=3)# 将结果写入文件
with open('result.txt', 'w') as file:for combination in combinations:password = ''.join(combination)file.write(password + '\n')

③ 已知密码类型,破字位

已知是数字型密码,位数未知假设为4位以内。
python穷举已知位数0<n<5,每位密码位0-9数字的所有情况,并将结果写入到 result.txt文件中

import itertools# 定义可能的字符集
characters = '0123456789'# 生成所有可能的密码组合
with open('result.txt', 'w') as file:for length in range(1, 5):combinations = itertools.product(characters, repeat=length)for combination in combinations:password = ''.join(combination)file.write(password + '\n')

出现非数字,此时加字母
python穷举已知位数0<n<3,每位密码位0-9数字或者a-z字母的所有情况,并将结果写入到 result.txt文件中
只需要更新字符集和位数范围

import itertools# 定义可能的字符集
characters = '0123456789abcdefghijklmnopqrstuvwxyz'# 生成所有可能的密码组合
with open('result.txt', 'w') as file:for length in range(1, 3):combinations = itertools.product(characters, repeat=length)for combination in combinations:password = ''.join(combination)file.write(password + '\n')

出现非字母非数,此时加中文字符串 仍旧更新字符集和位数范围

历史密码规律及可能出现的排列组合

- - - -

密码位数太多了,只能先排除一部分再慢慢猜测😿
在这里插入图片描述

⑤ 密码未知

啥都不知道/记不清了,毁灭吧,26字母+10数字+特殊符号+可能出现的大概率中文字符,更新字符集和位数范围 枚举所有可能排列

import itertools# 定义可能的字符集
characters = '0123456789abcdefghijklmnopqrstuvwxyz .,-·>?<+/#@!~$%^&*():啊我是'# 生成所有可能的密码组合
with open('result.txt', 'w') as file:for length in range(1, 3):combinations = itertools.product(characters, repeat=length)for combination in combinations:password = ''.join(combination)file.write(password + '\n')

此时可能就需要出现tkinter自动输入破解了 or 自动精灵/鼠标精灵

密码记得备份啊,太难追回了,10位数以上的强密码,忘记了让我去猜,我看得懂密码提示也破不了啊😿

相关 Python解压zip

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 《财经态度》︱行业领跑品牌格行创始人刘永先独家揭秘:格行随身WiFi如何抗内卷,成就品质与服务双重骄傲?随身WiFi推荐第一名!
  • FFmpeg 实现从麦克风获取流并通过RTMP推流
  • 递归(五)—— 初识暴力递归之“如何利用递归实现栈逆序”
  • 【React】Ant Design -- Table分页功能实现
  • DBeaver操作MySQL无法同时执行多条语句的解决方法
  • STM32-I2C硬件外设
  • 软件源码购买一般在哪个网站?避坑指南
  • 快手可图模型的要点
  • Django 实现子模版继承父模板
  • 无损音频格式 FLAC 转 MP3 音频图文教程
  • 2024.7.7刷题记录
  • 选择排序(C语言版)
  • 【AI应用探讨】—逻辑回归应用场景
  • Java内存区域与内存溢出异常(补充)
  • 01 企业网站架构部署与优化之Apache配置与应用
  • [译]Python中的类属性与实例属性的区别
  • ECMAScript入门(七)--Module语法
  • jdbc就是这么简单
  • MySQL QA
  • Python3爬取英雄联盟英雄皮肤大图
  • React Transition Group -- Transition 组件
  • Vue实战(四)登录/注册页的实现
  • Wamp集成环境 添加PHP的新版本
  • Web Storage相关
  • 包装类对象
  • 猴子数据域名防封接口降低小说被封的风险
  • 解决jsp引用其他项目时出现的 cannot be resolved to a type错误
  • 京东美团研发面经
  • 开发了一款写作软件(OSX,Windows),附带Electron开发指南
  • 来,膜拜下android roadmap,强大的执行力
  • 猫头鹰的深夜翻译:JDK9 NotNullOrElse方法
  • 面试题:给你个id,去拿到name,多叉树遍历
  • -- 数据结构 顺序表 --Java
  • 项目管理碎碎念系列之一:干系人管理
  • 自定义函数
  • ​七周四次课(5月9日)iptables filter表案例、iptables nat表应用
  • !!java web学习笔记(一到五)
  • #Datawhale AI夏令营第4期#AIGC方向 文生图 Task2
  • #define MODIFY_REG(REG, CLEARMASK, SETMASK)
  • $LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams
  • (BAT向)Java岗常问高频面试汇总:MyBatis 微服务 Spring 分布式 MySQL等(1)
  • (Java企业 / 公司项目)点赞业务系统设计-批量查询点赞状态(二)
  • (八)Flask之app.route装饰器函数的参数
  • (六)激光线扫描-三维重建
  • (生成器)yield与(迭代器)generator
  • (贪心 + 双指针) LeetCode 455. 分发饼干
  • *算法训练(leetcode)第四十天 | 647. 回文子串、516. 最长回文子序列
  • .Mobi域名介绍
  • .Net Core 中间件验签
  • .net 使用ajax控件后如何调用前端脚本
  • .ui文件相关
  • // an array of int
  • /usr/lib/mysql/plugin权限_给数据库增加密码策略遇到的权限问题
  • @CacheInvalidate(name = “xxx“, key = “#results.![a+b]“,multi = true)是什么意思
  • @Controller和@RestController的区别?