Skip to content

Instantly share code, notes, and snippets.

@mgeeky
Last active November 26, 2017 06:33
Show Gist options
  • Save mgeeky/cfd5dfc1ff10e613090eb9a99a250c24 to your computer and use it in GitHub Desktop.
Save mgeeky/cfd5dfc1ff10e613090eb9a99a250c24 to your computer and use it in GitHub Desktop.
Quick & dirty cleaner for PHP malware: 'php.brute.bf1lic.1??.UNOFFICIAL'
#!/bin/bash
echo "Quick & dirty cleaner for PHP malware: 'php.brute.bf1lic.187.UNOFFICIAL'"
echo
function disinfect {
infected=$1
echo "Disinfected file: ($infected)"
sed -i -r -e 's/<\?php if\(\!isset\(\$GLOBALS\["[\\x0-9a-fA-F]+"\]\)\) \{ \$ua=strtolower\(\$_SERVER\["[\\x0-9a-fA-F]+.+ \?><\?php/<?php/g' $infected
}
IFS=$'\n'
count=0
for infected in $(grep -Elr '<\?php if\(\!isset\(\$GLOBALS\["[\\x0-9a-fA-F]+"\]\)\) { \$ua=strtolower\(\$_SERVER\["[\\x0-9a-fA-F]+' .)
do
disinfect $infected
count=$((count + 1))
done
echo "[+] Disinfected: $count"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment