cve-2022-46169/internal/listener/listener.go

29 lines
538 B
Go
Raw Normal View History

2025-01-24 11:01:46 +08:00
package listener
import (
"fmt"
"os"
2025-01-24 11:19:19 +08:00
"os/exec"
2025-01-24 11:01:46 +08:00
)
2025-01-24 11:19:19 +08:00
func startNetcatListener(lport string) {
// Create the command to run netcat as a listener
2025-01-24 11:26:04 +08:00
cli := exec.Command("nc", "-lvp", lport)
2025-01-24 11:01:46 +08:00
2025-01-24 11:19:19 +08:00
// Set up the output to be printed to the console
2025-01-24 11:26:04 +08:00
cli.Stdout = os.Stdout
cli.Stderr = os.Stderr
2025-01-24 11:01:46 +08:00
2025-01-24 11:19:19 +08:00
// Run the command
2025-01-24 11:26:04 +08:00
err := cli.Run()
2025-01-24 11:01:46 +08:00
if err != nil {
2025-01-24 11:19:19 +08:00
fmt.Println("Error starting netcat listener:", err)
2025-01-24 11:01:46 +08:00
os.Exit(1)
}
}
2025-01-24 11:10:16 +08:00
func Listen(lport string) {
2025-01-24 11:19:19 +08:00
fmt.Printf("Starting netcat listener on port %s...\n", lport)
startNetcatListener(lport)
2025-01-24 11:01:46 +08:00
}