Skip to content

Commit

Permalink
Merge pull request #3 from octoman90/master
Browse files Browse the repository at this point in the history
  • Loading branch information
man90es authored Aug 9, 2021
2 parents 0ed777c + 6c09711 commit 1dc5f73
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ProxyShiva
proxyshiva
10 changes: 0 additions & 10 deletions .gitlab-ci.yml

This file was deleted.

40 changes: 17 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,45 @@
# ProxyShiva
[![license](https://img.shields.io/github/license/octoman90/proxyshiva)](https://github.com/octoman90/proxyshiva/blob/master/LICENSE)

ProxyShiva is a concurrent command-line proxy checker application.

## Getting the binary
### Prebuilt
You can download prebuilt binaries [here](https://gitlab.com/man90/ProxyShiva/-/pipelines).

### Building from source
Prerequisites: <abbr title="Not tested on other platforms.">GNU/Linux</abbr>, Go >=1.15

Command:
## Building from source
Prerequisites: Go >=1.15
```bash
git clone https://github.com/octoman90/proxyshiva.git
cd proxyshiva
go build
```

## Usage
Use Shiva's standard input stream to check proxies:
```bash
$ echo "socks5:https://127.0.0.1:9050" | ./ProxyShiva
echo "socks5:https://127.0.0.1:9050" | ./proxyshiva
```

Put the output into a file:
```bash
$ echo "socks5:https://127.0.0.1:9050" | ./ProxyShiva > good.txt
echo "socks5:https://127.0.0.1:9050" | ./proxyshiva > good.txt
```

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

Put files into the standard input stream for more convenience and flexibility:
```bash
$ touch addresses.txt
$ echo "socks5:https://127.0.0.1:9050" >> addresses.txt
$ echo "http,https,socks5:https://192.168.0.2-192.168.0.10:8080-8089" >> addresses.txt
$ cat addresses.txt | ./ProxyShiva
touch addresses.txt
echo "socks5:https://127.0.0.1:9050" >> addresses.txt
echo "http,https,socks5:https://192.168.0.2-192.168.0.10:8080-8089" >> addresses.txt
cat addresses.txt | ./proxyshiva
```

## Flags

| Flag | Description |
| ------ | ------ |
| -json | Output full data in JSON format |
| Flag | Description |
| ------------ | ------------------------------------------------------------ |
| -json | Output full data in JSON format |
| -interactive | Don't exit after completing the task and wait for more input |
| -skipcert | Skip the TLS certificate verification |
| -timeout | Request timeout in seconds (15 by default) |

## License
[MIT](https://choosealicense.com/licenses/mit/)
| -skipcert | Skip the TLS certificate verification |
| -timeout=15 | Request timeout in seconds (15 by default) |
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/octoman90/proxyshiva

go 1.15

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

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

var wg sync.WaitGroup

func validateScanned(str string) bool {
ipRegex := `((?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))`
protocolRegex := `(http|https|socks4|socks5)`
portRegex := `\d+`

regex := regexp.MustCompile(`` +
// Match protocol or protocol list
`^(` + protocolRegex + `(,` + protocolRegex + `)*)+` +

// Match ":https://"
`:\/\/` +

// Match IP or IP range
ipRegex + `(-` + ipRegex + `)?` +

// Match ":"
`:` +

// Match port or port range
`(` + portRegex + `)(-` + portRegex + `)?$`,
)

return regex.MatchString(str)
}

func main() {
flagJSON := flag.Bool("json", false, "Output full data in JSON format")
flagInteractive := flag.Bool("interactive", false, "Don't exit after completing the task and wait for more input")
Expand Down Expand Up @@ -43,7 +69,12 @@ func main() {
scanner := bufio.NewScanner(os.Stdin)
for {
if scanner.Scan() {
for proxy := range inputParser.RequestGenerator(scanner.Text()) {
scanned := scanner.Text()
if valid := validateScanned(scanned); !valid {
continue
}

for proxy := range inputParser.RequestGenerator(scanned) {
if !*flagSkipRes || !proxy.IsReserved() {
wg.Add(1)
go proxy.Check(resultQueue, flagTimeout, flagSkipCert)
Expand Down

0 comments on commit 1dc5f73

Please sign in to comment.