=^.^=

Portage Errors: app-arch/lzma-utils is blocking app-arch/xz-utils

Gentoo recently made the switch from lzma-utils to xz-utils, to quote the project page at http://tukaani.org/lzma/:

LZMA Utils are legacy data compression software with high compression ratio. LZMA Utils are no longer developed, although critical bugs may be fixed as long as fixing them doesn't require huge changes to the code.

Users of LZMA Utils should move to XZ Utils. XZ Utils support the legacy .lzma format used by LZMA Utils, and can also emulate the command line tools of LZMA Utils. This should make transition from LZMA Utils to XZ Utils relatively easy.

As you are probably aware, Portage has largely used lzma for the past year - before which bzip2 was the compression standard of choice. If alarm bells went off in your head when you saw this message:

[blocks B     ] app-arch/lzma-utils ("app-arch/lzma-utils" is blocking app-arch/xz-utils-4.999.9_beta)

You can rest easy uninstalling lzma, the xz-utils package comes in a good ol' fashioned tarball and it works as a drop-in replacement for it so it's safe to unmerge lzma-utils completely then - before emerging anything else - emerge xz-utils:

# emerge --unmerge lzma-utils; emerge xz-utils

 app-arch/lzma-utils
 selected: 4.32.7
 protected: none   
 omitted: none   

>>> 'Selected' packages are slated for removal.
>>> 'Protected' and 'omitted' packages will not be removed.

>>> Waiting 5 seconds before starting...
>>> (Control-C to abort)...
>>> Unmerging in: 5 4 3 2 1
>>> Unmerging app-arch/lzma-utils-4.32.7...

 * GNU info directory index is up-to-date.
Calculating dependencies... done!

# emerge xz-utils
Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) app-arch/xz-utils-4.999.9_beta
>>> Downloading 'http://gentoo.osuosl.org/distfiles/xz-4.999.9beta.tar.gz'

I'll take this opportunity to point out that in this day and age the word beta has become such a gimmick that Gentoo is including so-called beta software as part of its core system. Back in my day beta meant beta and you had to walk 17 miles uphill both ways to get to the nearest phone jack. Mind you we didn't call them modems in those days, we called em clinkerdinkers....

Way to go, Internet.

Making the Case for Access Controlled Recursive Lookups with BIND

To see how I actually solved this particular problem please see Thwarting the isc.org DDoS

It has long been held as best practice that one should use separate servers for authoritative (server) and recursive (client) domain name services. In some cases, this is not practical - for example I inherited one particular network at an ISP I do consulting for that has had its combined authoritative and recursive DNS servers on the same IP addresses for about a decade. Splitting up the roles of the servers would require either hundreds of clients with statically configured DNS to change their settings (imagine the load on tech support) or dozens of domain-holders to update their registrar glue, assuming their registrar even provides it (another load on tech support).

On this network I had - contrary to the gospel I know only too well - allowed recursive lookups from any source on the Internet for several years. I knew it was ideologically incorrect but have found it immeasurably handy to have a set of memorized nameserver IPs that you know will just work any time, anywhere in the world when you are tech supporting or trying to resolve an issue. No one seemed to notice for the years before and after I took on this client, and I couldn't see the harm if a few folks started using them. It didn't - and still doesn't - make sense to me that a spammer would outsource their DNS operations to a vastly remote location (see updates at bottom, they are spammers but they're actually trying to DDoS), at the cost of not only speed and latency but expensive bandwidth at all.

But today they did.

At around 12:40 I was notified of the situation and began my investigation. Handy-dandy iftop told me it was coming from one IP and they were making DNS requests - good news! The server wasn't hacked - it was just being DoSed as a side-effect of over-querying. In fact, named was performing exceptionally well for a ~5-mbit/s load on a tiny virtual machine used to 150kbit/s, it was only the upstream bandwidth throttling that was keeping the flow in check.

I ran a full port scan on the attacker and much to my surprise it didn't respond to pings and all ports were filtered. I was growing suspicious that this wasn't a typical zombie. I blocked the attacker at the gateway and for a moment the network settled down. Then out of nowhere another attacker from a completely different IP showed up - I gave them a full scan and they too were filtered and unresponsive to ICMP echo requests. The new attacker came from 173.1.52.117.reverse.gogrid.com but forward lookups didn't work. I didn't have to go to their website to realize this was a VPS provider, clearly I was dealing with someone who owned their own kit - an organized spammer. My suspicions confirmed, I knew I would have to give up my little "public" DNS service and implement an Access Control List for recursive lookups.

By the time the third and most aggressive (getting pissed off about the IPs I was blocking?) wave of queries rolled around I had collected a list of all the networks and public addresses which require recursive lookups. Regardless of whether you have your authoritative services separated from your recursive unless your recursive server is on a private network it is best practice (and even then I would recommend it) to implement an ACL.

Open your named.conf and before the global options section, define an ACL as shown below. Notice that address ranges can be specified with CIDR notation:

acl "trusted" {
 localhost;
 192.168.0.0/16;
 172.16.0.0/16;
 10.0.0.0/8;
 192.168.0.1;
 222.222.222.222;
};

Now we can call the trusted ACL with the allow-recursive directive in the global options section. You can define any number of ACLs with different names, we're just going with trusted as an example. Make sure the ACL includes every network and IP address that should have permission to perform recursive lookups - ensure your private subnets, public networks and any stray uplinks or remote locations are included. Those hosts not in the ACL and not performing lookups on domains for which your server is authoritative or already has cached will fail.

options {
 recursion yes;
 allow-recursion { trusted; };
 allow-query-cache { trusted; };
};

Run rndc reload or restart BIND for the changes to take effect.

As you can tell from the bumps in my graph after the giant spike this guy (or these guys) is taking his time trying to figure out what I did, but the good news is he's using less bandwidth and a whole whack of spam ain't goin nowhere. Eventually they will realize that this server isn't doing them any good and they'll move on to greener pastures.

Finally, I got one of the attackers post-ACL to submit to a scan:

bzp ~ # nmap -P0 87.237.229.150

