Showing posts with label debian. Show all posts
Showing posts with label debian. Show all posts

Tuesday, 29 September 2015

How to connect to WiFi using command line Ubuntu, Debian etc.

Tried to upgrade to Ubuntu 15.10 Beta 2, rebooted  and my system was broken. Could not connect to LAN, so my only option was to connect to Wifi via command line to hopefully repair my system.

This is what I did.

First, open a terminal:

Ctrl-Alt-T

If you got WPA like me you need wpa_supplicant to set it up, because iw can only handle WEP.

To bring up your wireless device (most likely wlan0):
sudo -s
ifconfig wlan0 up
#now scan for available wifi networks and note the ssid of your device
iwlist wlan0 scan
In /etc/wpa_supplicant.conf we need to put our ssid and password:
nano /etc/wpa_supplicant.conf
Example config:
network={
                     ssid="ssid"
                     psk="wifi password"
}

Ctrl + A to close and save.
To connect:
sudo wpa_supplicant -B -iwlan0 -c/etc/wpa_supplicant.conf -Dwext
Open a second tab/terminal:
sudo dhclient wlan0
Your connection should now work!

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

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, 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

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.

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

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.

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.