暴力破解带有密码的压缩文件

您所在的位置:网站首页 压缩文件密码暴力破解有什么影响 暴力破解带有密码的压缩文件

暴力破解带有密码的压缩文件

2023-08-15 12:16| 来源: 网络整理| 查看: 265

一 暴力破解,就是不断生成新的密码去尝试能否破解成功。假如我们的密码位数为3位,其里面的值有可能是0或者1,其产生的密码集的数量为2的3次幂,也就是八个,然后一个一个去破解。而这生成这8个密码的过程就有一个递归规则存在。 我们传入深度deep和对应字符串passwd两个参数,如果深度为1,直接输出字符串passwd,如果深度不为1,把深度deep减一,并把可能存在的字符串集合[0,1]遍历,添加到passwd的后面,重新回到这个递归函数,直到深度deep为1输出。

二 解压压缩文件 网上有对应的jar包去解压压缩文件,但是我这里使用一种比较简单的方法去实现,本地电脑window上装有winrar,java调用本地winrar.exe去解压压缩文件。 其核心代码为:

C:\Program Files\WinRAR\WinRAR.exe x -ibck -hp123 -y F:\\BaiduNetdiskDownload\\yewen4\\a.rar D:\\test\\unrar\\

第一个路径是winrar.exe的路径,第二个路劲是需要解压缩文件的路径地址,第三个是存放的路径。-hp后面的123表示密码。

下面是代码的实现

/** * * @param filePath 解压文件路径 * @param targetPath 解压之后存放的路径 * @param passwd 密码 * @return * @throws Exception */ public static int unrar(String filePath,String targetPath,String passwd) throws Exception { //winrar的执行路径 String rarPath="C:\\Program Files\\WinRAR\\WinRAR.exe"; StringBuilder sb = new StringBuilder(); sb.append(rarPath); sb.append(" x -ibck -hp"); sb.append(passwd).append(" -y ").append(filePath+" "+targetPath); Process process; process = Runtime.getRuntime().exec(sb.toString()); if(process.waitFor() ==0 ){ FileOutputStream fileOutputStream = new FileOutputStream(new File("D:\\test\\unrar\\getPassyewen4.txt")); String s = "解压后的密码:"+passwd; fileOutputStream.write(s.getBytes()); fileOutputStream.flush(); fileOutputStream.close(); return 1; }else{ System.out.println(new Date()+"--失败:"+passwd); return 0 ; } } /** * 递归获取密码过程 * @param deep 深度 * @param parent 密码 * @return * @throws Exception */ public static int findpwd(int deep,String parent) throws Exception { String[] dir ={"q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l", "z","x","c","v","b","n","m","Q","W","E","R","T","Y","U","I","O","P","A","S","D","F","G","H","J","K","L","Z","X", "C","V","B","N","M","1","2","3","4","5","6","7","8","9","0","`","!","@","#","$","%","&","*","(",")","-","_","+","=","[", "]","{","}","|","\\","\"",":",";","\'","",",",".","?","/"}; if(deep == 1){ if(unrar("","",parent) == 1){ return 1; }else{ return 0; } }else{ for(int j =0;j


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3