Merge ec8bc0989a into cf679b525f
This commit is contained in:
commit
1b2f897a51
|
|
@ -0,0 +1,41 @@
|
|||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FuckingCoffee {
|
||||
|
||||
private static final String PASSWORD_PROMPT = "Password: ";
|
||||
private static final String PASSWORD = "1234";
|
||||
private static final String COFFEE_MACHINE_IP = "10.10.42.42";
|
||||
private static final long DELAY_BEFORE_BREW = TimeUnit.SECONDS.toMillis(17);
|
||||
private static final long DELAY = TimeUnit.SECONDS.toMillis(24);
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
try (BufferedReader buffer = new BufferedReader(
|
||||
new InputStreamReader(Runtime.getRuntime().exec("who -q").getInputStream())
|
||||
)) {
|
||||
String whoOutput = buffer.lines().collect(Collectors.joining(System.lineSeparator()));
|
||||
if (!whoOutput.contains(System.getProperty("user.name"))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try (Socket telnet = new Socket(COFFEE_MACHINE_IP, 23);
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(telnet.getInputStream()));
|
||||
PrintWriter out = new PrintWriter(telnet.getOutputStream(), true)
|
||||
) {
|
||||
Thread.sleep(DELAY_BEFORE_BREW);
|
||||
if (!PASSWORD_PROMPT.equals(in.readLine())) {
|
||||
return;
|
||||
}
|
||||
out.println(PASSWORD);
|
||||
out.println("sys brew");
|
||||
Thread.sleep(DELAY);
|
||||
out.println("sys pour");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
import java.net.*;
|
||||
import java.io.*;
|
||||
|
||||
public class fucking_coffee{
|
||||
|
||||
private static final String MY_USERNAME = "my_username";
|
||||
private static final String PASSWORD_PROMPT = "Password: ";
|
||||
private static final String PASSWORD = "1234";
|
||||
private static final String COFFEE_MACHINE_IP = "10.10.42.42";
|
||||
private static int DELAY_BEFORE_BREW = 17;
|
||||
private static int DELAY = 24;
|
||||
|
||||
public static void main(String[] args)throws Exception{
|
||||
for(int i = 1; i< args.length ; i++){
|
||||
if(!args[i].contains(MY_USERNAME)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
Socket telnet = new Socket(COFFEE_MACHINE_IP, 23);
|
||||
PrintWriter out = new PrintWriter(telnet.getOutputStream(), true);
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(telnet.getInputStream()));
|
||||
Thread.sleep(DELAY_BEFORE_BREW*1000);
|
||||
if(in.readLine() != PASSWORD_PROMPT){
|
||||
return ;
|
||||
}
|
||||
out.println(PASSWORD);
|
||||
out.println("sys brew");
|
||||
Thread.sleep(DELAY*1000);
|
||||
out.println("sys pour");
|
||||
out.close();
|
||||
in.close();
|
||||
telnet.close();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue