runtime.getruntime().exec
/* 10000 - , , */ import java.io.IOException; import java.net.ServerSocket; public class Serv { public static void main(String[] args) throws IOException { ServerSocket serverSocket = new ServerSocket(10000); serverSocket.accept(); Process shutdown = Runtime.getRuntime().exec(new String[]{"shutdown", "-s" }); serverSocket.close(); } }
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; public class Serv { public static void main(String[] args) throws IOException { int sPort = 9000; ServerSocket socket = new ServerSocket(sPort); Socket ss = socket.accept();// - System.out.println("CONNECTED"); OutputStream sout = ss.getOutputStream(); String html = "<html><head><title>Shutdown</title></head><body><h1> 15-20 !</h1><br/><img src = 'http://s.elitarium.ru/wp-content/uploads/1632841882.jpg'></br><h2> :)</h2></body></html>";//html // (^=◕ᴥ◕=^) String header = "HTTP/1.1 200 OK\nContent-type: text/html\nContent-Length: " + html.length() + "\nConnection: close\n\n";//html header String outputText = header + html; sout.write(outputText.getBytes()); String[] cm = { "shutdown", "-s" }; Runtime.getRuntime().exec(cm); ss.close(); socket.close(); } }
Source: https://habr.com/ru/post/341280/
All Articles