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
|
package com.tylerstonge.honeypot.reporter
import akka.actor.{Actor, Props}
import akka.event.{Logging, LoggingAdapter}
import scalaj.http.Http
import com.tylerstonge.honeypot.messages.{MFoundFile, MFoundPassword, MFoundUsername, MNewConnection}
object DiscordReporter {
def props(webhook: String): Props = Props(new DiscordReporter(webhook))
}
class DiscordReporter(webhook: String) extends Actor {
val log: LoggingAdapter = Logging(context.system, this)
context.system.eventStream.subscribe(self, classOf[MNewConnection])
context.system.eventStream.subscribe(self, classOf[MFoundUsername])
context.system.eventStream.subscribe(self, classOf[MFoundPassword])
context.system.eventStream.subscribe(self, classOf[MFoundFile])
override def postStop(): Unit = {
super.postStop()
}
override def receive: Receive = {
case msg: MNewConnection =>
log.debug(">> DISCORD REPORTER (MNewConnection) >> :: {}", msg.ip)
Http(webhook).postData(formatMessage("attacker detected @ " + msg.ip)).header("content-type", "application/json").asString
case msg: MFoundUsername =>
log.debug(">> DISCORD REPORTER >> (MFoundUsername) :: {}", msg.username)
Http(webhook).postData(formatMessage("attacker identified as " + msg.username)).header("content-type", "application/json").asString
case msg: MFoundPassword =>
log.debug(">> DISCORD REPORTER (MFoundPassword) >> :: {}", msg.password)
Http(webhook).postData(formatMessage("attacker password is " + msg.password)).header("content-type", "application/json").asString
case msg: MFoundFile =>
log.debug(">> DISCORD REPORTER (MFoundFile) >> :: {}", msg.filename)
Http(webhook).postData(formatMessage("attacker deposited a file called " + msg.filename)).header("content-type", "application/json").asString
}
def formatMessage(msg: String): String = {
"""{ "username": "phreak", "content": "%s" }""".format(msg)
}
}
|