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