Skip to content

Commit

Permalink
version 0.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
corrad1nho committed Jul 27, 2018
1 parent cea5dce commit caac210
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 91 deletions.
5 changes: 4 additions & 1 deletion qomui/qomui_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,10 @@ def filter_servers(self, *arg, display="filter"):
self.randomSeverBt.setVisible(False)
country = self.countryBox.currentText()
provider = self.providerBox.currentText()
tunnel = self.tunnelBox.currentText()
if self.tunnelBox.isVisible is True:
tunnel = self.tunnelBox.currentText()
else:
tunnel = "OpenVPN"
if self.favouriteButton.isChecked() == True:
self.favouriteButton.setChecked(False)
if display == "all":
Expand Down
28 changes: 27 additions & 1 deletion qomui/qomui_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ def wireguard(self):
self.wg(path)

def openvpn(self):
self.air_ssl_port = "1413"
self.ws_ssl_port = "1194"
path = "%s/temp.ovpn" %ROOTDIR
cwd_ovpn = None
provider = self.ovpn_dict["provider"]
Expand All @@ -493,6 +495,10 @@ def openvpn(self):
for line, value in enumerate(ssl_config):
if value.startswith("connect") is True:
ssl_config[line] = "connect = %s:%s\n" % (ip, port)
elif value.startswith("accept") is True:
ssl_config[line] = "accept = 127.0.0.1:%s\n" %self.air_ssl_port
ssl_config.append("verify = 3\n")
ssl_config.append("CAfile = /usr/share/qomui/certs/stunnel.crt")
with open("%s/temp.ssl" % ROOTDIR, "w") as ssl_dump:
ssl_dump.writelines(ssl_config)
ssl_dump.close()
Expand All @@ -517,6 +523,23 @@ def openvpn(self):
self.write_config(self.ovpn_dict)

elif provider == "Windscribe":
if protocol == "SSL":
with open("%s/ssl_config" %ROOTDIR, "r") as ssl_edit:
ssl_config = ssl_edit.readlines()
for line, value in enumerate(ssl_config):
if value.startswith("connect") is True:
ssl_config[line] = "connect = %s:%s\n" % (ip, port)
elif value.startswith("accept") is True:
ssl_config[line] = "accept = 127.0.0.1:%s\n" %self.ws_ssl_port
with open("%s/temp.ssl" % ROOTDIR, "w") as ssl_dump:
ssl_dump.writelines(ssl_config)
ssl_dump.close()
ssl_edit.close()
self.write_config(self.ovpn_dict)
self.ssl_thread = threading.Thread(target=self.ssl, args=(ip,))
self.ssl_thread.start()
logging.info("Started Stunnel process in new thread")

self.write_config(self.ovpn_dict)

elif provider == "ProtonVPN":
Expand Down Expand Up @@ -576,7 +599,10 @@ def write_config(self, ovpn_dict, edit="temp", path=None):
if protocol == "SSL":
config.insert(13, "route %s 255.255.255.255 net_gateway\n" % (ip))
ip = "127.0.0.1"
port = "1413"
if provider == "Airvpn":
port = self.air_ssl_port
elif provider == "Windscribe":
port = self.ws_ssl_port
protocol = "tcp"

elif protocol == "SSH":
Expand Down
148 changes: 64 additions & 84 deletions qomui/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import logging
import shutil
import pycountry
import uuid


try:
_fromUtf8 = QtCore.QString.fromUtf8
Expand Down Expand Up @@ -458,20 +460,15 @@ def __init__(self, username, password):
self.password = password
self.ws_server_dict = {}
self.ws_protocol_dict = {}
#self.timer = QtCore.QTimer()

def run(self):
#self.timer.start()
self.username = "corrad1nho"
self.password = "***REMOVED***"
init_url = "https://res.windscribe.com/res/init"
login_url = "https://windscribe.com/login"

try:
with requests.Session() as self.session:
with requests.Session() as self.session:
self.session.headers.update(self.header)
failed_list = []
temp = "%s/temp" %DIRECTORY
self.temp = "%s/temp" %DIRECTORY
self.session.get(login_url)
self.session.headers.update({"Host" : "res.windscribe.com",
"Origin" : "https://windscribe.com"})
Expand All @@ -493,86 +490,69 @@ def run(self):
get_cred = self.session.get(cred_url)
credentials = json.loads(get_cred.content.decode("utf-8"))

with open("%s/windscribe_userpass.txt" %temp, "w") as cd:
cd.write("%s\n%s" %(credentials["username"], credentials["password"]))

cert_url = "https://assets.windscribe.com/desktop/other/openvpn_cert.zip"
get_certs = self.session.get(cert_url)
z = zipfile.ZipFile(io.BytesIO(get_certs.content))
z.extractall(temp)

download_url = "https://windscribe.com/getconfig/openvpn"

parse = BeautifulSoup(self.session.get(download_url).content, "lxml")

for s in parse.find("select", {"id":"location"}).findAll('option'):
s_id = s.get("value")
download_data = {"location": s_id,
"port" : "443",
"protocol" : "udp"
}

post = self.session.post(download_url, data=download_data)
with open("%s/%s.ovpn" %(temp, s_id), "w") as o:
o.write(post.content.decode("utf-8"))

with open("%s/%s.ovpn" %(temp, s_id), "r") as v:
lines = v.readlines()
for line in lines:
if line.startswith("remote "):
server = line.split(" ")[1]
ip = resolve(server)
if ip == "Failed to resolve":
failed_list.append(server)
countrycode = server.split(".")[0]
split = countrycode.split("-")
if len(split) >= 2:
if split[0] == "wf":
countrycode = split[1]
else:
countrycode = split[0]

if countrycode == "uk":
countrycode = "gb"

country = country_translate(countrycode.upper())

self.ws_server_dict[server] = {"name" : server, "country" : country,
"ip" : ip, "city" : "", "provider" : "Windscribe"
}

time.sleep(0.5)

try:
with open("%s/windscribe_userpass.txt" %self.temp, "w") as cd:
cd.write("%s\n%s" %(credentials["username"], credentials["password"]))
self.get_servers()
except KeyError:
self.importFail.emit("Airvpn")

self.ws_protocol_dict = {"protocol_1" : {"protocol": "UDP", "port": "443"},
"protocol_2" : {"protocol": "UDP", "port": "80"},
"protocol_3" : {"protocol": "UDP", "port": "53"},
"protocol_4" : {"protocol": "UDP", "port": "1194"},
"protocol_5" : {"protocol": "UDP", "port": "54783"},
"protocol_6" : {"protocol": "TCP", "port": "443"},
"protocol_7" : {"protocol": "TCP", "port": "587"},
"protocol_8" : {"protocol": "TCP", "port": "21"},
"protocol_9" : {"protocol": "TCP", "port": "22"},
"protocol_10" : {"protocol": "TCP", "port": "80"},
"protocol_11" : {"protocol": "TCP", "port": "143"},
"protocol_12" : {"protocol": "TCP", "port": "3306"},
"protocol_13" : {"protocol": "TCP", "port": "8080"},
"protocol_14" : {"protocol": "TCP", "port": "54783"},
"protocol_15" : {"protocol": "TCP", "port": "1194"}
}

ws_dict = {"server" : self.ws_server_dict,
"protocol" : self.ws_protocol_dict,
"provider" : "Windscribe",
"path" : temp,
"failed" : failed_list
}

self.down_finished.emit(ws_dict)

except requests.exceptions.RequestException as e:
self.importFail.emit("Network error: no internet connection")


def get_servers(self):
cert_url = "https://assets.windscribe.com/desktop/other/openvpn_cert.zip"
get_certs = self.session.get(cert_url)
z = zipfile.ZipFile(io.BytesIO(get_certs.content))
z.extractall(self.temp)

uid = uuid.uuid4()
random = uid.hex
api_url = "https://assets.windscribe.com/serverlist/openvpn/1/%s" %random

data = json.loads(self.session.get(api_url).content.decode("utf-8"))

for s in data["data"]:
try:
countrycode = s["country_code"]
for n in s["nodes"]:
city = n["group"].split("-")[0]
ip = n["ip2"]
ip2 = n["ip3"]
name = n["hostname"].replace("staticnetcontent", "windscribe")
country = country_translate(countrycode)
self.ws_server_dict[name] = {"name" : name, "country" : country,
"ip" : ip, "ip2" : ip2, "city" : city, "provider" : "Windscribe", "tunnel" : "OpenVPN"
}
except KeyError:
pass

self.ws_protocol_dict = {"protocol_1" : {"protocol": "UDP", "port": "443"},
"protocol_2" : {"protocol": "UDP", "port": "80"},
"protocol_3" : {"protocol": "UDP", "port": "53"},
"protocol_4" : {"protocol": "UDP", "port": "1194"},
"protocol_5" : {"protocol": "UDP", "port": "54783"},
"protocol_6" : {"protocol": "TCP", "port": "443"},
"protocol_7" : {"protocol": "TCP", "port": "587"},
"protocol_8" : {"protocol": "TCP", "port": "21"},
"protocol_9" : {"protocol": "TCP", "port": "22"},
"protocol_10" : {"protocol": "TCP", "port": "80"},
"protocol_11" : {"protocol": "TCP", "port": "143"},
"protocol_12" : {"protocol": "TCP", "port": "3306"},
"protocol_13" : {"protocol": "TCP", "port": "8080"},
"protocol_14" : {"protocol": "TCP", "port": "54783"},
"protocol_15" : {"protocol": "TCP", "port": "1194"},
"protocol_16" : {"protocol": "SSL", "port": "443"}
}

ws_dict = {"server" : self.ws_server_dict,
"protocol" : self.ws_protocol_dict,
"provider" : "Windscribe",
"path" : self.temp
}

self.down_finished.emit(ws_dict)

class ProtonDownload(QtCore.QThread):
down_finished = QtCore.pyqtSignal(object)
importFail = QtCore.pyqtSignal(str)
Expand Down
11 changes: 9 additions & 2 deletions qomui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ def create_server_dict(current_dict, protocol_dict):

except KeyError:
current_dict.update({"port": port, "protocol": protocol, "prot_index": mode})


elif provider == "Windscribe":
if protocol == "SSL":
ip = current_dict["ip2"]
current_dict.update({"port": port, "protocol": protocol, "prot_index": mode, "ip" : ip})

else:
current_dict.update({"port": port, "protocol": protocol, "prot_index": mode})
else:
current_dict.update({"port": port, "protocol": protocol, "prot_index": mode})

Expand All @@ -67,5 +74,5 @@ def create_server_dict(current_dict, protocol_dict):
current_dict.update({"port": port, "protocol": protocol})
except KeyError:
pass

return current_dict
6 changes: 3 additions & 3 deletions resources/ssl_config
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ client = yes
debug = 6

[openvpn]
accept = 127.0.0.1:1413
accept =
connect
TIMEOUTclose = 0
verify = 3
CAfile = /usr/share/qomui/certs/stunnel.crt


0 comments on commit caac210

Please sign in to comment.