• Stars
    star
    285
  • Rank 140,501 (Top 3 %)
  • Language
    Rust
  • License
    Other
  • Created over 2 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A fast and secure multi protocol honeypot.

Medusa

A fast and secure multi protocol honeypot that can mimic realistic devices running ssh, telnet, http, https or any other tcp and udp servers.

Building

Using Docker (recommended):

docker build -t medusa .
docker run \
  -v /path/to/services.d:/etc/medusa/services.d \
  -v /path/to/records:/var/lib/medusa/records \
  --network host \
  medusa

Lastly, you can build from sources if you have Rust installed in your system (it requires openssl and libpcap-dev):

cargo build 

Shodan Host Clone

You can use medusa to create a (best-effort) clone of a device that's indexed on shodan.io.

In order to do this you'll need an API key:

export SHODAN_API_KEY=your_api_key_here

Then you can clone a host (38.18.235.213 in this example) with:

docker run -v $(pwd)/mikrotik:/mikrotik medusa \
  --shodan-api-key $SHODAN_API_KEY \
  --shodan-clone 38.18.235.213 \
  --output /mikrotik

This will create the YAML service files inside the mikrotik folder. This folder can then be used with:

docker run \
  -v $(pwd)/mikrotik:/etc/medusa/services.d \
  -v $(pwd)/records:/var/lib/medusa/records \
  --network host \
  medusa

Usage

First you need to create at least one service file. Let's begin by defining a simple SSH honeypot that accepts any combination of user and password:

mkdir -p /path/to/services.d/
touch /path/to/services.d/example-ssh.yml

Open /path/to/services.d/example-ssh.yml with your favorite editor and paste these contents:

proto: ssh
address: '127.0.0.1:2222'
server_id: 'SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.10'
banner: 'Last login: Mon Sep  5 14:12:09 2022 from 127.0.0.1'
prompt: '# '
timeout: 15
commands:
  - parser: '^exit(\s.+)?$'
    handler: '@exit'

In some cases, custom SSH servers do not respect the RFC standard for server id termination characters \r\n, but rather use only \n. In this case it is possible to use the server_id_raw directive and include custom terminators in the string, while of server_id is used the default \r\n will be used.

proto: ssh
address: '127.0.0.1:2222'
server_id_raw: "SSH-1.99-TECHNICOLOR_SW_2.0\n"
banner: 'Last login: Mon Sep  5 14:12:09 2022 from 127.0.0.1'
prompt: '# '
timeout: 15
commands:
  - parser: '^exit(\s.+)?$'
    handler: '@exit'

Now run:

medusa --services "/path/to/services.d/" --records "/path/to/output/records" --capture-device "<your network interface name>"

This will start a single honeypoint on port 2222 and all the resulting events will be saved as JSON files in the folder indicated by --records. Additionally a pcap of the entire traffic will be saved as capture.pcap.

Commands

The previous example won't do much if somebody tries to execute actual commands. It only captures the exit command in order to terminate the session (via the @exit special handler). Let's add another command, for instance to parse simple echo inputs:

proto: ssh
address: '127.0.0.1:2222'
server_id: 'SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.10'
prompt: '# '
timeout: 15
commands:
  - parser: '^exit(\s.+)?$'
    handler: '@exit'
  - parser: '^echo(\s"?([^"]*)"?)?$'
    handler: '{$2}'

The parser expression will now capture the echo command and its argument (captured as $2), that will be echoed back via the handler ({$2} is replaced with the value of $2).

In other cases, the handler can contain the entire output as a raw string, like for the case of an http service honeypot:

proto: http 
address: '127.0.0.1:8080'
commands:
  - parser: '.*'
    handler: "<html><body>hello world</body></html>"

Docker Jail

Another useful handler is @docker. As the name suggests it executes any shell command it receives as an argument inside a docker container, therefore we could create a "jailed" ssh honeypot by doing:

proto: ssh
address: '127.0.0.1:2222'
server_id: 'SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.10'
prompt: '# '
timeout: 15
commands:
  - parser: '^exit(\s.+)?$'
    handler: '@exit'
  - parser: '^(.+)$'
    handler: '@docker jail {$1}'

You can create and start a jail container with:

docker container create --name jail busybox tail -f /dev/null # feel free to pick any image
docker start jail

This will execute any command that the client is sending on the jail container and it will transparently pass the output to the client.

Configuring a realistic docker container is beyond the purpose of this document, you can find useful images here.

