Recursive directory search for string

Posted by & filed under BASH, Linux.

The following command will search for a string within files in a directory recursively.

sudo find . -type f -print0 | xargs -0 grep -n 'STRING TO SEARCH FOR'


Posted by & filed under Linux, Programming.

Cross Compile for OpenWRT Kamikaze

# cd
# export OPENWRT_FOLDER=$(pwd)
# make menuconfig
# make V=99

* apply patch from ticket #1997 to enable UVC modules for OpenWRT

# make menuconfig

* Select UVC module in menu and build modules afterwards.
* Then install the created *.ipk package to the embedded device.
* Then compile the application “uvc_streamer”

# mkdir uvc_streamer
# cd uvc_streamer
# wget
# tar xzvf uvc_streamer_2007_07_11_20.55.20.tgz

# mv Makefile Makefile.orig
# cat Makefile.orig | sed -e “s/CC=gcc/CC=mipsel-linux-gcc/g” > Makefile
# PATH=$PATH:${OPENWRT_FOLDER}/staging_dir_mipsel/bin/

# make clean
# make all
# mipsel-linux-strip uvc_stream
# scp uvc_stream root@


Stream audio over SSH

Posted by & filed under BASH, Linux.

Ok this is sweet:

ssh “cat /Torrents/Complete/15\ years\ of\ Essential\ Mix\ Sasha\ \&\ Digweed/Essential\ Mix\ 137\ -\ Sasha\ -\ Live\ @\ radio\ 1\ on\ tour\ from\ Sanctuary\ -\ [30.06.1996].mp3” | mpg123 –

And here is a more advanced version to find multiple files (unworking)
ssh “find /Torrents/Complete -wholename \*Essential\*.mp3 -print0 | xargs -0 cat” | mpg123 –

this finds fines in /Torrents/Complete and pipes them to mpg123

Skynet — back to life

Posted by & filed under Linux, Pen Testing, Projects, Security, WiFi.

The other day, I decided to bring my old “Skynet” device back online. The master came right online, but the drone was having some problems. I worked it out, and it’s all working correctly now. w00t. Just waiting on my N-Female to RP-TNC connector and I will be read to rock with the Yagi.



Also, I noticed that Kismet-Newcore is out which has a lot of nice features. There is also a plugin available called “Lorcon” that allows kismet to inject and sniff 802.11 frames. Sweet! I will compile both on the rother when I get time…

DD Goodness

Posted by & filed under Linux.

Well after doing a simple dd backup of my WMBFS formatted usb drive, wiping it out and using it as a Ubuntu Netbook boot disk, I now wanted to recover my WMBFS image. It worked perfectly.

sudo dd if=/path/to/img.dd of=/dev/sdb

It took a while, but it’s all back!

Setup my iPhone’s VPN client tonight…

Posted by & filed under Linux, Security, Server Admin, VPN.

Well I finally got the VPN tunnel up for my iPhone.

First I tried IPSec, but it would not connect, and judging from the Firewall’s log output, I’m guessing the IPSec client only works with Cisco units.

Next, I tried L2TP, which I thought would work like a snap since the Sonicwall I’m using has a L2TP server built in. Unlucky for me, it turns out that Sonicwall’s built in L2TP server sucks and is only there for Windows clients.

Ffinally, I turned to PPTP. This was pretty easy to get working since my WLAN router has a PPTP server built in and just needed some quick configuration to get working. After that, I forwarded port 1723 (TCP-PPTP) to the LAN ip of the WLAN Router/PPTP Server.Now, I am able to connect my VPN tunnel, and transmit all data encrypted to my network, where it is then routed out to it’s final destination. Excellent!

I will do some packet captures later on to verify the traffic is truly passing thru my network.

Monitoring a Linux process by PID and sending a e-mail notification upon failure

Posted by & filed under BASH, Email, Linux, Programming.

One of my clients needs their vendor to be alerted when their Backup Exec service crashes. I wrote the following quick-n-dirty batch script intended to be ran as a cron job.

# Process Monitor
# Send e-mail alerts when service goes down
# -------------------------------------------------------------------------
# Author: Nathan Riley
# -------------------------------------------------------------------------
SUBJECT="Backup Exec Agent Failure"

#path to pgrep command

# Daemon name,

# find daemon pid

if [ $? -ne 0 ] # if daemon not running
# Generate email message body
echo "This is servername at location. The Backup Exec service is no longer running." > $EMAILMESSAGE
# send email alert
/usr/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE

And the cron line would be something like this:

*/5 * * * * root /root/  >/dev/null 2>&1

RedHat LVM Expansion Fiasco

Posted by & filed under Linux, Server Admin.

Finally I figured out a procedure for resizing the LVM partition. A server’s /usr partition has been dangerously full for some time now so this has become a priority.


  • Resize VHD with VhdResizer
  • fdisk /dev/hda
    Add a new primary partition (hda4 for this list)
  • Reboot
  • Tell LVM about the new physical volume
    pvcreate /dev/hda4
  • Extend the volume group
    vgextend VolGroup00 /dev/hda2
  • Extend the logical volume to use the newly expanded space
    lvextend -L 19G /dev/VolGroup00/LogVol00
  • Resize the filesystem to use the new space
    ext2online /dev/VolGroup00/LogVol00
  • Optional – check the disk for errors
    e3fsck -f /dev/VolGroup00/LogVol00