I'm sorry, I forgot to tell you about the Apache rewrite rules. The code red machines will actually be looking for "cmd.exe" so you have to put rewrite rules in that alias those URLs to your cmd.cgi. Here's mine:
- Code: Select all
<IfModule mod_userdir.c>
RewriteEngine on
# Code Red Windows Garbage
RewriteRule ^/codered$ /s/codered.php
RewriteRule ^/codered/$ /s/codered.php
RewriteRule ^/scripts/root.exe$ /z/cmd.cgi
RewriteRule ^/MSADC/root.exe$ /z/cmd.cgi
RewriteRule ^/msadc/root.exe$ /z/cmd.cgi
RewriteRule ^/c/winnt/system32/cmd.exe$ /z/cmd.cgi
RewriteRule ^/d/winnt/system32/cmd.exe$ /z/cmd.cgi
</IfModule>
The above rewrite rules will execute my cmd.cgi script if someone goes to one of these URLs:
http://voidmain.is-a-geek.net/scripts/root.exe
http://voidmain.is-a-geek.net/MSADC/root.exe
http://voidmain.is-a-geek.net/msadc/root.exe
http://voidmain.is-a-geek.net/c/winnt/system32/cmd.exe
http://voidmain.is-a-geek.net/d/winnt/system32/cmd.exe
Go ahead and click any of the above links and you should get the same thing as if you called the cmd.cgi directly:
http://voidmain.is-a-geek.net/z/cmd.cgi
If you unpacked the files in the codered.tar.gz you should have a file called "/public/dir.txt" which is nothing more than a C:\WINNT\SYSTEM32 directory listing of a Win2k Advanced Server, just for effect.
Also note that if you click the above links in your browser you will not actually get blocked because in the script I can tell if it is actually a codered hit or just a browser click. I only block the actual codered hits.
Also, the "cmd.cgi" program, as written, logs to a couple of files, one is "/public/codered.log" and the other is "/public/blocked.log". These files need to be writable by user Apache. After running the script for a couple of days look at those logs and you'll probably have a couple of entries in it. Also, if you do get some codered hits then your apache user must have the authority to run the "/usr/bin/sudo /sbin/block ipaddress" command. Replace "voidmain" in your /etc/sudoers with your own username and then under your user type:
$ /usr/bin/sudo /bin/block 192.168.100.100
You should get no errors. You can check if it is blocked by:
# /sbin/iptables -L -n | grep 192.168.100.100
You can unblock the above address by:
$ /usr/bin/sudo /bin/unblock 192.168.100.100