MCPcopy Create free account
hub / github.com/NARKOZ/hacker-scripts / KumarAsshole

Class KumarAsshole

java/KumarAsshole.java:11–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9//Dependencies- Java mail API
10
11public class KumarAsshole {
12
13 public static void main(String[] args) {
14 KumarAsshole asshole = new KumarAsshole();
15 asshole.read();
16 }
17
18 public void read() {
19 Properties props = new Properties();
20
21 //modify below properties to your details
22 String host = "smtp.gmail.com";
23 String username = "yourmailaddress@example.com goes here";
24 String password = "your password goes here ";
25 String Kumar_mail = "the mail address to be replied to !";
26
27 try {
28 Session session = Session.getDefaultInstance(props, null);
29
30 Store store = session.getStore("imaps");
31 store.connect(host, username, password);
32
33 Folder inbox = store.getFolder("inbox");
34 inbox.open(Folder.READ_ONLY);
35
36 Message messages[] = inbox.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
37
38 for (int i = 0; i < messages.length; i++) {
39 if (messages[i].getFrom()[0].toString().contains(Kumar_mail)) {
40 String bodytext = null;
41 Object content = messages[i].getContent();
42 if (content instanceof String) {
43 bodytext = (String) content;
44 } else if (content instanceof Multipart) {
45 Multipart mp = (Multipart) content;
46
47 BodyPart bp = mp.getBodyPart(mp.getCount() - 1);
48 bodytext = (String) bp.getContent();
49 }
50
51 Pattern pattern = Pattern.compile("sorry|help|wrong", Pattern.CASE_INSENSITIVE);
52 Matcher matcher = pattern.matcher(bodytext);
53 // check all occurance
54
55 if (matcher.find()) {
56 Properties props1 = new Properties();
57 Address[] tomail;
58
59 MimeMessage msg = new MimeMessage(session);
60 msg.setFrom(new InternetAddress(username));
61 tomail = messages[i].getFrom();
62 String t1 = tomail[0].toString();
63 msg.addRecipient(Message.RecipientType.TO, new InternetAddress(t1));
64 msg.setSubject("Database fixes");
65 msg.setText("No problem. I've fixed it. \n\n Please be careful next time.");
66 Transport t = null;
67 t = session.getTransport("smtps");
68 t.connect(host, username, password);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected