Friday, 31 May 2013

ZD1211RW packet injection being a bitch!

Well today i decided i was going to start to program a wifi cracking script that you can use with the adafruits 16x2 lcd.

but problems occurred firstly rt5370 is wrecking my head.

now i went back to my old belkin 54mb wifi adaptor due to the zd1211rw chipset and it decided it will pick things up but not inject or throw a wobbler.

now a quick google and i found something on the raspberry pi fourms.

i've followed the instructions and updated the information for the latest raspbian and when the bloody thing finish's making the drivers i should be sorted.

now i've thrown this in to an easy script to use.

A) cause i'm lazy and might need to wipe my SD card
B) cause i like to help others if i've found a fix or some one else has 

download the following if you want to get the ZD1211RW to do packet injection on the raspberry pi.


Tuesday, 21 May 2013

Install Aircrack-ng On Raspberry Pi

Easy to follow copy and paste:

sudo apt-get update
sudo apt-get install libssl-dev subversion iw libnl-dev libnl-3-dev  libnl-genl-3-dev -y
svn co aircrack-ng 
cd aircrack-ng 
sudo make install

sudo airodump-ng-oui-update

cd scripts
chmod +x airmon-ng
cp airmon-ng /usr/bin/

updated 14/01/2014

RT 5370 Packet Injection

Another day another driver damm giving me hell but heres some magic for you.

 cd /usr/src  
 sudo wget  
 sudo tar xvfz rpi-3.6.y.tar.gz  
 sudo ln -s /usr/src/linux-rpi-3.6.y/ /lib/modules/3.6.11+/build  
 cp -R /lib/modules/3.6.11+/build/linux-rpi-3.6.y/ /lib/modules/3.6.11+/build/  
 sudo make mrproper  
 sudo gzip -dc /proc/config.gz > .config  
 sudo su  
 gzip -dc /proc/config.gz > .config  
 make modules_prepare  
 cd /home/pi/  
 sudo wget  
 sudo tar xvf compat-wireless-3.6.2-1.tar.bz2  
 cd compat-wireless-3.6.2-1  
 sudo wget  
 sudo patch -p1 < mac80211.compat08082009.wl_frag+ack_v1.patch  
 sudo make  -i
 sudo make -i install  
 sudo make -i wlunload
 cd /udev/
 sudo cp 50-compat_firmware.rules /etc/udev/

This will build the kernel modules so you can install the packet injection drivers.

note it's only for the latest raspbian

Thursday, 2 May 2013

Auto-Sorting NAS/Media Server using MiniDLNA and Samba

This guide assumes you are using the 06-12-12 of Raspbian. It should also work on the latest version, but I can't guarantee that as I've not had chance to test it yet. I used the following IP scheme:

Pi Ethernet Port:
Pi wlan0:

Note: external hard drives on the Pi should be connected via a powered hub.

This guide can be downloaded as a pdf from instructables.

Automount USB hard disks & ntfs-3g

To use USB hard disks in your NAS setup, we need to make sure they auto-mount at boot. We also need to make sure that if the use the NTFS file system, we are allowed to write to them - this is what ntfs-3g is for. Install ntfs-3g from the terminal:

 sudo apt-get install ntfs-3g 

Create mount point directory

First, we need to make some folders for the disks to be mounted to. As an example, we'll assume there is a USB hard disk with a single partition, formatted with a NTFS file system. It contains all of your legally owned videos and music, so we will call it 'Media'. Make a folder for the drive to be mounted to, and change the permissions so everyone on the network can read and write to and from it:

 sudo mkdir /media/Media  
 sudo chmod 777 /media/Media

Setup auto-mount

Now, let's set the disk to auto-mount to that folder at boot. We will edit a file called fstab, which deals with all the file systems that are mounted at boot on your Pi. We need to gather some information about the drives first, so in a terminal type:

 sudo blkid  

blkid is a tool we can use to a drives metadata - specifically the UUID. This is what we are going to make fstab use to identify the drives. Drives are automatically assigned to files in the /dev folder, but these assignments are not guaranteed to be the same every time your Pi boots, so we will use the UUID.

