def configure(self): skip_settings = self._config.get('skip_settings', True) settings = self._config.get('settings', {}) human_readable = settings.get('human_readable', None) if human_readable is not None: L.describe("VPN application should be configured to {}".format( human_readable)) elif settings: L.describe( "VPN application should be configured to {}".format(settings)) if not settings: L.warning( "No settings specified for VPN application. Using current settings." ) return elif skip_settings: L.warning( "Configuring VPN application skipped as skip_settings=True") return msg = "" for key, value in list(settings.items()): msg += " {} => {}\n".format(key, value) message_and_await_enter( "Configure the VPN application with the following settings:\n{}". format(msg))
def setup(self): # TODO: This should be done with a network configuration step msg = "Ensure you have an Ethernet (wired) connection and at least one " \ "other network service, e.g. Wi-Fi\n" if not self._pull: msg += "Ensure that the cable is UNPLUGGED." message_and_await_enter(msg)
def test(self): L.describe('Open and connect the VPN application') self.target_device['vpn_application'].open_and_connect() L.describe('Capture traffic') self.capture_device['packet_capturer'].start() L.describe('Generate whatever traffic you want') message_and_await_enter('Are you done?') L.describe('Disconnect WiFi upstream') # TODO: self.upstream.disable()? message_and_await_enter('Unplug the cable from the router') message_and_await_enter( 'Wait until the application has noticed (or however long you want)' ) L.describe('Connect WiFi upstream') message_and_await_enter('Plug the cable back in') L.describe('Generate whatever traffic you want') message_and_await_enter('Are you done?') L.describe('Stop capturing traffic') packets = self.capture_device['packet_capturer'].stop() whitelist = self.capture_device.local_ips() L.debug('Excluding {} from analysis'.format(whitelist)) self.traffic_analyser.get_vpn_server_ip(packets, whitelist)
def _webrtc_ips(self, url_base): url = self._url(url_base) L.describe("Open ICE detection webpage {}".format(url)) self._webdriver.get(url) # TODO: This isn't working properly. Also, try to automate if self._ask_perms: message_and_await_enter( "Please grant the browser permissions to use audio/video") # Not in love with this but not sure we have a lot of choice. There's no way to know whether # the javascript code has done searching for IPs TODO: Verify that L.describe("Wait for {} seconds for IPs to report".format( WebRTCICEHelper.TIME_TO_WAIT_FOR_IPS)) time.sleep(WebRTCICEHelper.TIME_TO_WAIT_FOR_IPS) if 'xv_leak_tools local ICE IP detection' not in self._webdriver.title: raise XVEx("Got unexpected webpage title: {}".format( self._webdriver.title)) L.describe( "Check ICE detection webpage doesn't show our public IP addresses") inner_html = self._webdriver.find_element_by_id( 'ice_ips').get_attribute('innerHTML') if not inner_html: raise XVEx('ice_ips div in webrtc page contained no inner_html') json_reponse = json.loads(inner_html) if not json_reponse['webrtc_supported']: L.warning( 'WebRTC not supported for this browser. Reporting no ips.') return [] return [ipaddress.ip_address(ip) for ip in json_reponse['ips']]
def teardown(self): if self._has_disrupted: message_and_await_enter( "Reset the DNS servers for adapter {} ({})".format( self._primary_adapter.name(), self._primary_adapter.net_connection_id())) super().teardown()
def _start_server(self): L.warning("The server must be started manually :(") if self._device.connector().execute(['lsof', '-t', '-i', ':4444'])[0]: message_and_await_enter("Start the Selenium server") while self._device.connector().execute( ['lsof', '-t', '-i', ':4444'])[0]: L.debug("Waiting for Selenium") time.sleep(0.5) self._server_running = True
def test(self): L.describe('Open and connect the VPN application') self.target_device['vpn_application'].open_and_connect() L.describe('Capture traffic') self.capture_device['packet_capturer'].start() L.describe('Generate whatever traffic you want') message_and_await_enter('Are you done?') L.describe('Stop capturing traffic') packets = self.capture_device['packet_capturer'].stop() whitelist = self.capture_device.local_ips() L.debug('Excluding {} from analysis'.format(whitelist)) self.traffic_analyser.get_vpn_server_ip(packets, whitelist)
def test_with_packet_capture(self): L.describe('Generate traffic') message_and_await_enter( "Generate traffic however you want. Packet capture will continue in the background. " "When you're done press enter to check if anything leaked.")
def restore(self): msg = "Ensure the ethernet cable is plugged back in" L.describe(msg) message_and_await_enter(msg)
def disrupt(self): msg = DisrupterCable.PULL_MESSAGE if self._pull else DisrupterCable.PLUG_MESSAGE L.describe(msg) message_and_await_enter(msg)
def disrupt(self): self._has_disrupted = True message_and_await_enter( "Set the DNS servers for adapter {} ({}) to 8.8.8.8".format( self._primary_adapter.name(), self._primary_adapter.net_connection_id()))
def disable_airplane_mode(self): message_and_await_enter('Disable airplane mode')
def disable_mobile_data(self): message_and_await_enter('Disable data')
def connect(self): message_and_await_enter('Connect to the VPN')
def disconnect(self): message_and_await_enter('Disconnect from the VPN')
def close(self): message_and_await_enter('Close the VPN application')
def disable_wifi(self): message_and_await_enter('Disable WiFi')
def enable_mobile_data(self): message_and_await_enter('Enable data')
def wait_for_connection_interrupt_detection(self, timeout=65): # pylint: disable=unused-argument # TODO: Add timeout to message_and_await_enter? message_and_await_enter( 'Wait for the VPN application to detect a connection disruption then press enter' )
def enable_airplane_mode(self): message_and_await_enter('Enable airplane mode')
def disable_wired(self): message_and_await_enter('Plug out wired internet')
def enable_wired(self): message_and_await_enter('Plug in wired internet')
def disrupt(self): L.describe('Disable Wi-Fi') # TODO: I have no idea how to do this programmatically yet (or if it's even possible). # Probably it can be done via a registry setting message_and_await_enter("Disable Wi-Fi {}".format( WindowsWifiPowerDisrupter.VIA))
def enable_wifi(self): message_and_await_enter('Enable WiFi')
def restore(self): L.describe('Re-enable Wi-Fi') message_and_await_enter("Re-enable Wi-Fi {}".format( WindowsWifiPowerDisrupter.VIA))