Skip to content

Commit

Permalink
Added Makefile; Updated agent to have random padding size to message
Browse files Browse the repository at this point in the history
traffic.
  • Loading branch information
Ne0nd0g committed Nov 13, 2017
1 parent 64806dd commit 9e95f25
Show file tree
Hide file tree
Showing 10 changed files with 299 additions and 84 deletions.
84 changes: 84 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Merlin Server & Agent version number
VERSION=0.1.2

MSERVER=merlinServer
MAGENT=merlinAgent
BUILD=$(shell git rev-parse HEAD)
DIR=data/bin/v${VERSION}/
GOPATH := ${PWD}/_vendor:${GOPATH}
LDFLAGS=-ldflags "-X main.version=${VERSION} -X main.build=${BUILD}"
WINAGENTLDFLAGS=-ldflags "-X main.version=${VERSION} -X main.build=${BUILD} -H=windowsgui"

export GOPATH

# Make Directory to store executables
$(shell mkdir -p ${DIR})

# Change default to just make for the host OS and add MAKE ALL to do this
default: server-windows agent-windows server-linux agent-linux server-darwin agent-darwin

all: default

# Complile Windows binaries
windows: server-windows agent-windows

# Compile Linux binaries
linux: server-linux agent-linux

# Compile Darwin binaries
darwin: server-darwin agent-darwin

# Compile Server - Windows x64
server-windows:
export GOOS=windows;export GOARCH=amd64;go build ${LDFLAGS} -o ${DIR}/${MSERVER}-Windows-x64.exe cmd/merlinserver/main.go

# Compile Agent - Windows x64
agent-windows:

export GOOS=windows;export GOARCH=amd64;go build ${WINAGENTLDFLAGS} -o ${DIR}/${MAGENT}-Windows-x64.exe cmd/merlinagent/main.go

# Compile Server - Linux x64
server-linux:
export GOOS=linux;export GOARCH=amd64;go build ${LDFLAGS} -o ${DIR}/${MSERVER}-Linux-x64 cmd/merlinserver/main.go

# Compile Agent - Linux x64
agent-linux:

export GOOS=linux;export GOARCH=amd64;go build ${LDFLAGS} -o ${DIR}/${MAGENT}-Linux-x64 cmd/merlinagent/main.go

# Compile Server - Darwin x64
server-darwin:
export GOOS=darwin;export GOARCH=amd64;go build ${LDFLAGS} -o ${DIR}/${MSERVER}-Darwin-x64.dmg cmd/merlinserver/main.go

# Compile Agent - Darwin x64
agent-darwin:

export GOOS=darwin;export GOARCH=amd64;go build ${LDFLAGS} -o ${DIR}/${MAGENT}-Darwin-x64.dmg cmd/merlinagent/main.go

# Make directory 'data' and then agents, db, log, x509; Copy src folder, README, and requirements
tar-server-windows:

cd ${DIR};tar -zcvf ${MSERVER}-Windows-x64-v${VERSION}.tar.gz ${MSERVER}-Windows-x64.exe ../../../data/README.MD ../../../data/requirements.txt ../../../data/db ../../../data/log ../../../data/src ../../../data/x509 ../../../data/agents/README.MD

tar-server-linux:
cd ${DIR};tar -zcvf ${MSERVER}-Linux-x64-v${VERSION}.tar.gz ${MSERVER}-Linux-x64 ../../../data/README.MD ../../../data/requirements.txt ../../../data/db ../../../data/log ../../../data/src ../../../data/x509 ../../../data/agents/README.MD

tar-server-darwin:
cd ${DIR};tar -zcvf ${MSERVER}-Darwin-x64-v${VERSION}.tar.gz ${MSERVER}-Darwin-x64.dmg ../../../data/README.MD ../../../data/requirements.txt ../../../data/db ../../../data/log ../../../data/src ../../../data/x509 ../../../data/agents/README.MD

tar-agent-windows:
cd ${DIR};tar -zcvf ${MAGENT}-Windows-x64-v${VERSION}.tar.gz ${MAGENT}-Windows-x64.exe

tar-agent-linux:
cd ${DIR};tar -zcvf ${MAGENT}-Linux-x64-v${VERSION}.tar.gz ${MAGENT}-Linux-x64

tar-agent-darwin:
cd ${DIR};tar -zcvf ${MAGENT}-Darwin-x64-v${VERSION}.tar.gz ${MAGENT}-Darwin-x64.dmg

tar-all: tar-server-windows tar-server-linux tar-server-darwin tar-agent-windows tar-agent-linux tar-agent-darwin

clean:
$(RM) ${DIR}/merlin*

#Build all files for release distrobution
distro: clean all tar-all
73 changes: 44 additions & 29 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@

# Merlin
# Merlin (BETA)
Merlin is a Command & Control toolset written in golang that operates over an HTTP/2 connection. Communications are passed between the server and agent using JSON messages.

## Install GO
The Go programing language must be installed on the system hosting Merlin.

Download and install GO: `https://golang.org/doc/install`

## Running Merlin Server
Merlin Server can be run as a script or compiled and run as a standalone binary file.
>Ensure your GOPATH environment variable is set
Windows `set GOPATH=C:\Merlin`

*nix `export GOPATH=/opt/Merlin`

3rd party libraries must be installed with:
```
go get github.com/fatih/color
go get github.com/satori/go.uuid
```
## Running Merlin Server
Merlin Server can be run as a script or compiled and run as a standalone binary file.

> It is recommended to download the compiled binaries from the
[Releases](https://github.com/Ne0nd0g/merlin/releases) section

Run Merlin Server as a script:

Run Merlin Server as a script: `go run cmd/merlinserver/main.go`
`git clone https://github.com/Ne0nd0g/merlin/`

Compile Merlin Server into an executable: `go build -o merlinserver.exe cmd/merlinserver/main.go`
`go run cmd/merlinserver/main.go`

Compile Merlin Server into an executable:

`make server-windows` or `make server-linux` or `make server-darwin`

### Merlin Server Usage
```
Expand All @@ -41,6 +45,10 @@ Compile Merlin Server into an executable: `go build -o merlinserver.exe cmd/merl
```

## Merlin Server Commands
Merlin is equipped with a tab completion system that can be used to see
what commands are available at any given time. Hit double tab to get a
list of all available commands.

```
exit Exit and close Merlin
Expand All @@ -53,43 +61,50 @@ quit Exit and close Merlin
```

## Agent Commands
These are the commands to control an agent from the server. Tab
completion can be used to select an Agent's identifier.

```
agent_cmd <agent id> <command> A command to run on a remote agent
agent cmd <agent id> <command> A command to run on a remote agent
agent_control <agent id> <command> Configure/Control a remote agent (not the host)
agent control <agent id> <command> Configure/Control a remote agent (not the host)
[kill,]
agent_info <agent id> Display all information for an agent
agent info <agent id> Display all information for an agent
agent_list List agents
agent list List agents
```

### TLS Certificates
By default, Merlin will load server.crt and server.key from the `data/x509/` directory. You must generate your own certificate pair and place them in this directory.
### Third Party Libraries
github.com/fatih/color
github.com/satori/go.uuid
golang.org/x/net/http2
github.com/mattn/go-sqlite3
* requires gcc
* Use tdm64-gcc or mingw-w64 for Windows and add its /bin directory to your path
The 3rd party libraries used with Merlin are kept in the _vendor_
directory. This project will default to using the library files in that
folder.

Execute this command to install all dependencies:
`go get github.com/fatih/color github.com/satori/go.uuid golang.org/x/net/http2 github.com/mattn/go-sqlite3`
## Running Merlin Agent
The agent portion of Merlin should be run as a compiled binary file on
a target host.

## Merlin Agent
The agent portion of Merlin should be run as a compiled binary file on a target host.
> It is recommended to download the compiled binaries from the
[Releases](https://github.com/Ne0nd0g/merlin/releases) section

>Ensure your GOPATH environment variable is set
>Ensure your GOPATH environment variable is set!
Windows `set GOPATH=C:\Merlin`
Compile Merlin Agent into an executable

*nix `export GOPATH=/opt/Merlin`
`make agent-windows` or `make agent-linux` or `make agent-darwin`

Merlin Agent can also be compiled without Make, using just go. To
compile Merlin Agent with your Merlin Server's address, so it doesn't
have to specified on the command line, include `-ldflags
-X main.URL=https://acme.com:443/`

Compile Merlin Agent into an executable: `go build -o merlinagent.exe cmd/merlinagent/main.go`
>Example: `go build -o merlinagent.exe -ldflags
"-X main.URL=https://acme.com:443/" cmd/merlinagent/main.go`

Run Merlin Agent as script `go run cmd/merlinagent/main.go`
Run Merlin Agent as script: `go run cmd/merlinagent/main.go`

### USAGE

Expand Down
Loading

0 comments on commit 9e95f25

Please sign in to comment.