2
0
mirror of https://github.com/narkoz/hacker-scripts synced 2025-08-22 02:17:30 +00:00

🌟 Added kotlin

This commit is contained in:
theapache64 2019-04-29 18:51:33 +05:30
parent 166cae8079
commit d98c96fbdb
4 changed files with 207 additions and 0 deletions

33
kotlin/FuckingCoffee.kt Normal file
View File

@ -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<String>) {
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()
}

41
kotlin/Hangover.kt Normal file
View File

@ -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<NameValuePair>().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())
}

91
kotlin/KumarAsshole.kt Normal file
View File

@ -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<Address>
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()
}
}
}

42
kotlin/SmackMyBitch.kt Normal file
View File

@ -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<NameValuePair>().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())
}