From d98c96fbdbc07b7672fa9383a1339bcf18a61a00 Mon Sep 17 00:00:00 2001 From: theapache64 Date: Mon, 29 Apr 2019 18:51:33 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=9F=20Added=20kotlin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kotlin/FuckingCoffee.kt | 33 +++++++++++++++ kotlin/Hangover.kt | 41 +++++++++++++++++++ kotlin/KumarAsshole.kt | 91 +++++++++++++++++++++++++++++++++++++++++ kotlin/SmackMyBitch.kt | 42 +++++++++++++++++++ 4 files changed, 207 insertions(+) create mode 100644 kotlin/FuckingCoffee.kt create mode 100644 kotlin/Hangover.kt create mode 100644 kotlin/KumarAsshole.kt create mode 100644 kotlin/SmackMyBitch.kt diff --git a/kotlin/FuckingCoffee.kt b/kotlin/FuckingCoffee.kt new file mode 100644 index 0000000..f775ea9 --- /dev/null +++ b/kotlin/FuckingCoffee.kt @@ -0,0 +1,33 @@ +import java.io.BufferedReader +import java.io.InputStreamReader +import java.io.PrintWriter +import java.net.Socket + +private const val MY_USERNAME = "my_username" +private const val PASSWORD_PROMPT = "Password: " +private const val PASSWORD = "1234" +private const val COFFEE_MACHINE_IP = "10.10.42.42" +private const val DELAY_BEFORE_BREW = 17 +private const val DELAY = 24 + +fun main(args: Array) { + for (i in 1 until args.size) { + if (!args[i].contains(MY_USERNAME)) { + return + } + } + val telnet = Socket(COFFEE_MACHINE_IP, 23) + val out = PrintWriter(telnet.getOutputStream(), true) + val reader = BufferedReader(InputStreamReader(telnet.getInputStream())) + Thread.sleep((DELAY_BEFORE_BREW * 1000).toLong()) + if (reader.readLine() != PASSWORD_PROMPT) { + return + } + out.println(PASSWORD) + out.println("sys brew") + Thread.sleep((DELAY * 1000).toLong()) + out.println("sys pour") + out.close() + reader.close() + telnet.close() +} \ No newline at end of file diff --git a/kotlin/Hangover.kt b/kotlin/Hangover.kt new file mode 100644 index 0000000..35f13ef --- /dev/null +++ b/kotlin/Hangover.kt @@ -0,0 +1,41 @@ +import com.twilio.sdk.TwilioRestClient +import com.twilio.sdk.TwilioRestException +import com.twilio.sdk.resource.factory.MessageFactory +import com.twilio.sdk.resource.instance.Message +import org.apache.http.NameValuePair +import org.apache.http.message.BasicNameValuePair + +import java.util.ArrayList +import java.util.Random + +private val ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID") +private val AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN") + +private const val YOUR_NUMBER = "1231231231" +private const val BOSS_NUMBER = "3213213213" + +private val randomMessages = arrayOf( + "Locked out", + "Pipes broke", + "Food poisoning", + "Not feeling well" +) + + +fun main() { + + val client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN) + + val finalMessage = randomMessages.random() + + val params = ArrayList().apply { + add(BasicNameValuePair("Body", "Gonna work from home. $finalMessage")) + add(BasicNameValuePair("From", YOUR_NUMBER)) + add(BasicNameValuePair("To", BOSS_NUMBER)) + } + + val messageFactory = client.getAccount().getMessageFactory() + val message = messageFactory.create(params) + System.out.println(message.getSid()) +} + diff --git a/kotlin/KumarAsshole.kt b/kotlin/KumarAsshole.kt new file mode 100644 index 0000000..75c2398 --- /dev/null +++ b/kotlin/KumarAsshole.kt @@ -0,0 +1,91 @@ +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 + +//modify below properties to your details +private const val host = "smtp.gmail.com" +private const val username = "yourmailaddress@example.com goes here" +private const val password = "your password goes here " +private const val Kumar_mail = "the mail address to be replied to !" + + +//Dependencies- Java mail API +fun main() { + val asshole = KumarAsshole() + asshole.read() +} + +object KumarAsshole { + + fun read() { + val props = Properties() + + try { + + val session = Session.getDefaultInstance(props, null) + + val store = session.getStore("imaps") + store.connect(host, username, password) + + val inbox = store.getFolder("inbox") + inbox.open(Folder.READ_ONLY) + + val messages = inbox.search(FlagTerm(Flags(Flags.Flag.SEEN), false)) + + for (i in messages.indices) { + + if (messages[i].getFrom()[0].toString().contains(Kumar_mail)) { + + var bodytext: String? = null + val content = messages[i].getContent() + if (content is String) { + bodytext = content + + } else if (content is Multipart) { + + val mp = content as Multipart + + val bp = mp.getBodyPart(mp.getCount() - 1) + bodytext = bp.getContent() + + } + + val pattern = Pattern.compile("sorry|help|wrong", Pattern.CASE_INSENSITIVE) + val matcher = pattern.matcher(bodytext!!) + // check all occurance + + if (matcher.find()) { + + val props1 = Properties() + val tomail: Array
+ + val msg = MimeMessage(session) + msg.setFrom(InternetAddress(username)) + tomail = messages[i].getFrom() + val t1 = tomail[0].toString() + msg.addRecipient(Message.RecipientType.TO, InternetAddress(t1)) + msg.setSubject("Database fixes") + msg.setText("No problem. I've fixed it. \n\n Please be careful next time.") + var t: Transport? = null + t = session.getTransport("smtps") + t!!.connect(host, username, password) + t!!.sendMessage(msg, msg.getAllRecipients()) + } + + + } + } + inbox.close(true) + store.close() + + } catch (e: Exception) { + e.printStackTrace() + } + + } +} \ No newline at end of file diff --git a/kotlin/SmackMyBitch.kt b/kotlin/SmackMyBitch.kt new file mode 100644 index 0000000..9a73bb3 --- /dev/null +++ b/kotlin/SmackMyBitch.kt @@ -0,0 +1,42 @@ +import com.twilio.sdk.TwilioRestClient +import com.twilio.sdk.TwilioRestException +import com.twilio.sdk.resource.factory.MessageFactory +import com.twilio.sdk.resource.instance.Message +import org.apache.http.NameValuePair +import org.apache.http.message.BasicNameValuePair + +import java.util.ArrayList +import java.util.Random + +//Pre-requisite apache http and twilio java libraries + +private const val ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID") +private const val AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN") + +private const val YOUR_NUMBER = "1231231231" +private const val HER_NUMBER = "3213213213" + +private val randomMessages = arrayOf( + "Working hard", + "Gotta ship this feature", + "Someone fucked the system again" +) + + +@Throws(TwilioRestException::class) +fun main() { + + val client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN) + + val finalMessage = randomMessages.random() + + val params = mutableListOf().apply { + add(BasicNameValuePair("Body", "Late at work. $finalMessage")) + add(BasicNameValuePair("From", YOUR_NUMBER)) + add(BasicNameValuePair("To", HER_NUMBER)) + } + + val messageFactory = client.getAccount().getMessageFactory() + val message = messageFactory.create(params) + System.out.println(message.getSid()) +} \ No newline at end of file