« November 2006 | Main | May 2007 »

December 21, 2006

Convert Windows' dir /s to find format

Sometimes you would like to convert the output of DOS/Windows' DIR /S command into the output of UNIX' find command. You will find here a basic script that does just that.

hugh?
Sometimes some lazy or paranoid system administrator refuses to install the find command for Windows. So you are left only with the crappy Windows basic commands. You could reply of course that if they were so paranoid, they could download the source code, inspect it and recompile it themselves.

find is extremely useful to get a nice file tree that you can grep later from your Linux box (unless again you installed grep on Windows).

The Script
So when you don't have find and still need a basic find output eventually, you could use this script. It turns an output that looks like this:

 Volume in drive C has no label.
 Volume Serial Number is B0B8-957C

 Directory of C:\WINDOWS

12/19/2006 09:36 PM <DIR>        .
12/19/2006 09:36 PM <DIR>        ..
12/21/2006 03:44 PM            0 0.log
03/21/2006 11:01 AM <DIR>        addins
08/23/2001 08:00 PM        1,272 Blue Lace 16.bmp
08/23/2001 08:00 PM       82,944 clock.avi
08/23/2001 08:00 PM       17,062 Coffee Bean.bmp
12/19/2006 06:49 PM       43,027 comsetup.log
03/21/2006 11:01 AM <DIR>        Config
03/21/2006 11:01 AM <DIR>        Connection Wizard
03/21/2006 04:02 AM            0 control.ini
03/21/2006 03:55 AM <DIR>        Cursors
10/11/2006 05:43 PM <DIR>        Debug
...

Into an output that looks like this:

C:/WINDOWS
C:/WINDOWS/0.log
C:/WINDOWS/Blue Lace 16.bmp
C:/WINDOWS/clock.avi
C:/WINDOWS/Coffee Bean.bmp
C:/WINDOWS/control.ini
C:/WINDOWS/comsetup.log
C:/WINDOWS/addins
C:/WINDOWS/Config
C:/WINDOWS/Connection Wizard
C:/WINDOWS/Cursors
C:/WINDOWS/Debug
...

The script makes it easy to grep for particular files like .exe or .log or any other pattern that you may be looking for.

Native GNU tools on Windows
The better alternative of course is to install some vital GNU tools onto your Windows system.

Karl M. Syring has ported essential GNU tools to native Windows on his http://unxutils.sourceforge.net/ project.

' Here are some ports of common GNU utilities to native Win32. In this context, native means the executables do only depend on the Microsoft C-runtime (msvcrt.dll) and not an emulation layer like that provided by Cygwin tools. '

The tools included (at the time of this writing) are:

bc bison bzip2 diffutils
fileutils findutils flex gawk
grep gsar110 gzip indent
jwhois less m4 make
patch recode rman sed
shellutils tar textutils unrar
wget which

Emulated GNU tools on Windows
A team of enthusiasts originally from Cygnus (now part of RedHat) have created an emulation layer that allows to re-compile and run most GNU or standard Linux tools on Windows. You can download this environment called cygwin (in pre-compiled binary, or in source form).

' Cygwin is a Linux-like environment for Windows. It consists of two parts:

  • A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial Linux API functionality.
  • A collection of tools which provide Linux look and feel.

The Cygwin DLL works with all non-beta, non "release candidate", ix86 32 bit versions of Windows since Windows 95, with the exception of Windows CE. '

Cygwin contains an amazing number of GNU or Linux tools that come very handy on Windows, including mamoths like XWindow, XEmacs, openssh or ddd

Conclusion
In order of robustness & speed you should use:

  • the native version of find
  • or the cygwin version of find
  • or the script converting output from Windows' DIR /S into find format

December 18, 2006

ATM pin reversal scam

A scam letter is circuclating in Singapore telling potential victims of ATM money snatching how to call the police automatically. How naive people can be...

The letter

' If you should ever be forced by a robber to withdraw money from an ATM machine, you can notify the police by entering your PIN number in reverse. For example if your pin number is 1234 then you would put in 4321. The ATM recognizes that your pin number is backwards from the ATM card you placed in the machine.

The machine will still give you the money you requested, but unknown to the robber, the police will be immediately dispatched to help you.

This information was recently broadcasted on TV and it states that it is seldom used because people don't know it exists. '

Why is it nonsense?

  1. What happens if your pin is the same in straight order as in reverse order? (i.e.: 9229, 3113, etc...)
  2. Tell me (without thinking more than a second) you PIN number in reverse... can you? You probably would have to think longer...
  3. How would the bank call the police? And who would be responsible if people would start abusing this "service" in case the bank calls automatically?
  4. Even if the police gets automatically notified, by the time they do actually reach the ATM, the robber will be long gone with your cash... (and maybe your life)

The old saying "Your money or your life!" has always been ill-worded. It should have been "Your money or your life AND your money!"

What could work?
On the other hand we could think of better protections from ATM money snatching. I'm not really serious with these recommendations, but it would be fun if it existed:

  • The out of money solution
    The bank could put in place a discreet button or a buttons-combination that when pressed would instruct the ATM to refuse dispensing money, appearing to have ran out of money. The thief would genuinely believe that this particular ATM ran out of money (that's Murphy's Law after all), and would walk away (with or without your ATM card, and with or without having taken your life!).

    Of course for this to work, the bank would need to enable this function only to people who already successfully entered their PIN, otherwise non-customers would definitely abuse this to cause DoS. Of course this does not prevent the thief to steal your money, it's just that he wouldn't be able to steal it right here right now, he me still steal your ATM card, and kill you after you reveal him your code...
     
  • The 5th Element Solution
    [ You should really watch The 5 th Element if you haven't seen it yet. ] Anyway at some point in the movie, a bad guy attempts to pass as somebody else at an airline check-in counter and gets detected. Straight away a cage falls on him and prevent him from leaving, electronic aimed machine guns point at him to deter him from trying to break the cage, and a loud alarm start ringing.

    Now that would be a great way to prevent a bunch of ATM attacks like ATM money snatching, ATM tampering, ATM forcing and more! Having said that it's a bit extreme... ;-)
     
  • The Run! Forest, run! solution
    Of course the best solution is to run as fast as you can. There's nothing better than a big guy with a big blade pointed towards you to motivate you to break the 100 meters sprint world record...