mirror of
https://github.com/nickvourd/Windows-Local-Privilege-Escalation-Cookbook
synced 2026-06-08 16:23:53 +00:00
37 lines
1.4 KiB
Java
37 lines
1.4 KiB
Java
import java.io.File;
|
|
import java.io.FileWriter;
|
|
import java.io.IOException;
|
|
import java.io.PrintWriter;
|
|
|
|
public class CustomJavaApp {
|
|
|
|
public static void main(String[] args) {
|
|
String username = "Administrator";
|
|
String password = "Asa31904#!";
|
|
|
|
// Check if the provided credentials are correct
|
|
if (authenticate(username, password)) {
|
|
// Enumerate and print information about all processes
|
|
String desktopPath = System.getProperty("user.home") + "/Desktop";
|
|
String outputFile = desktopPath + "/processes.txt";
|
|
|
|
try (PrintWriter writer = new PrintWriter(new FileWriter(new File(outputFile)))) {
|
|
ProcessHandle.allProcesses().forEach(process -> {
|
|
writer.println("Process ID: " + process.pid() + ", Process Name: " + process.info().command().orElse("N/A"));
|
|
});
|
|
System.out.println("Process list saved to " + outputFile);
|
|
} catch (IOException e) {
|
|
System.err.println("Error writing to file: " + e.getMessage());
|
|
}
|
|
} else {
|
|
System.out.println("Authentication failed. Exiting...");
|
|
System.exit(1); // Exiting the application
|
|
}
|
|
}
|
|
|
|
static boolean authenticate(String username, String password) {
|
|
// Hardcoded authentication (for demonstration purposes only)
|
|
return username.equals("Administrator") && password.equals("Asa31904#!");
|
|
}
|
|
}
|