这篇教程前女友发来加密的"520快乐.pdf",我用python破解开之后,却发现写得很实用,希望能帮到您。 事情是这样的
520晚上,正跟队友 啪啪啪 组团开黑 突然,微信上前女友的头像跳动了起来 快一年了,难道是想要复合? 
发来的竟是一个 " 520快乐.pdf " 的加密文件 想复合就直说嘛 干嘛还要搞的这么有情趣,让我破解 
伴随着我队友刺耳的骂街声 我平静而果断的的退出了游戏 撸出了,我的python代码。。。 
明确需求
1、根据对前女友的了解,密码为4位纯数字。(代码中可以自定义代码生成函数,生成各种组合的密码,进行破解) 2、520快乐.pdf 如下 ↓ ↓ ↓ 加密了打不开 
安装pdf工具模块 pip install PyPDF2
PS D:/> pip install PyPDF2Looking in indexes: http://mirrors.aliyun.com/pypi/simpleCollecting PyPDF2 Downloading http://mirrors.aliyun.com/pypi/packages/b4/01/68fcc0d43daf4c6bdbc6b33cc3f77bda531c86b174cac56ef0ffdb96faab/PyPDF2-1.26.0.tar.gz (77 kB) |████████████████████████████████| 77 kB 919 kB/sUsing legacy 'setup.py install' for PyPDF2, since package 'wheel' is not installed.Installing collected packages: PyPDF2 Running setup.py install for PyPDF2 ... doneSuccessfully installed PyPDF2-1.26.0PS D:/> 如何给pdf加密码?
要想破解加密的pdf文件,就要知道如何给pdf加密。可以通过PyPDF2模块,给pdf加密。 代码如下: import PyPDF2#加密PDFdef encrypt(old_Path, new_Path): """ :param old_Path: 待加密文件的路径名 :param new_Path: 加密之后的文件路径名 """ with open(old_Path, 'rb') as pdfFile: pdfReader = PyPDF2.PdfFileReader(pdfFile) # 创建pdfWriter对象用于写出PDF文件 pdfWriter = PyPDF2.PdfFileWriter() # pdf对象加入到pdfWriter对象中 for pageNum in range(pdfReader.numPages): pdfWriter.addPage(pdfReader.getPage(pageNum)) # 密码设置为8888 pdfWriter.encrypt('8888') with open(new_Path, 'wb') as resultPDF: pdfWriter.write(resultPDF) print('加密成功!') 如何破解加密pdf文件
1、生成四位数纯数字密码的方法 你可以根据需求,自己定义密码的位数,这里只定义4位纯数字密码 #你可以根据需求,自己定义密码的位数,这里只定义4位纯数字密码for i in range(10000): #生成四位数密码 pwd=str(i).zfill(4) print(pwd) 2、破解pdf函数代码 引用pypdf2模块,调用pdfReader.decrypt('密码'),通过不停的遍历我们生成的密码。 破解密码函数 如下: def decrypt(old_Path, new_Path): """ :param old_Path: 待加密文件的路径名 :param new_Path: 加密之后的文件路径名 """ with open(old_Path, 'rb') as pdfFile: pdfReader = PyPDF2.PdfFileReader(pdfFile) pdfWriter = PyPDF2.PdfFileWriter() # 判断文件是否加密 if pdfReader.isEncrypted: # 判断密码是否正确 for i in range(10000): #生成四位数密码 pwd=str(i).zfill(4) if pdfReader.decrypt(pwd): for pageNum in range(pdfReader.numPages): pdfWriter.addPage(pdfReader.getPage(pageNum)) with open(new_Path, 'wb') as resultFile: pdfWriter.write(resultFile) print('成功了!密码是:'+pwd) else: print('密码错了!哼~~~') else: print('没有加密呀~~~') 开始破解
代码已经准备好,下面,我们正式开始破解~~~ 
效果如下 ↓ ↓ ↓ 几秒之后,密码破解成功。 emmm ,密码居然是 1314 
完整代码
https://download.csdn.net/download/weixin_42350212/19777145 故事结尾
密码居然是1314 让我有点不知所措呢 
迫不及待的打开 “520快乐.pdf” 啪啪啪 欢快的输入破解出的密码 1314 
----The End---- 到此这篇关于前女友发来加密的"520快乐.pdf",我用python破解开之后,却发现...的文章就介绍到这了,更多相关python破解加密内容请搜索51zixue.net以前的文章或继续浏览下面的相关文章希望大家以后多多支持51zixue.net! Python利用Charles 实现全部自动答题思路流程分析 在前女友婚礼上用python把婚礼现场的WIFI名称改成了 |