Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On branch arslan-director-dhavoc #461

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ client-build:
@ echo "[*] building client"
@ git submodule update --init --recursive
@ mkdir client/Build; cd client/Build; cmake ..
@ if [ -d "client/Modules" ]; then echo "Modules installed"; else git clone https://github.com/HavocFramework/Modules client/Modules --single-branch --branch `git rev-parse --abbrev-ref HEAD`; fi
@ if [ -d "client/Modules" ]; then echo "Modules installed"; else git clone https://github.com/HavocFramework/Modules client/Modules --single-branch --branch main; fi
@ cmake --build client/Build -- -j 4

client-cleanup:
Expand Down
28 changes: 14 additions & 14 deletions teamserver/Install.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#!/bin/bash

if [ ! -d "dir/x86_64-w64-mingw32-cross" ]; then
sudo apt -qq --yes install golang-go nasm mingw-w64 wget >/dev/null 2>&1
# if [ ! -d "dir/x86_64-w64-mingw32-cross" ]; then
# sudo apt -qq --yes install golang-go nasm mingw-w64 wget >/dev/null 2>&1

if [ ! -d "data" ]; then
mkdir data
fi
# if [ ! -d "data" ]; then
# mkdir data
# fi

if [ ! -f /tmp/mingw-musl-64.tgz ]; then
wget https://musl.cc/x86_64-w64-mingw32-cross.tgz -q -O /tmp/mingw-musl-64.tgz
fi
# if [ ! -f /tmp/mingw-musl-64.tgz ]; then
# wget https://musl.cc/x86_64-w64-mingw32-cross.tgz -q -O /tmp/mingw-musl-64.tgz
# fi


tar zxf /tmp/mingw-musl-64.tgz -C data
# tar zxf /tmp/mingw-musl-64.tgz -C data

if [ ! -f /tmp/mingw-musl-32.tgz ]; then
wget https://musl.cc/i686-w64-mingw32-cross.tgz -q -O /tmp/mingw-musl-32.tgz
fi
# if [ ! -f /tmp/mingw-musl-32.tgz ]; then
# wget https://musl.cc/i686-w64-mingw32-cross.tgz -q -O /tmp/mingw-musl-32.tgz
# fi

tar zxf /tmp/mingw-musl-32.tgz -C data
fi
# tar zxf /tmp/mingw-musl-32.tgz -C data
# fi
45 changes: 45 additions & 0 deletions teamserver/cmd/server/teamserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,42 @@ func (t *Teamserver) SetServerFlags(flags TeamserverFlags) {
t.Flags = flags
}



func (t *Teamserver) ReturnJsonTeamServer() *TeamserverJson {

var (
countClients int = 0
)
t.Clients.Range(func(key, value interface{}) bool {
countClients++
return true
})

var json *TeamserverJson = &TeamserverJson{
Clients: make(map[string]*ClientJson, countClients),
Users: t.Users,
Agents: t.Agents,
Listeners: t.Listeners,
Endpoints: t.Endpoints,
}

t.Clients.Range(func(key, value interface{}) bool {
json.Clients[fmt.Sprint(key)] = &ClientJson{
ClientID: value.(*Client).ClientID,
Username: value.(*Client).Username,
GlobalIP: value.(*Client).GlobalIP,
ClientVersion: value.(*Client).ClientVersion,
Authenticated: value.(*Client).Authenticated,
SessionID: value.(*Client).SessionID,
}
return true
})
return json
}

func (t *Teamserver) Start() {

logger.Debug("Starting teamserver...")
var (
ServerFinished chan bool
Expand Down Expand Up @@ -107,6 +142,16 @@ func (t *Teamserver) Start() {
go t.handleRequest(ClientID)
})

//quick and dirty way to dump jason
t.Server.Engine.GET("/quick", func ( context *gin.Context) {


var jsonReturn *TeamserverJson = t.ReturnJsonTeamServer()
//dumping the clients

context.JSON(http.StatusAccepted, jsonReturn)
})

// TODO: pass this as a profile/command line flag
t.Server.Engine.Static("/home", "./bin/static")

Expand Down
17 changes: 17 additions & 0 deletions teamserver/cmd/server/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ type Client struct {
Mutex sync.Mutex
}

type ClientJson struct {
ClientID string
Username string
GlobalIP string
ClientVersion string
Authenticated bool
SessionID string
}

type Users struct {
Name string
Password string
Expand Down Expand Up @@ -95,3 +104,11 @@ type Teamserver struct {
Nasm string
}
}

type TeamserverJson struct {
Clients map[string]*ClientJson
Users []Users
Agents agent.Agents
Listeners []*Listener
Endpoints []*Endpoint
}