From f4ae1d5bc42e0c182df26d9eb618762fb66ccf47 Mon Sep 17 00:00:00 2001 From: DeathNet123 Date: Thu, 22 Feb 2024 17:53:27 +0500 Subject: [PATCH] On branch arslan-director-dhavoc Changes to be committed: modified: makefile Remove the auto branch fetching for the client modules cloning to literal main just cuz of the branch issues modified: teamserver/Install.sh Commented the install.sh because it was downloading the compilers everytime after reboot because of the storage in tmp modified: teamserver/cmd/server/teamserver.go 1- Added the function for the Teamserver object to convert it into the TeamserverJson 2- Added the GET endpoint on the teamserver engine called quick to dump the TeamserverJson modified: teamserver/cmd/server/types.go 1- Added the TeamserverJson struct 2- Added the ClientJson struct --- makefile | 2 +- teamserver/Install.sh | 28 +++++++++--------- teamserver/cmd/server/teamserver.go | 45 +++++++++++++++++++++++++++++ teamserver/cmd/server/types.go | 17 +++++++++++ 4 files changed, 77 insertions(+), 15 deletions(-) diff --git a/makefile b/makefile index bd8ca643..885899df 100644 --- a/makefile +++ b/makefile @@ -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: diff --git a/teamserver/Install.sh b/teamserver/Install.sh index 84f5b633..c6f35fb2 100755 --- a/teamserver/Install.sh +++ b/teamserver/Install.sh @@ -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 diff --git a/teamserver/cmd/server/teamserver.go b/teamserver/cmd/server/teamserver.go index 9d1c21f9..32bb6b9f 100644 --- a/teamserver/cmd/server/teamserver.go +++ b/teamserver/cmd/server/teamserver.go @@ -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 @@ -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") diff --git a/teamserver/cmd/server/types.go b/teamserver/cmd/server/types.go index 7fd2b556..c4dd32d2 100644 --- a/teamserver/cmd/server/types.go +++ b/teamserver/cmd/server/types.go @@ -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 @@ -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 +} \ No newline at end of file