Rabu, 31 Desember 2003

Administering Servers with Webmin

I've been trying Webmin on FreeBSD, Solaris 8, and HP-UX 11i today. Once I repatriate my AIX box from my employer, I intend to install Webmin on it as well. For FreeBSD, I installed the package provided by the FreeBSD project. For Solaris, I used the package provided by Webmin. For HP-UX, I downloaded the tarball and installed from source. I tried the version packaged by HP with their port of Apache and Tomcat, but couldn't get it to install on its own. Webmin uses its own "miniserv.pl" so Apache is not needed.

Webmin is a Web-based, cross-platform system administration tool. Although I'm not a huge fan of Web-based interfaces, Webmin is slick. I recommend installing the Swelltech theme, which is cleaner than the default.

Using Webmin I successfully installed the lsof package for FreeBSD and Solaris. I didn't have any luck with the same package for HP-UX. Webmin allows you to run commands through the Web browser, so once lsof was installed on FreeBSD and Solairs I ran it and viewed the output in the browser.

One of my favorite aspects of Webmin is its package browsing features. You can peruse the installed software very easily. Webmin also makes browsing logfiles a snap.

Webmin's OS support is vast, since it's written in Perl. I noticed however that not all actions work as well as I'd like. For example, when trying to edit the FreeBSD bootup scripts, I was only given the option of editing /etc/rc.local. I expected to edit /etc/rc.conf or scripts in /usr/local/etc/rc.d. I may have been looking in the wrong place, though.

The two books written about Webmin are both available on the Web for free. The book written by Webmin's author is part of the Bruce Perens Open Source Series and can be downloaded in zipped .pdf. Swelltech's CEO wrote a book and provides it here.

Besides Webmin, there's also Usermin, designed for end-user work. It's good for reading mail. Virtualmin is a virtual hosting management system developed by the Webmin author under contract with Swelltech.

Senin, 29 Desember 2003

Security 101 Book

Today I was asked for my recommendation for a "security 101" book. I hadn't given the subject much thought, although I think Ed Skoudis' Counter-Hack is a great place to start. I looked around my office and found a book Addison-Wesley sent me last year: Internet Site Security by Erik Schetina, Ken Green, Jacob Carlson. After thumbing through the book, I've decided it's excellent. I won't review it on Amazon.com, since my policy is to only review books I've read. Still, a mention here is worthwhile.

This book is so solid I adopted its "assess -> protect -> detect -> respond" security process model to replace the "plan -> prevent -> detect -> respond" version in my own book, just to avoid reinventing the wheel. They also correct state the risk equation as "risk = threat X vulnerability X asset value." If you're looking to get your feet wet in security, or if you're a manager who needs to learn the fundamentals, Internet Site Security is a fine starting point.

Using Sysmon to Detect Faulty Hardware

No sooner had I posted the entry on Sysmon than it detected a network problem. Two of my systems were unreachable. They both sat of a DMZ leg of my gateway. After troubleshooting at various layers I narrowed the issue down to a faulty NIC in the gateway. How often does that happen? Unfortunately the bad NIC is a Intel PRO/100+ Dual Port Server Adapter (PILA8472). When trying to ping out from the NIC to the DMZ, here's the sort of traffic the NIC generated:


00:39:18.628691 192.168.60.1 > 192.168.60.3: icmp: echo request

00:39:19.638731 0:0:0:0:0:0 > 0:0:0:0:0:0 sap 00 I (s=0,r=0,C) len=80

0000 0000 0000 0000 0000 0000 0000 0000

0000 0000 0000 0000 0000 0000 0000 0000

0000 0000 0000 0000 0000 0000 0000 0000

0000 0000 0000 0000 0000 0000 0000 0000

0000 0000 0000 0000 0000 0000 0000 0000

00:39:20.648696 0:0:0:0:0:0 > 0:0:0:0:0:0 sap 00 I (s=0,r=0,C) len=80

0000 0000 0000 0000 0000 0000 0000 0000

0000 0000 0000 0000 0000 0000 0000 0000

0000 0000 0000 0000 0000 0000 0000 0000

0000 0000 0000 0000 0000 0000 0000 0000

0000 0000 0000 0000 0000 0000 0000 0000

