Sunday, 2 November 2014

Banana Pi: How To Install OpenMediaVault (NAS)

This was done on Bananian 14.09. OpenMediaVault is a simple out-of-the-box solution to set up a Network Attached Storage (NAS) and supports services such as SSH, (S)FTP, SMB/CIFS, DAAP media server, RSync, BitTorrent etc.




sudo su
wget -O - http://packages.openmediavault.org/public/archive.key | apt-key add -
apt-get install python-software-properties
apt-add-repository "deb http://packages.openmediavault.org/public kralizec main"
apt-get update
apt-get install openmediavault-keyring postfix
apt-get update
apt-get install openmediavault
omv-initsystem
reboot

Now open a browser and enter the IP address of the banana pi: e.g. http://10.0.0.x . Default user/password is admin/openmediavault.

Sunday, 19 October 2014

How To Extract Page(s) From A Single PDF File Using Command Line

PDFtk allows users to perform common pdf tasks from the command line such as merging or splitting PDF files and pages.










To install the program:
sudo apt-get install pdftk

To extract a page from an existing pdf file. For instance just the first page (A1):
pdftk A=/home/user/Desktop/cv.pdf  cat A1 output outfile.pdf

Wednesday, 8 October 2014

How To Install sqlmap on Debian (or Ubuntu)




sqlmap is an open-source pentesting tool that automates the exploitation of SQL injection flaws.

The tool makes it pretty easy for anyone with basic command line knowledge to exploit and break into databases.


Installation
sudo apt-get install git
git clone https://github.com/sqlmapproject/sqlmap.git sqlmap-dev
cd sqlmap-dev
To list available options:
python sqlmap.py -h
Fetch database names of vulnerable url:
python sqlmap.py -u www.example.com/home.php?ID=10 --dbs
Enumerate tables of a website's database (e.g.: test)
python sqlmap.py -u www.example.com/home.php?ID=10 -D test --tables
Dump all data in database (test) and table (e.g.: costumer_data)
python sqlmap.py -u www.example.com/home.php?ID=10 -D test -T costumer_data --dump
More examples are available here: https://gist.github.com/stamparm/5335217

Friday, 19 September 2014

Banana Pi: I2C Barometric Sensor BMP085


Wiring

---> 3.3 volts - to vcc on board
---> ground - to gnd on board
---> SDA - to sda on board
---> SLC - to scl on board


Banana Pi - I2C Barometer BMP085
Wiring, BMP085

Locating the sensor

root@lemaker:~# ls -l /dev/i2c*
crw-rw---T 1 root i2c 89, 0 Sep 19 14:43 /dev/i2c-0
crw-rw---T 1 root i2c 89, 1 Sep 19 14:43 /dev/i2c-1
crw-rw---T 1 root i2c 89, 2 Sep 19 14:43 /dev/i2c-2
crw-rw---T 1 root i2c 89, 3 Sep 19 14:43 /dev/i2c-3
crw-rw---T 1 root i2c 89, 4 Sep 19 14:43 /dev/i2c-4
As you can see there are 5 I2C buses. With the i2cdetect tool we are looking for the 0x77 address, which is the BMP085.
# -y 0, -y 1 etc
sudo i2cdetect -y 2
We are using the  Adafruit BMP Python Library to access the sensor.
sudo apt-get install git build-essential python-dev python-smbus
git clone https://github.com/adafruit/Adafruit_Python_BMP.git
cd Adafruit_Python_BMP
sudo python setup.py install
There are some example scripts in the examples folder.
cd examples

# we need to change the bus number
nano simpletest.py
#uncomment sensor = BMP085.BMP085(busnum=2)
#and comment #sensor = BMP085.BMP085()

#run code
sudo python simpletest.py

#sample output
Temp = 23.00 *C
Pressure = 97607.00 Pa
Altitude = 313.47 m
Sealevel Pressure = 97607.00 Pa

Wednesday, 17 September 2014

Banana Pi: Temperature Sensor (DS18B20) - Tutorial


