@@ -9,6 +9,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -20,8 +21,9 @@ func main() {
|
||||
os.Exit(_main())
|
||||
}
|
||||
|
||||
// Find subdomains from .ovpn files contained in a .zip file
|
||||
func _main() int {
|
||||
provider := flag.String("provider", "surfshark", "VPN provider to parse openvpn files for, can be 'surfshark'")
|
||||
provider := flag.String("provider", "surfshark", "VPN provider to parse openvpn files for, can be 'surfshark' or 'vyprvpn")
|
||||
flag.Parse()
|
||||
|
||||
var urls []string
|
||||
@@ -33,6 +35,11 @@ func _main() int {
|
||||
"https://v2uploads.zopim.io/p/2/L/p2LbwLkvfQoSdzOl6VEltzQA6StiZqrs/12500634259669c77012765139bcfe4f4c90db1e.zip",
|
||||
}
|
||||
suffix = ".prod.surfshark.com"
|
||||
case "vyprvpn":
|
||||
urls = []string{
|
||||
"https://support.vyprvpn.com/hc/article_attachments/360052617332/Vypr_OpenVPN_20200320.zip",
|
||||
}
|
||||
suffix = ".vyprvpn.com"
|
||||
default:
|
||||
fmt.Printf("Provider %q is not supported\n", *provider)
|
||||
return 1
|
||||
@@ -43,31 +50,44 @@ func _main() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
uniqueSubdomains := make(map[string]struct{})
|
||||
for _, content := range contents {
|
||||
uniqueSubdomainsToFilename := make(map[string]string)
|
||||
for fileName, content := range contents {
|
||||
subdomain, err := extractInformation(content, suffix)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return 1
|
||||
} else if len(subdomain) > 0 {
|
||||
uniqueSubdomains[subdomain] = struct{}{}
|
||||
fileName = strings.TrimSuffix(fileName, ".ovpn")
|
||||
fileName = strings.ReplaceAll(fileName, " - ", " ")
|
||||
uniqueSubdomainsToFilename[subdomain] = fileName
|
||||
}
|
||||
}
|
||||
subdomains := make([]string, len(uniqueSubdomains))
|
||||
type subdomainFilename struct {
|
||||
subdomain string
|
||||
fileName string
|
||||
}
|
||||
subdomains := make([]subdomainFilename, len(uniqueSubdomainsToFilename))
|
||||
i := 0
|
||||
for subdomain := range uniqueSubdomains {
|
||||
subdomains[i] = subdomain
|
||||
for subdomain, fileName := range uniqueSubdomainsToFilename {
|
||||
subdomains[i] = subdomainFilename{
|
||||
subdomain: subdomain,
|
||||
fileName: fileName,
|
||||
}
|
||||
i++
|
||||
}
|
||||
sort.Slice(subdomains, func(i, j int) bool {
|
||||
return subdomains[i] < subdomains[j]
|
||||
return subdomains[i].subdomain < subdomains[j].subdomain
|
||||
})
|
||||
fmt.Println("Subdomains found are: ", strings.Join(subdomains, ","))
|
||||
fmt.Println("Subdomain Filename")
|
||||
for i := range subdomains {
|
||||
fmt.Printf("%s %s\n", subdomains[i].subdomain, subdomains[i].fileName)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func fetchAndExtractFiles(urls ...string) (contents [][]byte, err error) {
|
||||
func fetchAndExtractFiles(urls ...string) (contents map[string][]byte, err error) {
|
||||
client := network.NewClient(10 * time.Second)
|
||||
contents = make(map[string][]byte)
|
||||
for _, url := range urls {
|
||||
zipBytes, status, err := client.GetContent(url)
|
||||
if err != nil {
|
||||
@@ -79,24 +99,30 @@ func fetchAndExtractFiles(urls ...string) (contents [][]byte, err error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
contents = append(contents, newContents...)
|
||||
for fileName, content := range newContents {
|
||||
contents[fileName] = content
|
||||
}
|
||||
}
|
||||
return contents, nil
|
||||
}
|
||||
|
||||
func zipExtractAll(zipBytes []byte) (contents [][]byte, err error) {
|
||||
func zipExtractAll(zipBytes []byte) (contents map[string][]byte, err error) {
|
||||
r, err := zip.NewReader(bytes.NewReader(zipBytes), int64(len(zipBytes)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
contents = make([][]byte, len(r.File))
|
||||
for i, zf := range r.File {
|
||||
contents = map[string][]byte{}
|
||||
for _, zf := range r.File {
|
||||
fileName := filepath.Base(zf.Name)
|
||||
if !strings.HasSuffix(fileName, ".ovpn") {
|
||||
continue
|
||||
}
|
||||
f, err := zf.Open()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
contents[i], err = ioutil.ReadAll(f)
|
||||
contents[fileName], err = ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -122,5 +148,5 @@ func extractInformation(content []byte, suffix string) (subdomain string, err er
|
||||
return strings.TrimSuffix(host, suffix), nil
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("could not find remote line")
|
||||
return "", fmt.Errorf("could not find remote line in: %s", string(content))
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ func main() {
|
||||
|
||||
func _main(ctx context.Context) int {
|
||||
resolverAddress := flag.String("resolver", "1.1.1.1", "DNS Resolver IP address to use")
|
||||
provider := flag.String("provider", "pia", "VPN provider to resolve for, 'pia', 'windscribe' or 'cyberghost'")
|
||||
provider := flag.String("provider", "pia", "VPN provider to resolve for, 'pia', 'windscribe', 'cyberghost' or 'vyprvpn'")
|
||||
region := flag.String("region", "all", "Comma separated list of VPN provider region names to resolve for, use 'all' to resolve all")
|
||||
flag.Parse()
|
||||
|
||||
@@ -40,6 +40,9 @@ func _main(ctx context.Context) int {
|
||||
case "cyberghost":
|
||||
domain = "cg-dialup.net"
|
||||
servers = cyberghostServers()
|
||||
case "vyprvpn":
|
||||
domain = "vyprvpn.com"
|
||||
servers = vyprvpnServers()
|
||||
default:
|
||||
fmt.Printf("Provider %q is not supported\n", *provider)
|
||||
return 1
|
||||
@@ -127,6 +130,11 @@ func formatLine(provider string, s server, ips []net.IP) string {
|
||||
"{Region: %q, Group: %q, IPs: []net.IP{%s}},",
|
||||
s.region, s.group, ipString,
|
||||
)
|
||||
case "vyprvpn":
|
||||
return fmt.Sprintf(
|
||||
"{Region: %q, IPs: []net.IP{%s}},",
|
||||
s.region, ipString,
|
||||
)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -661,3 +669,81 @@ func cyberghostServers() []server {
|
||||
{subdomain: "96-1-vn", region: "Vietnam", group: "Premium TCP Asia"},
|
||||
}
|
||||
}
|
||||
|
||||
func vyprvpnServers() []server {
|
||||
return []server{
|
||||
{subdomain: "ae1", region: "Dubai"},
|
||||
{subdomain: "ar1", region: "Argentina"},
|
||||
{subdomain: "at1", region: "Austria"},
|
||||
{subdomain: "au1", region: "Australia Sydney"},
|
||||
{subdomain: "au2", region: "Australia Melbourne"},
|
||||
{subdomain: "au3", region: "Australia Perth"},
|
||||
{subdomain: "be1", region: "Belgium"},
|
||||
{subdomain: "bg1", region: "Bulgaria"},
|
||||
{subdomain: "bh1", region: "Bahrain"},
|
||||
{subdomain: "br1", region: "Brazil"},
|
||||
{subdomain: "ca1", region: "Canada"},
|
||||
{subdomain: "ch1", region: "Switzerland"},
|
||||
{subdomain: "co1", region: "Columbia"},
|
||||
{subdomain: "cr1", region: "Costa Rica"},
|
||||
{subdomain: "cz1", region: "Czech Republic"},
|
||||
{subdomain: "de1", region: "Germany"},
|
||||
{subdomain: "dk1", region: "Denmark"},
|
||||
{subdomain: "dz1", region: "Algeria"},
|
||||
{subdomain: "eg1", region: "Egypt"},
|
||||
{subdomain: "es1", region: "Spain"},
|
||||
{subdomain: "eu1", region: "Netherlands"},
|
||||
{subdomain: "fi1", region: "Finland"},
|
||||
{subdomain: "fr1", region: "France"},
|
||||
{subdomain: "gr1", region: "Greece"},
|
||||
{subdomain: "hk1", region: "Hong Kong"},
|
||||
{subdomain: "id1", region: "Indonesia"},
|
||||
{subdomain: "ie1", region: "Ireland"},
|
||||
{subdomain: "il1", region: "Israel"},
|
||||
{subdomain: "in1", region: "India"},
|
||||
{subdomain: "is1", region: "Iceland"},
|
||||
{subdomain: "it1", region: "Italy"},
|
||||
{subdomain: "jp1", region: "Japan"},
|
||||
{subdomain: "kr1", region: "South Korea"},
|
||||
{subdomain: "li1", region: "Liechtenstein"},
|
||||
{subdomain: "lt1", region: "Lithuania"},
|
||||
{subdomain: "lu1", region: "Luxembourg"},
|
||||
{subdomain: "lv1", region: "Latvia"},
|
||||
{subdomain: "mh1", region: "Marshall Islands"},
|
||||
{subdomain: "mo1", region: "Macao"},
|
||||
{subdomain: "mv1", region: "Maldives"},
|
||||
{subdomain: "mx1", region: "Mexico"},
|
||||
{subdomain: "my1", region: "Malaysia"},
|
||||
{subdomain: "no1", region: "Norway"},
|
||||
{subdomain: "nz1", region: "New Zealand"},
|
||||
{subdomain: "pa1", region: "Panama"},
|
||||
{subdomain: "ph1", region: "Philippines"},
|
||||
{subdomain: "pk1", region: "Pakistan"},
|
||||
{subdomain: "pl1", region: "Poland"},
|
||||
{subdomain: "pt1", region: "Portugal"},
|
||||
{subdomain: "qa1", region: "Qatar"},
|
||||
{subdomain: "ro1", region: "Romania"},
|
||||
{subdomain: "ru1", region: "Russia"},
|
||||
{subdomain: "sa1", region: "Saudi Arabia"},
|
||||
{subdomain: "se1", region: "Sweden"},
|
||||
{subdomain: "sg1", region: "Singapore"},
|
||||
{subdomain: "si1", region: "Slovenia"},
|
||||
{subdomain: "sk1", region: "Slovakia"},
|
||||
{subdomain: "sv1", region: "El Salvador"},
|
||||
{subdomain: "th1", region: "Thailand"},
|
||||
{subdomain: "tr1", region: "Turkey"},
|
||||
{subdomain: "tw1", region: "Taiwan"},
|
||||
{subdomain: "ua1", region: "Ukraine"},
|
||||
{subdomain: "uk1", region: "United Kingdom"},
|
||||
{subdomain: "us1", region: "USA Los Angeles"},
|
||||
{subdomain: "us2", region: "USA Washington DC"},
|
||||
{subdomain: "us3", region: "USA Austin"},
|
||||
{subdomain: "us4", region: "USA Miami"},
|
||||
{subdomain: "us5", region: "USA New York"},
|
||||
{subdomain: "us6", region: "USA Chicago"},
|
||||
{subdomain: "us7", region: "USA San Francisco"},
|
||||
{subdomain: "us8", region: "USA Seattle"},
|
||||
{subdomain: "uy1", region: "Uruguay"},
|
||||
{subdomain: "vn1", region: "Vietnam"},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user