From 248f358e3a7602e5e3e4149ebbd0e7f1b6fa9e37 Mon Sep 17 00:00:00 2001 From: "Tyler St. Onge" Date: Sat, 18 Jul 2020 01:24:12 -0400 Subject: initial commit --- .gitignore | 107 +++++++++++++++++++ .idea/.gitignore | 3 + .idea/codeStyles/Project.xml | 7 ++ .idea/codeStyles/codeStyleConfig.xml | 5 + .idea/misc.xml | 4 + .idea/modules.xml | 9 ++ .idea/modules/honeypot-build.iml | 114 +++++++++++++++++++++ .idea/modules/honeypot.iml | 18 ++++ .idea/sbt.xml | 17 +++ .idea/scala_compiler.xml | 6 ++ .idea/vcs.xml | 6 ++ build.sbt | 7 ++ project/build.properties | 1 + src/main/scala/com/tylerstonge/honeypot/Main.scala | 9 ++ .../tylerstonge/honeypot/SimplisticHandler.scala | 11 ++ .../com/tylerstonge/honeypot/Supervisor.scala | 14 +++ .../com/tylerstonge/honeypot/ftp/FtpListener.scala | 48 +++++++++ .../tylerstonge/honeypot/http/HttpListener.scala | 28 +++++ 18 files changed, 414 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/modules/honeypot-build.iml create mode 100644 .idea/modules/honeypot.iml create mode 100644 .idea/sbt.xml create mode 100644 .idea/scala_compiler.xml create mode 100644 .idea/vcs.xml create mode 100644 build.sbt create mode 100644 project/build.properties create mode 100644 src/main/scala/com/tylerstonge/honeypot/Main.scala create mode 100644 src/main/scala/com/tylerstonge/honeypot/SimplisticHandler.scala create mode 100644 src/main/scala/com/tylerstonge/honeypot/Supervisor.scala create mode 100644 src/main/scala/com/tylerstonge/honeypot/ftp/FtpListener.scala create mode 100644 src/main/scala/com/tylerstonge/honeypot/http/HttpListener.scala diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3f1345d --- /dev/null +++ b/.gitignore @@ -0,0 +1,107 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/scala,intellij +# Edit at https://www.toptal.com/developers/gitignore?templates=scala,intellij + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/**/sonarlint/ + +# SonarQube Plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +### Scala ### +*.class +*.log + +target/ + +# End of https://www.toptal.com/developers/gitignore/api/scala,intellij diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..919ce1f --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..794aa67 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..acc4039 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/honeypot-build.iml b/.idea/modules/honeypot-build.iml new file mode 100644 index 0000000..725673b --- /dev/null +++ b/.idea/modules/honeypot-build.iml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/honeypot.iml b/.idea/modules/honeypot.iml new file mode 100644 index 0000000..e735fa7 --- /dev/null +++ b/.idea/modules/honeypot.iml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/sbt.xml b/.idea/sbt.xml new file mode 100644 index 0000000..fffb6e3 --- /dev/null +++ b/.idea/sbt.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/.idea/scala_compiler.xml b/.idea/scala_compiler.xml new file mode 100644 index 0000000..3185530 --- /dev/null +++ b/.idea/scala_compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/build.sbt b/build.sbt new file mode 100644 index 0000000..04e6aec --- /dev/null +++ b/build.sbt @@ -0,0 +1,7 @@ +scalaVersion := "2.13.1" + +name := "honeypot" +organization := "com.tylerstonge" +version := "1.0" + +libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.6.6" diff --git a/project/build.properties b/project/build.properties new file mode 100644 index 0000000..a919a9b --- /dev/null +++ b/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.3.8 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 -- cgit v1.1