Over a million developers have joined DZone.

Stealing Authentication Tokens From Locked Machines With a Mobile Phone

DZone's Guide to

Stealing Authentication Tokens From Locked Machines With a Mobile Phone

Locked machines shouldn't allow for credentials to be stolen. USB Ethernet adapters running on Windows, OSX and Linux combined with Android tethered devices and specific Linux tools can steal network credentials. Very scary!

· Mobile Zone
Free Resource

Get gorgeous, multi-touch charts for your iOS application with just a few lines of code.

Stealing credentials from locked machines shouldn’t work. And yet, it does. The main reason for this is that the operating system automatically loads device drivers if it has access to them. This is true even when a machine is locked. In the case of locked machines, USB Ethernet adapter drivers ship with every major operating system (e.g., Windows, MacOSX, Linux).

Leveraging this fact, it’s possible to create a network using Android tethering. When tethering, the mobile device receives all of the host’s traffic and acts as a network gateway. Once implemented, it is trivial to conduct any number of man-in-the-middle (MitM) attacks. In this post, I’ll explain the steps, tools, and configuration needed to conduct a successful attack on a locked device.

Android Tethering

When an Android device enters tethering mode, it adds an additional USB descriptor to the USB interface and restarts it.

When the operating system queries the Android device—connected via USB port—it receives the USB network device descriptor (among others). It then loads the driver.

Once the driver loads, the host operating system creates a new network interface (via USB). The host treats the new network interface as any other. Since the USB link is active, the host requests an IP by sending a Dynamic Host Configuration Protocol (DHCP) request.

In the native Android tethering configuration, use dnsmasq to set up a DHCP and DNS server that responds to the request. This provides the host with the IP and routing details necessary to connect to the network.

In Android’s tethering implementation, these configuration details are hardcoded in the “Tethering.java” package. However, in a rooted Android device, manual configuration is possible.

Apart from these elements, iptables forwarding rules can be set up to forward traffic from the USB to the external interface (typically Wi-Fi or 3G). Once this is done, the host can use the USB network to connect to the Internet (i.e., tethering).

Man-in-the-middle Attacks

Carrying out a MitM attack in which the attacker poisons the network with rogue packets to force network devices to connect through the attacker’s network isn’t necessary with tethering. When tethering, all host traffic passes through the device as explained above. Even if the device connects to another network, some network traffic eventually goes through the USB network. This is proven to be enough to leak some authentication credentials as we’ll expand on below.

Stealing Credentials

In this example, the MitM tool of choice is Responder. A passive credentials gathering tool, Responder listens for specific NetBIOS Name Service (NBT-NS) and Link-local Multicast Name Resolution (LLMNR) queries. It also poisons the issuer. This tool involves rogue authentication servers listening via UDP and TCP ports. Additionally, the victim is redirected to these services in an attempt to capture their authentication credentials.

Using Responder to MitM traffic and capture credentials is extremely effective. This is especially true when the user is active in the network (e.g., browsing the Internet, accessing internal shares, etc.).

Stealing Credentials From Locked Machines

This attack vector assumes that the user isn’t present or active on the network. However, the user must have previously authenticated to the host for this to work. It also assumes physical access to the host and USB ports.

The Web Proxy Auto-Discovery (WPAD) protocol is a method that operating system’s utilize to locate a proxy auto-config (PAC) file automatically. The location of the PAC can be presented to the user in the DHCP response “site-local” option 252 (i.e., auto-proxy-config) with a “http://example.com/wpad.dat” value.

DHCP has a higher priority than DNS. If DHCP provides the WPAD URL, no DNS lookup is performed. This only works with DHCPv4. In DHCPv6, there is no defined WPAD option.

All Web browsers support this protocol: Windows, MacOSX, and Linux, as well as iOS and Android. However, it is only enabled by default in Windows operating systems.

Bringing It All Together

With regard to tethering and DHCP, we’ve seen that it’s possible to create a network and set up a DHCP server using an Android device. It’s also trivial to set up a DHCP server using Android’s dnsmasq and configure the WPAD option to point to Responder.

Regarding authentication, the attack works on locked computers because of the proxy automatic configuration file details that pass with the DHCP response.

When the host tries to retrieve the PAC file, Responder’s HTTP server responds with a “(407) authentication required” message. In many cases, the host authenticates via the user’s cached credentials.

Windows uses the NTLM protocol, a challenge-response authentication protocol, for this authentication. A hash derived from the user’s password and the challenge-response steps act as the user’s authentication token.

Although these aren’t plaintext credentials that an attacker can use directly, with modern hardware it’s possible to crack the hash and reveal the user’s password in a realistic time-frame. The time for this is significantly lower if the password used is weak.

This will not work in a freshly-booted host since cached credentials aren’t available. However, once the user authenticates, the host can try to get the file again.

One of the key challenges is running Responder (a Python project) in Android. There are a number of potential solutions to consider. The easiest and most effective is to install the qPython application. qPython is a Python interpreter compiled for Android. It’s able to run Responder without any issues.

An alternate solution is to install NetHunter. NetHunter is a Kali Linux installation ported to Android. It also contains a Python interpreter.

Have a Rooted Android and Want to Try It Out?

Install qPython, download the scripts and Responder, and follow the instructions.


This video displays a Windows 10 lock screen. The test host has a fresh Windows installation and it doesn’t join to any domain. It also isn’t connected to any other network. The user previously authenticated and locked the screen. Additionally, the Android device connected to it is running the aforementioned Responder scripts.

Notice that seconds after executing Responder, the user’s NTLM hash is captured without any user interaction.

The images below better illustrate what is captured:

Authentication Tokens

Image 1: The script’s execution steps. These enable tethering by setting up the network and running Responder.

Authentication Tokens

Image 2: The captured hash (in yellow) and other poisoned responses.


A potential control, at least against locked computer attacks, is to disable the automatic proxy configuration setting in the operating system and browsers.

Note that this could also create issues in corporate networks that use proxies and rely on automatic configuration to provision employee workstations. Nevertheless, when using proxies, it’s recommended for the settings to be hardcoded or provided by automatic configuration scripts.

Below you’ll find operating system-specific directions:

Windows 10, 8.1, and 8

  1. Open Settings (Start → Settings in Windows 10 / Left corner → Change PC Settings in Windows 8, 8.1).
  2. Select Network and then pick Proxy on the left.
  3. Ensure “Automatically Detect Settings” is disabled.

Windows 7, Vista, XP

  1. Click Start and go to Control Panel.
  2. In Control Panel select Internet Options.
  3. In the Connections tab select LAN Settings.
  4. Ensure “Automatically Detect Settings” is disabled.


  1. Open System Preferences.
  2. Select Network and pick the active connection.
  3. Select Advanced then pick the Proxies tab.
  4. Ensure “Auto Proxy Discovery” is disabled.

.Net developers: use Highcharts, the industry's leading interactive charting library, without writing a single line of JavaScript.

configuration ,host ,interface ,mobile

Published at DZone with permission of Nikos Vassakis, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}