Starting Nmap 5.00 ( http://nmap.org ) at 2010-07-20 18:15 EDT
Interesting ports on 87.237.229.150:
Not shown: 990 closed ports
PORT     STATE    SERVICE
21/tcp   open     ftp
22/tcp   open     ssh
23/tcp   open     telnet
25/tcp   filtered smtp
80/tcp   open     http
139/tcp  filtered netbios-ssn
445/tcp  filtered microsoft-ds
646/tcp  filtered ldp
2000/tcp open     callbook
8291/tcp open     unknown

Nmap done: 1 IP address (1 host up) scanned in 390.66 seconds

Well, that looks like any number of shared hosting servers, I wonder what's on port 80:

An embedded linux routing solution. And their webconfig is wide open to cracking.

MikroTik RouterOS is the operating system of MikroTik RouterBOARD hardware.

It can also be installed on a PC and will turn it into a router with all the necessary features - routing, firewall, bandwidth management, wireless access point, backhaul link, hotspot gateway, VPN server and more.

RouterOS is a stand-alone operating system based on the Linux v2.6 kernel, and our goal here at MikroTik is to provide all these features with a quick and simple installation and an easy to use interface.

You can try RouterOS today, go to www.mikrotik.com and download the installation CD image. The free trial provides all of the features with no limitations.

If I had to guess I'd say this guy went the server route, or maybe he virtualizes his gateways like me. This kind of explains why my port scans are being cut off, a sufficiently advanced firewall like this probably has some sort of Intrusion Prevention mechanism and since I caught them with their web config (and telnet config for that matter) exposed and flapping in the breeze I'd say this is one of the installations my friend the spammer has not completed configuring, hence this one successful scan.

For the interest of Googlers trying to figure out why so and so is blasting the shit out of their name server(s) one IP at a time, here's a list of IPs and PTRs (where available) I've caught so far:

82.225.94.140   sju13-2-82-225-94-140.fbx.proxad.net
173.1.52.117    173.1.52.117.reverse.gogrid.com
74.208.164.54   something from schlund.de
87.237.229.150  RIPE says the block belongs somewhere in Dubai 194.8.74.227    hosted by dragonara.net, listed as comment spammer by project honeypot
75.125.150.106  hosted by ev1servers.net
173.1.52.117   173.1.52.117.reverse.gogrid.com
98.126.124.203 MOLECHART.com
88.191.89.71
74.208.149.208  hosted by schlund.de
78.129.202.96
78.129.202.142
74.208.166.146  hosted by schlund.de
74.198.4.87     Rogers (Wave ???)
174.36.42.115   Italian-show-passion-quality-hostserver.com (lol)
98.126.54.227   98.126.54.227.STATIC.CUSTOMER.KRYPT.COM
74.198.0.53     Rogers (Wave ???)
88.191.109.130
85.25.150.72
173.192.224.100 173.192.224.100-static.reverse.softlayer.com
209.11.242.123  server12.elnastalk.com

Update I found 87.237.229.150 spamming on a strange Iraqi forum that reveals posters' IP addresses to the general public. Strange indeed, but now I know I'm dealing with web form spammers, not e-mail spammers. Here's a sample of the spam found at http://www.iraqal7ob.com/vb/t710.html

The image at the top was hotlinked from a free hosting service, the exact URL was http://hosting.bearzddl.com/uploads/9b0b60d466.jpg. Bearzddl is itself a shady file site and at the time of writing http://hosting.bearzddl.com/uploads/ provides a directory listing of all sorts of spammy looking images that have been uploaded through their free file hosting feature:

Update This morning we were attacked once again, I took the following sample capture:

 11.695249 194.8.74.227 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.695449 xxx.xxx.xxx.xxx -> 194.8.74.227 DNS Standard query response RRSIG RRSIG DS DS NS ams.sns-pb.isc.org NS ns.isc.afilias-nst.info NS ord.sns-pb.isc.org NS sfba.sns-pb.isc.org
 11.705516 194.8.74.227 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.705891 xxx.xxx.xxx.xxx -> 194.8.74.227 DNS Standard query response RRSIG RRSIG DS DS NS ns.isc.afilias-nst.info NS ams.sns-pb.isc.org NS sfba.sns-pb.isc.org NS ord.sns-pb.isc.org
 11.723779 194.8.74.227 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.723787 194.8.74.227 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.723983 194.8.74.227 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.723989 194.8.74.227 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.724154 xxx.xxx.xxx.xxx -> 194.8.74.227 DNS Standard query response RRSIG RRSIG DS DS NS sfba.sns-pb.isc.org NS ams.sns-pb.isc.org NS ns.isc.afilias-nst.info NS ord.sns-pb.isc.org
 11.724333 xxx.xxx.xxx.xxx -> 194.8.74.227 DNS Standard query response RRSIG RRSIG DS DS NS ord.sns-pb.isc.org NS sfba.sns-pb.isc.org NS ns.isc.afilias-nst.info NS ams.sns-pb.isc.org
 11.724495 xxx.xxx.xxx.xxx -> 194.8.74.227 DNS Standard query response RRSIG RRSIG DS DS NS ams.sns-pb.isc.org NS ns.isc.afilias-nst.info NS sfba.sns-pb.isc.org NS ord.sns-pb.isc.org
 11.724648 xxx.xxx.xxx.xxx -> 194.8.74.227 DNS Standard query response RRSIG RRSIG DS DS NS ams.sns-pb.isc.org NS ord.sns-pb.isc.org NS sfba.sns-pb.isc.org NS ns.isc.afilias-nst.info
 11.725244 194.8.74.227 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.725256 194.8.74.227 -> xxx.xxx.xxx.xxx DNS Standard query ANY isc.org
 11.725488 xxx.xxx.xxx.xxx -> 194.8.74.227 DNS Standard query response RRSIG RRSIG DS DS NS sfba.sns-pb.isc.org NS ord.sns-pb.isc.org NS ns.isc.afilias-nst.info NS ams.sns-pb.isc.org
 11.725645 xxx.xxx.xxx.xxx -> 194.8.74.227 DNS Standard query response RRSIG RRSIG DS DS NS ns.isc.afilias-nst.info NS ord.sns-pb.isc.org NS ams.sns-pb.isc.org NS sfba.sns-pb.isc.org

See how this story progressed:

http://foxpa.ws/2010/07/21/thwarting-the-isc-org-dns-ddos/T

Using DFind.exe and Blocking w00tw00t.at.ISC.SANS.DFind

Chances are you've seen something like this in your access/error_logs:

[Tue Jul 13 12:13:54 2010] [error] [client 74.63.218.250] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Tue Jul 13 12:16:45 2010] [error] [client 74.63.218.250] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Wed Jul 14 00:26:44 2010] [error] [client 62.103.39.74] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Wed Jul 14 10:27:20 2010] [error] [client 74.63.218.250] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)
[Wed Jul 14 10:30:11 2010] [error] [client 74.63.218.250] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)

You can start breathing again - it's just the signature of a slightly outdated vulnerability scanner for windows-based script kiddies. I couldn't find anything particularly useful on it with Google so this article will show you not only how to block sources of the scans (they could be zombies equipped with other tools after all) but also how to use it.

You can either download DFind from its project homepage (requires an account) or you can grab it from http://foxpa.ws/dist/DFind_1.0.9.rar and extract it somewhere on a windows box. Your antivirus will probably have a fit since it's a common component of bundled malware, just make it shut up for a bit.

It doesn't come with much in the way of documentation, just a revision.txt file:

Usage:

