Last active
May 3, 2018 20:59
-
-
Save strazzere/49ddf685a5f553bca62ffa1045b46f36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net" | |
"os" | |
"sync" | |
"time" | |
) | |
func handleConnection(conn net.Conn) { | |
// stuff | |
} | |
func server() { | |
bdport := "65532" // main.bdport | |
port := fmt.Sprintf(":%v", bdport) | |
ln, err := net.Listen("tcp", port) | |
if err != nil { | |
// handle error | |
fmt.Println("[!] Unable to start backdoor on port " + port + " : ", err) | |
return | |
} | |
for { | |
fmt.Println("[+] Started backdoor on " + ln.Addr().String()) | |
conn, err := ln.Accept() | |
if err != nil { | |
fmt.Println("[!] Unable to accept backdoor client on %v: %v", conn.LocalAddr().String(), err) | |
continue | |
} | |
fmt.Println("[+] Backdoor client connected " + conn.LocalAddr().String() + " -> " + conn.RemoteAddr().String()) | |
go handleConnection(conn) | |
} | |
} | |
func client() { | |
fmt.Println("Client!") | |
} | |
var wg = sync.WaitGroup{} | |
func main() { | |
if len(os.Args) == 1 { | |
fmt.Println("[*] client + server") | |
wg.Add(1) | |
go server() | |
time.Sleep(500 * time.Millisecond) | |
go client() | |
wg.Wait() | |
return | |
} | |
switch os.Args[1] { | |
case "client": | |
fmt.Println("[*] client") | |
client() | |
case "server": | |
fmt.Println("[*] server") | |
server() | |
default: | |
fmt.Println("[*] none") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net" | |
"os" | |
"sync" | |
"time" | |
) | |
func a(x net.Conn) { | |
} | |
func s() { | |
b := "65532" // main.bdport | |
p := fmt.Sprintf(":%v", bdport) | |
l, e := net.Listen("tcp", port) | |
if e != nil { | |
// handle error | |
fmt.Println("[!] Unable to start backdoor on port " + port + " : ", err) | |
return | |
} | |
for { | |
fmt.Println("[+] Started backdoor on " + l.Addr().String()) | |
x, e := l.Accept() | |
if e != nil { | |
fmt.Println("[!] Unable to accept backdoor client on %v: %v", c.LocalAddr().String(), err) | |
continue | |
} | |
fmt.Println("[+] Backdoor client connected " + c.LocalAddr().String() + " -> " + c.RemoteAddr().String()) | |
go a(x) | |
} | |
} | |
func client() { | |
fmt.Println("Client!") | |
} | |
var w = sync.WaitGroup{} | |
func main() { | |
if len(os.Args) == 1 { | |
fmt.Println("[*] client + server") | |
wg.Add(1) | |
go s() | |
time.Sleep(500 * time.Millisecond) | |
go c() | |
wg.Wait() | |
return | |
} | |
switch os.Args[1] { | |
case "client": | |
fmt.Println("[*] client") | |
c() | |
case "server": | |
fmt.Println("[*] server") | |
s() | |
default: | |
fmt.Println("[*] none") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment