Mastodon

Gaining Root Access on Netgear Nighthawk Mobile 5G/LTE Routers

This blog posts covers the required steps to gain root access via Telnet on Netgear Nighthawk Mobile 5G/LTE Routers. Its the first post in a small series covering my experiences playing around with this device.

Last month I obtained one of Netgear’s latest mobile 5G routers, the Netgear Nighthawk M5 (model MR5200-100EUS) . Being one of the most expensive consumer 5G routers, I was lucky to get a fairly good second hand deal from eBay.

The router is powered by Qualcomm’s® Snapdragon X55 5G Modem-RF system. Looking closer at the internals of the device by checking the FCC filing for the closely related American model MR5100, we can see that the system consists of a Qualcomm SDX55 chipset which combines both the mobile baseband and application processors.

Gaining root access

Gaining root access to the device is actually fairly simple in comparison to rooting modern Android-based devices. The router exposes an open TCP port providing an AT command interface. However, this port is only accessible via a tethered USB connection, not via Wifi.

Using this AT command interface, we can interact with the modem, unlock an extended command set which allows us enable a Telnet daemon.

Detailed steps

1. Install the Sierra Wireless debug tools from bkerler:

sudo apt install python3 git
git clone https://github.com/bkerler/edl.git
cd edl
sudo python setup.py install

(More detailed installation instructions are covered in the README file of the repo.)

2. Connect your machine via USB-C to the Netgear router.

3. Make sure to disconnect from the Netgear Wifi.

4. Open a terminal an connect to the AT command interface via netcat (nc).
(Make sure not to miss the -c option as it will the enable nc to use the proper CRLF line-endings which are required for the AT interface).

nc -c 192.168.1.1 5510

4. Once connected to the AT command interface, you need to request a unlock challenge code by sending:

AT!OPENLOCK?

The previous command will return a challenge code which we use to generate a corresponding response code via the previously installed sierrakeygen.py tool:

sierrakeygen.py -l <replace_with_challenge_code> -d SDX55

The previous command will print out another AT+OPENLOCK command which you need to copy verbatim back to your AT command session.

5. Run the following AT commands to enable the Telnet daemon:

AT!TELEN=1
AT!CUSTOM="RDENABLE", 1
AT!CUSTOM="TELNETENABLE", 1

You can now close the AT command session by pressing Ctrl+C.

6. Power-cycle the Netgear Router to start the Telnet daemon.

Voila, you can now telnet into the device via both the tethered USB-C cable or Wifi.

nc -c 172.23.156.129 23
��������
mdm 1623 sdxprairie
/ # uname -a
uname -a
Linux sdxprairie 4.14.117 #1 PREEMPT Thu Aug 19 23:42:26 UTC 2021 armv7l GNU/Linux

Disclaimer: Please be aware that the device security is now breached as all devices connected to the Wifi or USB can gain root access to the device. The root Telnet login requires no password.

Next steps

Before proceeding we should make sure that we can bring the device back to a secure state by replacing the Telnet by an Secure Shell (SSH) daemon. In one of the next posts of this series, I will be building a statically linked version of the Dropbear SSH server to replace Telnet.

Before continuing my reverse engineering efforts on the device, I would like to ensure that I will not brick the router while doing so by dumping the firmware and extract all the details from it. This will allow us to hopefully restore the device by flashing the original firmware. Maybe we will be able to run OpenWRT on it.

I have also designed a wall mount for the router which allows me to mount it permanently into by van.

Workshop: Security Token

Der Open Source Arbeitskreis (OSAK) der Fachschaft FSMPI, veranstaltet nun zum zweiten Mal eine Crypto Party auf der sich Interessierte über Verschlüsselung und verwandte Themen informieren können.

Ich möchte hier die Gelegenheit nutzen um etwas Werbung für diese Veranstaltung zu machen. Genaue Infos findet Ihr unten im Flyer.

Dieses Mal wird es auch einen kleinen Workshop von mir geben:

Hardware Crypto Tokens

„I know none of my passwords“

Ich werde in ca. 20 Min eine kurze Übersicht über Security Tokens wie bspw. den Yubikey oder die OpenPGP Smartcard geben. Dabei wird der Fokus auf verschiedenen Anwendungsszenarien wie bspw. One-Time-Passwords, Logins, E-Mail Verschlüsselung usw liegen.

Update: Hier sind die Vortragsfolien und das Handout:

Präsentation (pdf)
Handout (pdf)

cryptoparty-ss2015

transWhat

simsons_vermittlung„transWhat“ ist ein XMPP Transport, der den WhatsApp Messenger in das Jabber Netzwerk einbindet.

Das Gateway simuliert dabei serverseitig die normale WhatsApp App von Android bzw. iPhone. Der User benötigt nur noch einen normalen XMPP Client wie beispielsweise Adium, Gaijm, IM+ oder Pidgin. Damit ist es nun möglich WhatsApp auf nahezu allen Geräten und Betriebssystemen einzusetzen.
Ich kann transWhat sehr in Kombination mit Pidgin auf Desktops und Laptops und mit IM+ auf Tablets empfehlen 🙂

