Tuesday, October 30, 2012

Selenium headless with python

Headless selenium. Will be useful to integrate with CI

Install virtual display and python wrapper for it:
 $ sudo apt-get install xvfb xserver-xephyr  
 $ sudo pip install pyvirtualdisplay  
Usage example:
 from pyvirtualdisplay import Display  
 from selenium import webdriver  
 """visible=0, visible=1 for display or not virual display"""  
 display = Display(visible=0, size= (1024, 768))
 display.start()
 driver= webdriver.Chrome() 
 driver.get('http://www.qa-notes.blogspot.com')
 print 'The title of current page is: ', driver.title  
 driver.quit()
 display.stop()  

Saturday, October 27, 2012

Install Java in Ubuntu 12.04

If there is a problem with java in Ubuntu, remove previous version 
$sudo apt-get purge openjdk*
add new repo and install Oracle Java 7
$sudo add-apt-repository ppa:webupd8team/java
$sudo apt-get update
$sudo apt-get install oracle-java7-installer

Sunday, October 14, 2012

Just for me

///////
$ echo 'Andrii The Great' | hexdump -Cv
00000000 41 6e 64 72 69 69 20 54 68 65 20 47 72 65 61 74 |Andrii The Great|
00000010 0a |.|
00000011
$ echo -e '\x41\x6e\x64\x72\x69\x69\x20\x54\x68\x65\x20\x47\x72\x65\x61\x74'
Andrii The Great
: if you have huge amount of hex data to convert to binary---you can use xxd utility (part of vim package).
$ echo -e $( echo "30 31 323334 35 " | sed 's/ //g; s/../\\x&/g' )
////////

WPA Suplicant How to

wpa_supplicant short guide

1. Download last stable supplicant from http://hostap.epitest.fi/wpa_supplicant/
2. Install libssl-dev, if it wasn’t installed
3. Install wpa-gui
On Debian-based:
sudo apt-get install wpagui
4. Backup your /etc/resolv.conf
cp /etc/resolv.conf/etc/resolv.conf.old
5. Stop your systems network-manager, to stop wpa_supplicant
sudo invoke-rc.d network-manager stop
6. Restore your /etc/resolv.conf from backup mv /etc/resolv.conf.old/etc/resolv.conf
7. Create or edit your wpa_supplicant.conf, example, which is working for me:
cat /etc/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=users
8. Go to wpa_supplicant directory and create a config file:
cd wpa_supplicant-0.7.3/wpa_supplicant/
cp defconfig .config
9. Enable WPS support by editing .config file
cd wpa_supplicant-0.7.3/wpa_supplicant/
vim ./config
uncomment the following line:
CONFIG_WPS=y
9. Build supplicant, which was downloaded
cd wpa_supplicant-0.7.3/wpa_supplicant/
make
10. Start your supplicant
sudo ./wpa_supplicant -i<wireless interface> -c/etc/wpa_supplicant.conf -d
11. Start your wpa_cli
sudo ./wpa_cli -p /var/run/wpa_supplicant -i <wireless interface>

Performing WPS using wpa_cli
1. Initiate scan in wpa_cli:
In wpa_cli console type:
>scan
to show scan results:
>scan_result

2. WPS-PIN
In wpa_cli console type:
>wps_pin <BSSID> <PIN>
3. WPS-PBC
In wpa_cli console type:
>wps_pbc <BSSID>
wpa_cli will ensure you that client is connected.
By the way, use help:
>help
Performing WPS using wpa_gui
1. Start wpa_gui
Alt+F2 ---> gksu wpa_gui
2. Choose WPS tab
3. Press “Generate PIN” button
4. Copy generated PIN to yours device WEB gui and start WPS.
5. Ensure that your client is connected.

Have fun!:)