Skip to content

Instantly share code, notes, and snippets.

@salut1618
Last active September 3, 2022 11:04
Show Gist options
  • Save salut1618/19ef63427f49e06474aafd307f603130 to your computer and use it in GitHub Desktop.
Save salut1618/19ef63427f49e06474aafd307f603130 to your computer and use it in GitHub Desktop.
adds rockstars ip addresses to ProtonVpn split tunneling config
# Required dependencies
# ! pip install dnspython
# ! pip install xmltodict
import dns
import dns.resolver
from os import listdir, getlogin
from json import dumps, loads
import xmltodict
from packaging import version
from pathlib import Path
from xml.dom import minidom
_path = f"C:\\Users\\{getlogin()}\\AppData\\Local\\ProtonVPN\\ProtonVPN.exe_Url_5k5woeau2v3gmtlay4mjwsftlqxjnn2p"
_ver = max(listdir(_path), key=version.parse)
_user_config_path = f"{_path}\\{_ver}\\user.config"
hostnames = ["socialclub.rockstargames.com",
"signin.rockstargames.com",
"www.rockstargames.com",
"support.rockstargames.com",
"store.rockstargames.com",
"rockstargames.com",
"vpn.rockstargames.com",
"click.newsletter.rockstargames.com"]
with open(_user_config_path, 'r+') as xml_file:
data_dict = xmltodict.parse(xml_file.read())
l = data_dict['configuration']['userSettings']['ProtonVPN.Properties.Settings']['setting']
e = l[next((ind for (ind, sett) in enumerate(l) if sett['@name'] == "SplitTunnelIncludeIps"))]
dicts = loads(e['value'])
for hostname in hostnames:
for ip in dns.resolver.resolve(hostname):
if not next((x for x in dicts if x['Ip'] == ip.to_text()), None):
dicts.append({'Ip': ip.to_text(), 'Enabled': True})
print(f"{hostname}->{ip.to_text()}")
e['value'] = dumps(dicts)
with open(_user_config_path, 'w') as xml_file:
xml_file.write(minidom.parseString(xmltodict.unparse(data_dict)).toprettyxml())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment