Monday, March 20, 2006

Sniping eBay Auctions with esniper on FreeBSD

I've been using esniper to automatically place bids on eBay for a couple months now, and it's worked flawlessly. Check the esniper web site for information on what sniping is, amongst other related questions. They explain that well, I won't duplicate their explanation here.

So what does
esniper do?
In a nutshell, esniper allows you to bid your maximum amount at the last second, either on a single item, or on a list of items. I use it for lists as much as anything, because I'm frequently looking for multiple identical items, like 5 of switch model X, or 7 of router model Y, etc. I can define a quantity in the auction file, then put in a list of auction numbers and my max price, and it will automatically bid until I have won the desired quantity (or it reaches the end of my list of items).

Installing esniper on FreeBSD
esniper can be found in the FreeBSD ports collection under /usr/ports/misc/esniper. To install:

cd /usr/ports/misc/esniper && make install clean

Using esniper on FreeBSD
First, you need to create a .esniper file in your home directory (note the leading dot) containing some configuration information.

Here is the ~/.esniper file I use:
# A configuration file contains option settings,
# blank lines, and comments (begin with #). The
# default configuration file is $HOME/.esniper, and
# if you specify an auction file, .esniper in the
# auction file's directory as well. If you specify a
# configuration file using the -c command-line option,
# then that configuration file will be the only one
# read.
# If you set your password in a configuration file
# and you are on a unix system, you should be the
# owner of the file, and you should set the
# permissions so that it is readable only by the
# owner.
# Here are all the options. Note that if the
# default (as defined in esniper -H) is fine, you
# don't need to specify it in a configuration file.

# boolean parameters can be set to:
# true, y, yes, on, 1, enabled
# false, n, no, off, 0, disabled
batch = false
bid = yes
debug = enabled
reduce = y

# Note: quantity is usually set in an auction file
quantity = 1
# Note: seconds can also be "now", if you want to
# bid immediately
seconds = 10
Replace EBAYUSERNAME with your eBay user name, and EBAYPASSWORD with your eBay password. The quantity above is the default quantity, and seconds is how long before the end of the auction that esniper will put in your bid by default. You can change "bid = no" if you just want to see what it would do, rather than letting it start bidding.

I create ~/esniper/ and ~/esniper/logs/ directories, and put auction files in ~/esniper/ and the above .esniper file sends logs to ~/esniper/logs/. Make sure you 'chmod 600 ~/.esniper' after you create the file, to help protect it from other users since it contains your plain text eBay password.

Also check the sample configuration from the esniper web site.

Creating an Auction File
For each type of item you wish to bid on, you need to first create an auction file. I call it something that makes sense to me, based upon the items within it. You can call it whatever you like.

You define the quantity of items you want, the auction numbers you want to bid on, and the dollar amount of the bid to place.

See the sample auction file on the esniper website for details.

Starting esniper
Once you have your configuration file and auction file created, you can run esniper. To run it using the auction file "my-auction-file.txt" in ~/esniper/:

$ esniper ~/esniper/my-router-auction-file.txt

And let it run, it will check with eBay periodically and place your bid at the time you defined in your .esniper file.

Have fun!

Tuesday, December 20, 2005

FreeBSD 6.0 and VMware 5.5

FreeBSD has always worked well "out of the box" for me in VMware, until FreeBSD 6.0 and VMware Workstation 5.5. FreeBSD was having serious issues with time, which caused serious issues with the network stack, amongst other things.

Thanks to some advice from Scott Ullrich, and a VMware forum post from Richard Bejtlich, I was able to get things going.

In short, add the following two lines to


And one line to /etc/sysctl.conf


Then reboot, and all will be well.

Sunday, October 16, 2005

Upgrading FreeBSD 5.4 to 6.0

I upgraded my first production box from FreeBSD 5.4 to 6.0 with great success. This box runs Apache, MySQL, PHP, and my ncid server. Other than ncid, nothing else is really production nor critical on this box. This is my least "production" server so it was the least-risky to attempt.

I did the usual cvsup, using tag RELENG_6 to get the 6.0 RC1 sources, and built and installed world/kernel and ran mergemaster. For more details on how to do these things, I recommend Richard Bejtlich's excellent Keeping FreeBSD Up To Date article. Richard does a good job of addressing everything there, no need to reinvent the wheel.

Everything came out perfectly well with one small change with serial port naming that kept my ncid server from starting. Serial ports in 5.x were /dev/cuaaX and are now /dev/cuadX where X is the number of the serial port. This box has one serial port so it changed from /dev/cuaa0 to /dev/cuad0. A simple change in my ncidd.conf file and manually firing up ncidd fixed that.

All else is running well with no other changes at all. Looks like FreeBSD 5.x to 6.0 upgrades will be pretty painless.

Saturday, October 01, 2005

Installing MySQL on FreeBSD

I'm installing MySQL in a fresh FreeBSD jail and thought it'd be a good idea to document the quick, easy process, so the next time someone asks me how to do this, I can just point them to this.

Update your Ports
First, cvsup your ports collection so you have the most recent versions available.

Choose a Version
This isn't very clear or simple. There are four different MySQL versions in FreeBSD ports - 3.23, 4.0, 4.1, and 5.0. Unless your intended application only works with MySQL 3.x, I wouldn't recommend using that version. MySQL 5 is the current development version, so I wouldn't recommend it for production use either. MySQL 4.1 is the latest "production release" as of this writing, so generally this is what you will want to use.

The installation is almost as straight forward as usual. There are some make options that may be of interest.

You may use the following build options:

WITH_CHARSET=charset Define the primary built-in charset (latin1).

WITH_XCHARSET=list Define other built-in charsets (may be 'all').

WITH_COLLATION=collate Define default collation (latin1_swedish_ci).

WITH_OPENSSL=yes Enable secure connections.

WITH_LINUXTHREADS=yes Use the linuxthreads pthread library.

WITH_PROC_SCOPE_PTH=yes Use process scope threads
(try it if you use libpthread).

BUILD_OPTIMIZED=yes Enable compiler optimizations
(use it if you need speed).

BUILD_STATIC=yes Build a static version of mysqld.
(use it if you need even more speed).

WITHOUT_INNODB=yes Disable support for InnoDB table handler.

WITH_NDB=yes Enable support for NDB Cluster.

For the most common uses you can get by without any options. I typically use BUILD_OPTIMIZED and BUILD_STATIC.

cd /usr/ports/databases/mysql41-server
make BUILD_OPTIMIZED=yes BUILD_STATIC=yes install clean

MySQL will now install.

Configure to Start on Boot
A startup script is installed in the usual location, /usr/local/etc/rc.d/. Before this startup script will function, you need to open your /etc/rc.conf and add the line mysql_enable="YES".

Start MySQL
MySQL is now configured to start at boot, but you probably don't want to reboot just to get it to start. Just run the following.

/usr/local/etc/rc.d/ start

Now MySQL is running and ready for use.

Recent Happenings

Couple things keeping me busy lately.

One, the new m0n0wall Documentation Site and all the new documentation contained therein for this open source firewall project. This makes public much of the work I've done over the last several months, and will become the new location for documentation as soon as I get it in a bit better shape. I'm hosting this site on my colocated server at Louisville ISP's data center, rather than on the main site. This makes it easier on Manuel, founder of m0n0wall, and I, since I write most of the documentation and he isn't involved much in it. The documentation for open source firewall project pfSense will begin to be forked off of this site once we decide on a suitable documentation platform.

Second, I've been working with best selling computer book author Dave Taylor as coauthor on a series of e-books. Connect Safely is the name of this project, offering Wireless Security and Privacy Guides. My typical audience isn't really the intended audience for this series, but if you're a frequent wireless network user and aren't extremely familiar with wireless network security concerns, you really should consider this. I can't tell you how many even quite computer literate folks I've seen giving their passwords to the world on a hot spot. As a bonus for more technical readers, I wrote a section on using Ethereal to analyze your network traffic to ensure it is being protected. Stay safe on wireless networks - check it out.

Tuesday, July 19, 2005

Replacing Notepad on Windows

A fast lightweight text editor is always nice to have, but on Windows, Notepad falls far short. There are a few light text editors for Windows that are just as light and fast as Notepad, but include features that frequently come in handy.

Metapad is my Notepad replacement of choice. A few notable features it offers that Notepad lacks follows (with a full list on the Metapad site).
  • URL's are clickable links
  • Doesn't botch up non-Windows text files (some Unix and Mac file types are problematic in Notepad)
  • Line and column count
  • No file size limit
Actually getting Notepad replaced is a major pain. File associations, context menu replacements, etc. etc. It's much easier to just replace notepad.exe. But Microsoft makes that difficult too!

notepad.exe is located in C:\Windows\system32. But if you delete it, or rename it, as soon as you do Windows will replace it. This is a "feature" of Windows File Protection. When you do this, you'll see a message like the following in your Event Viewer:

Event Type: Information
Event Source: Windows File Protection
Event Category: None
Event ID: 64002
Date: 7/19/2005
Time: 5:06:58 PM
User: N/A
Computer: CMB
File replacement was attempted on the protected system file notepad.exe. This file was restored to the original version to maintain system stability. The file version of the system file is 5.1.2600.2180.

To get around this, I run a batch file with the following three lines. The batch file lives in the same directory as the downloaded metapad.exe.

copy metapad.exe %windir%\system32\dllcache\notepad.exe

copy metapad.exe %windir%\system32\notepad.exe

copy metapad.exe %windir%\notepad.exe

The dllcache directory is where Windows File Protection keeps its files used to replace protected files if they become modified. Windows obviously doesn't protect the dllcache the way it does the rest of the files, so the above seems to work fine (at least for me). I've used it on Windows 2000 Server, XP Pro, and Server 2003 without a hitch.

Tuesday, June 14, 2005

Gathering Cisco Router Configurations with Perl

Have a number of routers from which to gather configurations? The following bit of Perl makes this extremely quick and easy, if they all have matching telnet and enable passwords. Must install the CPAN module Net::Telnet::Cisco, and enter the IP addresses of the routers in a file called routerlist.txt, one IP per line. To use this, you just need to replace "TELNET_PASSWORD" and "ENABLE_PASSWORD" below with the appropriate real passwords from the router.

It'll output files in the directory you run it from called, one file per IP.

#!/usr/bin/perl -w

use Net::Telnet::Cisco;
@routers = `cat routerlist.txt`;

foreach my $router (@routers) {
      my $session = Net::Telnet::Cisco->new(Host => $router);
      @conf = $session->cmd("wr t");
      open LOG, "> $router.conf";
      select LOG;
      print @conf;
      close LOG;

Disclaimer: Are there better ways to write this? I'm sure there are. I don't proclaim to be a programmer, but the way I do things *works*, whether or not it's the "best" way. There's more than one way to do it!