Created
August 21, 2019 23:59
-
-
Save serid/50f08927dc96fd3c9120a703d719ba11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
class Programm { | |
public static void main(String[] args) { | |
get_netsh_profiles(); | |
} | |
public static void get_wifi_pass(String net_name) { | |
ProcessBuilder processBuilder = new ProcessBuilder(); | |
processBuilder.command("bash", "-c", "cat /home/serid/netsh.txt"); | |
//processBuilder.command("cmd.exe", "/c", "netsh ojfdsjdorjj show profile " + net_name); | |
try { | |
Process process = processBuilder.start(); | |
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); | |
String line; | |
while ((line = reader.readLine()) != null) { | |
System.out.println(line); | |
} | |
int exitVal = process.waitFor(); | |
if (exitVal == 0) { | |
System.out.println("Success!"); | |
return; | |
} else { | |
//abnormal... | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
// Fail case | |
System.out.println("crap"); | |
System.exit(1); | |
} | |
public static void get_netsh_profiles() { | |
ProcessBuilder processBuilder = new ProcessBuilder(); | |
processBuilder.command("bash", "-c", "cat /home/serid/netsh.txt"); | |
try { | |
Process process = processBuilder.start(); | |
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); | |
String line; | |
while ((line = reader.readLine()) != null) { | |
System.out.println("New line!"); | |
System.out.println(line); | |
//String[] splited = line.split(" "); | |
String last_word = line.split(" Все профили пользователей : ")[1]; | |
System.out.println(last_word); | |
get_wifi_pass(last_word); | |
} | |
int exitVal = process.waitFor(); | |
if (exitVal == 0) { | |
System.out.println("Success!"); | |
System.exit(0); | |
} else { | |
//abnormal... | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
// Fail case | |
System.out.println("crap"); | |
System.exit(1); | |
} | |
/* | |
public static String get_netsh_profiles() { | |
ProcessBuilder processBuilder = new ProcessBuilder(); | |
processBuilder.command("bash", "-c", "ls /home/serid/"); | |
try { | |
Process process = processBuilder.start(); | |
StringBuilder output = new StringBuilder(); | |
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); | |
String line; | |
while ((line = reader.readLine()) != null) { | |
output.append(line + "\n"); | |
} | |
int exitVal = process.waitFor(); | |
if (exitVal == 0) { | |
System.out.println("Success!"); | |
return output.toString(); | |
//System.exit(0); | |
} else { | |
//abnormal... | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
// Fail case | |
System.out.println("crap"); | |
System.exit(1); | |
return null; | |
} | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment