kyoketsu.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "log"
  6. "strings"
  7. "sync"
  8. kyoketsu "git.aetherial.dev/aeth/kyoketsu/pkg"
  9. )
  10. func main() {
  11. // kyoketsu.PingWithDependency(os.Args[1])
  12. // os.Exit(1)
  13. local := flag.Bool("local", true, "set flag to false to run this in targeted remote mode")
  14. remoteAddrs := flag.String("ips", "", "comma seperated list of ip addresses to gather info about")
  15. iface := flag.String("iface", "eth0", "use this flag to specify the interface to autonomously use for scanning.")
  16. flag.Parse()
  17. if !*local {
  18. spAddr := strings.Split(*remoteAddrs, ",")
  19. addr, err := kyoketsu.GetAllRemoteAddresses(spAddr)
  20. if err != nil {
  21. log.Fatal(err)
  22. }
  23. var wg sync.WaitGroup
  24. for i := range addr.Addr {
  25. wg.Add(1)
  26. go func(idx int, wg *sync.WaitGroup) {
  27. out := kyoketsu.PortWalk(addr.Addr[idx].String(), kyoketsu.PORT_MAP)
  28. if len(out.ListeningPorts) > 0 {
  29. fmt.Printf("%+v\n", out)
  30. }
  31. wg.Done()
  32. }(i, &wg)
  33. }
  34. wg.Wait()
  35. } else {
  36. addr, err := kyoketsu.GetAllAddresses(*iface)
  37. if err != nil {
  38. log.Fatal(err)
  39. }
  40. var wg sync.WaitGroup
  41. for i := range addr.Addr {
  42. wg.Add(1)
  43. go func(idx int, wg *sync.WaitGroup) {
  44. out := kyoketsu.PortWalk(addr.Addr[idx].String(), kyoketsu.PORT_MAP)
  45. if len(out.ListeningPorts) > 0 {
  46. fmt.Printf("%+v\n", out)
  47. }
  48. wg.Done()
  49. }(i, &wg)
  50. }
  51. wg.Wait()
  52. }
  53. }