Saturday, 20 December 2014

Distro hunt for Dell M4800

Few weeks ago i received my Dell M4800 Mobile Workstation. It's a nice machine with good config and lot of power.
My config has

Intel Core i7-4710MQ
QHD+ Screen (3200x1800)
750 GB 7200 RPM HDD
SmartCard Reader
FingerPrint Reader

However, before placing order with Dell i did a lot of search on google to find reviews of existing owners of M4800.
And i found that lot of users are not happy with M4800 with Linux. Few have WiFi issues, few have screen brightness issues, few have problem with sound and etc...

Even after reading about those problems i decided to go with Linux (as left Windows 3 years ago and now live with Linux for day to day use, now i use Windows only for .Net development only). 

After receiving the machine, first i tried to get my hands dirty with preinstalled Ubuntu 12.04 LTS. It is working fine and there were no such issues as i read over internet.
But Ubuntu 12.04 is quite old and also i don't like Unity. So i decided to try other distro.

I tried with following distros
Ubuntu 14.04
Kubuntu 14.04
Kali Linux  (based on Debian) with Gnome3
Kali Linux with KDE4
Arch Linux with Gnome3
Arch Linus with KDE4

Except the Arch+KDE all distro has some problems. One thing is working in a distro but not in other and vise-versa.

Here is summery of different distro evaluation on M4800.

Ubuntu 12.04 LTS
Kernel 3.5.X
Ubuntu 14.04
Kernel 3.13.X
Kubuntu 14.04
Kernel 3.13.X
Kali Linux + Gnome
Kernel 3.14.X
Kali Linux + KDE
Kernel 3.14.X
Arch + Gnome
Kernel 3.17.X
Arch + KDE
Kernel 3.17.X

WiFi Switch on/off
WiFi should auto-connect after switch off and on
But doesn't recognize unless once turn radio (hardware wifi switch) off then on.
Fingerprint Reader(not tested)(not tested)(not tested)(not tested)(not tested)(not tested)(not tested)
Smartcard Reader(not tested)(not tested)(not tested)(not tested)(not tested)(not tested)(not tested)

BrightnessWorkingNOT WORKINGWorking
But response was slow. After pressing keys it take 1-2 sec to change brightness.
Touchpad ToggleWorkingWorkingWorkingWorkingNOT WORKINGWorkingWorking
Volume ButtonsWorkingWorkingWorkingWorkingWorkingWorkingWorking

Screen Lock
Password box should appear to unlock (no blank screen)
Screen Turn Off
Screen should turn on after mouse/keyboard activity
Wakeup After Sleep
Screen should turn on and Password box should appear wakeup
Virtual Terminal
Blank Screen Problem
Here Virtual Terminal Blank Screen Problem exist on all distros. It is actually the problem with nVidia display driver and distros has nothing to do with it (i guess).

As you can see above, only two distros are working fine. One is Ubuntu 12.04 LTS that comes preinstalled, and another is Arch Linux with KDE.

After playing with both the distro i prefer Arch. I found Arch very light weight, much responsive than Ubuntu and without bloatware (that Ubuntu has like Unity).

So it is all about the distro hunt for Dell M4800. I spend many days to find a working and stable distro so i thought i should share it, it may help another M4800 owner ;)

Saturday, 31 August 2013

Install NVIDIA Proprietary Driver in Kali Linux and Debian wheezy

If you are using Linux and have NVIDIA graphics card then most likely you are using open source NVIDIA driver nouveau. It works quite well, but if you want to use 3D acceleration feature or want to use GPU based applications then you need to install NVIDIA proprietary driver. Here is how to do it. First Install linux headers as those will be required to build nvidia modules. Issue following command at terminal
$ aptitude -r install linux-headers-$(uname -r)
Now install required nvidia components. Following command will install and build nvidia modules, and also disable nouveau module.
$ aptitude install nvidia-kernel-dkms
Now we should create new Xorg server configuration file or modify existing to tell it to load nvidia module. nvidia-xconfig package make this task quite easy, install and execute it.
$ aptitude install nvidia-xconfig
$ nvidia-xconfig
Now reboot and check if system is using nvidia graphics driver. On start of xsession nvidia splash screen should be displayed. You can also confirm it by issuing following commands
First check if system is using glx module.
$ glxinfo | grep -i "direct rendering"
It should output "direct rendering: Yes"
If you do not have glxinfo then first install mesa-utils package then again issue above command and check output
$ aptitude install mesa-utils
Check if nvidia module loaded.
$ lsmod | grep nvidia
If it produces output like 'nvidia      11239499  45' or something similar (numbers could be different at your system) then nvidia module is loaded.
Just to be sure nouveau module NOT loaded, issue following command
$ lsmod | grep nouveau
It should NOT produce any output. If it produces output then something is wrong.
If you are planning to use NVIDIA Graphics Driver just for better disply and 3D rendering then it is almost finished. But if you want to run applications that uses NVIDIA CUDA for processing (like cudahashcat+) then you will also need to install CUDA drivers as below
$ aptitude install nvidia-cuda-toolkit nvidia-opencl-icd
 Now you should be able to use applications designed to utilize GPU.