We are interested in the UUID of each drive/partition you wish to mount on your NAS. My drives were formatted and partitioned on a Windows client some time ago, and are easily identifiable by their labels. Copy the full output of blkid, then type:

 sudo nano /etc/fstab  

This will open the fstab file for editing. Bellow the text that is already there, leave a bit of space then paste the output form blkid. We will be deleting this later, but I think it's easier to have all the info infront of you - this won't be an issue on a Pi setup with a monitor, but I was doing this headless so it worked better in that situation.

Entries in fstab are in this format:

Device Name | Mount Point | File System | Options | Dump Options | FS Check Options

One of my entries as an example:

Device Name  Mount Point  FS    Options              DO | FSC O
 /dev/sda    /media/Ipod  vfat auto,user,rw,exec 0 0  

In the device name column, UUID= and Label can also be used. All entries are seperated by a single tab. Your entry should be structured like this:
  • Device Name: Use the UUID identified in the blkid output, without the quotes.
  • Mount Point: In the Mount Point column, enter the location of the mount point we created earlier.
  • File System: The information for the File System column can be found in the blkid output, after the word TYPE. The file system for FAT32 drives is vfat, and for NTFS drives you should use 3g-ntfs.
  • After these three columns, paste auto,user,rw,exec 0 0
So the entry for the fictional 'Media' drive would be (I'm just gonna make up a UUID):

 UUID=5d2047b5-6eaf-46de-9a52-a3a19dfc3706  /media/Media  ntfs-3g   auto,user,rw,exec 0 0  

Repeat this process (including creating a mount folder) for each drive or partition you want to share. Be sure to delete the output from blkid that you pasted in before you save and exit.

To test your new entries in fstab, in the terminal type:

 sudo mount -a  
 df -h  

This will attempt to mount all entries in fstab, unless they are already mounted. The second command will output information about currently mounted drives, which will indicate wether or not the entries in fstab are valid. If you see the mount folders you created listed in the output of df, navigate to them and list their contents to confirm all is well.

Make sure you have nailed this part before carrying on - your Pi will have problems booting if there are faulty entries in fstab. If this occurs, you should be given the option of a terminal prompt, at which point you can open fstab in nano like before and remove the bad entry.

Install and configure Samba

Samba is a suite of programs that allows Linux and Windows clients to easily use the same shares. There's a lot more too it than that, so check the Samba website for more info if you're interested.

Install Samba from the terminal:

 sudo apt get install samba  

Samba config

Once it's finished downloading and installing, we need to configure it. I make a backup of the 'out of the box' config file, delete the original and then start with a blank canvas:

 sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_bak  
 sudo rm /etc/samba/smb.conf  
 sudo nano /etc/samba/smb.conf   

Paste the following into nano:

 #### GLOBAL CONFIG #####  

 workgroup = home  
 netbios name = nas  
 server string = %h  
 wins support = yes  
 dns proxy = no  
 security = user  
 null passwords = yes  
 guest account = nobody
 hosts allow = 
 hosts deny =  
 interfaces = eth0 wlan0 lo
 bind interfaces only = yes

 #### PUBLIC SHARE #####  

 comment = Media Drive
 path = /media/Media
 browseable = yes  
 guest ok = yes  
 writeable = yes  
 public = yes  
 available = yes  
 create mask = 0666  
 directory mask = 0777  

The text above is a really simple Samba config that works for me. I've highlighted the parts that will need your attention:
  • Hosts Allow defines the networks or individual hosts which will be permitted to access the shares.
  • Hosts Deny defines the networks or individuals not permitted. The entry I've used explicitly denies everyone not in the allow list.
  • Interfaces defines the interfaces Samba will allow connections on - if your Pi has a direct connection to the internet, do you want your Samba shares to be accessible via that interface?
  • Bind Interfaces Only tells Samba to use only those interfaces in the Interfaces list.
Make a public share for each drive or partition you mounted with fstab. Once you have finished with smb.conf, save changes and exit (ctrl+x, y, Enter). Restart the Samba service to apply the changes:

 sudo service samba restart  

If you have a Windows machine on the same network as the Pi, open a command prompt and type:

 net view \\  
Replacing the IP address with that of your Pi's. This should show a list of the shares you defined in smb.conf, confirming your shares are accessible. Samba can be a bit of a mysterious beast at times, so if you have any problems leave a comment and I'll try and help you. I am by no means an expert though :)