00:39:21.658706 192.168.60.1 > 192.168.60.3: icmp: echo request

00:39:22.668711 192.168.60.1 > 192.168.60.3: icmp: echo request

00:39:23.678706 192.168.60.1 > 192.168.60.3: icmp: echo request

00:39:24.688706 192.168.60.1 > 192.168.60.3: icmp: echo request

00:39:25.698714 0:0:0:0:ff:54 0:0:0:0:0:0 2410 98:

8d44 2414 50f7 4054 0000 0200 7503 8e68

14b8 5801 0000 50cd 80eb fe90 ff54 2410

8d44 2414 50f7 4018 0000 0200 7503 8e68

44c7 404c 16d5 0100 b858 0100 0050 cd80

ebfe 89f6 2c8f 1128 0100 0000 0cfe bfbf

0100 0000


That is truly bizarre. I replaced the NIC with an Adaptec ANA-62044 PCI quad NIC.

FreeBSD on Laptops

I thought the best I could do for help running FreeBSD on laptops was Linux on Laptops, until I learned of the FreeBSD Laptop Compatibility List. This site even had an entry for my Thinkpad a20p. There's an article at Freebsd.org and another database of information also available.

I've had various versions of FreeBSD running on this laptop since I tried installing FreeBSD 4.1.1. I plan to install FreeBSD 5.2 REL once issues in the todo list are solved.

Sabtu, 27 Desember 2003

Understanding Snort DNS TTL Alerts

While reading a recent Network Computing magazine article, I noticed an interesting discussion of "DNS-based route optimizers." These sounded like the products which confused IDS operators four years ago. I read about it in an earlier NWC article.

This December 2003 article states:

"Handling external Web requests... is accomplished by advertising a low DNS TTL of about 10 seconds. This forces the end user's DNS server to request an updated IP address every 10 seconds... the device will provide the external IP address that will provide the best path through the network."

The whole idea with DNS-based systems is to trick clients into visiting the server that's "closest" to them in Internet space. By "closest" I mean the one offering the lowest latency. It's a performance enhancement for visitors.

NWC's graphic does a nice job explaining the system.

Notice the mention of "probes." The review mentions ICMP and TCP-based "probes" in its product feature list. NSM analysts might see these probes and consider them suspicious, when they're normal and harmless.

This made me think of recent alerts I'd seen in Sguil, based on this Snort rule:

alert udp $EXTERNAL_NET 53 -> $HOME_NET any
(msg:"DNS SPOOF query response with TTL of 1 min. and no authority";
content:"|81 80 00 01 00 01 00 00 00 00|";
content:"|c0 0c 00 01 00 01 00 00 00 3c 00 04|";
classtype:bad-unknown; sid:254; rev:3;)

This rule was written to detect intruders responding to a victim's DNS query before the legitimate DNS server does. Whether this is worthwhile is debatable, especially since the rule uses the DNS TTL of exactly one minute. An intruder who uses 59 or 61 seconds evades this rule.

Here is Ethereal's look for one of the DNS responses which triggered this Snort rule. I queried for www.orbitz.com, and the DNS record it returned had a TTL of 1 minute and no authority records. Because the DNS TTL is so low, www.orbitz.com might be using a DNS optimization scheme like that mentioned in NWC.
Compare that to a response for images.amazon.com, where the TTL for the first record is 0, the second has is 5 hours 32 minutes, and the third is 20 seconds. Amazon.com appears to use Akamai extensively:

Finally, keep those responses in mind when looking at the DNS info for a smaller company like Sourcefire that doesn't need to play DNS tricks:

This mini-case study shows how keeping current on Internet infrastructure products helps NSM analysts understand their alerts.

Ways to Install FreeBSD

While perusing the newgroups at unix.derkeiler.com, I learned a new way to get FreeBSD. The FreeBSD Project publishes .iso images of its release software, like 4.9 REL or 5.1 REL. Easy enough. Mirrors for these distributions are available at FreeBSD mirrors.

However, I discovered the FreeBSD Snapshots site offers .iso images of the latest version of each tree, e.g., 4-stable and 5-current. You can download the .iso and finish with a system running the newest FreeBSD, assuming they work on your hardware. If you're more conservative, they maintain a "security release" of the 4.8 distribution as well, which right now is 4.8-RELEASE-p13.

