From f235756361c0cc16b16ebada97c21dc75eb85843 Mon Sep 17 00:00:00 2001 From: delorean Date: Thu, 5 Sep 2024 23:00:08 -0500 Subject: [PATCH] performance improvement, cleanup --- README.md | 10 +++++----- go.mod | 0 go.sum | 0 main.go | 36 ++++++++++++++++++++---------------- 4 files changed, 25 insertions(+), 21 deletions(-) mode change 100644 => 100755 README.md mode change 100644 => 100755 go.mod mode change 100644 => 100755 go.sum mode change 100644 => 100755 main.go diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 15027e5..9581388 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ right here _ _ |_| |_| - | | /^^^\ | | + | | /^^^\ | | _| |_ (| "o" |) _| |_ _| | | | _ (_---_) _ | | | |_ | | | | |' | _| |_ | '| | | | | @@ -22,15 +22,15 @@ #### inspired by blackout's [MagicPacketGenerator](https://github.com/LetUsFsck/MagicPacketGenerator), ___gaynoise___ was tailored to further infuriate whitey with improvements including - operating system header spoofing (linux, windows, cisco ios, solaris, etc) to legitimize traffic - - targeted destination ip address generation (every ip is gauranteed a visit!) - - rfc1918 circumvention + - targeted destination ip address generation + - rfc1918 awareness - improved performance - #### with enough instances running, ___gaynoise___ could render many categories of threat intelligence sensors' data aggregations completely useless + #### with enough instances running, ___gaynoise___ could render many categories of threat intelligence sensors' data aggregations useless ## usage grab a binary for your architecture from **Releases** - + **everyone everywhere:** ```./gaynoise``` diff --git a/go.mod b/go.mod old mode 100644 new mode 100755 diff --git a/go.sum b/go.sum old mode 100644 new mode 100755 diff --git a/main.go b/main.go old mode 100644 new mode 100755 index c1a73e3..add47be --- a/main.go +++ b/main.go @@ -25,6 +25,13 @@ var ( workers = flag.Int("c", 10, "") delay = flag.Int("u", 0, "") + rfc1918 = []string{ + "0.0.0.0/8", + "10.0.0.0/8", + "192.168.0.0/16", + "172.16.0.0/12", + } + // colors colorReset = "\033[0m" colorRed = "\033[31m" @@ -119,15 +126,14 @@ func assemble(daddr, saddr string, dport, sport, system int) ([]byte, error) { return packet, nil } -func rfc1918(ip net.IP) bool { - _, net0, _ := net.ParseCIDR("0.0.0.0/8") - _, net10, _ := net.ParseCIDR("10.0.0.0/8") - _, net192, _ := net.ParseCIDR("192.168.0.0/16") - _, net172, _ := net.ParseCIDR("172.16.0.0/12") - - if net0.Contains(ip) || net10.Contains(ip) || net192.Contains(ip) || net172.Contains(ip) { - return true +func excluded(ip net.IP) bool { + for _, ex := range rfc1918 { + _, cidr, _ := net.ParseCIDR(ex) + if cidr.Contains(ip) { + return true + } } + return false } @@ -162,7 +168,7 @@ func runCIDR(cidr string, out chan string) error { } for target := ip.Mask(ipnet.Mask); ipnet.Contains(target); inc(target) { - if rfc1918(target) { + if excluded(target) { continue } addr, _ := net.ResolveIPAddr("ip", target.String()) @@ -186,7 +192,7 @@ func randIP() string { ip := rand.Uint32() binary.LittleEndian.PutUint32(buf, ip) nip := net.IP(buf) - if !rfc1918(nip) { + if !excluded(nip) { return nip.String() } } @@ -237,7 +243,7 @@ func banner() { right here%s%s _ _ |_| |_| - | | /^^^\ | | + | | /^^^\ | | _| |_ (| "o" |) _| |_ _| | | | _ (_---_) _ | | | |_ | | | | |' | _| |_ | '| | | | | @@ -327,11 +333,9 @@ func main() { // threads addrs := make(chan string) - go func() { - for x := 0; x < *workers; x++ { - thread(addrs) - } - }() + for x := 0; x < *workers; x++ { + go thread(addrs) + } // start alarm if *duration > 0 {