summaryrefslogtreecommitdiff
path: root/src/main/scala/com
diff options
context:
space:
mode:
authorTyler St. Onge <tylertstonge@gmail.com>2020-07-18 01:24:12 -0400
committerTyler St. Onge <tylertstonge@gmail.com>2020-07-18 01:24:12 -0400
commit248f358e3a7602e5e3e4149ebbd0e7f1b6fa9e37 (patch)
tree671f263b351fe68b58207af6de90531a9fe9663a /src/main/scala/com
initial commit
Diffstat (limited to 'src/main/scala/com')
-rw-r--r--src/main/scala/com/tylerstonge/honeypot/Main.scala9
-rw-r--r--src/main/scala/com/tylerstonge/honeypot/SimplisticHandler.scala11
-rw-r--r--src/main/scala/com/tylerstonge/honeypot/Supervisor.scala14
-rw-r--r--src/main/scala/com/tylerstonge/honeypot/ftp/FtpListener.scala48
-rw-r--r--src/main/scala/com/tylerstonge/honeypot/http/HttpListener.scala28
5 files changed, 110 insertions, 0 deletions
diff --git a/src/main/scala/com/tylerstonge/honeypot/Main.scala b/src/main/scala/com/tylerstonge/honeypot/Main.scala
new file mode 100644
index 0000000..3c01fc8
--- /dev/null
+++ b/src/main/scala/com/tylerstonge/honeypot/Main.scala
@@ -0,0 +1,9 @@
+package com.tylerstonge.honeypot
+
+import akka.actor.{ActorSystem, Props}
+import com.tylerstonge.honeypot.ftp.FtpListener
+
+object Main extends App {
+ val system = ActorSystem("hello-system")
+ val listener = system.actorOf(Props[FtpListener], name = "ftp-listener")
+}
diff --git a/src/main/scala/com/tylerstonge/honeypot/SimplisticHandler.scala b/src/main/scala/com/tylerstonge/honeypot/SimplisticHandler.scala
new file mode 100644
index 0000000..41b49c9
--- /dev/null
+++ b/src/main/scala/com/tylerstonge/honeypot/SimplisticHandler.scala
@@ -0,0 +1,11 @@
+package com.tylerstonge.honeypot
+
+import akka.actor.Actor
+import akka.io.Tcp.{PeerClosed, Received, Write}
+
+class SimplisticHandler extends Actor {
+ def receive: Receive = {
+ case Received(data) => sender() ! Write(data)
+ case PeerClosed => context.stop(self)
+ }
+}
diff --git a/src/main/scala/com/tylerstonge/honeypot/Supervisor.scala b/src/main/scala/com/tylerstonge/honeypot/Supervisor.scala
new file mode 100644
index 0000000..a04a6e8
--- /dev/null
+++ b/src/main/scala/com/tylerstonge/honeypot/Supervisor.scala
@@ -0,0 +1,14 @@
+package com.tylerstonge.honeypot
+
+import akka.actor.Actor
+
+class Supervisor extends Actor {
+
+ override def receive: Receive = {
+ case _ => println("kk dood")
+ }
+
+ override def postStop {
+ println("Supervisor::postStop")
+ }
+} \ No newline at end of file
diff --git a/src/main/scala/com/tylerstonge/honeypot/ftp/FtpListener.scala b/src/main/scala/com/tylerstonge/honeypot/ftp/FtpListener.scala
new file mode 100644
index 0000000..460f2f8
--- /dev/null
+++ b/src/main/scala/com/tylerstonge/honeypot/ftp/FtpListener.scala
@@ -0,0 +1,48 @@
+package com.tylerstonge.honeypot.ftp
+
+import java.net.InetSocketAddress
+
+import akka.actor.{Actor, Props}
+import akka.event.{Logging, LoggingAdapter}
+import akka.io.Tcp._
+import akka.io.{IO, Tcp}
+import akka.util.ByteString
+
+class FtpListener extends Actor {
+
+ val log: LoggingAdapter = Logging(context.system, this)
+ IO(Tcp)(context.system) ! Bind(self, new InetSocketAddress("localhost", 2121))
+
+
+ override def receive: Receive = {
+ case Bound(localAddress) =>
+ log.info("listening on {}", localAddress)
+ case CommandFailed(_: Bind) => context.stop(self)
+ case Connected(remote, local) =>
+ val handler = context.actorOf(Props[FtpHandler])
+ val connection = sender()
+ connection ! Register(handler)
+ connection ! Write(ByteString.apply("220 (vulnFTPd 2.0.1)\n"))
+ }
+}
+
+class FtpHandler extends Actor {
+ val log: LoggingAdapter = Logging(context.system, this)
+
+ override def receive: Receive = {
+ case Received(data) => {
+ log.info(">> {}", data.utf8String)
+ sender() ! Write(ByteString.apply(parse(data.utf8String)))
+ }
+ case PeerClosed => {
+ log.info("closing connection")
+ context.stop(self)
+ }
+ }
+
+ def parse(msg: String): String = msg match {
+ case "AUTH SSL" => "500 cmd not recognized\n"
+ case "USER dropkick" => "200 come on in\n"
+ case _ => "200 sure\n"
+ }
+}
diff --git a/src/main/scala/com/tylerstonge/honeypot/http/HttpListener.scala b/src/main/scala/com/tylerstonge/honeypot/http/HttpListener.scala
new file mode 100644
index 0000000..edd2b01
--- /dev/null
+++ b/src/main/scala/com/tylerstonge/honeypot/http/HttpListener.scala
@@ -0,0 +1,28 @@
+package com.tylerstonge.honeypot.http
+
+import java.net.InetSocketAddress
+
+import akka.actor.{Actor, Props}
+import akka.event.Logging
+import akka.io.Tcp._
+import akka.io.{IO, Tcp}
+import com.tylerstonge.honeypot.SimplisticHandler
+
+
+class HttpListener extends Actor {
+ val log = Logging(context.system, this)
+
+ import context.system
+
+ IO(Tcp) ! Bind(self, new InetSocketAddress("localhost", 7333))
+
+ override def receive: Receive = {
+ case b@Bound(localAddress) => context.parent ! b
+ case CommandFailed(_: Bind) => context.stop(self)
+ case c@Connected(remote, local) =>
+ val handler = context.actorOf(Props[SimplisticHandler])
+ val connection = sender()
+ connection ! Register(handler)
+ }
+
+} \ No newline at end of file