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.

61
main.go
View File

@ -1,6 +1,7 @@
package main
import (
"bufio"
"encoding/binary"
"flag"
"fmt"
@ -8,6 +9,7 @@ import (
"net"
"os"
"os/signal"
"strings"
"syscall"
"time"
@ -17,10 +19,11 @@ import (
var (
// flags
cidr = flag.String("r", "", "cidr to target")
duration = flag.Int("t", -1, "duration (seconds)")
workers = flag.Int("c", 10, "threads")
delay = flag.Int("u", 0, "usec delay between sends")
cidr = flag.String("r", "", "")
targlist = flag.String("l", "", "")
duration = flag.Int("t", -1, "")
workers = flag.Int("c", 10, "")
delay = flag.Int("u", 0, "")
// colors
colorReset = "\033[0m"
@ -30,7 +33,7 @@ var (
skull = "\u2620"
// 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 {
@ -192,7 +195,7 @@ func randIP() string {
func thread(addrs chan string) {
sock, err := rawsocket()
if err != nil {
fatal(err)
fatal(err.Error())
}
defer syscall.Close(sock)
for addr := range addrs {
@ -258,13 +261,14 @@ sincerely,
func usage() {
fmt.Fprintf(os.Stderr, `gaynoise:
(%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-t%s) - duration [%s-1%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)
os.Exit(-1)
}
@ -274,15 +278,42 @@ func alarm(secs int) {
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() {
flag.Usage = usage
flag.Parse()
var target string
if *cidr == "" {
target = "0.0.0.0/0"
var targets []string
if *targlist != "" {
targets = parsetargets(*targlist)
} else if *cidr == "" {
targets = []string{"0.0.0.0/0"}
} else {
target = *cidr
targets = []string{*cidr}
}
// signals
@ -310,8 +341,10 @@ func main() {
banner()
for {
if e := runCIDR(target, addrs); e != nil {
fatal(e)
for _, target := range targets {
if err := runCIDR(target, addrs); err != nil {
fatal(err.Error())
}
}
}
}