Skip to content

Commit 3b29406

Browse files
committed
Merge pull request NARKOZ#127 from syedautherabbas/master
Changed naming conventions to be in line with java. Closes NARKOZ#122
2 parents f8478c4 + 08c6099 commit 3b29406

File tree

3 files changed

+131
-0
lines changed

3 files changed

+131
-0
lines changed

java/FuckingCoffee.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 FuckingCoffee{
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().equals(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+
}

java/KumarAsshole.java

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
2+
import java.io.File;
3+
import java.io.FileInputStream;
4+
import java.util.*;
5+
import java.util.regex.*;
6+
7+
import javax.mail.*;
8+
import javax.mail.internet.*;
9+
import javax.mail.search.FlagTerm;
10+
//Dependencies- Java mail API
11+
12+
public class KumarAsshole {
13+
14+
public static void main(String[] args) {
15+
KumarAsshole asshole = new KumarAsshole();
16+
asshole.read();
17+
}
18+
19+
public void read() {
20+
Properties props = new Properties();
21+
22+
23+
//modify below properties to your details
24+
String host = "smtp.gmail.com";
25+
String username = "yourmailaddress@example.com goes here";
26+
String password = "your password goes here ";
27+
String Kumar_mail = "the mail address to be replied to !";
28+
29+
try {
30+
31+
Session session = Session.getDefaultInstance(props, null);
32+
33+
Store store = session.getStore("imaps");
34+
store.connect(host, username, password);
35+
36+
Folder inbox = store.getFolder("inbox");
37+
inbox.open(Folder.READ_ONLY);
38+
39+
Message messages[] = inbox.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
40+
41+
for (int i = 0; i < messages.length; i++) {
42+
43+
if (messages[i].getFrom()[0].toString().contains(Kumar_mail)) {
44+
45+
String bodytext = null;
46+
Object content = messages[i].getContent();
47+
if (content instanceof String) {
48+
bodytext = (String) content;
49+
50+
} else if (content instanceof Multipart) {
51+
52+
Multipart mp = (Multipart) content;
53+
54+
BodyPart bp = mp.getBodyPart(mp.getCount() - 1);
55+
bodytext = (String) bp.getContent();
56+
57+
}
58+
59+
Pattern pattern = Pattern.compile("sorry|help|wrong", Pattern.CASE_INSENSITIVE);
60+
Matcher matcher = pattern.matcher(bodytext);
61+
// check all occurance
62+
63+
if (matcher.find()) {
64+
65+
Properties props1 = new Properties();
66+
Address[] tomail;
67+
68+
MimeMessage msg = new MimeMessage(session);
69+
msg.setFrom(new InternetAddress(username));
70+
tomail = messages[i].getFrom();
71+
String t1 = tomail[0].toString();
72+
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(t1));
73+
msg.setSubject("Database fixes");
74+
msg.setText("No problem. I've fixed it. \n\n Please be careful next time.");
75+
Transport t = null;
76+
t = session.getTransport("smtps");
77+
t.connect(host, username, password);
78+
t.sendMessage(msg, msg.getAllRecipients());
79+
80+
81+
}
82+
83+
84+
}
85+
}
86+
inbox.close(true);
87+
store.close();
88+
89+
}catch(Exception e)
90+
{
91+
92+
e.printStackTrace();
93+
}
94+
}
95+
}

java/SmackMyBitch.java

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import java.util.List;
1010
import java.util.Random;
1111

12+
//Pre-requisite apache http and twilio java libraries
13+
1214

1315
public class SmackMyBitch {
1416

0 commit comments

Comments
 (0)