2024-11-21 06:16:20 +00:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log/slog"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
func thread(l *slog.Logger, dests <-chan string, tab chan<- interface{}) {
|
|
|
|
c := MkClient()
|
2024-12-06 20:24:56 +00:00
|
|
|
|
2024-11-21 06:16:20 +00:00
|
|
|
for dest := range dests {
|
|
|
|
uriloop:
|
|
|
|
for _, uri := range Paths {
|
2024-12-06 20:24:56 +00:00
|
|
|
url := "https://" + dest + uri
|
|
|
|
if err := Hit(l, c, url); err != nil {
|
|
|
|
break uriloop
|
2024-11-21 06:16:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
}
|