summaryrefslogtreecommitdiff
path: root/src/main/scala/com/tylerstonge/honeypot/ftp/FtpFileReceiver.scala
diff options
context:
space:
mode:
authorTyler St. Onge <tylertstonge@gmail.com>2020-11-05 15:16:00 -0500
committerTyler St. Onge <tylertstonge@gmail.com>2020-11-05 15:16:00 -0500
commita7ba75b1b6ca4faa392cb3e5655fc784687e02ac (patch)
tree2fbb86557038b616513e1e2561d4e7ad7ae30d0e /src/main/scala/com/tylerstonge/honeypot/ftp/FtpFileReceiver.scala
parent07abec1108c69cf1f85ae039066e90f14eaca78a (diff)
added discord reporter
Diffstat (limited to 'src/main/scala/com/tylerstonge/honeypot/ftp/FtpFileReceiver.scala')
-rw-r--r--src/main/scala/com/tylerstonge/honeypot/ftp/FtpFileReceiver.scala20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/main/scala/com/tylerstonge/honeypot/ftp/FtpFileReceiver.scala b/src/main/scala/com/tylerstonge/honeypot/ftp/FtpFileReceiver.scala
index bf74e8b..aee40cb 100644
--- a/src/main/scala/com/tylerstonge/honeypot/ftp/FtpFileReceiver.scala
+++ b/src/main/scala/com/tylerstonge/honeypot/ftp/FtpFileReceiver.scala
@@ -2,7 +2,7 @@ package com.tylerstonge.honeypot.ftp
import java.io.File
import java.net.InetSocketAddress
-import java.nio.file.{Files, Paths, StandardOpenOption}
+import java.nio.file.{Files, StandardOpenOption}
import java.util.UUID
import akka.actor.{Actor, ActorRef, Props}
@@ -10,7 +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}
+import com.tylerstonge.honeypot.messages.MFoundFile
object FtpFileReceiver {
@@ -19,11 +19,11 @@ object FtpFileReceiver {
class FtpFileReceiver(port: Int, controller: ActorRef) extends Actor {
- val path = "/home/dropkick/honeypot/"
+ val path = "/tmp/files/"
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
- val name: String = UUID.randomUUID().toString
+ var name: String = UUID.randomUUID().toString
override def postStop {
log.debug("shutting down")
@@ -38,19 +38,23 @@ class FtpFileReceiver(port: Int, controller: ActorRef) extends Actor {
connection ! Register(self)
context.become {
case Received(data) =>
- log.info("read {} bytes", data.length)
+ log.debug("read {} bytes", data.length)
fileData.addAll(data)
case PeerClosed =>
log.debug("peer closed connection, writing file to disk")
- 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))
+ val out = Files.newByteChannel(new File(this.path + this.name).toPath, StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE)
out.write(fileData.result().toByteBuffer)
out.close()
controller.tell(Write(ByteString.apply("226 File transferred.\n")), context.parent)
+ context.system.eventStream.publish(MFoundFile(this.path + this.name))
context.stop(self)
+ case SetName(name) =>
+ log.info("file accepted as {}", name)
+ this.name = name
case msg@_ => log.warning("unknown message: {}", msg)
}
}
}
-case class Ready() \ No newline at end of file
+case class Ready()
+case class SetName(name: String) \ No newline at end of file