Nutzung

Alle Details, Serverdaten, Logins, Tipps und Tricks findet ihr hier im Wiki.

Aus verschiedenen Gründen werde ich den Code nicht veröffentlichen sondern das Gateway nur als Service anbieten.

Ich habe mich nun doch dazu entschieden den Quelltext freizugeben. Er ist in meinem GitHub Repository zu finden.

Nach dem Break gibt’s noch ein paar technische Details und Informationen zur Umsetzung. transWhat weiterlesen

cron Jobs für Sonnenauf- & untergang

Nicht selten kommt es mal vor, dass sich ein Rechner nach astronomischen Zyklen orientiert. Die zur Berechnung der Osterfeiertage häufig verwendete Gaußsche Osterformel basiert so z.T. auf der Mondgleichung.

Unser Problem stellte sich etwas anders dar: Die LED-Flurbeleuchtung in unserem Flur wird durch den Router geregelt und lief bisher in der Regel 24/7. Mit dem hier vorgestellten Programm haben wir es nun geschafft die Laufzeit auf die Nachstunden zu begrenzen, indem wir die von unserer geografischen Position abhängige Sonnenuntergangszeit nutzen um die Lampen erst bei Dämmerung einzuschalten.

UPDATE: Ich habe nochmal etwas Arbeit in das Tool investiert und es in ein eigenes Projekt ausgelagert. Das neue Tool liefert wesentliche genauere Ergebnisse und mehr Funktionen. Zu finden ist es hier: calcelestial.

Das neue Tool besitzt eine Reihe weiterer nützlicher Funktionen:

usage: sun mode [options]
  mode is one of: rise, set, noon, daytime, nighttime

  following OPTIONS are available
	-t, --twilight	use special twilight (nautic|civil|astro)
	-d, --date	calculcate for specified date (eg. 2011-12-25)
	-f, --format	output format (eg. %H:%M:%S)
	-a, --lat	geographical latitude (-90° to 90°)
	-o, --lon	geographical longitude (-180° to 180°)
	-q, --query	query geonames.org for geographical position
	-z, --zone	use timezone for output
	-h, --help	show this help
	-v, --version	show version

A combination of --lat, --lon or --query is required!

Beispiele

Die einfachste Variante nutzt das Unix Tool at:

echo ~/bin/enable-lightning | at $(sun set -q Frankfurt -t civil)

Mit folgenden Cronjobs, lässt sich dieses Prinzip auch leicht auf andere Anwendungen übertragen:

0 0 * * * echo 'fnctl stop && fnctl fade -c 000000' | at $(sun rise -q Aachen)
0 0 * * * echo 'fnctl start' | at $(sun set -q Frankfurt)

Mit dem Tool nvram-wakeup, lässt sich so bsp. der Rechner jeden Tag 10 Minuten for Sonnenaufgang automatisch starten ^^:

nvram-wakeup -s $(date -d "-10min $(sun rise -q Berlin)" +%s)

Oder möchtest du deinen Rechner nach Sonnenuntergang automatisch herrunterfahren?

shutdown $(date -d +10min $(src/sun set --lat=50.55 --lon=-6.2) +%H:%M)

HIDeKey

Als Abschlussprojekt und Vorbereitung auf meine Betreuertätigkeit für die Mikrocontroller-AG des MMI’s habe ich mich näher mit dem USB-Bus und dem darauf aufbauenden HID-Protokoll befasst.

HIDeKey ist ein kleiner USB-Stick, der als HID-Tastatur vom Rechner erkannt wird und beliebge Zeichenketten und Tastenkombinationen an den Host-Rechner senden kann.

Mein Ziel war es ein kleinen Hardware-Dongle zu entwickeln welcher Passwörter, TANs und Onetime-Tokens direkt an jeden beliebigen Rechner senden kann. Meine Passwörter sind im verschlüsselt EEPROM des Mikrocontrollers gespeichert. Beim Drücken, des Tasters auf dem Stick, wird das Passwort eingegeben.

Als Hardware nutze ich die zuvor vorgestellten USBasp Programmieradapter aus China, deren Firmware ich durch eine eigene ersetzt habe. Mit einem zusätzlichen Taster lässt sich so über ein kleines Menü zwischen 10 User-Passwort-Kombination wählen.

Neue Passwörter können mit einem kleinen Konsolen-Programm direkt über den Rechner einprogrammiert werden.

HIDeKey soll auch zur Generierung von One Time Passwords (OTP) genutzt werden können. Da er sich wie ein gewöhnliche USB-Tastatur verhält, kann er auch unterwegs am Schlüsselbund in Internet-Cafes und Rechner-Pools genutzt werden.

Sourcecode & Schaltpläne etc. gibt es wieder per git. In meinem Wiki ist auch noch etwas Dokumentation gesammelt.

HIDeKey ist wie die meisten meiner Prrojekte als OpenSource veröffentlicht. Ich freue mich über jede Verbesserung, Erweiterung oder andere Beiträge zu diesem Projekt 🙂