Skip to content

Commit 1dc5f73

Browse files
authored
Merge pull request #3 from octoman90/master
2 parents 0ed777c + 6c09711 commit 1dc5f73

File tree

6 files changed

+76
-36
lines changed

6 files changed

+76
-36
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ProxyShiva
1+
proxyshiva

.gitlab-ci.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

README.md

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,45 @@
11
# ProxyShiva
2+
[![license](https://img.shields.io/github/license/octoman90/proxyshiva)](https://github.com/octoman90/proxyshiva/blob/master/LICENSE)
23

34
ProxyShiva is a concurrent command-line proxy checker application.
45

5-
## Getting the binary
6-
### Prebuilt
7-
You can download prebuilt binaries [here](https://gitlab.com/man90/ProxyShiva/-/pipelines).
8-
9-
### Building from source
10-
Prerequisites: <abbr title="Not tested on other platforms.">GNU/Linux</abbr>, Go >=1.15
11-
12-
Command:
6+
## Building from source
7+
Prerequisites: Go >=1.15
138
```bash
9+
git clone https://github.com/octoman90/proxyshiva.git
10+
cd proxyshiva
1411
go build
1512
```
1613

1714
## Usage
1815
Use Shiva's standard input stream to check proxies:
1916
```bash
20-
$ echo "socks5://127.0.0.1:9050" | ./ProxyShiva
17+
echo "socks5://127.0.0.1:9050" | ./proxyshiva
2118
```
2219

2320
Put the output into a file:
2421
```bash
25-
$ echo "socks5://127.0.0.1:9050" | ./ProxyShiva > good.txt
22+
echo "socks5://127.0.0.1:9050" | ./proxyshiva > good.txt
2623
```
2724

2825
Use scheme lists, IP ranges and port ranges to check more proxies at once:
2926
```bash
30-
$ echo "http,https,socks5://192.168.0.2-192.168.0.10:8080-8089" | ./ProxyShiva
27+
echo "http,https,socks5://192.168.0.2-192.168.0.10:8080-8089" | ./proxyshiva
3128
```
3229

3330
Put files into the standard input stream for more convenience and flexibility:
3431
```bash
35-
$ touch addresses.txt
36-
$ echo "socks5://127.0.0.1:9050" >> addresses.txt
37-
$ echo "http,https,socks5://192.168.0.2-192.168.0.10:8080-8089" >> addresses.txt
38-
$ cat addresses.txt | ./ProxyShiva
32+
touch addresses.txt
33+
echo "socks5://127.0.0.1:9050" >> addresses.txt
34+
echo "http,https,socks5://192.168.0.2-192.168.0.10:8080-8089" >> addresses.txt
35+
cat addresses.txt | ./proxyshiva
3936
```
4037

4138
## Flags
4239

43-
| Flag | Description |
44-
| ------ | ------ |
45-
| -json | Output full data in JSON format |
40+
| Flag | Description |
41+
| ------------ | ------------------------------------------------------------ |
42+
| -json | Output full data in JSON format |
4643
| -interactive | Don't exit after completing the task and wait for more input |
47-
| -skipcert | Skip the TLS certificate verification |
48-
| -timeout | Request timeout in seconds (15 by default) |
49-
50-
## License
51-
[MIT](https://choosealicense.com/licenses/mit/)
44+
| -skipcert | Skip the TLS certificate verification |
45+
| -timeout=15 | Request timeout in seconds (15 by default) |

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/octoman90/proxyshiva
22

33
go 1.15
44

5-
require inet.af/netaddr v0.0.0-20210403172118-1e1430f727e0
5+
require inet.af/netaddr v0.0.0-20210421205553-78c777480f22

go.sum

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
11
github.com/dvyukov/go-fuzz v0.0.0-20201127111758-49e582c6c23d/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw=
2+
github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw=
3+
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
24
go4.org/intern v0.0.0-20210108033219-3eb7198706b2 h1:VFTf+jjIgsldaz/Mr00VaCSswHJrI2hIjQygE/W4IMg=
35
go4.org/intern v0.0.0-20210108033219-3eb7198706b2/go.mod h1:vLqJ+12kCw61iCWsPto0EOHhBS+o4rO5VIucbc9g2Cc=
46
go4.org/unsafe/assume-no-moving-gc v0.0.0-20201222175341-b30ae309168e/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
57
go4.org/unsafe/assume-no-moving-gc v0.0.0-20201222180813-1025295fd063 h1:1tk03FUNpulq2cuWpXZWj649rwJpk0d20rxWiopKRmc=
68
go4.org/unsafe/assume-no-moving-gc v0.0.0-20201222180813-1025295fd063/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
9+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
10+
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
11+
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
12+
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
13+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
14+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
15+
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
16+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
17+
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
18+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
19+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
20+
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
21+
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
22+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
23+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
24+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
25+
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
26+
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
27+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
28+
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
29+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
730
inet.af v0.0.0-20181218191229-53da77bc832c h1:U3RoiyEF5b3Y1SVL6NNvpkgqUz2qS3a0OJh9kpSCN04=
831
inet.af/netaddr v0.0.0-20210313195008-843b4240e319 h1:cSGjHEjS/Nu6pts6yZfSYsRqcfW5ieqSrQI+XcZQObM=
932
inet.af/netaddr v0.0.0-20210313195008-843b4240e319/go.mod h1:I2i9ONCXRZDnG1+7O8fSuYzjcPxHQXrIfzD/IkR87x4=
1033
inet.af/netaddr v0.0.0-20210403172118-1e1430f727e0 h1:ANl7piXB3SHmhwTNeTO0yl0yf4gO3/aaFjcBCdH9Ftg=
1134
inet.af/netaddr v0.0.0-20210403172118-1e1430f727e0/go.mod h1:I2i9ONCXRZDnG1+7O8fSuYzjcPxHQXrIfzD/IkR87x4=
35+
inet.af/netaddr v0.0.0-20210421205553-78c777480f22 h1:TX8hopxzHycFVkIsvu6DSpCWUCqDqOvyyPj/5IK1fUQ=
36+
inet.af/netaddr v0.0.0-20210421205553-78c777480f22/go.mod h1:z0nx+Dh+7N7CC8V5ayHtHGpZpxLQZZxkIaaz6HN65Ls=

main.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"flag"
77
"fmt"
88
"os"
9+
"regexp"
910
"sync"
1011

1112
"github.com/octoman90/proxyshiva/inputParser"
@@ -14,6 +15,31 @@ import (
1415

1516
var wg sync.WaitGroup
1617

18+
func validateScanned(str string) bool {
19+
ipRegex := `((?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))`
20+
protocolRegex := `(http|https|socks4|socks5)`
21+
portRegex := `\d+`
22+
23+
regex := regexp.MustCompile(`` +
24+
// Match protocol or protocol list
25+
`^(` + protocolRegex + `(,` + protocolRegex + `)*)+` +
26+
27+
// Match "://"
28+
`:\/\/` +
29+
30+
// Match IP or IP range
31+
ipRegex + `(-` + ipRegex + `)?` +
32+
33+
// Match ":"
34+
`:` +
35+
36+
// Match port or port range
37+
`(` + portRegex + `)(-` + portRegex + `)?$`,
38+
)
39+
40+
return regex.MatchString(str)
41+
}
42+
1743
func main() {
1844
flagJSON := flag.Bool("json", false, "Output full data in JSON format")
1945
flagInteractive := flag.Bool("interactive", false, "Don't exit after completing the task and wait for more input")
@@ -43,7 +69,12 @@ func main() {
4369
scanner := bufio.NewScanner(os.Stdin)
4470
for {
4571
if scanner.Scan() {
46-
for proxy := range inputParser.RequestGenerator(scanner.Text()) {
72+
scanned := scanner.Text()
73+
if valid := validateScanned(scanned); !valid {
74+
continue
75+
}
76+
77+
for proxy := range inputParser.RequestGenerator(scanned) {
4778
if !*flagSkipRes || !proxy.IsReserved() {
4879
wg.Add(1)
4980
go proxy.Check(resultQueue, flagTimeout, flagSkipCert)

0 commit comments

Comments
 (0)