diff --git a/brute.go b/brute.go index c24ea38..e8bf420 100644 --- a/brute.go +++ b/brute.go @@ -1,11 +1,8 @@ package main import ( - "bufio" "encoding/json" "fmt" - "gopkg.in/alecthomas/kingpin.v2" - "gopkg.in/cheggaaa/pb.v1" "io/ioutil" "log" "math/rand" @@ -19,6 +16,9 @@ import ( "strings" "sync" "time" + + "gopkg.in/alecthomas/kingpin.v2" + "gopkg.in/cheggaaa/pb.v1" ) const ( @@ -29,20 +29,20 @@ const ( ) var ( - link = kingpin.Arg("link", "URL of BaiduYun file you want to get.").Required().String() - preset = kingpin.Flag("preset", "The preset start of key to brute.").Short('p').Default("0000").String() - thread = kingpin.Flag("thread", "Number of threads.").Short('t').Default("1000").Int64() - resolver []*Resolve - bar *pb.ProgressBar - shareid, uk string - start int64 - refer string - wg sync.WaitGroup - proxies map[Proxy]int - updater []*Proxies - mapLocker *sync.Mutex - useable *AtomBool - nullP Proxy + link = kingpin.Arg("link", "URL of BaiduYun file you want to get.").Required().String() + preset = kingpin.Flag("preset", "The preset start of key to brute.").Short('p').Default("0000").String() + thread = kingpin.Flag("thread", "Number of threads.").Short('t').Default("1000").Int64() + resolver []*Resolve + bar *pb.ProgressBar + surl string + start int64 + refer string + wg sync.WaitGroup + proxies map[Proxy]int + updater []*Proxies + mapLocker *sync.Mutex + useable *AtomBool + nullP Proxy ) type Info struct { @@ -125,70 +125,6 @@ func increProxy(in Proxy) { } func saveProxies() { - updater = append(updater, - &Proxies{ - func() { - for { - resp, err := http.Get("http://api.xicidaili.com/free2016.txt") - if err != nil { - log.Println(err) - time.Sleep(RETRY_TIME) - continue - } - sca := bufio.NewScanner(resp.Body) - for sca.Scan() { - spl := strings.Split(sca.Text(), ":") - if len(spl) != 2 { - log.Fatal("Unexpected error: ", sca.Text()) - } - ne := Proxy{"http", spl[0], spl[1]} - addProxy(ne) - } - resp.Body.Close() - time.Sleep(15 * time.Minute) - } - }, - }) - updater = append(updater, - &Proxies{ - func() { - for { - resp, err := http.Get("http://proxy.tekbreak.com/1000/json") - if err != nil { - log.Println(err) - time.Sleep(RETRY_TIME) - continue - } - var sca []struct { - IP string `json:"ip"` - Port string `json:"port"` - Type string `json:"type"` - } - if err := json.NewDecoder(resp.Body).Decode(&sca); err != nil { - log.Println(err) - time.Sleep(RETRY_TIME) - continue - } - for _, i := range sca { - ne := Proxy{addr: i.IP, port: i.Port} - ignore := false - switch i.Type { - case "HTTP": - ne.typ = "http" - case "HTTPS": - ne.typ = "https" - default: - ignore = true - } - if !ignore { - addProxy(ne) - } - } - resp.Body.Close() - time.Sleep(5 * time.Minute) - } - }, - }) updater = append(updater, &Proxies{ func() { @@ -206,7 +142,7 @@ func saveProxies() { time.Sleep(RETRY_TIME) continue } - re, _ := regexp.Compile(`