Thursday, 4 July 2013

Boot KALI Linux in console mode (command line) as it was in BackTrack

A good thing i like in BackTrack was it boot in console mode. It is quite helpful if we have to run few console commands instead of using full GUI.

But Kali linux directly boot into graphical mode. To make it boot into command line mode we need to remove auto start of xdm service (or kdm or gdm based on your desktop manager) from current runlevel.

To do it first we need to know current runlevel. Issue following command

$ who -r

Remember your current runlevel from output of previous command. Mine is 2.

We also need to know service name of display manager we are running, check it with following command (replace 2 with your run level)

$ chkconfig --list | grep '2:on'

It will list all services set to autostart for run level 2. Look here for entry similar to gdm or kdm or xdm etc. I am running gdm3.

Ok, now we have identified which service (gdm3 in my case) we have to turn off at which run level (mine is 2).

Now issue following command to stop gdm3 service for run level 2.

$ chkconfig --level 2 gdm3 off

Now on next boot it will boot into command line login. After login use startx command to start xsession.

Failsafe: If something went wrong or later you decided to boot again into graphical mode, revert it back with following

$ chkconfig --level 2 gdm3 on

Note: I do not remember if chkconfig is pre-installed with Kali or i installed it manually. In case it say 'chconfig command not found' then you can install it with following command

apt-get install chkconfig

That's all. Happy pentesting with Kali linux :)

Sunday, 9 June 2013

Customize workspace, change wallpaper, execute script on workspace switching

I mostly switch to dfferent workspace and i really like if i could have different settings on different workspace like different wallpaper.
A few solutions like using compiz along with few plugins already exist (i don't know if they work or not because i have never tried them), but they are limited only to wallpaper change. I was looking for something where i can run my own commands on changing workspace.
After googling a lot i found a small C program here. It was really cool (thanks to Isaac) and showing a notification on workspace switching. I had taken C (wsn.c) code from there, modified and added support to call scripts on each workspace change.
You can download modified C code along with the compiled binary here. Binary is compiled on Debian Wheezy Stable x64, it may or may not work on your configuration. If it doesn't work then compile it from C code, don't worry compiling it is quite easy.
Using the wsnd program
USAGE:  wsnd [-s] [-1:script -2:script -3:script -4:script]

-s           Silent mode. Turn off displaying notification,
             but passed scripts will be executed.
-1:script    Path to script to be executed when workspace 1 activated.
-2:script    Path to script to be executed when workspace 2 activated.
-3:script    Path to script to be executed when workspace 3 activated.
-4:script    Path to script to be executed when workspace 4 activated.

    wsdn -1:~/ -2:~/
Ok, so what we have to do is, just pass path to a script that we want to execute when a particular workspace activated.
In above example i set wsdn to execute when i switch to wroskspace 1 and execute when i switch to workspace 2. I use only two workspaces so i skipped passing arguments for workspace 3 and 4.
We can also pass -s argument, to stop showing notification on workspace switching but passed scripts will still execute.
What the scripts and doing?
Both scripts are doing three things-
First changing the wallpaper, second mute/unmute sound and third toggling touchpad.
In Workspace-1 i usually do my work, lot of typing etc. so i simply turnoff touchpad and also mute sound.
In workspace-2, i do browsing, listening songs etc., so again i turned touchpad on and unmute sound.
Here is how my looks like

# change wallpaper
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s /home/samtech/Pictures/evolution.jpg

# turn off touchpad
synclient touchpadoff=1

# mute sound
/usr/bin/amixer --quiet set Master toggle
You are free to use different commands as per your needs.
Set wsnd to run on startup
Set wsnd to auto start by adding it to 'Application Menu' > Settings > 'Session and Startup'. Do not forget to pass scripts to execute.

Compiling from the code
If attached binary doesn't work for you then you can compile the application with following command
gcc -O2 -o wsnd pkg-config  --cflags --libs libnotify --libs libwnck-1.0 wsn.c
It it doesn's work then try this
gcc -O2 -DWNCK_I_KNOW_THIS_IS_UNSTABLE -o wsnd pkg-config  --cflags --libs libnotify --libs libwnck-1.0 wsn.c
It it complain for libnotify and libwnck not found then run following to install missing libraries
sudo apt-get install libnotify-dev libwnck-dev
Then again try to compile.
Hope it will help you customize your different workspace as you want it to be.
It is working well on my XFCE 4.8, i have not  tested but it should work on other desktops too. On other desktops you may need to use different commands, like for changing wallpaper in GNOME use gconftool-2.

Saturday, 8 June 2013

Listing network connections along with associated application name in conky

Conky's TCP port monitor (tcp_portmon) is quite useful to list inbound/outbound connections. You can find many examples of tcp_portmon by googling concy inbound outbound connections.

Only the problem i see with tcp_portmon is that it doesn't provide name of associated application/process using that connection.

To list application name along with connection details we can make use of netstat command with conky's texeci.

After applying it in conky, it will look similar to this

Here is how to do it
Open your .conkyrc file in text editor

gedit ~/.conkyrc

Paste following at the end of TEXT section

${color Tan2}ESTABLISHED Connections${color DarkSlateGray}${hr 2}

${offset 10}${color lightgrey}Inbound: ${color white}${tcp_portmon 1 32767 count}    ${color lightgrey}Outbound: ${color white}${tcp_portmon 32768 61000 count}${alignr}${color lightgrey}Total: ${color white}${tcp_portmon 1 65535 count}

${color slate grey}Process                 ${color slate grey}Remote Host                     ${color slate grey}L-Port ${alignr}${color slate grey}R-Port${color lightgrey}

${font Ubuntu Mono:size=8}${texeci 30 netstat -ap | grep 'ESTABLISHED' | sed -r 's|.*[0-9.]+:([0-9]*)\s*([^:]+):([a-zA-Z]+)[^/]+/([a-zA-Z0-9]*)|\4 \2 \1 \3|' | awk '{printf("%-14s %-20s %5s %7s\n",$1,$2,$3,$4)}'}

Save and close file.

Now conky will display established connections along with associated process name and refresh it every 30 seconds.

Instead of remote host and port name you can display remote IP and port number like below

Conky displaying connection list with remote IP and port

For this layout paste following in your .conkyrc files instead of above.

${color Tan2}ESTABLISHED Connections${color DarkSlateGray}${hr 2}

${offset 10}${color lightgrey}Inbound: ${color white}${tcp_portmon 1 32767 count}    ${color lightgrey}Outbound: ${color white}${tcp_portmon 32768 61000 count}${alignr}${color lightgrey}Total: ${color white}${tcp_portmon 1 65535 count}

${color slate grey}Process                 ${color slate grey}Remote IP              ${color slate grey}L-Port ${alignr}${color slate grey}R-Port${color lightgrey}

${font Ubuntu Mono:size=8}${texeci 30 netstat -anp | grep 'ESTABLISHED' | sed -r 's|.*192.[0-9.]+:([0-9]*)\s*([0-9.]+):([0-9]+)[^/]+/([a-zA-Z0-9]*)|\4 \2 \1 \3|' | awk '{printf("%-14s %-15s %5s %5s\n",$1,$2,$3,$4)}'}

Friday, 7 June 2013

Using Kali Linux as main Operating System

If you are a fan of kali linux then probably you may want to use it as your main operating system (i do).
Here are following thumbs Up to use it as main OS
  • It is based on most popular rock solid debian wheezy, which is now stable release of debian.
  • It is as stable as debian wheezy
  • Large package repository. One can use almost all the packages that can be used on debian wheezy
  • Regular updates available.
And following thumbs Down for not to use it as main OS
  • It is designed for pentesting (with some modifications in kernel) and has lot of pentest/exploiting tools pre-installed
  • It work with root (super user) account

That's ok, but what's the verdict? Should we use it as main OS or not?
In my openion we can use it as main OS but we should use it with non-root user for regular use, and use root login only for pentesting.
Here is how you can create regular (non-root) user
Open terminal and type following to create new user (replace user1 with your desired user name)
useradd -m user1
Now set password for this user
passwd user1
    Enter desired password twice.
Add user to sudo group so  you can run common commands (like fdisk -l)
usermod -a -G sudo user1
4. Change default shell of previously created user to bash
chsh -s /bin/bash user1
All done! Now logout from root account and login as non-root user.
Enjoy Kali Linux as your main OS.
Note: If you like to strenghten the secuity then you should also setup firewall rules using gufw or firestarter.

Saturday, 6 October 2012

Securing your FileZilla settings from prying eyes

FileZilla save FTP site settings in plain text including passwords.
There is no way to save FTP passwords in encrypted form (as of my knowledge). The only thing we can do is, save FileZilla settings to encrypted volume/disk.

To do it we we need edit fzdefaults.xml file and change 'Config Location' property to location where we want to save our passwords.
Here are steps we need to follow

1. Find fzdefaults.xml.example file. On my debian squeeze it is located at '/usr/share/doc/filezilla-common/examples/'. Issue following command to find it at your computer

sudo find -name fzdefaults.xml.example

2. Copy it to $HOME/.filezilla folder. Do not forget to put here actual path to folder having fzdefaults.xml.example

cp (path to folder)/fzdefaults.xml.example ~/.filezilla/fzdefaults.xml

3. Open copied file in text editor

gedit ~/.filezilla/fzdefaults.xml

4. Scroll down and loacte property "Config Location". There will be a path just next to it. Replace it with the path to your desired secured location. Save and close.

5. Now move your previously saved FTP site settings to secured location. Make sure you move it NOT copied.

mv ~/.filezilla/sitemanager.xml (your desired secured path)/sitemanager.xml

Now all is done!
To verify if new settings are effective, run FileZilla, you should see all your old FTP settings there.