DFind is a free command line scanner used to be small, fast, introducing a large number of command lines, helping anyone to identify
in one line the kiddie's doors.

Revision:

---x32.1.0.9---
+PestPatrol detects the last MD5 hash of DFind, quick binary update to bypass
+WEBDAV status scanner on IIS/5.0 added.
+Back to VC6 and old mfc, much smaller and stable
+Symantec detected signature gone; "\x20\x20VULNE" is enough for them to classify it as 'HackTool.DFind', this is updated to "\x20\x20VULN...", keep it up sym ;>
+"DFind -update" added to check like a lazy for new updates, this will calculate and compare the md5hash of the file your are using with the one I publish on the website.
---x32.1.0.8---
+No more using MFC libraries, too recents, too buggy...
+'HackTool.DFind' on Symantec 10.0.1.1000 gone
+New compilation moved under Visual Studio 2005 and Platorm SDK.
+x64.1.0.8 compilation available to the website (for the new 64-bit systems).
---------------

http://getdfind.class101.org (32-bit)
http://getdfind32.class101.org (32-bit)
http://getdfind64.class101.org (64-bit)

Note:

The author of this tool isn't responsible of the bad use of it, just try it on (and secure..) your network before the attacker does.

A.D

Pop open a command line and give it a whirl, you'll get a help menu similar to this:

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind.exe

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 MAIN MENU
 =============================================================

[+] Usage: DFind <option> <syntax>
[+] <option>:
 _______________________________________________________
 |___-p___|___+p___|___-pu__|__-ban__|__-web__|__-dde__|
 |__-wdv__|
 _______________________________________________________
 |__-rad__|__-wns__|_-http__|_-sock__|__-ipc__|__-nbn__|
 |__-vnc__|
 _____________
 |__-update__|

[+] Type DFind <option> to look the <syntax>
[+] Number of possibles <syntax>: 973

Here's the help listing for each flag:

================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 TCP port scanner
 =============================================================

[+]  . DFind -p 80 192.168.0.1  [-v]
[+]  . DFind -p 80 192.168.0.0 192.168.0.255  [THREADS] [-v]
[+]  . DFind -p 80 150 192.168.0.1  [THREADS] [-v]
[+]  . DFind -p 80 150 192.168.0.0 192.168.0.255  [THREADS] [-v]
[+]  . DFind -p 1,2,..,9,10 192.168.0.1  [-v]
[+]  . DFind -p 1,2,..,9,10 192.168.0.0 192.168.0.255  [THREADS] [-v]

 If ([THREADS]==NULL) thread=500, maximum allowed=2500

 visit class101.org for more informations

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind +p

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 PING port scanner
 =============================================================

[+]  . DFind +p 80 192.168.0.1  [-v]
[+]  . DFind +p 80 192.168.0.0 192.168.0.255  [THREADS] [-v]
[+]  . DFind +p 80 150 192.168.0.1  [THREADS] [-v]
[+]  . DFind +p 80 150 192.168.0.0 192.168.0.255  [THREADS] [-v]
[+]  . DFind +p 1,2,..,9,10 192.168.0.1  [-v]
[+]  . DFind +p 1,2,..,9,10 192.168.0.0 192.168.0.255  [THREADS] [-v]

 If ([THREADS]==NULL) thread=500, maximum allowed=2500

 visit class101.org for more informations

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind -pu

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 UDP port scanner
 =============================================================

[+]  . DFind -pu 80 192.168.0.1  [-v]
[+]  . DFind -pu 80 192.168.0.0 192.168.0.255  [THREADS] [-v]
[+]  . DFind -pu 80 150 192.168.0.1  [THREADS] [-v]
[+]  . DFind -pu 80 150 192.168.0.0 192.168.0.255  [THREADS] [-v]
[+]  . DFind -pu 1,2,..,9,10 192.168.0.1  [-v]
[+]  . DFind -pu 1,2,..,9,10 192.168.0.0 192.168.0.255  [THREADS] [-v]

 If ([THREADS]==NULL) thread=500, maximum allowed=2500

 visit class101.org for more informations

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind -ban

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 BANNER port scanner
 =============================================================