Protocols

SSH server emulation (with docker jail):

proto: ssh
address: '127.0.0.1:2222'
server_id: 'SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.10'
prompt: '# '
timeout: 15
commands:
  - parser: '^exit(\s.+)?$'
    handler: '@exit'
  - parser: '^(.+)$'
    handler: '@docker medusajail {$1}'

Telnet server emulation (with docker jail):

proto: telnet
address: '127.0.0.1:2323'
banner: 'TNAS v1.0'
login_prompt: 'TNAS login: '
password_prompt: 'Password: '
prompt: '[admin@TNAS ~]$ '
timeout: 15
commands:
  - parser: '^exit(\s.+)?$'
    handler: '@exit'
  - parser: '^(.+)$'
    handler: '@docker medusajail {$1}'

HTTP server emulation with custom headers:

proto: http 
address: '127.0.0.1:8181'
headers:
  - 'Content-Type: text/html; charset=UTF-8'
  - 'X-Powered-By: TerraMaster'
  - 'Server: TOS/1.16.1'
  
commands:
  - parser: '.*'
    handler: |
      <!--user login-->
      <!DOCTYPE HTML>
      <html>
      <head>
          <title>TOS</title>
      </head>
      <div>
          Hello World
      </div>
      </html>

HTTPS is also supported, you'll need to generate a new RSA key and certificate first:

 openssl req -newkey rsa:2048 -nodes -keyout medusa-https.key -x509 -days 365 -out medusa-https.crt

Then just enable tls in your http service configuration:

proto: http 
address: '127.0.0.1:8181'
tls: true
key: medusa-https.key
certificate: medusa-https.crt
headers:
  - 'Content-Type: text/html; charset=UTF-8'
  - 'X-Powered-By: TerraMaster'
  - 'Server: TOS/1.16.1'
  
commands:
  - parser: '.*'
    handler: |
      <!--user login-->
      <!DOCTYPE HTML>
      <html>
      <head>
          <title>TOS</title>
      </head>
      <div>
          Hello World
      </div>
      </html>

Other TCP servers can be simulated by exposing a banner:

proto: tcp
address: '127.0.0.1:1723'
banner: |
  Firmware: 1
  Hostname: ASBN-BB-RT01
  Vendor: MikroTik

And UDP servers as well:

proto: udp
address: '0.0.0.0:5353'
banner: |
  dnsmasq-2.73
  Recursion: enabled
  Resolver name: X4200

Other options

Run medusa --help for the complete list of options.

License

Medusa was made with β™₯ by Simone Margaritelli and it's released under the GPL 3 license.

More Repositories

1

opensnitch

OpenSnitch is a GNU/Linux interactive application firewall inspired by Little Snitch.
Python
9,655
star
2

pwnagotchi

(βŒβ– _β– ) - Deep Reinforcement Learning instrumenting bettercap for WiFi pwning.
JavaScript
5,830
star
3

bettercap

DEPRECATED, bettercap developement moved here: https://github.com/bettercap/bettercap
2,507
star
4

xray

XRay is a tool for recon, mapping and OSINT gathering from public networks.
Go
1,966
star
5

bleah

This repository is DEPRECATED, please use bettercap as this tool has been ported to its BLE modules.
1,094
star
6

dnssearch

A subdomain enumeration tool.
Go
879
star
7

arc

A manager for your secrets.
Go
838
star
8

ditto

A tool for IDN homograph attacks and detection.
Go
694
star
9

uroboros

A GNU/Linux monitoring and profiling tool focused on single processes.
Go
668
star
10

shellz

shellz is a small utility to manage your ssh, telnet, kubernetes, winrm, web or any custom shell in a single place.
Go
537
star
11

sg1

A wanna be swiss army knife for data encryption, exfiltration and covert communication.
Go
528
star
12

smali_emulator

This software will emulate a smali source file generated by apktool.
Python
458
star
13

arminject

An application to dynamically inject a shared object into a running process on ARM architectures.
C++
432
star
14

jscythe

Abuse the node.js inspector mechanism in order to force any node.js/electron/v8 based process to execute arbitrary javascript code.
Rust
310
star
15

spycast

A crossplatform mDNS enumeration tool.
HTML
304
star
16

ergo

🧠 A tool that makes AI easier.
Python
285
star
17

bettercap-proxy-modules

This repository contains some bettercap transparent proxy example modules.
285
star
18

dirsearch

A Go implementation of dirsearch.
Go
253
star
19

kitsune

🧠 πŸ”Ž πŸ€– Kitsune is an artificial neural network designed to detect and correlate Twitter profiles with similar behaviours.
Python
228
star
20

librestd

A low dependencies and self contained library to create C++ RESTful API services.
C++
199
star
21

shieldwall

zero-trust remote firewall instrumentation
Go
195
star
22

pwnagotchi-plugins-contrib

User contributed Pwnagotchi plugins.
Python
170
star
23

ergo-pe-av

🧠 🦠 An artificial neural network and API to detect Windows malware, based on Ergo and LIEF.
Python
166
star
24

sauron

A minimalistic cross-platform malware scanner with non-blocking realtime filesystem monitoring using YARA rules.
Rust
162
star
25

islazy

A Go library containing a set of opinionated packages, objects, helpers and functions implemented with the KISS principle in mind.
Go
153
star
26

gitstats

Git Repository Analyzer.
Go
145
star
27

gibson

A high performance tree-based cache server.
C
136
star
28

androswat

tool to inspect, dump, modify, search and inject libraries into Android processes.
C++
121
star
29

pdusms

PoC app for raw pdu manipulation on Android.
Java
119
star
30

veryfied

Mark pre-Musk era Twitter actually verified accounts.
JavaScript
113
star
31

ebpf-process-anomaly-detection

Process behaviour anomaly detection using eBPF and unsupervised-learning Autoencoders
Python
108
star
32

pwngrid

(βŒβ– _β– ) - API server for pwnagotchi.ai
Go
100
star
33

coffee

Smarter Coffee terminal client.
Python
97
star
34

joe

The Swiss Army knife for backend engineers.
Go
90
star
35

sum

A specialized database server for linear algebra and machine learning.
Go
87
star
36

www.pwnagotchi.ai

(βŒβ– _β– ) - pwnagotchi.ai
CSS
84
star
37

nikeplus-fuelband-se-reversed

A a proof of concept application that uses BLE api and the Nike+ FuelBand SE protocol to communicate with Nike BLE devices.
Java
82
star
38

takuan

Takuan is a system service that parses logs and detects noisy attackers in order to build a blacklist database of known cyber offenders.
Go
82
star
39

ftrace

Go library to trace Linux syscalls using the FTRACE kernel framework.
Go
76
star
40

openbank

OpenBank - Your BTC realtime tracker.
PHP
68
star
41

fang

A multi service threaded MD5 cracker
Python
66
star
42

dotfiles

My zsh, bash and vim dot files
Shell
66
star
43

libpe

A C/C++ library to parse Windows portable executables written with speed and stability in mind.
C
64
star
44

brutemachine

A Go library which main purpose is giving an interface to loop over a dictionary and use those words/lines as input for some custom logic such as HTTP file bruteforcing, DNS bruteforcing, etc.
Go
53
star
45

fido

Fido is a minimalistic, IDE and language agnostic project generator supporting various toolchains and build systems.
Python
52
star
46

mpcfw

Reverse engineering of Apple MultipeerConnectivity Framework
Python
51
star
47

quijote

Quijote is an highly configurable HTTP middleware for API security.
Go
48
star
48

altair

A Modular Web Vulnerability Scanner
Python
47
star
49

mcaptcha_bypass

PoC to bypass mCaptcha and its rate limiting capabilities from a fully automated bot.
Rust
47
star
50

ergo-planes-detector

🧠✈️ An ergo based project that relies on a convolutional neural network to detect airplanes from satellite imagery.
Python
44
star
51

stork

A small utility that aims to automate and simplify some tasks related to software release cycles.
Go
43
star
52

SafeInCloud

This repository contains a class to decrypt SafeInCloud (https://www.safe-in-cloud.com/) database files and a couple of command line utilities.
Python
41
star
53

pycryptocat

pyCryptoCat - A CryptoCat standalone python client.
JavaScript
36
star
54

unisbom

UniSBOM is a tool to build a software bill of materials on any platform with a unified data format.
Rust
34
star
55

dunmer

An ELF parasite command injector.
C
31
star
56

evilsocket.github.io

evilsocket.github.io files
HTML
28
star
57

dsploit-arpspoof

The dSploit arpspoof module.
C
27
star
58

octoghost

A python script to process Octopress markdown files and write a JSON file ready to import into Ghost.
Python
27
star
59

backup

Backup scripts I use on my drives.
Shell
26
star
60

SoftWire

SoftWire is a class library written in object-oriented C++ for compiling assembly code. It can be used in projects to generate x86 machine code at run-time as an alternative to self-modifying code. Scripting languages might also benefit by using SoftWire as a JIT-compiler back-end. It also allows to eliminate jumps for variables which are temporarily constant during run-time, like for efficient graphics processing by constructing an optimised pipeline. Because of its possibility for 'instruction rewiring' by run-time conditional compilation, I named it "SoftWire". It is targeted only at developers with a good knowledge of C++ and x86 assembly. Project originally by Nicolas Capens, new implementation by Simone Margaritelli aka evilsocket
C++
25
star
61

SWG

Static Website Generator
Python
23
star
62

hybris

Hybris scripting language interpreter engine and standard library modules.
C++
23
star
63

rubertooth

A complete Ruby porting of the ubertooth libraries and utilities.
Ruby
23
star
64

BioIdentify

BioIdentify is a command line tool for fingerprints feature extraction, 1on1 match and 1onN match .
C++
21
star
65

emoticode

This is the code repository for v2.0 of http://www.emoticode.net/
Ruby
21
star
66

gobench

A simple bash script that does its best to automate and visualize differential benchmarking for Go projects.
Shell
21
star
67

eve

(◍‒﹏‒) - Hi, I'm Eve
Python
21
star
68

clang-ebpf-builder

A Rust crate that simplifies the integration of Rust and eBPF programs written in C.
C
20
star
69

hackrfpp

HackRF C++ playground plus basic demodulation.
C++
20
star
70

wax

Wax is a mediocre fuzzer I'm prototyping to test some ideas and get rid of others.
Go
19
star
71

pineproxy

A ruby self contained, low resource consuming HTTP transparent proxy designed for the WiFi Pineapple MKV.
Ruby
16
star
72

pwngrid-queries-joe

PwnGRID queries for Joe
Go
15
star
73

octofairy

A machine learning based GitHub bot for Issues.
Python
15
star
74

webmon

A webpage monitor bot, currently used to monitor Twitter ToS.
Python
13
star
75

twitter-num-followers-bot

A bot that'll monitor the number of followers of its followers and tweet when the counter gets to interesting values.
Go
13
star
76

arc-android-wrapper

An Android wrapper for Arc
Java
13
star
77

update.dsploit.net

The code repository for the dSploit project update server.
Ruby
13
star
78

Eigetron

Face recognition program that uses Eigen faces with a fast Jacobi eigen decomposition
C++
13
star
79

Pynject

Pynject - An automatic MySQL injector and data dumper tool.
Python
13
star
80

keras-goodreads

book rating system using LSTM and Goodreads
Python
12
star
81

MSP

Multidimensional Space Processing Library
C++
11
star
82

phpgibson

The phpgibson extension provides an API for communicating with the Gibson cache server.
C
10
star
83

mmdb2json

A script to dump a MMDB ( MaxMind ) binary database to JSON.
Python
9
star
84

backupbox

Sup biatch?
Python
9
star
85

Kerby_Surveillance

Kerby - Light weight video surveillance system.
C++
9
star
86

charon

A Ruby library to query the Zen service on SpamHaus.org
Ruby
6
star
87

evilsocket

about me
6
star
88

42

.
5
star
89

sumphp

PHP client interface to the Sum linear algebra database.
PHP
5
star
90

gauntlet-nginx

Gauntlet IPS nginx module
C
5
star
91

libgibsonclient

Gibson cache server native client library.
C
5
star
92

codeforces

Solutions for the codeforces.com problemset section exercises.
C
5
star
93

rpi-l298n-motor-driver

Those are experimental scripts to be used with a Raspberry Pi, a L298N chip and two motors.
Python
5
star
94

dsploit-thomson

Assembly
5
star
95

caspermod

A modified version of the Casper theme for Ghost blog platform.
CSS
4
star
96

takuan-reports

4
star
97

TED

TED (acronym for neTwork Event Daemon) is a GNU/Linux daemon that will inform you upon new inbound connections, when an host on your network is alive or not, and so on .
C++
4
star
98

sumpy

Python client interface to the Sum linear algebra database.
Python
4
star
99

node-gibson

A pure-JavaScript Gibson client library for node.
JavaScript
3
star
100

dotme

A gem to handle dot files easily.
Ruby
3
star