49 lines
878 B
Go
49 lines
878 B
Go
package common
|
|
|
|
import (
|
|
"log/slog"
|
|
"os"
|
|
)
|
|
|
|
func thread(l *slog.Logger, dests <-chan string, tab chan<- interface{}) {
|
|
c := MkClient()
|
|
|
|
for dest := range dests {
|
|
uriloop:
|
|
for _, uri := range Paths {
|
|
url := "https://" + dest + uri
|
|
if err := Hit(l, c, url); err != nil {
|
|
break uriloop
|
|
}
|
|
}
|
|
}
|
|
tab <- "H A C K T H E P L A N E T"
|
|
}
|
|
|
|
func Takeoff() {
|
|
dests := make(chan string)
|
|
tab := make(chan interface{})
|
|
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
|
|
|
|
for i := 0; i < Conf.Threads; i++ {
|
|
go thread(logger, dests, tab)
|
|
}
|
|
|
|
if Conf.List != "" {
|
|
Readfile(Conf.List, dests)
|
|
} else if Conf.Cidr != "" {
|
|
if !ValidRange(Conf.Cidr) {
|
|
Fatal("invalid cidr range")
|
|
}
|
|
LCG(Conf.Cidr, dests)
|
|
} else {
|
|
Fatal("provide either a list (-l) or cidr range (-r)")
|
|
}
|
|
close(dests)
|
|
|
|
for x := 0; x < Conf.Threads; x++ {
|
|
<-tab
|
|
}
|
|
close(tab)
|
|
}
|