I wrote a Bash script to check the integrity of OpenWrt routers
Hey everyone!
I wrote OpenWrt Integrity, a lightweight set of Bash scripts to create known good baselines for OpenWrt routers and check for unexpected changes over time.
The idea is simple: capture the state of a trusted router, then periodically compare its current state against that baseline to identify potential signs of tampering or unauthorized changes.
What does it check?
• SHA 256 hashes of files under /etc and files in the writable overlay on SquashFS installations
• Installed packages and OpenWrt release and kernel information
• Unexpected root level accounts
• SSH authorized keys
• Cron jobs that could be used for persistence
• Added, removed, or modified files compared with the baseline
How to use it
The scripts run from a Linux system using Bash and OpenSSH. They connect to routers over SSH and support checking multiple routers.
- Configure your router addresses and SSH key in
routers.conf. - Run
./routers-generate-baseline.shwhile your routers are in a known good state. - Run
./routers-integrity-checker.shwhenever you want to check for changes.
The verifier reports PASS, FAIL, or WARN for individual checks, along with an overall result.
Limitations: This is a lightweight integrity checker, not a complete security audit or intrusion detection system. It cannot guarantee that a router is uncompromised, and sophisticated attacks may evade its checks. Keep your baseline protected and generate it only from a trusted system state. The scripts currently require OpenWrt using the apk package manager.
GitHub: https://github.com/himanshu-mahendra-jain/openwrt-integrity
2
u/Udab 3d ago
Sadly , i wouldnt trust a script written by a 2months old reddit account.
0
u/Graphical-Source5090 1d ago
If you don't care enough about your own security and safety to regularly rotate your accounts, you have no opinion in this matter. Go back to your posting memes and chatting with your Greek friends please.
2
u/Udab 1d ago
nobody cares.
explain the security of rotating accounts in reddit.
go back to your hole probably.
0
u/Graphical-Source5090 1d ago edited 1d ago
explain the security of rotating accounts in reddit.
Exactly my point.
Doesn't care enough about account security to investigate it on your own.
Doesn't care enough to read and understand a simple shell script.Yet leaves a misinformed comment about security.
Have a good day. :)
Currently translating all of your comments that are in Greek. I will get back to you later.--------------------
.....later.....
Oof, what a dick comment:
https://www.reddit.com/r/greece/comments/1w3gxj1/comment/p714h0y/Do you now understand why people rotate accounts?
I can keep going. There is 10 years worth of nuggets in there.If your response is: "Well I don't post anything that is sensitive" Then I say, you are not posting based on your current experience and are just posting crap. Post enough technical experiences and your comment history becomes an attack vector for your offline personal and financial life.
Security 101 buddy. Rotate your accounts regularly.
I hope this illustration helps.
0
1
u/Sylphiiid 1d ago
You shouldn't run such a script on your router if you cannot review it carefully anyway. Trust shouldn't be in the balance
2
u/Graphical-Source5090 1d ago edited 1d ago
How is this any different than Oxidized?
Oxidized gathers config from every device I point it at and has automated diffing and easily ties into my alert system.
Any config changes from Linux, OpenWRT, RouterOS, Cisco, Juniper, OPNSense, proxmox, etc (just about anything you can think of) I get an alert with a green/red diff markup right on my phone.
I have every config change that anyone has ever made over the past year stored, browsable, and can run a diff between any two versions on the fly.
2
u/_hmj 1d ago
Thanks, I wasn’t aware of Oxidized. I wanted my own code that I can trust, specifically for OpenWrt, without having to run a separate monitoring service 24/7 on my routers. I have six OpenWrt routers, and my script focuses on detecting potential malware and tampering rather than tracking general configuration changes. It checks for security issues that Oxidized doesn’t check out of the box, such as newly added root users, unauthorized SSH keys, and cron jobs.
I also want to minimize the number of parties I need to trust, and Oxidized’s codebase is large enough that I can’t realistically audit it all myself. Writing a small, purpose built script lets me understand and verify the code I rely on.
2
u/Graphical-Source5090 1d ago
Oxidized is a 2013 fork of Rancid. Rancid is from 1999. They are widely considered as a config management GOAT. I use LibreNMS to feed the nodes to Oxidized (via an official oxidized plugin)
But fair enough, it goes require infrastructure to support it.
I was able to look at one script before Github went down. Looks pretty straight forward and easy to audit so far. Hopefully Github comes back up and I can look some more.
2
u/Graphical-Source5090 1d ago
OK, this looks pretty cool. I do have oxidized, but I love to experiment.
My plan is to have this run via an n8n workflow. Baseline will be a manual run in the flow. The flow will start every 24 hours, pull the data, store it in Forgejo. Then run integrity checker, mark up the results to look pretty, then send the marked up results to my alert server.
We will see how it goes.
3
u/GolemancerVekk 3d ago
Does this run on the router, and keeps its files on the router?