Skip to content

Commit 4903144

Browse files
authored
Update main.go
1 parent c71af7d commit 4903144

File tree

1 file changed

+64
-95
lines changed

1 file changed

+64
-95
lines changed

main.go

Lines changed: 64 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
/*
2-
(c) Yariya
2+
(c) Yariya
33
*/
44

55
package main
66

77
import (
8-
"encoding/json"
9-
"flag"
10-
"fmt"
11-
"io"
12-
"log"
13-
"math/rand"
14-
"net/http"
15-
"os"
16-
"os/signal"
17-
"strings"
18-
"time"
8+
"encoding/json"
9+
"flag"
10+
"fmt"
11+
"log"
12+
"math/rand"
13+
"os"
14+
"os/signal"
15+
"strings"
16+
"time"
1917
)
2018

2119
var port = flag.Int("p", 80, "proxy port")
@@ -28,95 +26,66 @@ var fetch = flag.String("url", "", "url proxy fetch")
2826
const wt = 3
2927

3028
type Api struct {
31-
Status string `json:"Status"`
32-
Reason string `json:"Reason"`
29+
Status string `json:"Status"`
30+
Reason string `json:"Reason"`
3331
}
3432

3533
type Config struct {
36-
License string `json:"license"`
37-
CheckSite string `json:"check-site"`
38-
ProxyType string `json:"proxy-type"`
39-
HttpThreads int `json:"http_threads"`
40-
Headers struct {
41-
UserAgent string `json:"user-agent"`
42-
Accept string `json:"accept"`
43-
} `json:"headers"`
44-
PrintIps struct {
45-
Enabled bool `json:"enabled"`
46-
DisplayIpInfo bool `json:"display-ip-info"`
47-
} `json:"print_ips"`
48-
Timeout struct {
49-
HttpTimeout int `json:"http_timeout"`
50-
Socks4Timeout int `json:"socks4_timeout"`
51-
Socks5Timeout int `json:"socks5_timeout"`
52-
} `json:"timeout"`
34+
CheckSite string `json:"check-site"`
35+
ProxyType string `json:"proxy-type"`
36+
HttpThreads int `json:"http_threads"`
37+
Headers struct {
38+
UserAgent string `json:"user-agent"`
39+
Accept string `json:"accept"`
40+
} `json:"headers"`
41+
PrintIps struct {
42+
Enabled bool `json:"enabled"`
43+
DisplayIpInfo bool `json:"display-ip-info"`
44+
} `json:"print_ips"`
45+
Timeout struct {
46+
HttpTimeout int `json:"http_timeout"`
47+
Socks4Timeout int `json:"socks4_timeout"`
48+
Socks5Timeout int `json:"socks5_timeout"`
49+
} `json:"timeout"`
5350
}
5451

5552
var config Config
5653

5754
func main() {
58-
if strings.Contains(strings.Join(os.Args[0:], ""), "-h") {
59-
fmt.Printf("\t\tShock Proxmeno.\nHelp:\n\t-p <port> - Port you want to scan.\n\t-o <proxies.txt> - Writes proxy hits to file.\n\n\t-input <proxies.txt> - Loads the proxy list and checks it.\n\t-url https://api.com/proxies - Loads the proxies from an api and checks it.\n\n\tconfig.json - Customize the whole proxy checker\n")
60-
return
61-
}
62-
flag.Parse()
63-
rand.Seed(time.Now().UnixNano())
64-
65-
cfgBytes, err := os.ReadFile(*configFile)
66-
if err != nil {
67-
log.Println("error while opening config file")
68-
return
69-
}
70-
err = json.Unmarshal(cfgBytes, &config)
71-
if err != nil {
72-
fmt.Println("error while parsing config json")
73-
return
74-
}
75-
76-
res, err := http.Get("https://license.shock.ac/?license=" + config.License)
77-
if err != nil {
78-
fmt.Println("api error")
79-
return
80-
}
81-
body, err := io.ReadAll(res.Body)
82-
if err != nil {
83-
log.Println("body error")
84-
return
85-
}
86-
res.Body.Close()
87-
88-
var api Api
89-
err = json.Unmarshal(body, &api)
90-
if err != nil {
91-
log.Println("json error")
92-
return
93-
}
94-
95-
if api.Status != "Success" {
96-
log.Println("license error: expired?")
97-
return
98-
}
99-
100-
if len(os.Args) <= 1 {
101-
fmt.Println("note: default port is set to 80. If you want to change this use [-p] argument.")
102-
}
103-
104-
_ = os.Remove(*output)
105-
106-
exporter = &Exporter{
107-
out: *output,
108-
}
109-
110-
go exporter.create()
111-
go Queue()
112-
go Scanner()
113-
for x := 0; x < wt; x++ {
114-
go Proxies.WorkerThread()
115-
}
116-
go Stater()
117-
time.Sleep(time.Second)
118-
119-
sc := make(chan os.Signal, 1)
120-
signal.Notify(sc, os.Kill, os.Interrupt)
121-
<-sc
55+
if strings.Contains(strings.Join(os.Args[0:], ""), "-h") {
56+
fmt.Printf("\t\tZmap ProxyScanner @tcpfin\nHelp:\n\t-p <port> - Port you want to scan.\n\t-o <proxies.txt> - Writes proxy hits to file.\n\n\t-input <proxies.txt> - Loads the proxy list and checks it.\n\t-url https://api.com/proxies - Loads the proxies from an api and checks it.\n\n\tconfig.json - Customize the whole proxy checker\n")
57+
return
58+
}
59+
flag.Parse()
60+
rand.Seed(time.Now().UnixNano())
61+
62+
cfgBytes, err := os.ReadFile(*configFile)
63+
if err != nil {
64+
log.Println("error while opening config file")
65+
return
66+
}
67+
err = json.Unmarshal(cfgBytes, &config)
68+
if err != nil {
69+
fmt.Println("error while parsing config json")
70+
return
71+
}
72+
73+
_ = os.Remove(*output)
74+
75+
exporter = &Exporter{
76+
out: *output,
77+
}
78+
79+
go exporter.create()
80+
go Queue()
81+
go Scanner()
82+
for x := 0; x < wt; x++ {
83+
go Proxies.WorkerThread()
84+
}
85+
go Stater()
86+
time.Sleep(time.Second)
87+
88+
sc := make(chan os.Signal, 1)
89+
signal.Notify(sc, os.Kill, os.Interrupt)
90+
<-sc
12291
}

0 commit comments

Comments
 (0)