blob: 460f2f88090bf316a41754603b0cc57ce0232227 (
plain)
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
44
45
46
47
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"
}
}
|