29 lines
538 B
Go
29 lines
538 B
Go
package listener
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
)
|
|
|
|
func startNetcatListener(lport string) {
|
|
// Create the command to run netcat as a listener
|
|
cmd := exec.Command("nc", "-lvp", lport)
|
|
|
|
// Set up the output to be printed to the console
|
|
cmd.Stdout = os.Stdout
|
|
cmd.Stderr = os.Stderr
|
|
|
|
// Run the command
|
|
err := cmd.Run()
|
|
if err != nil {
|
|
fmt.Println("Error starting netcat listener:", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func Listen(lport string) {
|
|
fmt.Printf("Starting netcat listener on port %s...\n", lport)
|
|
startNetcatListener(lport)
|
|
}
|