You can even finger their server to learn the newest builds available there:

finger @snapshots.jp.freebsd.org

[snapshots.jp.freebsd.org]
FreeBSD/i386:
The latest version of FreeBSD -CURRENT is: 5.2-CURRENT-20031227-JPSNAP
The latest version of FreeBSD 4-STABLE is: 4.9-STABLE-20031202-JPSNAP
FreeBSD/alpha:
The latest version of FreeBSD -CURRENT is: 5.2-CURRENT-20031227-JPSNAP

More information: finger info@snapshots.jp.FreeBSD.org
Service index: finger help@snapshots.jp.FreeBSD.org

I also learned of two new projects to create CD-ROM based FreeBSD systems, like Knoppix: FreeSBIE and the FreeBSD live-FS project. The original live CD project is LiveCD, which exists in the ports tree.

In miscellaneous news, I tried two new MBLA3300 Intel PRO/100 CardBus II PCMCIA NICs on my Thinkpad a20p running FreeBSD 5.1 REL. I intend to use them for a mobile NSM platform. I found that they were recognizes as fxp0 and fxp1, but only if I booted with one NIC in the top PCMCIA slot or both in the two slots. One NIC in the bottom slot didn't work!

I'm going to put 5.2 REL on the laptop when the new release is published next month. I may followed this thread's guidance on disabling ACPI and enabling APM. I learned how to create a restore partition here. If my XFree86 fonts are ugly, I'll try the guidance in the XFree86 Font De-uglification HOWTO. At some point I may buy a new laptop with no OS installed, like this.

Jumat, 26 Desember 2003

Adding a New Disk in NetBSD

People complain about FreeBSD's '/stand/sysinstall' program, but I wish I could have used it yesterday when adding an 8 GB HDD to my NetBSD box. I loosely followed the official documentation but laughed when I read "Now we create some disklabel partitions, editing the tempfile as already explained. The result is...", followed by a disklabel output created from scratch! This reminded me of the "intuitively obvious" phrase from my college calculus books.

Here's how I did it. This is what the disk looked in dmesg output:


wd1 at pciide0 channel 0 drive 1:

wd1: drive supports 16-sector PIO transfers, LBA addressing

wd1: 8063 MB, 16383 cyl, 16 head, 63 sec, 512 bytes/sect x 16514064 sectors

wd1: 32-bit data port

wd1: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 2 (Ultra/33)

wd1(pciide0:0:1): using PIO mode 4, Ultra-DMA mode 2 (Ultra/33) (using DMA data

transfers)


First I ran fdisk. Notice the BIOS never seems to get the HDD geometry correct. Luckily the OS makes good guesses and I remembered the geometry when I saw it on the HDD label:


bash-2.05b# fdisk -u wd1

Disk: /dev/rwd1d

NetBSD disklabel disk geometry:

cylinders: 16383 heads: 16 sectors/track: 63 (1008 sectors/cylinder)



BIOS disk geometry:

cylinders: 1023 heads: 255 sectors/track: 63 (16065 sectors/cylinder)



Do you want to change our idea of what BIOS thinks? [n] y

BIOS's idea of #cylinders: [1023] 16383

BIOS's idea of #heads: [255] 16

BIOS's idea of #sectors: [63] 63

Disk: /dev/rwd1d

NetBSD disklabel disk geometry:

cylinders: 16383 heads: 16 sectors/track: 63 (1008 sectors/cylinder)



BIOS disk geometry:

cylinders: 16383 heads: 16 sectors/track: 63 (1008 sectors/cylinder)



Are you happy with this choice? [n] y

Partition table:

The data for partition 0 is:

sysid 11 (Primary DOS with 32 bit FAT)

start 63, size 5445972 (2659 MB), flag 0x80

beg: cylinder 0, head 1, sector 1

end: cylinder 338, head 254, sector 63

Do you want to change it? [n] y

sysid: [11] 169

start: [63]

size: [5445972] 8000M

8000M is not a valid decimal number.

size: [5445972] 16384000

Explicitly specify beg/end address? [n] n

sysid 169 (NetBSD)

start 63, size 16384000 (8000 MB), flag 0x80

beg: cylinder 0, head 1, sector 1

end: cylinder 894, head 0, sector 31

Is this entry okay? [n] y

The data for partition 1 is:

sysid 15 (Ext. partition - LBA)

start 5446035, size 11020590 (5381 MB), flag 0x0

beg: cylinder 339, head 0, sector 1

end: cylinder 1022, head 254, sector 63

Extended partition table:

0: sysid 11 (Primary DOS with 32 bit FAT)

start 5446098, size 5510232 (2690 MB), flag 0x0

beg: cylinder 339, head 1, sector 1

end: cylinder 681, head 254, sector 63

1: sysid 5 (Extended partition)

start 10956330, size 5510295 (2690 MB), flag 0x0

beg: cylinder 682, head 0, sector 1

end: cylinder 0, head 254, sector 63

Extended partition table:

0: sysid 11 (Primary DOS with 32 bit FAT)

start 10956393, size 5510232 (2690 MB), flag 0x0

beg: cylinder 682, head 1, sector 1

end: cylinder 0, head 254, sector 63

1:

2:

3:

2:

3:

Do you want to change it? [n] y

sysid: [15] 0

start: [5446035] 0

size: [11020590] 0

Explicitly specify beg/end address? [n]



Is this entry okay? [n] y

The data for partition 2 is:



Do you want to change it? [n] n

The data for partition 3 is:



Do you want to change it? [n] n



We haven't written the MBR back to disk yet. This is your last chance.

Disk: /dev/rwd1d

NetBSD disklabel disk geometry:

cylinders: 16383 heads: 16 sectors/track: 63 (1008 sectors/cylinder)



BIOS disk geometry:

cylinders: 16383 heads: 16 sectors/track: 63 (1008 sectors/cylinder)



Partition table:

0: sysid 169 (NetBSD)

start 63, size 16384000 (8000 MB), flag 0x80

beg: cylinder 0, head 1, sector 1

end: cylinder 894, head 0, sector 31

1:

2:

3:

Should we write new partition table? [n] y


Next I created a disklabel:


bash-2.05b# disklabel -i -I wd1


Basically I messed around with disklabel until something that looked ok was produced. I'm not sure how to get rid of the 'd' and 'e' entries or if it's possible. My understanding is that a is the 'root' partition, 'b' is usually the swap file, 'c' is the entire disk, and 'd' and on are other paritions. This is a second non-booting disk:


8 partitions:

# size offset fstype [fsize bsize cpg/sgs]

a: 16514001 63 4.2BSD 0 0 0 # (Cyl. 0*- 16382)

c: 16514064 0 unused 0 0 # (Cyl. 0 - 16382)

d: 16514064 0 unused 0 0 # (Cyl. 0 - 16382)

e: 16384000 63 unused 0 0 # (Cyl. 0*- 16254*)


Then I did 'newfs':


bash-2.05b# newfs /dev/wd1a



Warning: 64 sector(s) in last cylinder unallocated

/dev/wd1a: 16514000 sectors in 16383 cylinders of 16 tracks, 63 sectors

8063.5MB in 50 cyl groups (328 c/g, 161.44MB/g, 20352 i/g)

super-block backups (for fsck -b #) at:

32, 330720, 661408, 992096, 1322784, 1653472, 1984160,

2314848, 2645536, 2976224, 3306912, 3637600, 3968288, 4298976,

4629664, 4960352, 5290016, 5620704, 5951392, 6282080, 6612768,

6943456, 7274144, 7604832, 7935520, 8266208, 8596896, 8927584,

9258272, 9588960, 9919648, 10250336, 10580000, 10910688, 11241376,

11572064, 11902752, 12233440, 12564128, 12894816, 13225504, 13556192,

13886880, 14217568, 14548256, 14878944, 15209632, 15540320, 15869984,

16200672,


When done I could mount the new drive on a new directory called '/var/extra':


bash-2.05b# mount /dev/wd1a /var/extra


I added the last entry to /etc/fstab:


/dev/wd0a / ffs rw 1 1

/dev/wd0b none swap sw 0 0

/dev/wd0e /var ffs rw 1 2

/dev/wd0f /home ffs rw 1 2

/dev/wd0g /tmp ffs rw 1 2

/dev/wd1a /var/extra ffs rw 1 2