[+] . DFind -ban 80 192.168.0.1  [-v] [-spy "text"]
[+] . DFind -ban 80 192.168.0.0 192.168.0.255  [THREADS] [-v] [-spy "text"]
[+] . DFind -ban 80 150 192.168.0.1  [THREADS] [-v] [-spy "text"]
[+] . DFind -ban 80 150 192.168.0.0 192.168.0.255  [THREADS] [-v] [-spy "text"]
[+] . DFind -ban 1,.,10 192.168.0.1  [-v] [-spy "text"]
[+] . DFind -ban 1,.,10 192.168.0.0 192.168.0.255  [THREADS] [-v] [-spy "text"]

 [-spy "text"] == case sensitive

 If ([THREADS]==NULL) thread=500, maximum allowed=2500

 visit class101.org for more informations

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind -web

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 WEBSERVER BANNER port scanner
 =============================================================

[+] . DFind -web 192.168.0.1  [-v] [-spy "text"]
[+] . DFind -web 192.168.0.0 192.168.0.255  [THREADS] [-v] [-spy "text"]
[+] . DFind -web 80 192.168.0.1  [-v] [-spy "text"]
[+] . DFind -web 80 192.168.0.0 192.168.0.255  [THREADS] [-v] [-spy "text"]
[+] . DFind -web 80 150 192.168.0.1  [THREADS] [-v] [-spy "text"]
[+] . DFind -web 80 150 192.168.0.0 192.168.0.255  [THREADS] [-v] [-spy "text"]
[+] . DFind -web 1,.,10 192.168.0.1  [-v] [-spy "text"]
[+] . DFind -web 1,.,10 192.168.0.0 192.168.0.255  [THREADS] [-v] [-spy "text"]

 [-spy "text"] == case sensitive

 If ([THREADS]==NULL) thread=500, maximum allowed=2500

 visit class101.org for more informations

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind -dde

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 Microsoft NETDDE port scanner
 -----------------------
 ripped from HOD exploit with a recoded nbname checking
 =============================================================

[+]  . DFind -dde 192.168.0.1  [-v]
[+]  . DFind -dde 192.168.0.0 192.168.0.255  [THREADS] [-v]

 If ([THREADS]==NULL) thread=500, maximum allowed=2500

 visit class101.org for more informations

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind -rad

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 Famatech LLC RAdmin 2.1 vulnerability scanner
 =============================================================

[+]  . DFind -rad 192.168.0.1  [-v|-vv]
[+]  . DFind -rad 192.168.0.0 192.168.0.255  [THREADS] [-v|-vv]
[+]  . DFind -rad 80 192.168.0.1  [-v|-vv]
[+]  . DFind -rad 80 192.168.0.0 192.168.0.255  [THREADS] [-v|-vv]
[+]  . DFind -rad 80 150 192.168.0.1  [THREADS] [-v|-vv]
[+]  . DFind -rad 80 150 192.168.0.0 192.168.0.255  [THREADS] [-v|-vv]
[+]  . DFind -rad 1,2,..,9,10 192.168.0.1  [-v|-vv]
[+]  . DFind -rad 1,2,..,9,10 192.168.0.0 192.168.0.255  [THREADS] [-v|-vv]

 If ([THREADS]==NULL) thread=500, maximum allowed=2500

 visit class101.org for more informations

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind -nns

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==

[+] wrong command line, type DFind to view the main menu

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind -wns

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 Microsoft WINS MS04-045 vulnerability and os/sp scanner
 =============================================================

[+]  . DFind -wns 192.168.0.1  [-v|-vv]
[+]  . DFind -wns 192.168.0.0 192.168.0.255  [THREADS] [-v|-vv]

 If ([THREADS]==NULL) thread=500, maximum allowed=2500

 visit class101.org for more informations

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind -http

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 Anonymous/Transparent/High-Anon HTTP proxy scanner
 =============================================================

[+]  . DFind -http 192.168.0.1  [-v]
[+]  . DFind -http 192.168.0.0 192.168.0.255  [THREADS] [-v]
[+]  . DFind -http 80 192.168.0.1  [-v]
[+]  . DFind -http 80 192.168.0.0 192.168.0.255  [THREADS] [-v]
[+]  . DFind -http 80 150 192.168.0.1  [THREADS] [-v]
[+]  . DFind -http 80 150 192.168.0.0 192.168.0.255  [THREADS] [-v]
[+]  . DFind -http 1,2,..,9,10 192.168.0.1  [-v]
[+]  . DFind -http 1,2,..,9,10 192.168.0.0 192.168.0.255  [THREADS] [-v]

 If ([THREADS]==NULL) thread=500, maximum allowed=2500

 visit class101.org for more informations

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind -sock

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 Anonymous SOCKS5 proxy scanner
 =============================================================

[+]  . DFind -sock 192.168.0.1  [-v]
[+]  . DFind -sock 192.168.0.0 192.168.0.255  [THREADS] [-v]
[+]  . DFind -sock 80 192.168.0.1  [-v]
[+]  . DFind -sock 80 192.168.0.0 192.168.0.255  [THREADS] [-v]
[+]  . DFind -sock 80 150 192.168.0.1  [THREADS] [-v]
[+]  . DFind -sock 80 150 192.168.0.0 192.168.0.255  [THREADS] [-v]
[+]  . DFind -sock 1,2,..,9,10 192.168.0.1  [-v]
[+]  . DFind -sock 1,2,..,9,10 192.168.0.0 192.168.0.255  [THREADS] [-v]

 If ([THREADS]==NULL) thread=500, maximum allowed=2500

 visit class101.org for more informations

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind -ipc

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 Microsoft NETBIOS NULL SESSION port scanner
 =============================================================

[+]  . DFind -ipc 192.168.0.1  [-v]
[+]  . DFind -ipc 192.168.0.0 192.168.0.255  [THREADS] [-v]

 If ([THREADS]==NULL) thread=500, maximum allowed=2500

 visit class101.org for more informations

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind -nbn

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 Microsoft NETBIOS NAME port scanner
 -----------------------------
 ripped from HOD exploit with a recoded nbname checking
 =============================================================

[+]  . DFind -nbn 192.168.0.1  [-v]
[+]  . DFind -nbn 192.168.0.0 192.168.0.255  [THREADS] [-v]

 If ([THREADS]==NULL) thread=500, maximum allowed=2500

 visit class101.org for more informations

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind -vnc

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 VNC4 systems vulnerability scanner
 =============================================================

[+]  . DFind -vnc 192.168.0.1  [-v|-vv]
[+]  . DFind -vnc 192.168.0.0 192.168.0.255  [THREADS] [-v|-vv]
[+]  . DFind -vnc 80 192.168.0.1  [-v|-vv]
[+]  . DFind -vnc 80 192.168.0.0 192.168.0.255  [THREADS] [-v|-vv]
[+]  . DFind -vnc 80 150 192.168.0.1  [THREADS] [-v|-vv]
[+]  . DFind -vnc 80 150 192.168.0.0 192.168.0.255  [THREADS] [-v|-vv]
[+]  . DFind -vnc 1,2,..,9,10 192.168.0.1  [-v|-vv]
[+]  . DFind -vnc 1,2,..,9,10 192.168.0.0 192.168.0.255  [THREADS] [-v|-vv]

 If ([THREADS]==NULL) thread=500, maximum allowed=2500

 visit class101.org for more informations

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind -update

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 DFind updates checker
 =============================================================

[+] -----Calculating the MD5 hash (actual binary:32-bit)-----
[+] "dfind.exe" => 3188826a5c39dd49d0ef3ce3d7bea1c2
[+] -----Retrieving the MD5 hash (official binary:32-bit)-----
[+] "official md5" => 3188826a5c39dd49d0ef3ce3d7bea1c2
[+]
[+] Your version is up to date, no updates required

As you can see it sports an automatic update feature and its small size makes it perfect for bundling in a trojan payload. If you guessed the -web flag was responsible for the log entries you win a gold star:

C:\Documents and Settings\Administrator\My Documents\Downloads>dfind.exe -web xxx.
xxx.xxx.xxx

 ================================================[rev-1.0.9]==
 ==============DFind - #1 Tiny Security Scanner===============
 ============multi-threaded for Linux and Windows=============
 ===================================================[32-bit]==
 WEBSERVER BANNER port scanner
 =============================================================

[+] status..: 100% thread(s):0
[+] results.: 1 / 5 PORT(s) / 1 IP(s) (open:1)

Showed up as this in my error_log:

[Wed Jul 14 15:56:55 2010] [error] [client yyy.yyy.yyy.yyy] client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /w00tw00t.at.ISC.SANS.DFind:)

Since this error is generated by requests missing the mandatory (in HTTP 1.1 but not 1.0) Host header it begs the question if this is just the result of sloppy programming or an intended signature. Either way we can take advantage of it to block hosts using the -web flag. BobA on the hostgator forums suggests blocking these requests with some mod_rewrite rules:

RewriteEngine on
# Block undesired user-agents
RewriteCond %{HTTP_USER_AGENT} ^w00tw00t.at.ISC.SANS.DFind
RewriteRule ^.*$ http://www.thenameofmydomain.com/403.html [L]

That doesn't really do us any good. Port scanning will still show an exposed web server, which is about all the output you get with the -web flag anyway. Chances are good that if you're being scanned by this thing it's not the only tool in the zombie's box either. We need something that will IP-block the bugger so they can't keep scanning.

We need a Snort rule:

alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:"WEB-MISC DFind Web Server Scan"; flow:to_server,established; uricontent:".at.ISC.SANS.DFind"; reference:foxpa.ws,301; classtype:web-application-attack; sid:4000001; rev:1; fwsam: src, 1 day;)

You'll notice I dropped the w00tw00t, it seems some folks are getting test0 and other prefixes and the chances of the rest of the string popping up in your URLs legitimately are fairly slim. Pop this into your snort ruleset somewhere (make sure the SID doesn't conflict with any other custom rules) and restart, with the addition of snortsam or a similar IPS add-on attackers should now find themselves automatically firewalled.

Securing /tmp the Cheap Hooker Way

Numerous exploits take advantage of /tmp's open nature by uploading scripts or executables to it, then running them from it. While we may or may not be able to do something about the scripts being uploaded (not really possible in a shared hosting environment where any number of unknown clients' scripts and so on have to be run regardless of their flaws) we can certainly keep them from being run from within /tmp. The noexec mount option makes it impossible to run shell scripts or binaries directly from a filesystem that has been mounted with it. The nosuid option keeps people from using or setting the setuid flag on any files.

If you're not using LVM or you're working with virtual machines tossing on another partition might not be practical. Fortunately /tmp works just as well when mounted from a partition image file. Follow through these shell commands, replacing the count= value for dd to whatever size you would like to make the /tmp image in megs. You won't need much space, on a typical shared hosting server the most one tends to find in there is session data. You are welcome to make a sparse file image however the frequency of writes and deletes as well as the small required size makes this less practical than it might sound. I think 256 megs is a nice round number, unless you're doing something fancy that actually needs /tmp files.

# dd if=/dev/zero of=/tmp.img bs=1M count=256
# mke2fs -j /tmp.img
# chmod 600 /tmp.img
# mkdir /mnt/tmp
# mount -o loop /tmp.img /mnt/tmp
# mv /tmp/* /mnt/tmp/
# umount /mnt/tmp
# rmdir /mnt/tmp
# mount -o loop,noexec,nosuid /tmp.img /tmp
# chmod 777 /tmp
# chmod +t /tmp

Now we can add the image to our /etc/fstab to ensure that it automounts on boot:

/tmp.img                /tmp            ext3            loop,nosuid,noexec      1 2

Mass Virtual Hosting Part Seven: Securing PHP with Suhosin

Suhosin is a Korean word which, roughly translated, means guardian angel. It is also the name of a clever PHP extension brought to us by the Hardened-PHP Project. When I found out it could provide transparent on-the-fly session and cookie encryption I thought sexual thoughts and sped off to install it. Fortunately for gentoo users, it's a simple matter of adding the suhosin USE flag to PHP and (re)compiling:

# echo "dev-lang/php suhosin" >> /etc/portage/package.use
# emerge --newuse php

In fact, now is probably a good time to reevaluate your PHP USE flags; I tend to disable a bunch of functions that would simply not exist if certain extensions were not compiled in at all. This is what your stripped-down flags might look like:

[ebuild R ] dev-lang/php-5.2.13 USE="apache2 bcmath berkdb bzip2 cgi cli crypt ctype exif filter gd hash iconv ipv6 json mysql mysqli ncurses nls pcntl pcre pdo readline reflection session simplexml snmp spl ssl suhosin threads truetype unicode xml zip zlib -adabas -birdstep -calendar -cdb -cjk -concurrentmodphp -curl -curlwrappers -db2 -dbase -dbmaker -debug -discard-path -doc -empress -empress-bcs -esoob -fastbuild -fdftk -firebird -flatfile -force-cgi-redirect -frontbase -ftp -gd-external -gdbm -gmp -imap -inifile -interbase -iodbc (-java-external) -kerberos -kolab -ldap -ldap-sasl -libedit -mcve -mhash -msql -mssql -oci8 -oci8-instant-client -odbc -pic -posix -postgres -qdbm -recode -sapdb -sharedext -sharedmem -soap -sockets -solid -spell -sqlite -sybase -sybase-ct -sysvipc -tidy -tokenizer -wddx -xmlreader -xmlrpc -xmlwriter -xpm -xsl -yaz"

Once you've recompiled you're going to have to add the Suhosin configuration directives to your php.ini. For apache open /etc/php/apache-php5/php.ini and tack this on to the end:

; Logging
suhosin.log.syslog = S_ALL
suhosin.log.syslog.facility = LOG_USER
suhosin.log.syslog.priority = LOG_WARNING
suhosin.log.sapi = S_ALL
;suhosin.log.script
;suhosin.log.phpscript
;suhosin.log.script.name
;suhosin.log.phpscript.name
;suhosin.log.use-x-forwarded-for

; Executor Options
suhosin.executor.max_depth = 1000000
suhosin.executor.include.max_traversal = 3
;suhosin.executor.include.whitelist
;suhosin.executor.include.blacklist
;suhosin.executor.func.whitelist
suhosin.executor.func.blacklist = ""
;suhosin.executor.eval.whitelist
suhosin.executor.eval.blacklist = ""
suhosin.executor.disable_eval = On
suhosin.executor.disable_emodifier = On
suhosin.executor.allow_symlink = Off

; Misc Options
suhosin.simulation = Off
suhosin.apc_bug_workaround = Off
suhosin.sql.bailout_on_error = On
;suhosin.sql.user_prefix
;suhosin.sql.user_postfix
suhosin.multiheader = On
suhosin.mail.protect = 2
;suhosin.memory_limit

; Transparent Encryption Options
suhosin.session.encrypt = On
suhosin.session.cryptkey = "INSERT RANDOM CRAP HERE"
suhosin.session.cryptua = On
suhosin.session.cryptdocroot = On
suhosin.session.cryptraddr = 2
suhosin.session.checkraddr = 2
suhosin.cookie.encrypt = On
suhosin.cookie.cryptkey = "INSERT RANDOM CRAP HERE"
suhosin.cookie.cryptua = On
suhosin.cookie.cryptdocroot = On
suhosin.cookie.cryptraddr = 2
suhosin.cookie.checkraddr = 2
;suhosin.cookie.cryptlist
;suhosin.cookie.plainlist

; Filtering Options
suhosin.filter.action = 402
suhosin.cookie.max_array_depth = 100
suhosin.cookie.max_array_index_length = 64
suhosin.cookie.max_name_length = 64
suhosin.cookie.max_totalname_length = 256
suhosin.cookie.max_value_length = 10000
suhosin.cookie.max_vars = 100
suhosin.cookie.disallow_nul = On
suhosin.get.max_array_depth = 50
suhosin.get.max_array_index_length = 64
suhosin.get.max_name_length = 64
suhosin.get.max_totalname_length = 256
suhosin.get.max_value_length = 512
suhosin.get.max_vars = 100
suhosin.get.disallow_nul = On
suhosin.post.max_array_depth = 100
suhosin.post.max_array_index_length = 64
suhosin.post.max_name_length = 64
suhosin.post.max_totalname_length = 256
suhosin.post.max_value_length = 50000000
suhosin.post.max_vars = 200
suhosin.post.disallow_nul = On
suhosin.request.max_array_depth = 100
suhosin.request.max_array_index_length = 64
suhosin.request.max_totalname_length = 256
suhosin.request.max_value_length = 65000
suhosin.request.max_vars = 200
suhosin.request.max_varname_length = 64
suhosin.request.disallow_nul = On
suhosin.upload.max_uploads = 25
suhosin.upload.disallow_elf = On
suhosin.upload.disallow_binary = Off
suhosin.upload.remove_binary = Off
;suhosin.upload.verification_script
suhosin.session.max_id_length = 128

Now head over to http://www.hardened-php.net/suhosin/configuration.html and tailor the configuration to suit your environment. Don't forget to blacklist dangerous functions like apache_child_terminate, apache_setenv, define_syslog_variables, eval, exec, ftp_connect, ftp_exec, ftp_get, ftp_login, ftp_nb_fput, ftp_put, ftp_raw, ftp_rawlist, highlight_file, ini_alter, ini_get_all, ini_restore, inject_code, openlog, passthru, php_uname, phpAds_remoteInfo, phpAds_XmlRpc, phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, posix_setuid, posix_uname, proc_close, proc_get_status, proc_nice, proc_open, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode, exec, pipe, set_time_limit, popen, proc_open, parse_ini_file, show_source, mail, dl, ini_set, ini_alter, virtual, openlog, apc_add, apc_bin_dump, apc_bin_dumpfile, apc_bin_loadfile, apc_cache_info, apc_cas, apc_clear_cache, apc_compile_file, apc_dec, apc_define_constants, apc_delete_file, apc_delete, apc_exists, apc_fetch, apc_inc, apc_load_constants, apc_store, symlink and eval!

It seems Suhosin provides its own stack-smashing protection, potentially removing the need for the slow PIC (-fstack_protector_all) compile-time option. Until I get confirmation on this I'll be using both just to be safe.