targeting via list of ranges, more common sensor ports, cleanup

This commit is contained in:
delorean 2024-02-19 20:10:17 -06:00
parent 3486d783b7
commit a0b0780fd6
No known key found for this signature in database
GPG Key ID: 08CFF8565BE941CD
6 changed files with 48 additions and 15 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

63
main.go
View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"bufio"
"encoding/binary" "encoding/binary"
"flag" "flag"
"fmt" "fmt"
@ -8,6 +9,7 @@ import (
"net" "net"
"os" "os"
"os/signal" "os/signal"
"strings"
"syscall" "syscall"
"time" "time"
@ -17,10 +19,11 @@ import (
var ( var (
// flags // flags
cidr = flag.String("r", "", "cidr to target") cidr = flag.String("r", "", "")
duration = flag.Int("t", -1, "duration (seconds)") targlist = flag.String("l", "", "")
workers = flag.Int("c", 10, "threads") duration = flag.Int("t", -1, "")
delay = flag.Int("u", 0, "usec delay between sends") workers = flag.Int("c", 10, "")
delay = flag.Int("u", 0, "")
// colors // colors
colorReset = "\033[0m" colorReset = "\033[0m"
@ -30,7 +33,7 @@ var (
skull = "\u2620" skull = "\u2620"
// target ports // target ports
ports = []int{21, 22, 23, 80, 123, 389, 443} ports = []int{21, 22, 23, 25, 53, 80, 81, 123, 389, 443, 445, 999, 1080, 1433, 2323, 5555, 5900, 7547, 8080, 8081, 8888}
) )
func winsize(system int) uint16 { func winsize(system int) uint16 {
@ -192,7 +195,7 @@ func randIP() string {
func thread(addrs chan string) { func thread(addrs chan string) {
sock, err := rawsocket() sock, err := rawsocket()
if err != nil { if err != nil {
fatal(err) fatal(err.Error())
} }
defer syscall.Close(sock) defer syscall.Close(sock)
for addr := range addrs { for addr := range addrs {
@ -249,7 +252,7 @@ func banner() {
%s%sg a y n o i s e%s %s%sg a y n o i s e%s
sincerely, sincerely,
~ delorean ~ delorean
`, colorRed, colorReset, colorCyan, colorReset, colorPurple, colorReset) `, colorRed, colorReset, colorCyan, colorReset, colorPurple, colorReset)
@ -258,13 +261,14 @@ sincerely,
func usage() { func usage() {
fmt.Fprintf(os.Stderr, `gaynoise: fmt.Fprintf(os.Stderr, `gaynoise:
(%s-r%s) - cidr range [%s0.0.0.0/0%s] (%s-r%s) - cidr range [%s0.0.0.0/0%s]
(%s-l%s) - target cidr list
(%s-c%s) - concurrent threads [%s100%s] (%s-c%s) - concurrent threads [%s100%s]
(%s-t%s) - duration [%s-1%s] (%s-t%s) - duration [%s-1%s]
(%s-p%s) - usec delay between sends [%s0%s] (%s-p%s) - usec delay between sends [%s0%s]
`, colorCyan, colorReset, colorPurple, colorReset, colorCyan, colorReset, colorPurple, colorReset, colorCyan, colorReset, colorPurple, colorReset, colorCyan, colorReset, colorPurple, colorReset) `, colorCyan, colorReset, colorPurple, colorReset, colorCyan, colorReset, colorCyan, colorReset, colorPurple, colorReset, colorCyan, colorReset, colorPurple, colorReset, colorCyan, colorReset, colorPurple, colorReset)
} }
func fatal(e error) { func fatal(e string) {
fmt.Printf("%s %s error:%s %s\n", colorRed, skull, colorReset, e) fmt.Printf("%s %s error:%s %s\n", colorRed, skull, colorReset, e)
os.Exit(-1) os.Exit(-1)
} }
@ -274,15 +278,42 @@ func alarm(secs int) {
os.Exit(0) os.Exit(0)
} }
func parsetargets(list string) []string {
fd, err := os.Open(list)
if err != nil {
fatal(err.Error())
}
defer fd.Close()
var targets []string
fs := bufio.NewScanner(fd)
for fs.Scan() {
line := strings.TrimSpace(fs.Text())
if len(line) > 0 {
if _, _, err := net.ParseCIDR(line); err == nil {
targets = append(targets, line)
}
}
}
if len(targets) == 0 {
fatal("no valid ranges parsed from file")
}
return targets
}
func main() { func main() {
flag.Usage = usage flag.Usage = usage
flag.Parse() flag.Parse()
var target string var targets []string
if *cidr == "" { if *targlist != "" {
target = "0.0.0.0/0" targets = parsetargets(*targlist)
} else if *cidr == "" {
targets = []string{"0.0.0.0/0"}
} else { } else {
target = *cidr targets = []string{*cidr}
} }
// signals // signals
@ -310,8 +341,10 @@ func main() {
banner() banner()
for { for {
if e := runCIDR(target, addrs); e != nil { for _, target := range targets {
fatal(e) if err := runCIDR(target, addrs); err != nil {
fatal(err.Error())
}
} }
} }
} }