Advertisement
Sweetening

drop.py

Feb 7th, 2025
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. import requests
  2. import subprocess
  3. import time
  4.  
  5. # Fetch SOCKS5 proxies from Mullvad API
  6. def get_proxies():
  7. url = "https://api.mullvad.net/network/v1-beta1/socks-proxies"
  8. response = requests.get(url)
  9.  
  10. if response.status_code != 200:
  11. print("Error fetching proxy data.")
  12. return []
  13.  
  14. try:
  15. data = response.json()
  16. if isinstance(data, list):
  17. return data
  18. else:
  19. print("Unexpected proxy response format.")
  20. return []
  21. except ValueError as e:
  22. print(f"Error parsing JSON response: {e}")
  23. return []
  24.  
  25. # Fetch relay information from Mullvad API
  26. def get_relays():
  27. url = "https://api.mullvad.net/www/relays/all/?action=query&titles=Alex&format=json&formatversion=2"
  28. response = requests.get(url)
  29.  
  30. if response.status_code != 200:
  31. print("Error fetching relay data.")
  32. return []
  33.  
  34. try:
  35. data = response.json()
  36. if isinstance(data, list):
  37. return data
  38. elif isinstance(data, dict):
  39. return data.get('query', {}).get('pages', [])
  40. else:
  41. print("Unexpected response format.")
  42. return []
  43. except ValueError as e:
  44. print(f"Error parsing JSON response: {e}")
  45. return []
  46.  
  47. # Set up the VPN client using the fetched proxy and relay data
  48. def setup_vpn(proxy, relay):
  49. print(f"Connecting to VPN using proxy {proxy['ipv4_address']}:{proxy['port']}...")
  50. # Example VPN setup with OpenVPN (or you can customize as needed)
  51. command = [
  52. "openvpn",
  53. "--config", "path/to/your/openvpn/config.ovpn",
  54. "--remote", proxy['ipv4_address'], str(proxy['port']),
  55. "--tls-client", "--auth-nocache",
  56. "--dev", "tun"
  57. ]
  58.  
  59. try:
  60. subprocess.run(command, check=True)
  61. except subprocess.CalledProcessError as e:
  62. print(f"Error starting VPN client: {e}")
  63.  
  64. # Main function to run the VPN client with proxies and relays
  65. def run_vpn_client():
  66. proxies = get_proxies()
  67. relays = get_relays()
  68.  
  69. if not proxies or not relays:
  70. print("No proxies or relays found.")
  71. return
  72.  
  73. # Randomly choose a proxy (you can customize this logic)
  74. proxy = proxies[0] # For simplicity, taking the first one
  75. relay = relays[0] # For simplicity, taking the first relay
  76.  
  77. print(f"Using proxy: {proxy['hostname']}, {proxy['ipv4_address']}, Port: {proxy['port']}")
  78. print(f"Using relay: {relay.get('title', 'Unknown')}")
  79.  
  80. # Set up VPN connection
  81. setup_vpn(proxy, relay)
  82.  
  83. # Run the VPN client
  84. if __name__ == "__main__":
  85. while True:
  86. run_vpn_client()
  87. time.sleep(30) # Wait for 30 seconds before attempting to reconnect or choose a new proxy/relay
  88.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement