Skip to content

Commit c300bc5

Browse files
committed
Merge pull request NARKOZ#103 from colonelmo/master
Added java directory + fucking_coffee.java
2 parents 2c40ffd + a78bc2d commit c300bc5

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

java/fucking_coffee.java

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import java.net.*;
2+
import java.io.*;
3+
4+
public class fucking_coffee{
5+
6+
private static final String MY_USERNAME = "my_username";
7+
private static final String PASSWORD_PROMPT = "Password: ";
8+
private static final String PASSWORD = "1234";
9+
private static final String COFFEE_MACHINE_IP = "10.10.42.42";
10+
private static int DELAY_BEFORE_BREW = 17;
11+
private static int DELAY = 24;
12+
13+
public static void main(String[] args)throws Exception{
14+
for(int i = 1; i< args.length ; i++){
15+
if(!args[i].contains(MY_USERNAME)){
16+
return;
17+
}
18+
}
19+
Socket telnet = new Socket(COFFEE_MACHINE_IP, 23);
20+
PrintWriter out = new PrintWriter(telnet.getOutputStream(), true);
21+
BufferedReader in = new BufferedReader(new InputStreamReader(telnet.getInputStream()));
22+
Thread.sleep(DELAY_BEFORE_BREW*1000);
23+
if(in.readLine() != PASSWORD_PROMPT){
24+
return ;
25+
}
26+
out.println(PASSWORD);
27+
out.println("sys brew");
28+
Thread.sleep(DELAY*1000);
29+
out.println("sys pour");
30+
out.close();
31+
in.close();
32+
telnet.close();
33+
}
34+
}

0 commit comments

Comments
 (0)