How do I check my router for malware?
I have a store bought consumer router connected to my ISP's router which is in bridge mode, and it's one of the few remaining proprietary mystery boxes in my network that I don't know how to audit. I recently made a post about whether I should switch to PFsense, and this was one of my motivations (though I forgot to mention it in that post).
Is there an effective way to check whether my router is part of a Mirai botnet or some other malware that scanned the internet and found some vulnerability in my router? As far as I know, once infected, things like updating the firmware or pressing the reset button aren't guaranteed to remove it because it can just take control of those processes and persist. In my specific configuration, can malware from the internet even see my main router or just the ISP router it's connected to?
In my threat model, I'm most concerned about my local traffic to and from my server being exfiltrated by some cybercrime group as a lot of it is HTTP or HTTP proxy data. Not so much general internet bound traffic which is usually HTTPS or VPN. Obviously I don't want to be "participating" in botnet attacks or other cybercrime infrastructure either.

hansolo
in reply to HiddenLayer555 • • •floquant
in reply to hansolo • • •hansolo
in reply to floquant • • •HiddenLayer555
in reply to hansolo • • •hansolo
in reply to HiddenLayer555 • • •floquant
in reply to HiddenLayer555 • • •davel
in reply to HiddenLayer555 • • •You said the ISP’s router is in bridge mode, which means your router is exposed to the wild, so it’ll be attacked as well, and of course it’s up to you to run a good firewall on it.
I don’t know how to test for malware, but I do know that basic consumer routers that can run OpenWRT are very cheap. I can’t speak to pfSense as I don’t have experience with it.
Nate
in reply to HiddenLayer555 • • •check.labs.greynoise.io
Check the reputation of your IP address (in addition to the other comment suggesting reflashing the devices firmware)
If anything is reaching out en masse, your address will likely be reported and some sites will block you. This is not to say that you're 100% definitely clean, but that you're probably not in a botnet
GreyNoise IP Check
GreyNoise LabsHiddenLayer555
in reply to Nate • • •Vinny_93
in reply to HiddenLayer555 • • •I'm not familiar with how malware like that masks but you can pretty much find any traffic with a tool like WireShark. It's just a matter of finding out how processes recreate themselves once killed.
If something lives in the storage of your router, specifically, I'd see about formatting the storage and flashing new firmware. As you stated, that may not solve anything.
Regardless of how they enter and what is installed where, once it's inside your home network it can pretty much access anything. If you wanna be fully secure you'd need a firewall and just block any traffic you don't specifically whitelist. As you can imagine, this is cumbersome.
Are you worried that something has infected your network devices? Do you have any reason to suspect something? In some countries, ISPs do some passive monitoring on what goes in and out of your home and if they see anything untoward they'll disable that bridge device and notify you.
redlemace
in reply to HiddenLayer555 • • •Especially when switching to pfsense
𞋴𝛂𝛋𝛆
in reply to HiddenLayer555 • • •::: spoiler The easiest way I know of to check any machine is to put another router or machine in front of it with a white list firewall or way of logging DNS traffic. You just need to spot the address in the list.
DNS filtering usually only filters on incoming packets, but for bot stuff that should catch issues.
In general, most routers run everything from a serial flash chip on the board. These are usually 8, 16, or 32 megabytes. They have a simple bootloader like U-Boot. This is what loads the operating system. These devices have a UART serial port on the PCB. You can use a USB to serial UART adaptor to see what is happening in the device. With a proprietary OS, you are still likely to see the pre-init boot sequence that the bootloader prints to terminal. Most operating systems also print information to this interface, at least of the couple dozen junk devices I have been given and messed around with. I make a little mount for a USB to serial adaptor and add it to all of my routers when new, so I only need to plug in USB to get to the internal bootloader and tty ter
... Show more...::: spoiler The easiest way I know of to check any machine is to put another router or machine in front of it with a white list firewall or way of logging DNS traffic. You just need to spot the address in the list.
DNS filtering usually only filters on incoming packets, but for bot stuff that should catch issues.
In general, most routers run everything from a serial flash chip on the board. These are usually 8, 16, or 32 megabytes. They have a simple bootloader like U-Boot. This is what loads the operating system. These devices have a UART serial port on the PCB. You can use a USB to serial UART adaptor to see what is happening in the device. With a proprietary OS, you are still likely to see the pre-init boot sequence that the bootloader prints to terminal. Most operating systems also print information to this interface, at least of the couple dozen junk devices I have been given and messed around with. I make a little mount for a USB to serial adaptor and add it to all of my routers when new, so I only need to plug in USB to get to the internal bootloader and tty terminal interface of OpenWRT. You will need to know the default baud rate of the device, although it is probably listed somewhere online or can be guessed as one of the common high values at or above 9600.
Getting into this further gets complicated. It is probably better to look for any CVE that is relevant to the device or software and work backwards. Look for any software updates that have obfuscated the risk for each CVE. If the issue was not fixed, that is where to look to see if someone has exploited the device. Ultimately, they need clock cycles from the CPU scheduler. So it must be a process or some way of executing code from unregistered memory.
This is getting to the edge of what I have messed around with and understand. There may be a way to get a memory map that includes unused pages, and compare that with a hex dump of the flash memory. This is outside of your scope of a proprietary OS, but hopefully frames the abstract scope of what is possible on this class of device when you have an open source stack. The main advantage of this kind of device and issue is that you can physically remove the flash chip and then see and manipulate every page and memory location. The device likely doesn't have microcode loaded into the CPU(s) that make it challenging to determine what is going on.
There is probably an easier way, but a hex dump of the current system can be hashed against the factory updated version to see if any differences are present. It is likely that any exploit will include a string with the address to connect to somewhere in flash memory. It could be obfuscated through encryption or a cypher, but a simple check for strings in the hex dump and a grep for "http" is a simple way to looks for issues.
The OpenWRT forum is a good general source. The people behind the bootloaders for these devices are also Linux kernel developers and on the OpenWRT forum.
:::
bcovertigo
in reply to 𞋴𝛂𝛋𝛆 • • •Konstant
in reply to HiddenLayer555 • • •stupid_asshole69 [none/use name]
in reply to HiddenLayer555 • • •What router?
Point Shodan or grey noise or something at your public ip. Find your public ip by disabling your computers vpn, asking google what your public ip is then comparing that to the address shown at your routers wan interface.
Another person said to just update it. Just update it. But before you do:
Look at freshtomato, openwrt, pfsense etc to see if any of the open firmwares support your hardware. You may like them better.
About the best you can do without opening it up, finding a uart and watching is to put a device you control between it and the isp device.
eleitl
in reply to HiddenLayer555 • • •HiddenLayer555
in reply to eleitl • • •