Access shares on Windows/Linux client


Each flavour of windows has a slightly different route to provide the credentials required to access the Samba shares on your Pi via the gui, so I am going to avoid that completely and use the command line. If that disturbs you in any way and you really want to do it via the gui, let me google that for you!

Open a command prompt, and type:

 net view \\IP_ADDRESS_OF_PI

This will list the shares published by Samba on your Pi. In order to map the drive so you can see it in My Computer we will use the net command, type the following (I'm continuing to use the 'Media' share example):

 net use z: \\IP_ADDRESS_OF_PI\Media /pi:raspberry raspberry /P:Yes  

The 'z:' argument specifies which drive to assign the share to. I'm assuming you don't have a 'Z' drive. The next part specifies the location of the Samba share on the network. The following part supplies the credentials in the format USER:DOMAIN PASSWORD. I have used the Raspbian default credentials in this example - change as necessary for your setup. The final argument, 'P:Yes' tells net to auto-connect the share at start up.

There should now be a browseable Z drive, labelled 'Media' in My Computer!


There are many more flavors of Linux than there are of Windows. As such, I'm only going to cover the method I used to access the Samba shares - the OS in question is Linux Mint 13 Xfce. This should work for most Debian based systems though.

First we have to install smbfs, which is the file system we will specify in fstab. Next create an entry in fstab, using the same method as we did when mounting the shares on the Pi (remember to create a mount point directory!):

 // /media/Media smbfs credentials=/home/USERNAME/creds,gid=users 0 0  

The UUID has been replaces by the network location of the share, the file system column contains 'smbfs' and in the options we have the location of a file containing the login credentials for the shares. We need to create that file now. While in your home directory:

 sudo nano creds  

Now paste the following information - again, I have used the default Raspbian credentials, change as necessary:


Mount the shares using the same 'mount' command as you did on the Pi. They should now be 
browsable through the file manager!

Setup torrent auto-download and download auto-sort

I set all my browsers on both Windows and Linux to download to the same Downloads folder on a NAS share. I use fsniper installed on the Pi to monitor this folder, and send anything that is created in (downloaded to) it to the relevant folder. For example, image files to an /image folder, music files to a /music folder and executable files to an /apps folder. It also sends any torrents to a folder which is monitored by my torrent client, qBittorent - when the client sees a new torrent file appear in the folder, it automatically downloads it.


To install fsniper on the pi:

 gunzip fsniper-1.3.1.tar.gz  
 tar -xvf fsnuper-1.3.1.tar  
 cd fsniper-1.3.1  
 sudo apt-get install libmagic-dev  
 sudo ./configure  
 sudo make  
 sudo make install  

Now we need to create some rules for fsniper. As an example, we'll make a rule which moves all torrent files to the /Torrents folder. This will in turn be monitored by our torrent client.

 watch {  
  /media/Downloads {  
  *.torrent {  
  handler = mv %% ~/torrentMonitor  

This config causes fsniper to scan the /media/Downloads directory. Whenever a torrent file appears in the directory, it moves it to the /torrentMonitor folder in the home directory on the Pi. The configs should be pasted into the fsniper config file, which can be opened with:

 sudo nano /home/pi/.config/fsniper/config  

To make fsniper start on boot, add the following line to /etc/rc.local:

 /usr/bin/fsniper --deamon  


We will be using qBittorrent to monitor the folder all torrents will be placed in by fsniper. As soon as it sees a new one, it will download it. We will be using the command line version, controlling it via a web interface - this means we can control it from any client on the network.

Install and start qBittorrent with:

 sudo apt-get install qbttorrent-nox  
 qbittorrent-nox &  

Access the web interface using a browser on any client on the network, pointed to IP_ADDRESS_OF_PI:8080. The default user:pass is admin:adminadmin.

Settings for the monitor and directory folders can be found in the config page (click the little spanner/screwdriver icon.

Github has instructions and an init.d script to make qBittorrent run at startup.

Setup MiniDLNA

MiniDLNA will scan all folders you tell it for movies, audio and pictures. It will then make these available to anyUPnP devices such as televisions and games consoles.

Install MiniDLNA with:

 sudo apt-get install minidlna  

Next we need to configure MiniDLNA to scan the shared drives that contain your media. The Arch Linux wiki has a good example of a simple config file. Edit the config file with:

 sudo nano /etc/minidlna.conf  

MiniDLNA runs at boot by default

Login using a public key for ssh (without password) from GNU/Linux

Login using ssh, a public key and a password related to that file is a more secure way to do it than just using a password. I'll show you a not so secure way to login to you pi but more secure than a password. We'll use a passwordless private/public key.

I'll refer to your computer to refer to the computer where you'll connect from and to pi to the little rapsberry pi. Let's go.

We must create a private/public key pair if we don't already have one. On green what you must enter:

ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/donosor00/.ssh/id_rsa): [press ENTER]
Created directory '/home/donosor00/.ssh'.
Enter passphrase (empty for no passphrase): [press ENTER*]
Enter same passphrase again: [press ENTER*]
Your identification has been saved in /home/donosor00/.ssh/id_rsa.
Your public key has been saved in /home/donosor00/.ssh/
The key fingerprint is:
f8:5f:d7:b2:bb:a9:25:5f:51:0f:e8:64:c3:8e:ad:3e donosor00@weee
The key's randomart image is:
+--[ RSA 2048]----+
| |
| . . |
| * . .|
| . B . .o|
| . S . + ..|
| . . ..|
| . . o + o|
| oE. = = |
| o...*o |

Where is [press ENTER*] you shoud enter a password if you want that additional protection but we are here for easeness.

[font='courier new', ', courier, monospace} ']Now we have to copy our public key to the pi. There are two ways :[/font]
  • [font='courier new', ', courier, monospace} ']the easy one, just typing: [/font][font=courier new,courier,monospace]ssh-copy-id pi@[/font] <-- here the IP of your pi
  • [font="courier new, , courier, monospace}"]the old one. ssh-copy-id doesn't exist and we must copy it the hard way:[/font]
host $ scp .ssh/ pi@[ip of the raspberry]:
host $ ssh pi@[ip of the raspberry]

pi $ if [ ! -d .ssh ] ; then
>  mkdir .ssh
>  chmod 700 .ssh
pi $ cat >> .ssh/authorized_keys
pi $ rm

Install OpenELEC with XBMC on Pi

Step 1 : Download all the needed files

You will need the following

A copy of SDFormatter (https://www.sdcard.o...ds/formatter_3/).

The binary version of win32diskimager from this location: download

An image of openELEC (Download the latest image file at the bottom). 

Step 2 : Format the Memory Card

1.First thing to do is to format the memory card. Open up the SDformatter and run the install/setup.
2.Once installed, run SDformatter (start > all programs > SDFormatter). Select the drive that your Raspberry Pi memory card is inserted in, then click 'format'. Please note this will swipe your memory card so if you want to keep what's on it, we suggest using a different memory card.

**You will be asked to confirm the format. Click OK to continue.

3.Next you will be informed not to remove the memory card during format. Click OK.

4.Once the format is complete, click OK and close SDformatter by clicking Exit.

Step 3 : Install openELEC to the SD Card

1.Open Win32 Disk Imager and click the browse button then select the openELEC img file you downloaded earlier.
**Next thing to do is put the image onto the card. Make sure the drive your memory card is in is selected in the 'device' dropdown, then click the 'Write' button.

2.You will be asked to confirm the write, click OK or Yes to continue.

**OpenELEC XBMC will now install on your SD Card.

Finally once the writing is complete you will see a 'Write Successful' box. Click OK to finish.

That's it. Pop your memory card into your Raspberry Pi, hook it up to the TV and enjoy your new media cente

How to easily install Fedora Remix 14 to your Pi

1. Download the installer for Windows [ Fedora installer / Linux Others Installer ( Python ) ]

2. Unzip the windows file to an easy destination. Then Right click and run as Admin with highest privileges.

3. Once the installer has started , then click the refresh (circle) button to refresh all of the download packages.

4. Select the image "Raspberry Pi Fedora Remix 14" ( or select the image if you downloaded it separately) 

5. Refresh the list of devices till you see your SD card drive. 

6. Select your SD card

7. Click INSTALL

8. Wait for installation to complete, and then remove the SD card, and boot with your Pi. Enjoy :) 

adding usb drives to raspberry pi

Powered USB Hub Required

In order to expand storage capacity, you will need to connect a powered USB hub to one of your Pi USB jacks, and then connect the keyboard, mouse/trackpad (if any), and USB drive to the hub. A USB hard drive can either have its own AC/mains power supply or it can have two USB plugs, and get a USB 2.0 hub with at least four expansion ports - more is better, within a reasonable cost. A four-port USB 2.0 hub will cost about US$7 - $15, and don't bother with a USB 3.0 hub, as the Pi only has a USB 2.0 interface.

Mounting Drive Partitions

You can plug in a USB flash or hard disk drive while the Pi is running without any problem, but, be sure to unmount a drive before unplugging it from the Pi (covered below). The USB device will be sensed by the Pi, however, it probably won't be added to the operating system's file system unless you are running an X window desktop such as LXDE, where USB drives should appear in the file manager. Running at just the command line will require some manual intervention to "mount" the device onto the file system. A flash or hard drive may be configured with one, or more, partitions, which you can create yourself in the unlikely event that the drive doesn't already have any. Creating partitions is covered in a separate tutorial.

USB Drive Hierarchy

Linux hardware devices are organized and identified by letters under the file system's device hierarchy, /dev. USB drives attached to the Pi are found under the file system as /dev/sdX, where "X" starts with the letter "a" representing the first USB drive, "b" for the second drive, "c" for the third, etc. The individual partitions on each drive are represented by incremented numbers, starting with "1". So, the first partition on the first USB drive is located in the file system as /dev/sda1, the second partition on that drive is /dev/sda2, the third partition on a third drive would be /dev/sdc3, etc.

Mount Points

In order to make a partition accessible to the file system, you need to use the Linux "mount" command, referencing the hardware (e.g., /dev/hda1) and a "mount point" in the file system, which is any empty directory, usually created for the purpose by the user. There is a canonical (i.e., standard) directory path where mount points are usually created: the /mnt directory. You can create a new directory under /mnt for each partition to be mounted, and it can be named anything you want as long as it doesn't contain any spaces. You might want to name it to correspond to the drive's physical characteristics, e.g., /mnt/1GB_USB_flash, or /mnt/120GB_USB_hard_disk.

Mounting a Partition

After creating the mount point for a partition, the only thing left to do is to actually mount the drive partition, e.g.:
sudo mount -o uid=pi,gid=pi /dev/sda1 /mnt/1GB_USB_flash
-o (lowercase letter "o", not the number zero) specifies that an option string follows
uid=pi,gid=pi specifies the user ID is user "pi" and the group ID is "pi" (note there are no spaces allowed between these terms)
/dev/sda1 is the first partition on the first USB drive
/mnt/1GB_USB_flash is the mount point directory

Operations on a Mounted Partition

If all goes well, you will see nothing after pressing the Return key other than another command line prompt, which means there were no errors encountered during the mount process. You can then access the partition by referring it via /mnt/1GB_USB_flash/... where the "..." would be the file system path to the directories and files on which you want to perform an operation. For example, to list the details about the files at the top of the partition, you would simply type:
ls -l /mnt/1GB_USB_flash
To copy a file named "file1.txt" to another file named "file2.txt" in the directory "my_directory", you would type:
cp /mnt/1GB_USB_flash/my_directory/file.txt /mnt/1GB_USB_flash/my_directory/file2.txt
Of course, you can make this a lot simpler by just changing the current directory to my_directory like this:
cd /mnt/1GB_USB_flash/my_directory
To run an executable file "my_program.bin" while in that directory, you would type:
You can copy or move files and directories to or from any directory in the mounted partition by just referring to the appropriate path to that directory in the partition.

Unmounting a Partition Before Drive Disconnection

When you're done with a drive and want to disconnect it from the Pi, you should unmount the drive by using the "umount" command (notice there is no letter "n" between the "u" and the "m") and referring to the mount point:
sudo umount /mnt/1GB_USB_flash

Other mount and umount Features

You can learn more about mount and umount features by typing mount -h or mount --help,umount -h or umount --help, or via their "man" (manual) pages by typing man mount or man umount.



Donate Towards More Raspberry PI's for Projects