summaryrefslogtreecommitdiff
path: root/src/main/scala/com/tylerstonge/honeypot/ftp
diff options
context:
space:
mode:
authorTyler St. Onge <tylertstonge@gmail.com>2020-09-25 17:39:10 -0400
committerTyler St. Onge <tylertstonge@gmail.com>2020-09-25 17:39:10 -0400
commit07abec1108c69cf1f85ae039066e90f14eaca78a (patch)
tree72a92c52a6d434e9845c5357cf02ada339e90551 /src/main/scala/com/tylerstonge/honeypot/ftp
parent7aca24d0086080eb5babdf499c1c484d1b2a4ca1 (diff)
added subscription model for reporter actors
Diffstat (limited to 'src/main/scala/com/tylerstonge/honeypot/ftp')
-rw-r--r--src/main/scala/com/tylerstonge/honeypot/ftp/FtpFileReceiver.scala5
-rw-r--r--src/main/scala/com/tylerstonge/honeypot/ftp/FtpHandler.scala15
2 files changed, 13 insertions, 7 deletions
diff --git a/src/main/scala/com/tylerstonge/honeypot/ftp/FtpFileReceiver.scala b/src/main/scala/com/tylerstonge/honeypot/ftp/FtpFileReceiver.scala
index fa54d28..bf74e8b 100644
--- a/src/main/scala/com/tylerstonge/honeypot/ftp/FtpFileReceiver.scala
+++ b/src/main/scala/com/tylerstonge/honeypot/ftp/FtpFileReceiver.scala
@@ -10,6 +10,7 @@ import akka.event.{Logging, LoggingAdapter}
import akka.io.Tcp._
import akka.io.{IO, Tcp}
import akka.util.{ByteString, ByteStringBuilder}
+import com.tylerstonge.honeypot.messages.{MFoundFile, MFoundPassword}
object FtpFileReceiver {
@@ -18,6 +19,7 @@ object FtpFileReceiver {
class FtpFileReceiver(port: Int, controller: ActorRef) extends Actor {
+ val path = "/home/dropkick/honeypot/"
val log: LoggingAdapter = Logging(context.system, this)
IO(Tcp)(context.system) ! Bind(self, new InetSocketAddress("127.0.0.1", port))
val fileData: ByteStringBuilder = ByteString.newBuilder
@@ -40,7 +42,8 @@ class FtpFileReceiver(port: Int, controller: ActorRef) extends Actor {
fileData.addAll(data)
case PeerClosed =>
log.debug("peer closed connection, writing file to disk")
- val out = Files.newByteChannel(new File("C:\\Users\\dropkick\\Documents\\dev\\honeypot\\" + this.name).toPath, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE)
+ val out = Files.newByteChannel(new File(this.path + "/" + this.name).toPath, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE)
+ context.system.eventStream.publish(MFoundFile(this.path + "/" + this.name))
out.write(fileData.result().toByteBuffer)
out.close()
controller.tell(Write(ByteString.apply("226 File transferred.\n")), context.parent)
diff --git a/src/main/scala/com/tylerstonge/honeypot/ftp/FtpHandler.scala b/src/main/scala/com/tylerstonge/honeypot/ftp/FtpHandler.scala
index 46263c6..b7b6f03 100644
--- a/src/main/scala/com/tylerstonge/honeypot/ftp/FtpHandler.scala
+++ b/src/main/scala/com/tylerstonge/honeypot/ftp/FtpHandler.scala
@@ -4,6 +4,7 @@ import akka.actor.{Actor, ActorRef, Props}
import akka.event.{Logging, LoggingAdapter}
import akka.io.Tcp.{PeerClosed, Received, Write}
import akka.util.ByteString
+import com.tylerstonge.honeypot.messages.{MFoundPassword, MFoundUsername}
import scala.util.Random
@@ -18,21 +19,23 @@ class FtpHandler(client: ActorRef) extends Actor {
override def receive: Receive = {
case Received(data) => client ! Write(ByteString.apply(parse(sanitize(data))))
case PeerClosed =>
- log.info("peer closed connection")
+ log.debug("peer closed connection")
context.stop(self)
}
def parse(msg: Array[String]): String = msg(0) match {
case "user" =>
- log.info("attempted login with username: {}", msg(1))
+ log.debug("attempted login with username: {}", msg(1))
+ context.system.eventStream.publish(MFoundUsername(msg(1)))
"331 Please specify password.\n"
case "pass" =>
- log.info("attempted login with password: {}", msg(1))
+ log.debug("attempted login with password: {}", msg(1))
+ context.system.eventStream.publish(MFoundPassword(msg(1)))
"230 Login successful.\n"
case "pwd" => "257 \"/\" is the current directory\n"
case "quit" => "221 Goodbye.\n"
case "pasv" =>
- log.info("entering passive mode")
+ log.debug("entering passive mode")
val r = new Random()
val p1 = r.nextInt(200)
val p2 = r.nextInt(200)
@@ -40,10 +43,10 @@ class FtpHandler(client: ActorRef) extends Actor {
Thread.sleep(256)
"227 entering passive mode (127,0,0,1," + p1 + "," + p2 + ")\n"
case "stor" =>
- log.info("stor: {}", msg(1))
+ log.debug("stor: {}", msg(1))
"150 File status okay; about to open data connection.\n"
case _ =>
- log.info("unsupported command received: {}", msg.mkString(" "))
+ log.debug("unsupported command received: {}", msg.mkString(" "))
"451 Requested action aborted. Local error in processing.\n"
}