From 07abec1108c69cf1f85ae039066e90f14eaca78a Mon Sep 17 00:00:00 2001 From: "Tyler St. Onge" Date: Fri, 25 Sep 2020 17:39:10 -0400 Subject: added subscription model for reporter actors --- src/main/scala/com/tylerstonge/honeypot/ftp/FtpFileReceiver.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/main/scala/com/tylerstonge/honeypot/ftp/FtpFileReceiver.scala') 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) -- cgit v1.1