Miscellaneous

1. Reclaim memory space

We can attempt to reclaim memory space on the router by killing some of the unneccessary processes

View current processes:

UART console
# ps
...
264 root       3332 S   resetbutton
329 root       2440 S   tftpd -s /tmp -c -l -P E150
330 root       2168 S   cron
333 root       3864 S   httpd
336 root       3864 S   /tmp/gn-httpd -p 51000 -G
340 root       2272 S   dnsmasq -R -h -i br1 -i br0 -c 0 -r /tmp/resolv.conf
345 root       1024 S   cesmDNS -o /tmp/.mdns_host_info -d -h CISCO007 -l 192
347 root       6936 S   /tmp/gn-dhcpd -cf /tmp/dhcpd-br1.conf -lf /tmp/dhcpd-
349 root       6936 S   dhcpd -cf /tmp/dhcpd-br0.conf -lf /tmp/dhcpd.leases -
354 root       3164 S   upnp -D -W vlan2
385 root       2180 S   /bin/eapd
388 root       2576 S   nas
392 root       3764 S   /bin/wps_monitor
394 root       2156 S   netbios /tmp/samba/lib/netbios.conf
419 root       1436 S   /usr/sbin/lld2d br0
473 root       2804 S   /sbin/monitor_cable
536 root       1772 S   /bin/sh

View more information about a particular process:

Kill the process

  • From the known running processes, we can consider killing the following:

  • May lose DHCP/DNS name resolution

  • UART access and /tmp/gn-httpd unaffected

  • Lose wifi capabilities

  • Ethernet + UART unaffected

  • Other processes that are safe to kill

DO NOT KILL THE FOLLOWING

Verify newly reclaimed memory:

2. Transfer binary from host to device

Remember to always check the available memory space available on the device, before transferring files

Before we continue, let's install the busybox binary on the device (via UART), which provides us with a more comprehensive set of tools

Host:

Device (UART console):

3. Transfer binary from device to host

3.1 tftp

Host:

  • Enable tftp server

Device (UART console):

3.2 Netcat (busybox)

Device (UART console):

Host:

  • We can now access the vulnerable binary from /path/to/gn-httpd on the host machine

4. Connect to a remote shell on the device via dropbear

4.1 Existing binaries

There exists a few compiled dropbear binaries on the internet, with issues that prevents us from using them on our device:

  • Compiled for MIPS (big-endian) instead of MIPSEL (little-endian)

  • Non-statically compiled

4.2 Compile manually

  • We will compile a static dropbear and dropbearkey binary for the MIPSEL architecture

  1. Cross-compile dropbear for MIPSEL:

  • /tmp/dropbear-bin is a binary file, while /tmp/dropbear is the directory which stores the dropbear RSA host key

  • The device will now be listening on default SSH port 22 for the current user (root)

  • Important options for dropbear-bin:

    • -B: allow blank passwords

  1. Connect to the device via SSH

  • The -o StrictHostKeyChecking=no can be added to disable strict checking (if required)

5. Useful scripts

I have created a few Bash scripts to improve the overall workflow of exploit development. This includes:

  1. Device:

  • Loading necessary binaries from host machine

  • Configuration and hosting of SSH server with dropbear

  • Retrieval and running of a patched (with custom instruction) httpd binary, before starting a gdbserver instance attached to the newly started process PID

  1. Host:

  • Patch httpd binary

  • Hosting binary for device to retrieve

5.1 device__load-bins.sh

5.2 device__start-dropbear.sh

5.3 device__retrieve-httpd-and-start-gdbserver.sh

5.4 host__patch-and-host-httpd.sh

Last updated