Requirements

    --> Banana Pi running Raspbian for Banana Pi
    --> Breadboard
    --> Jumper Wires
    --> DS18b20
    --> 4.7K Ohm resistor
    --> Breakout cobbler

       

      Hardware Setup

      Refer to the graphic for the correct wiring. Make sure the Banana Pi is switched off to prevent any possible damage.

      Banana Pi Temperature Sensor - DS18B20

      Software Setup

      Double check the wiring and boot the device. In order to be able to access the temperature data, we need to make some minor adjustments to the script.bin file, which is a binary configuration file used by Allwinner SOC.
      sudo apt-get install git
      git clone https://github.com/linux-sunxi/sunxi-tools
      cd sunxi-tools
      make
      
      #location of the script.bin file
      cd /boot/bananapi/
      
      #get the fex file
      sudo /home/bananapi/sunxi-tools/bin2fex script.bin bananapi.fex
      
      #edit the fex file
      sudo nano bananapi.fex
      
      #add the following at the end, save (CTRL + O) and close
      [w1_para]
      gpio = 4
      
      #.fex back to .bin
      sudo /home/bananapi/sunxi-tools/fex2bin bananapi.fex script.bin
      
      sudo reboot

      Reading raw data from the sensor

      After successfully rebooting your device, you will notice that /sys/bus/w1/devices is no longer empty.
      bananapi@lemaker ~ $ cd /sys/bus/w1/devices
      bananapi@lemaker /sys/bus/w1/devices $ ls
      28-000006203041  w1_bus_master1
      bananapi@lemaker /sys/bus/w1/devices $ cd 28-000006203041
      bananapi@lemaker /sys/bus/w1/devices/28-000006203041 $ ls
      driver  id  name  power  subsystem  uevent  w1_slave
      bananapi@lemaker /sys/bus/w1/devices/28-000006203041 $ cat w1_slave
      5e 01 4b 46 7f ff 02 10 8d : crc=8d YES
      5e 01 4b 46 7f ff 02 10 8d t=21875
      t=21875 is the number we are looking for. E.g.: 21.9 degree Celsius (°C) in my case.

      Banana Pi Temperature Sensor (DS18B20)
      my setup

      Tuesday, 16 September 2014

      Building Wireshark from Source - Linux (Debian 7.6)


      OS: Debian GNU/Linux 7.6 (wheezy)











      Latest releases can be found here: https://www.wireshark.org/download.html
      wget https://1.eu.dl.wireshark.org/src/wireshark-1.12.0.tar.bz2
      tar xaf wireshark-1.12.0.tar.bz2
      cd wireshark-1.12.0
      #could be that you need to install libgtk-3-dev before compiling
      sudo apt-get install libgtk-3-dev 
      #to compile
      ./configure
      make
      #now run it
      sudo ./wireshark
      Building Wireshark from source under Linux (Debian 7.6)

      Saturday, 13 September 2014

      OsmocomBB - Hardware and Software Setup - Tutorial (Motorola C118)

      OsmocomBB is an Open Source GSM Baseband software implementation. By using the sofware on a compatible phone (e.g. Motorola C118), you are able to make and receive phone calls, send and receive SMS, etc. based on Free Software only.

       

       

       

      Hardware

      • PL2303HX USB Serial To RS232 TTL Chip
      • 2.5 mm audio jack
      • Motorola C118 (E88)
      This is a typical pin-out of a 2.5 mm audio jack:

      L (Left Signal) Tip 1 Green
      R (Right Signal) Ring 2 Red
      GND (Ground) Sleeve 3 Bare Copper

      You need to soldier the 2.5mm audio jack to the USB Serial To RS232 TTL Chip, whereas
      • TxD is at the tip of the plug
      • RxD is at the middle contact
      • GND is the outer contact 
      2.5mm audio jack to the USB Serial To RS232 TTL Chip Osmocom

      Software

      Connect the phone to your PC and check if it is being recognized.
      dmesg | grep tty
      user@user:~$ dmesg | grep tty
      [    0.000000] console [tty0] enabled
      [ 6522.143379] usb 3-2: pl2303 converter now attached to ttyUSB0
      To make sure everything is working, install cu and connect at 115200 baud. Permissions need to be set correctly, otherwise you will run into this error: "Cannot open /dev/ttyUSB0: Permission denied".
      sudo adduser user dialout
      sudo chmod a+rw /dev/ttyUSB0
      sudo cu -l /dev/ttyUSB0 -s 115200
      Assuming the phone is switched off, press the power button and cu should display fmttool erro, which means you are ready to go!

      Compiling OsmocomBB

      Compiling GNU ARM toolchain

      Ensure you add the path of arm-elf-gcc using export (check in shell: arm-elf-gcc). This is absolutely vital as failure to do so will yield you errors when trying to compile osmocom later on.  
      mkdir gnuarm
      cd gnuarm
      wget  http://bb.osmocom.org/trac/raw-attachment/wiki/GnuArmToolchain/gnu-arm-build.2.sh
      chmod +x gnu-arm-build.2.sh
      
      sudo apt-get install build-essential libgmp3-dev libmpfr-dev libx11-6 libx11-dev texinfo flex bison libncurses5 \
       libncurses5-dbg libncurses5-dev libncursesw5 libncursesw5-dbg libpcsclite-dev libncursesw5-dev zlibc zlib1g-dev libmpfr4 libmpc-dev aptitude
      
      sudo aptitude install libtool shtool automake autoconf git-core pkg-config make gcc
      
      mkdir build install src
      cd src/
      wget http://ftp.gnu.org/gnu/gcc/gcc-4.5.2/gcc-4.5.2.tar.bz2
      wget http://ftp.gnu.org/gnu/binutils/binutils-2.21.1a.tar.bz2
      wget ftp://sources.redhat.com/pub/newlib/newlib-1.19.0.tar.gz
      cd ..
      ./gnu-arm-build.2.sh
      
      export PATH=$PATH:/home/user/gnuarm/install/bin

      Compiling libosmocore

      git clone git://git.osmocom.org/libosmocore.git
      cd libosmocore/
      autoreconf -i
      ./configure
      make
      sudo make install

      Compiling osmocomBB

      git clone git://git.osmocom.org/osmocom-bb.git
      cd osmocom-bb
      git pull --rebase
      cd src
      make

      OsmocomBB Hello world! 

      Plug everything in, switch phone off, run command and press the phone's power button.
      cd ~/osmocom-bb/src/host/osmocon/
      ./osmocon -p /dev/ttyUSB0 -m c123xor ../../target/firmware/board/compal_e88/hello_world.compalram.bin
      Osmocom Motorola C118

      Loading RSSI 

      sudo ./osmocon -d tr -p /dev/ttyUSB0 -m c123xor -c ../../target/firmware/board/compal_e88/rssi.highram.bin
      OsmocomBB RSSI

      Friday, 15 August 2014

      Banana Pi: Onboard, User-Definable Green Led

      As you may have noticed the BPi has a green LED, which starts blinking as soon as the Pi is powered on: i.e. as soon as something happens with the SD card. It is possible to program the behavior of the LED such as switching it off.

      To list the available options open a terminal and enter cat /sys/class/leds/green:ph24:led1/trigger. The default value is heartbeat. If you want to permanently switch it off the trigger needs to be set to none.
      user@lemaker ~ $ cat /sys/class/leds/green:ph24:led1/trigger  
      none battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid ac-online usb-online mmc0 timer [heartbeat] backlight gpio cpu0 cpu1 default-on  
      user@lemaker ~ $ sudo su  
      root@lemaker:~# echo none >  /sys/class/leds/green:ph24:led1/trigger
      The LED may be manually turned on and off using the brightness file. The minimum is 0 (i.e. off), and the maximum is 255. To switch it on:
      root@lemaker:~# echo 1 >  /sys/class/leds/green:ph24:led1/brightness 

      Let it blink

      #!/bin/bash
      
      echo none >  /sys/class/leds/green:ph24:led1/trigger
      while true; do
      echo 1 >  /sys/class/leds/green:ph24:led1/brightness
      sleep 1
      echo 0 >  /sys/class/leds/green:ph24:led1/brightness
      sleep 1
      done
      Make sure to run the script as root - e.g. sudo sh led.sh

      Saturday, 9 August 2014

      Banana Pi - Raspberry Pi Upgraded


      Given that I finally received my Banana Pi, it is time for a little review of the Chinese Raspberry Pi "competitor". Before I tell you about my first experiences with the board, let's have a quick look at its hardware specs and how they compare to the newly released Raspberry Model B +.


       

      Hardware


      The first thing that sticks out is the Banana Pi's much faster dual-core, Cortex-A7-based Allwinner A20 system-on-chip running at 1GHz, which definitely beats the Raspberry's "well-known" 700MHz, ARM11-based Broadcom BCM2835 processor.

      The Banana Pi is also equipped with 1GB of RAM and built-in Ethernet that can handle up to 1Gbps, which is approximately ten-times as fast as the Raspberry Pi's.

      Raspberry Pi Model B+
      Raspberry Pi Model B+
      The only area where the new Model B+ can really shine, next to the 4 x 2.0 USB ports, is the additional GPIO headers. There are now 40 compared to 26 on the Model B. The Banana Pi's GPIO layout is the same as the Raspberry Pi Model B, which makes most projects based on Raspbian and the RPi.GPIO libraries compatible with the Banana Pi.

      Unfortunately the Banana uses a parallel camera interface, which means that your Raspberry Pi camera board won't connect to the Banana's CSI interface. Luckily, Lemaker is working on their own module.

      Banana Pi
      Banana Pi
      Additionally the Banana Pi features some interesting ''perks'': power & reset switch, an IR receiver, a microphone, a programmable LED, SATA and a LVDS display interface.

      OS & first run

      The Banana Pi runs Lubuntu, Raspbian, Android, Fedora, Arch Linux, OpenSuse and Scratch.  The image files can be downloaded here: http://www.lemaker.org/content-9-38-1.html

      To write the image (in my case Raspbian) to a SD card, execute the following commands:
      #to get the location of your card. /dev/sdb in my case
      sudo fdisk -l
      #to write the image
      sudo bs=4M dd if=/home/user/Documents/Raspbian_For_BananaPi_v3_1.img of=/dev/sdb

      Default Credentials

      No need for a fancy HDMI monitor as ssh is enabled by default. Just connect the Pi via Ethernet and you are ready to go: the default credentials are userid: root, password: bananapi. To get the IP address of the Banana Pi, you can either access your router's control panel or perform a scan with nmap.
      #to scan for all the devices on the network  
      nmap -sn 192.168.0.1/24  
      #to connect  
      ssh root@192.168.0.20
      First thing you might want to do is to expand the file system and disable Desktop boot.
      root@lemaker raspi-config
      Select "Expand Filesystem" and reboot for the changes to take effect. The next thing I did was adding a new user, deleting the default bananapi user and disabling ssh access for the root user.
      #to add a new user  
      sudo adduser user  
      #to add a user to the sudo group  
      sudo adduser user sudo  
      #logout and login with your new user  
      #to delete the a user account  
      sudo userdel bananapi  
      # to disable root ssh login  
      sudo nano /etc/ssh/sshd_config  
      # restart ssh   
      sudo service ssh restart  
      
      Look for "PermitRootLogin" in the /etc/ssh/sshd_config file and set it to no.

      Setting Up Tight VNC Server

      If you are like me and using the BPi in headless mode, you might want to setup a VNC connection.
      # install tightvncserver  
      sudo apt-get update && sudo apt-get install tightvncserver -y  
      # start the vnc server  
      vncserver :1 -geometry 800x600 -depth 24  
      # now connect to the BPi with any VNC client. e.g. xtightvncviewer  
      xtightvncviewer  192.168.0.20:1 
      Banana Pi - Raspbian Desktop
      Banana Pi - Raspbian Desktop
      My initial verdict after a few hours with the Banana Pi is very positive indeed. You will notice a considerable performance increase compared to your Raspberry Pi and the board's peripherals (e.g. SATA) make it ideal for many projects. As far as I am concerned I do not see any significant downsides. Sure, there is no camera module yet and some RPi extension boards won't fit the BPi,  but overall a great effort by Lemaker. I'll be back with additional tutorials.

      Tutorials 

      Banana Pi: Onboard, User-Definable Green Led 

      Banana Pi: Temperature Sensor (DS18B20)

      Banana Pi: I2C Barometric Sensor BMP085

      Banana Pi: How To Install OpenMediaVault (NAS)

       

      Friday, 1 August 2014

      How To Install i2p On Debian Wheezy

      Steps should be performed with root access: i.e. sudo su

      Add the following lines to /etc/apt/sources.list.d/i2p.list

      1. nano /etc/apt/sources.list.d/i2p.list  
      2.   
      3. deb http://deb.i2p2.no/ stable main  
      4. deb-src http://deb.i2p2.no/ stable main 
      Download the key used to sign the repository and add it to apt
      1. apt-key add debian-repo.pub  
      Update repositories and install i2p
      1. apt-get update  
      2. apt-get install i2p i2p-keyring  
      Run i2p (NEVER AS ROOT!)
      1. i2prouter start  
      How To Install I2P On Debian Wheezy

      Monday, 21 July 2014

      How To Install Mate On Debian Wheezy

      Mate is forked from the unmaintained code base of GNOME 2 and has become quite popular. To install it on your debian wheezy, the following steps are required.
      1. sudo su  
      2. add-apt-repository 'deb http://repo.mate-desktop.org/debian wheezy main'  
      3. apt-get update  
      4. apt-get --yes --quiet --allow-unauthenticated install mate-archive-keyring  
      5. apt-get update  
      Install MATE core, the MATE desktop environment and the extras.
      1. sudo apt-get install mate-desktop-environment-extra  

      Friday, 18 July 2014

      Wednesday, 16 July 2014

      mmal: mmal_vc_component_enable: failed to enable component: ENOSPC

      This is a nasty bug with the Raspberry Pi camera module, which has not been resolved. Although I cannot guarantee that my solution will work for you, it fortunately did the trick for me.
      1. sudo apt-get update && sudo apt-get dist-upgrade  
      2. sudo rpi-update  

      Make sure your  /etc/modprobe.d/raspi-blacklist.conf looks like this.


      1. sudo nano /etc/modprobe.d/raspi-blacklist.conf  
      # blacklist spi and i2c by default (many users don't need them)

      #blacklist spi-bcm2708
      blacklist i2c-bcm2708

      My /etc/modules config

      1. sudo nano /etc/modules

       # /etc/modules: kernel modules to load at boot time.
      #
      # This file contains the names of kernel modules that should be loaded
      # at boot time, one per line. Lines beginning with "#" are ignored.
      # Parameters can be specified after the module name.


      w1-gpio pullup=1
      w1-therm
      i2c-bcm2708
      i2c-dev
      spi-bcm2708
      snd-bcm2835
      lirc_dev
      lirc_rpi gpio_out_pin=7

      Test

      1. sudo reboot  
      2. raspistill -v -o image.jpg  

      Sample output

      raspistill Camera App v1.3.8

      Width 2592, Height 1944, quality 85, filename image.jpg
      Time delay 5000, Raw no
      Thumbnail enabled Yes, width 64, height 48, quality 35
      Link to latest frame enabled  no
      Full resolution preview No
      Capture method : Single capture

      Preview Yes, Full screen Yes
      Preview window 0,0,1024,768
      Opacity 255
      Sharpness 0, Contrast 0, Brightness 50
      Saturation 0, ISO 0, Video Stabilisation No, Exposure compensation 0
      Exposure Mode 'auto', AWB Mode 'auto', Image Effect 'none'
      Metering Mode 'average', Colour Effect Enabled No with U = 128, V = 128
      Rotation 0, hflip No, vflip No
      ROI x 0.000000, y 0.000000, w 1.000000 h 1.000000
      Camera component done
      Encoder component done
      Starting component connection stage
      Connecting camera preview port to video render.
      Connecting camera stills port to encoder input port
      Opening output file image.jpg
      Enabling encoder output port
      Starting capture 0
      Finished capture 0
      Closing down
      Close down completed, all components disconnected, disabled and destroyed

      Raspberry Pi As A Radio Transmitter

      GPIO Raspberry PiFirst thing you have to do is attach a jumper wire to GPIO 4. That's it for the hardware part.

      The Software

      The Code that does the job is called Pifm by icrobotics.co.uk .
      1. wget www.icrobotics.co.uk/wiki/images/c/c3/Pifm.tar.gz  
      2. tar -xvf Pifm.tar.gz  

      Start Broadcasting

      1. sudo ./pifm sound.wav 100.5  
      - sound.wav - the audio file which you would like to broadcast. only .wav will work.
      - 100.5 - the FM frequency. usually between 87.5 and 108.0 MHz.

      Saturday, 12 July 2014

      [FIX] Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. Device 5289

      Couldn't get my SD card reader to work. This is what I had to do.

      wget https://bugs.launchpad.net/bugs/971876/+attachment/2991730/+files/rts_bpp.tar.bz2
      tar jxf rts_bpp.tar.bz2
      cd rts_bpp/


      Open the driver file “rtsx.c” and remove all instances of the string  “__devinit” “__devexit” and “__devexit_p” from it.

      Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. Device 5289
      make
      sudo make install
      sudo depmod
      sudo modprobe rts_bpp

      Put in your SD card. It should be automatically mounted.

      Thursday, 3 July 2014

      How To Enable USB Debugging On The Nexus 7

      Step 1 - Enable "Developer Options"


      Go into "About device" in Settings and tap on the "Build number" entry seven times. This will unlock "Developer Options".

      Step 2 - Enable "USB Debugging"


      Go into "Developer Options" and select "USB debugging" from the list of options.

      How To Enable USB Debugging in Android

      Tuesday, 24 June 2014

      How To Send Email With Python (smtplib and MIMEText)

      It is actually pretty easy to  send emails with python. The smtplib module provides the necessary "tools" to send mail to any Internet machine with an SMTP or ESMTP listener daemon.

      In this script I am using gmail, but it is not limited to Google as long as your provide the correct smtp server + port.

      Python 2.7.3 

      1. from email.mime.text import MIMEText  
      2. import smtplib  
      3.   
      4. def sendmail(to,subject,text):  
      5.     user = 'name@gmail.com'  
      6.     pwd = 'password'  
      7.     msg = MIMEText(text)  
      8.     msg['From'] = 'james@gmail.com'  
      9.     msg['To'] = to  
      10.     msg['Subject'] = subject  
      11.     try:  
      12.         smtpServer = smtplib.SMTP('smtp.gmail.com', 587)  
      13.         smtpServer.ehlo()  
      14.         smtpServer.starttls()  
      15.         smtpServer.ehlo()  
      16.         smtpServer.login(userpwd)  
      17.         smtpServer.sendmail(user, to, msg.as_string())  
      18.         smtpServer.close()  
      19.         print "mail sent."  
      20.     except SMTPException:  
      21.         print "failed."  

      Let's take it for a test drive... 


      How To Send Email With Python (smtplib and MIMEText)

       Seems to work.

      How To Send Email With Python



      Monday, 16 June 2014

      Automatically Check The Raspberry Pi's Temperature (+Prevent Overheating)

      No need to install anything. Just open a terminal and execute the following command to get the temperature of your RasPi.
      /opt/vc/bin/vcgencmd measure_temp

      Automate the process

      The below script will automatically reboot your Raspberry Pi should it reach a specified threshold (maxtemp). First of all make sure you can reboot/shutdown your raspi without linux asking you for a password. 

      user@user:~$ sudo visudo
      
      Add the following to the sudoers file. 
      user ALL=NOPASSWD: /sbin/shutdown
      

      The script

      Save as temp.sh. Maxtemp specifies the temperature cut-off point, at which the Raspi will reboot. 
      #!/bin/bash  
      #title           :temp.sh  
      #description     :Checks Temperature of Raspberry Pi and reboots at maxtemp.  
      #author          :Mike M | www.linuxx.eu  
      #notes           :Add "user ALL=NOPASSWD: /sbin/shutdown" to sudoers file   
        
      temp=`/opt/vc/bin/vcgencmd measure_temp | cut -c 6-7`  
      maxtemp=75  
      if [ $temp -ge $maxtemp ]; then  
      xmessage  "Alert! Temp above 75. System rebooting in 3 minutes"  
      sudo /sbin/shutdown -r +3  
      elif [ $temp -lt $maxtemp ]; then  
      exit 0  
      fi
      

      Create a cronjob

      user@user:~$ sudo crontab
      

      Add the following

      PATH=/usr/sbin:/usr/bin:/sbin:/bin
      */5 * * * * sh /home/user/temp.sh
      
      This will run the temp.sh script every 5 minutes and make sure that the Raspberry Pi does not overheat.

      Saturday, 14 June 2014

      Streaming Video From Your Raspberry Pi Camera Module with VLC

      If you want to build a surveillance cam you might want to have a look at motion, but for simple video streaming I 'd go for vlc.

      Enable Camera Module

      sudo raspi-config

      Install VLC Media Player

      sudo apt-get install vlc

      Stream (RTSP)

       raspivid -o - -t 0 -n -w 800 -h 600 -fps 20 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264

      - w: width
      - h: heigt
      - fps: frames per second

      Viewing The RTSP Stream 

      You need a video player capable of RTSP (e.g. VLC). Open a network stream:

      rtsp://###.###.###.###:8554/

      ###.###.###.### is the IP address of your raspberry pi. Also, do not forget the '/'  at the end, otherwise it won't work.

      Streaming Over HTTP

       raspivid -o - -t 0 -n -w 800 -h 600 -fps 20 | cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8554}' :demux=h264


      Streaming Video From Your Rasperry Pi Camera Module with VLC
      Camera Module

      Sunday, 8 June 2014

      How to Setup Wi-Fi On Your Raspberry Pi via the Command Line

      Configure Your AP Details

      sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

      Make sure the file reads like this

      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
      update_config=1
      
      network={
          ssid="SSID"
          proto=RSN
          key_mgmt=WPA-PSK
          pairwise=CCMP TKIP
          group=CCMP TKIP
          psk="yourkey"
      }

      Configuring the interface

       sudo nano /etc/network/interfaces

      Add the following

      allow-hotplug wlan0
      iface wlan0 inet manual
      wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
      iface default inet dhcp

      sudo ifconfig wlan0 down
      sudo ifconfig wlan0 up

      Reboot. Done.

      Configure WPA2 On Raspberry Pi
      Model B

      Thursday, 22 May 2014

      How to Host Your Own Tor Hidden Service

      This is a tutorial on how to securely host and run your own Tor hidden service.

      First thing that's required is your own web server and secondly you need to  configure the server in such a way as to prevent any possible information leaks (most importantly your location!).

      This tutorial makes use of whonix, which means any accidental leaks (DNS, IP etc.) are highly unlikely. For even better security consider using a dedicated machine for running your web server.

      So go ahead, download Whonix Workstation + Gateway. Download VirtualBox,  import the .ova files and fire up your machines. 

      On the Whonix Gateway
      sudo nano /etc/tor/torrc
      #make sure to add the following 2 lines to file, save and exit
      HiddenServiceDir /var/lib/tor/hidden_service/ 
      HiddenServicePort 80 10.152.152.11:80
      How to Host Your Own TOR Hidden Service Restart Tor
      sudo service tor@default reload
      A a hostname (e.g. 123xuadfuhqwer.onion) has been created! You can obtain it by displaying the contents of the  "hostname" file.
      sudo cat /var/lib/tor/hidden_service/hostname
      Now that you are done with configuring the Whonix Gateway, switch over to the Whonix Workstation, where we will install our Linux web server. I recommend using lighttpd an open-source web server which has an especially low memory footprint.
      sudo apt-get update
      sudo apt-get install lighttpd
      Browsing to your .onion address will now result in the default lighttpd "placeholder"  and you may proceed to get your content up and running. 
      How to Host Your Own tor Hidden Service

      Sunday, 18 May 2014

      How To Geolocate an IP Address with Python

      Python 2.7.3

      In order to geolocate an IP address with Python you will need a database to match an IP to a location. I am using the Maxmind database, which is available for free.
      wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
      gunzip GeoLiteCity.dat.gz
      Next, we install the Pure Python API for Maxmind's GeoIP databases (https://github.com/appliedsec/pygeoip)
      sudo pip install pygeoip
      Code
      import pygeoip
      rawdata = pygeoip.GeoIP('/home/user/GeoLiteCity.dat')
      def ipquery(ip):
          data = rawdata.record_by_name(ip)
          country = data['country_name']
          city = data['city']
          longi = data['longitude']
          lat = data['latitude']
          print '[x] '+str(city)+',' +str(country)
          print '[x] Latitude: '+str(lat)+ ', Longitude: '+ str(longi)
      
      Running the code
      How To Geolocate an IP with Python

      UPDATE - PYTHON 3 (Ubuntu 16.04)

      sudo pip3 install pygeoip
      Download Maxmind location-data
      user@user:~$ cd Desktop
      user@user:~/Desktop$ mkdir geolocate
      user@user:~/Desktop$ cd geolocate
      user@user:~/Desktop/geolocate$ wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
      user@user:~/Desktop/geolocate$ gunzip GeoLiteCity.dat.gz

      Code (save as geo.py in folder geolocate)

      import pygeoip
      rawdata = pygeoip.GeoIP('/home/user/Desktop/geolocate/GeoLiteCity.dat')
      def ipquery(ip):
          data = rawdata.record_by_name(ip)
          country = data['country_name']
          city = data['city']
          longi = data['longitude']
          lat = data['latitude']
          print ('[x] '+str(city)+',' +str(country))
          print ('[x] Latitude: '+str(lat)+ ', Longitude: '+ str(longi))
      
      #optional
      
      ip = input("What's your ip? ")
      print (ipquery(ip))
      

      Run the code

      user@user:~/Desktop/geolocate$ python3 geo.py
      What's your ip? 207.38.138.230
      [x] New York,United States
      [x] Latitude: 40.7449, Longitude: -73.9782

      Thursday, 15 May 2014

      Compiling Vertminer 0.5.2 TheKev's Fork On Ubuntu 12.04

      Tried this on Ubuntu 12.04 LTS but it should work on any other Linux OS. Open a terminal.

      sudo apt-get install autoconf opencl-headers libcurl4-openssl-dev libtool libncurses5-dev git

      git clone https://github.com/thekev/vertminer-gpu.git




      Download ADL (http://developer.amd.com/tools-and-sdks/graphics-development/display-library-adl-sdk/)

      Unzip and copy files from folder include  to vertminer-gpu/ADL_SDK/ folder

      Go back to your terminal.

      cd vertminer-gpu
      sudo su
      libtoolize
      autoreconf -ivf
      CFLAGS="-O2 -Wall -march=native" ./configure
      sh ./buildit.sh

      Friday, 11 April 2014

      VTC/USD, VTC/EUR and VTC/GBP Python Script

      You may  want download the file here: https://drive.google.com/file/d/0B06EJahqJCOCVzY1eTVMYTZDS00/edit?usp=sharing 

      import urllib2
      import json
      import time
      import pandas as pd
      from pandas import Series, DataFrame
      from urllib2 import URLError
      import ystockquote
      
      # Accessing VTC/BTC price from Cryptsy
      
      def vtcbtc():
          try:
              raw = urllib2.urlopen("http://pubapi.cryptsy.com/api.php?method=singleorderdata&marketid=151").read()
              dictionary = json.loads(raw)
              #BID
              bidraw = dictionary['return']['VTC']['buyorders']
              newformatb = pd.DataFrame(bidraw)
              newnameb = newformatb.rename(columns={'price': 'BID'})
              global finalbid1
              finalbid1 = newnameb[0:1]
          except URLError, error:
              print error
      
      #BTC/USD price from BTC-e
      
      def btcusd():
          btcePrices = urllib2.urlopen("https://btc-e.com/api/2/btc_usd/ticker").read()
          btcejson = json.loads(btcePrices)
          global btcelastP 
          btcelastP = btcejson['ticker']['last']
          
          global btcelastB #bid
          btcelastB = btcejson['ticker']['sell']
          
          global btcelastA #ask
          btcelastA = btcejson['ticker']['buy']
      
      def eurusd():
          global eur
          eur=ystockquote.get_price('eurusd=X')
      
      def gpbusd():
          global gbp
          gbp=ystockquote.get_price('GBPUSD=X')
      
      # Calculates Vert/USD price
      
      while True:
          vtcbtc()
          btcusd()
          eurusd()
          gpbusd()
          pricevtcbtc = float(finalbid1["BID"])
          VertUSD = btcelastP * pricevtcbtc
          VertEUR = VertUSD / float(eur)
          VertGBP = VertUSD / float(gbp)
          print time.strftime('%I:%M%p %Z on %b %d, %Y')
          print "VERT/$", VertUSD
          print "VERT/EUR", VertEUR
          print "VERT/GBP", VertGBP
          print
          time.sleep(20) #20 seconds.  
       
       
      Sample Output
       

      Tuesday, 1 April 2014

      Thursday, 27 March 2014

      How To Create A Bootable USB In Debian

      Yes, Unetbootin is a great tool, but for some reason I can't get it to work in Debian. Fortunately you can achieve the same by using the command line and it is nearly as straightforward as using unetbootin.


      Creating Bootable USB In Debian


      First, we want to get the exact name of our USB device.

      sudo fdisk -l

      The output should be similar to mine.

      Disk /dev/sdb: 2013 MB, 2013265920 bytes 

      Now that we now the location, we want to write our .iso or .img file to the USB.

      dd if='/home/user/Downloads/linuxmint-201403-mate-dvd-64bit.iso' of=/dev/sdb

      This will take some time, so be patient and do not interrupt the process.

      Sunday, 16 March 2014

      Automatically Reconnect WIFI (Debian, Ubuntu etc.)

      The Problem

      For several reason I do not have access to LAN and thus have to rely on WIFI for my mining rigs. It is fine for most of the time, but the shit hits the fan, when the connection drops for one reason or another.


      The Solution
      #!/bin/bash

      wlan=`/sbin/ifconfig wlan1 | grep inet\ addr | wc -l`
      if [ $wlan -eq 0 ]; then
      service network-manager restart
      else
      echo WIFI IS UP
      fi
      Note: It's either wlan0 or wlan1. Check with sudo ifconfig.

      Save the script and make it executable.

      sudo chmod +x filename.sh

      Now there are several ways of making sure that our script is being executed every x minutes. The easiest way of accomplishing that I think is by using the command watch.
      sudo su
      watch -n 600 sh filename.sh

      What it does is execute our filename.sh script every 600 seconds.

      Or you implement a so called cron job  

      sudo crontab -e

      Add the following

      PATH=/usr/sbin:/usr/bin:/sbin:/bin
      */5 * * * * sh /home/username/filename.sh

      */5 * * * * means that the task will run every 5 minutes.

      Monday, 3 March 2014

      Adding a Watermark To a Video Via Shell

      Recently I wanted to add a watermark to one of my videos. Obviously there are two possible ways of achieving this in Linux.

       
      Sample Watermark


      Via command line
      avconv -i input.mpg -vf “movie=watermark.png [watermark];[in][watermark] overlay=0:0 [out]” -c:v mpeg2video -an output1.mpg 

      Via Openshot (text)

      Openshot Video Editor is a free, open-source video editor for Linux licensed under the GPL version 3.0. http://www.openshot.org/

      sudo apt-get install openshot

      Open the program.
      CTRL + T
      Choose Footer
      Create New Title: <Enter your watermark>
      First color option: Pick your desired colour
      Second color option: Set Opacity to 0
      Apply and drag and drop to Track.

      Sunday, 2 March 2014

      Saturday, 1 March 2014

      Public Key Authentication SSH (Debian, Ubuntu)

      Generate RSA keys on Client

      mkdir ~/.ssh 
      chmod 700 ~/.ssh 
      ssh-keygen -t rsa -b 4096

      Transfer Client Key to Host

      ssh-copy-id username@host

      Test

      ssh username@host

      Disable Password Authentication On Host

      sudo nano /etc/ssh/sshd_config


      Look for <#PasswordAuthentication yes> and change it to <no>.

      Restart SSH

      sudo service ssh restart

      DONE

      Wednesday, 26 February 2014

      How To Monitor Failed SSH Attempts

      Disable Password Authentication for better Security

      More about SSH can be found here.

      You might be astonished how many people try to break into your computer via ssh. It is advisable to use key-based authentication only. Article for key-based authentication.

      Enable monitoring

      sudo gedit /etc/ssh/sshd_config
      --> change LogLevel INFO to LogLevel VERBOSE

      SSH login attempts will now be saved in your /var/log/auth.log file.

      Accessing the information

      sudo cat /var/log/auth.log | grep sshd
      sudo cat /var/log/auth.log | grep Fail

      sudo cat /var/log/auth.log | grep Invalid

      Disabling SSH all-together

      sudo mv /etc/init/ssh.conf /etc/init/ssh.conf.disabled

      Tuesday, 25 February 2014

      WPScan Tutorial (Debian, Ubuntu etc..)



      WPScan is a tool to automatically scan Wordpress-Blogs for vulnerabilities. Furthermore it can enumerate user names and carry out bruteforce attacks on accounts associated with the blog.

      Link: http://wpscan.org/

      Install

      sudo apt-get install libcurl4-gnutls-dev libopenssl-ruby libxml2 libxml2-dev libxslt1-dev ruby-dev git
      git clone https://github.com/wpscanteam/wpscan.git 
      cd wpscan 
      sudo gem install bundler && bundle install --without test development

      Enumerate vulnerable plugins and themes

      • Plugins  
      ruby wpscan.rb --url http://www.wpblog.com --enumerate vp
      • Themes
      ruby wpscan.rb --url http://www.wpblog.com --enumerate vt

      Get usernames

      ruby wpscan.rb --url http://www.wpblog.com --enumerate u

      Brute-forcing accounts

      Most of the time, user don't chance the default 'admin' username, so you should start here.

      ruby wpscan.rb --url www.wpblog.com --wordlist YOURWORDLIST --username admin

      You can get an extremely good wordlist here: https://crackstation.net/buy-crackstation-wordlist-password-cracking-dictionary.htm

      If you have any questions, drop me a line.

      Monday, 24 February 2014

      Locking The Screen In Openbox

      I guess most of you (including me) would like to lock their screens.  You  accomplish this  in Openbox by installing and using XscreenSaver.


      XScreenSaver

      Terminal

      sudo apt-get install xscreensaver
      sudo nano /home/YOURUSERNAME/.config/openbox/autostart.sh
      #ad this line
      xscreensaver -no-splash &#save and exit
      sudo chmod +x /home/YOURUSERNAME/.config/openbox/autostart.sh

      Adding an entry to obmenu
      obmenu
      new item ==> label: lock ==> action: execute ==> execute: xscreensaver-command -lock
      save the menu & exit

      You should now be able to lock your screen. 

      Sunday, 16 February 2014

      Installing Flappy Bird on Android (and iPhone)


      http://theadvertisingoutlet.files.wordpress.com/2014/02/flappy-bird.jpg

      It might be ''Game Over'' for Flappy Bird on the iTunes store, but its still possible to install and play the game.

      Download: File


      iPhone 

      Download and install iFunBox to your computer
      Connect iPhone to your computer
      Open iFunBox and click the <<Install App>> button
      Open the Flappy Bird .IPA file

      Android

      Settings > Security > Enable Unknown sources
      Open a web browser and download the Flappy Bird zip file
      Extract
      Open and install the file (.apk)


      That's it. 

      Saturday, 15 February 2014

      How To Mine Your First Litecoins For Free

      Before we start with the guide, I would like to point out that if you want to get serious, you need the invest some money.  This is what I would recommend and run myself (I have 4 rigs):

      3 * ASUS R9 280X-DC2T-3GD5 Graphics Cards 
      1 * ASRock MB-970EX4 Socket AM3+/ AMD 970
      1 * AMD Sempron 145 Processor
      1* Corsair Professional Series AX 1200 Watt
      1* Kingston Hyper X Blu 4 GB 
      PCI-E PCI Express 16X Riser  

      The 280x graphics cards currently offer the best bang for the buck and yield 740-760 khs each.


      Litecoin is scrypt-based


      But now back to the actual topic: i.e. how to mine your first Litecoins for free. ;)

      Requirements

      • sign up for a mining pool such as LTCRabbit and create a worker (LTCRabbit: My Account > My Workers > Add New Worker)
      • an azure trial account
      • approx. 15 min of your time
      The Azure Account

      You need a credit card to qualify for the trial period of 1 month (Link: Trial). Note that the subscription will end automatically. (You can even sign up twice with the same card ;) )

      After you have access, click on + new - compute - virtual machine -quick create.

      ==> choose Ubuntu server 12.04 LTS + Extra large

      Back to your machine

      Download Putty and open it. Link.

      Host: yourdnsname.cloudapp.net (the one you've chosen when creating the virtual machine)
      User: azureuser
      Password: yourpassword (password you've set before)

      You will be presented with a Linux terminal.

      Issue the following commands

      sudo su
      apt-get install build-essential libcurl4-openssl-dev
      wget http://sourceforge.net/projects/cpuminer/files/pooler-cpuminer-2.3.2.tar.gz
      tar xzf pooler-cpuminer-*.tar.gz
      cd cpuminer-*
      ./configure CFLAGS="-O3"
      make
      ./minerd --url=stratum+tcp://stratum+tcp://eu.ltcrabbit.com:3333 --userpass=username.worker:password --background

      Of course you need to adjust the settings (e.g. "username.worker:password"). Login to LTCRabbit  and you will be able to see your KH/S rate if everything is set up right.

      Now create another virtual machine and repeat the above steps.

      Any questions? Leave me a comment!

      Saturday, 1 February 2014

      OpenVpn Connected, But Not Directing/Routing Traffic (Windows 7 and Riseup VPN)


      I recently encountered a problem with OpenVpn and the riseup VPN on a friend's notebook. Although it connected and seemed to work none of the traffic was going over the RiseupVPN.


      This is the configuration of the .ovpn file that did the trick for me. Save it under C:\Program Files\OpenVPN\config\RiseupVpn.ovpn.
      client
      dev tun
      remote vpn.riseup.net
      auth-user-pass
      ca RiseupCA.pem
      redirect-gateway def1
      verb 4

      Or alternatively download the file here: https://drive.google.com/file/d/0B06EJahqJCOCOVV2NERwNEtVRlE/edit?usp=sharing

      Also, make sure to run  OpenVpn as administrator. Right click on the OpenVPN application >> choose “Run as Administrator"

      Thursday, 30 January 2014

      Installing Latest LibreOffice in Debian stable

      To get the latest version of libreoffice, do the following:

      sudo su
      echo 'deb http://ftp.debian.org/debian/ wheezy-backports main contrib non-free' >> /etc/apt/sources.list
      echo 'deb-src http://ftp.debian.org/debian/ wheezy-backports main contrib non-free' >> /etc/apt/sources.list


      apt-get update && apt-get -t wheezy-backports install libreoffice

      Wednesday, 29 January 2014

      Tuesday, 21 January 2014

      How to hash and crack UNIX passwords in python

      Crypt module

      I am using the crypt module here, which is a one-way hash function based upon a modified DES algorithm. You can easily adjust the script to crack secure hash algorithms (SHA1, SHA224, SHA256, SHA384, and SHA512 (defined in FIPS 180-2) as well as RSA’s MD5 algorithm ) by using the hashlib  module.

      Crypt Overview

      import crypt
      crypt.crypt("user", "AD")
      'AD5Qg2vQhsLRw'

      AD is the salt, which is a random two-character string which will be used to perturb the DES algorithm in one of 4096 ways.

      The python password cracking script

      import crypt
      def testPass(hashpass):
          salt = hashpass[0:2]
          dictionary = open('dictionary.txt', 'r') #this is our dictionary file
          for word in dictionary.readlines():
              word = word.strip('\n')
              crypto = crypt.crypt(word,salt)
              if crypto == hashpass:
                  print "[+] Password: "+word+"\n"
                  return
          print "[-] Password Not Found.\n"
          return
      
      def main():
          hashpass = open('passwords.txt', 'r') #file with hashed password
          for line in hashpass.readlines():
              if ":" in line:
                  user = line.split(':')[0]
                  hashpass = line.split(':')[1].strip(' ')
                  print "[*] Cracking Password For: "+user
                  testPass(hashpass)
      if __name__ == "__main__":
          main() 
       
      Save the script as cracker.py.
      You also need to create a dictionary.txt and password.txt  (with the hashed passwords) file to successfully run the program.

      Create a new folder and put the three files into it, afterwards simply run 
      python cracker.py

      You can download all of the files here: Drive

      Sunday, 12 January 2014

      Installing Metasploit on Debian (or Ubuntu)














      sudo su  
      
      apt-get -y install build-essential zlib1g zlib1g-dev libxml2 libxml2-dev libxslt-dev locate libreadline6-dev libcurl4-openssl-dev git-core libssl-dev libyaml-dev openssl autoconf libtool ncurses-dev bison curl wget postgresql postgresql-contrib libpq-dev libapr1 libaprutil1 libsvn1 libpcap-dev  
      
      apt-get install git-core postgresql curl ruby1.9.3 nmap gem  
      gem install wirble sqlite3 bundler  
      
      cd /opt  
      git clone https://github.com/rapid7/metasploit-framework.git  
      
      cd metasploit-framework  
      bundle install  
      
      ./msfconsole  


      msfconsole tutorial: click