Monday, December 29, 2008

Bash scripting :: Handling filenames with spaces


The following script moves a specified amount of files from the currect directory to a specified directory. I had a lots of images saved in one folder. Accessing the folder used to take a long time. So I decided to put the files chronologically in seperate folders. The challenge was - lots of my files had spaces in their names. So, a normal "for i in `ls -t`" does not work. So, I came up with the following work around. So far it works pretty good ;)



 1 #!/bin/bash
 2
 3 my_space="XXYYZZ"
 4 me=`basename $0`
 5
 6 if [ -z $1 ] || [ -z $2 ];then
 7         echo
 8         echo "[*] usage:  $me  dirname how_many"
 9         echo
10         exit
11 fi
12
13 if [ ! -d $1 ];then
14         echo
15         echo "[*] '$1' does not exist."
16         echo
17         exit
18 fi
19
20 ii=`ls -t1 | grep -v $me | sed "s/ /$my_space/g"`
21
22 c=0
23 for i in $ii
24 do
25         c=$((c+1))
26         n=`echo $i | sed "s/$my_space/ /g"`
27         echo -n "[$c]  "
28         mv -v -f "$n" $1
29         if [ $c -ge $2 ];then
30                 exit
31         fi
32 done
33

Tuesday, December 23, 2008

Ubuntu/Linux force monitor to turn on/off


DPMS (Display Power Management Signalling) for vesa compliant devices can be controlled by two tools on linux:
  1. xset
  2. vbetool
man xset/vbetool for more details.

To force the monitor to stay turned on or off can be achieved by doing the following:

root@kubuntu:/home/babil# xset dpms force on/off
OR,
root@kubuntu:/home/babil# vbetool dpms on/off

Tuesday, December 16, 2008

Generating initrd on ubuntu


  • compile the kernel

    cd /usr/src/dccp_exp


    make ; make modules ; make install ; make modules_install


  • generate initrd

    update-initramfs -k 2.6.xx-xx -c

  • update grub entries to reflect the new kernel

    update-grub


Friday, December 12, 2008

Reading BIOS


dd if=/dev/mem bs=1k skip=768 count=256 2>/dev/null | strings -n 8


Thursday, November 27, 2008

Awk pattern matching over a particular field


1 #!/bin/bash
2
3 echo babbbbil 12223 | awk '{for(i=1;i<=NF;i++){if($i ~ "122"){print $i;i=NF+1}}}'
4

This piece of awk code will go through all the fields and look for pattern "122" and print them. The "i=NF+1" will work like "break;" in C which will make awk to stop printing after the first hit. Happy Awk'ing ;)


Controlling netgear ( D834G ) router from shell


You can perform the following operations from the shell
  • Disconnect
  • Connect
  • Reconnect (Disconnect, then connect again)
  • Show status
  • reboot router



1 #!/bin/bash
2
3 router_ip=192.168.0.1
4 username="admin"
5 password="CHANGE-ME"
6
7 debug_url="http://$router_ip/setup.cgi?todo=debug"
8 status_url="http://$router_ip/setup.cgi?next_file=s_status.htm"
9 connection_url="http://$router_ip/setup.cgi?next_file=st_poe.htm"
10 disconnect_url="http://$router_ip/setup.cgi?todo=disconnect&next_file=st_poe.htm"
11 connect_url="http://$router_ip/setup.cgi?todo=connect&next_file=st_poe.htm"
12
13
14 RED='\e[1;31m'
15 CYAN='\e[1;36m'
16 NC='\e[0m' # No Color
17
18 tmp_file="/tmp/babil-router.info"
19 sleep_time=3
20
21
22 function clean_up()
23 {
24 rm -f $tmp_file
25 }
26
27 function reboot_router()
28 {
29 report=`wget -q --user $username --password $password $debug_url -O /dev/null`
30 echo "[+] $report"
31 sleep 2
32 (sleep 2; echo "reboot"; sleep 2) | telnet $router_ip
33 }
34
35
36 function ip()
37 {
38 #curl --basic --user $username:$password $status_url 2>/dev/null | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
39 wget -q --user $username --password $password $status_url -O - | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
40
41 c=1
42 while read line
43 do
44 #echo "$c $line"
45 if [[ $c == 71 ]];then
46 echo -e "[+] outbound ip : ${RED} $line ${NC}"
47
48 elif [[ $c == 83 ]];then
49 echo -e "[+] gateway ip : ${RED} $line ${NC}"
50
51 fi
52
53 c=$((c+1))
54
55 done < $tmp_file
56 clean_up
57 }
58
59
60 function stat()
61 {
62
63 ip
64
65 #curl --basic --user $username:$password $connection_url 2>/dev/null | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
66 wget -q --user $username --password $password $connection_url -O - | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
67
68 c=1
69 while read line
70 do
71 #echo "$c $line"
72 if [[ $c == 61 ]];then
73 echo -e "[+] duration : ${RED} $line ${NC}"
74
75 elif [[ $c == 65 ]];then
76 echo -e "[+] status : ${RED} $line ${NC}"
77
78 fi
79
80 c=$((c+1))
81
82 done < $tmp_file
83
84 clean_up
85
86 }
87
88
89 function connect()
90 {
91 echo -n "[+] connecting "
92 #curl --basic --user $username:$password $connect_url 2>/dev/null | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
93 wget -q --user $username --password $password $connect_url -O - | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
94 for ((i=0;i<$sleep_time;i++))
95 do
96 echo -n "."
97 sleep 1
98 done
99
100 echo
101 stat
102 }
103
104
105 function disconnect()
106 {
107 echo -n "[+] disconnecting "
108 #curl --basic --user $username:$password $disconnect_url 2>/dev/null | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
109 wget -q --user $username --password $password $disconnect_url -O - | sed -e :a -e 's/<[^>]*>//g;/<;/N;//ba' > $tmp_file
110 for ((i=0;i<$sleep_time;i++))
111 do
112 echo -n "."
113 sleep 1
114 done
115
116 echo
117 stat
118 }
119
120 case "$1" in
121
122 connect)
123 echo
124 connect
125 echo
126 ;;
127
128 disconnect)
129 echo
130 disconnect
131 echo
132 ;;
133
134 stat)
135 echo
136 stat
137 echo
138 ;;
139 reboot)
140 echo
141 reboot_router
142 echo
143 ;;
144 reconnect)
145 echo
146 connect
147 echo
148 disconnect
149 echo
150 ;;
151 *)
152 echo
153 echo -e "[+] usage: `basename $0` { ${RED}connect | disconnect | reconnect | stat | reboot${NC} }"
154 echo
155 exit 1
156 ;;
157
158 esac
159
160

Saturday, November 22, 2008

Ubuntu (intrepid) - skype blocking audio device


After performing a very starnge (and stupid) migration from kubuntu-intrepid to edubuntu-intrepid, then to xbunbu-intrepid and lastly to original Ubuntu-intrepid, my skype sound was blocking all other audio softwares from using my sound card while in a skype-call (basically no software mixing).

I seem to have found two solutions for the problem after suffering and searching for almost a day:

solution-1:: making sure you have pulse-audio installed [1]

  • backup previous configuration files
$ mkdir ~/pulse-backup && cp -r ~/.pulse ~/.asound* /etc/asound.conf /etc/pulse -t ~/pulse-backup/
$ sudo rm -r ~/.pulse ~/.asound* /etc/asound.conf


  • install pulse and adobe flash
$ sudo apt-get install libasound2-plugins padevchooser libao-pulse libsdl1.2debian-pulseaudio flashplugin-nonfree; apt-get remove --purge libflashsupport flashplugin-nonfree-extrasound



solution-2:: create a dummy "skype" device for alsa [2]

  • copy and paste the folling code in ~/.asoundrc and restart skype
======================================================================
pcm.skype {
type asym
playback.pcm "skypeout"
capture.pcm "skypein"
}

pcm.skypein {
# Convert from 8-bit unsigned mono (default format set by aoss when
# /dev/dsp is opened) to 16-bit signed stereo (expected by dsnoop)
#
# We can't just use a "plug" plugin because although the open will
# succeed, the buffer sizes will be wrong and we'll hear no sound at
# all.
type route
slave {
pcm "skypedsnoop"
format S16_LE
}
ttable {
0 {0 0.5}
1 {0 0.5}
}
}

pcm.skypeout {
# Just pass this on to the system dmix
type plug
slave {
pcm "dmix"
}
}

pcm.skypedsnoop {
type dsnoop
ipc_key 1133
slave {
# "Magic" buffer values to get skype audio to work
# If these are not set, opening /dev/dsp succeeds but no sound
# will be heard. According to the alsa developers this is due
# to skype abusing the OSS API.
pcm "hw:0,0"
period_size 256
periods 16
buffer_size 16384
}
bindings {
0 0
}
}
======================================================================



[1] http://ubuntuforums.org/showthread.php?t=789578&highlight=pulseaudio+perfect
[2] http://ubuntuforums.org/showthread.php?t=44753&page=15




Monday, October 27, 2008

Extract audio stream from a video file by "mencoder"


mplayer -vc null -vo null -ao pcm -benchmark test.avi


Thursday, October 23, 2008

Skype crashes in VitualBox


This is a bug in skype (or maybe intentional by skype people). However using an older version saves the day :: http://www.filehippo.com/download_skype/4090/

latest version that works :: Skype 3.8.0.115


Wednesday, October 22, 2008

X forwarding problem on Debian/Etch


  1. check /etc/ssh/sshd_config : X11Forwarding yes
  2. apt-get install xbase-clients

ssh -X username@hostname should forward X applications properly now ;)


Wednesday, September 24, 2008

Rotate figures in latex


\begin{figure}[!ht]
\begin{center}
\rotatebox{270}{\includegraphics[scale=0.32]{b}}
\caption{bla bla blah}
\label{fig_1}
\end{center}
\end{figure}


Thursday, September 18, 2008

Here Without You


A hundred days have made me older
Since the last time that I saw your pretty face
A thousand lies have made me colder
And I don't think I can look at this the same
But all the miles that separate
Disappear now when I'm dreaming of your face

I'm here without you baby
But you're still on my lonely mind
I think about you baby
And I dream about you all the time
I'm here without you baby
But you're still with me in my dreams
And tonight it's only you and me

The miles just keep rolling
As the people leave their way to say hello
I've heard this life is overrated
But I hope that it gets better as we go

I'm here without you baby
But you're still on my lonely mind
I think about you baby
And I dream about you all the time
I'm here without you baby
But you're still with me in my dreams
And tonight girl its only you and me

Everything I know, and anywhere I go
It gets hard but it won't take away my love
And when the last one falls
When it's all said and done
It gets hard but it wont take away my love

I'm here without you baby
But you're still on my lonely mind
I think about you baby
And I dream about you all the time
I'm here without you baby
But you're still with me in my dreams
And tonight girl its only you and me

--"3 Doors Down"




Sunday, September 14, 2008

Rename AppleTV plugins



vim /Volumes/OSBoot/System/Library/CoreServices/Finder.app/Contents/PlugIns/nitoTV.frappliance/Contents/Resources/English.lproj/InfoPlist.strings

replace nitoTV.frappliance with the plugin name you want to replace ;)




Thursday, September 11, 2008

Swapping eth1/eth0 names


On Debian/Ubuntu, the file to look into is here :

/etc/udev/rules.d/z25_persistent-net.rules


Stop LaTex from breaking words


\newcommand{\nwb}[1]{\sloppy #1 \fussy}

\nwb{DO_NOT_BREAK_THIS_WORD}


Friday, September 5, 2008

Reverse engineering on Linux :: CrackMe (1)

The CrackMe is here :: http://www.crackmes.de/users/libertyordeath/libertyordeaths_keygenme_3/

0x8048a18 --> anti-debug
0x80489b0 --> serial can be sniffed from EAX.

name hash is generated here ::

=========================================
0x80488b6 : shl DWORD PTR [ebp-0x220],1 <----- shift.left 0x80488bc : add esi,0x1
0x80488bf : movzx eax,BYTE PTR [esi+ebp*1-0x10f]
0x80488c7 : test al,al
0x80488c9 : je 0x80488de
0x80488cb : test esi,0x1
0x80488d1 : je 0x80488b6
0x80488d3 : movsx eax,al
0x80488d6 : mov DWORD PTR [ebp-0x220],eax
0x80488dc : jmp 0x80488b6
=========================================


hostname hash is generated here ::

=================================================================
0x80488e0 : mov DWORD PTR [ebp-0x224],0x0
0x80488ea : jmp 0x8048904
0x80488ec : lea esi,[esi+eiz*1+0x0]
0x80488f0 : test bl,0x1
0x80488f3 : jne 0x8048901
0x80488f5 : imul eax,ebx <------------
0x80488f8 : imul eax,esi <------------
0x80488fb : mov DWORD PTR [ebp-0x224],eax
0x8048901 : add ebx,0x1
0x8048904 : mov eax,ds:0x80494e4
0x8048909 : mov DWORD PTR [esp],eax
0x804890c : call 0x8048574 <_io_getc@plt>
0x8048911 : cmp eax,0xa
0x8048914 : jne 0x80488f0
===================================================================

Keygen ::


#include "stdio.h";
#include "string.h";

int main ()
{
 char name[30];
 char hostname[30];

 int  i;
 int name_hash;
 int host_hash;

 printf("\n[?] Input name : ");
 scanf("%s",name);

 printf("[?] Input hostname : ");
 scanf("%s",hostname);

 for (i=0;i<strlen(name);i+=2)
 {
  name_hash = name[i] * i * strlen(hostname);
 }

 for (i=1;i<strlen(hostname);i+=2)
 {
  host_hash = hostname[i] << 2;
 }

 printf("\n>>> serial = %d-",name_hash+host_hash);

 for (i=0;i<strlen(hostname);i+=2)
 {
  putchar(hostname[i]);
 }

 printf("\n\n");
 return 0;
}

Writing tutorial is very boring, yet if anyone wants to know any detail, drop me a line. I'll try to explain. The CrackMe was not very difficult anyway.

Wednesday, August 27, 2008

Syntax highlighted source code in latex


\usepackage{color}
\usepackage{listings}

\definecolor{Brown}{cmyk}{0,0.81,1,0.60}
\definecolor{OliveGreen}{cmyk}{0.64,0,0.95,0.40}
\definecolor{CadetBlue}{cmyk}{0.62,0.57,0.23,0}


\lstset{
language=R,
frame=ltrb,
framesep=5pt,
basicstyle=\normalsize,
keywordstyle=\ttfamily\color{OliveGreen},
identifierstyle=\ttfamily\color{CadetBlue}\bfseries,
commentstyle=\color{Brown},
stringstyle=\ttfamily,
showstringspaces=false,
breaklines=true
}

\beging{lstlisting}

[SOURCE CODES GOES HERE]

\end{lstlisting}


The environment has support for the following languages :: Fortran, C, C++, csh, HTML, Java, Matlab, Mathematica, Pascal, Perl, SQL, XML, Delphi, PHP, VBScript, SAS and even Latex itself - and many more.


Monday, August 18, 2008

Converting 3gp to Avi

ffmpeg -i input.3gp -f avi -vcodec xvid -acodec mp3 -ar 22050 output.avi

Monday, August 11, 2008

Converting & joining multiple MPEG-1 files into one AVI


  • convert with "ffmpeg" ::
ffmpeg -i input-1.avi -r 24 output-1.avi
ffmpeg -i input-2.avi -r 24 output-2.avi
ffmpeg -i input-3.avi -r 24 output-3.avi
ffmpeg -i input-4.avi -r 24 output-4.avi


  • cat them together ::
cat output-1.avi outout-2.avi output-3.avi output-4.avi > out_tmp.avi

  • recreate the audio/video index with "mencoder" ::
mencoder -forceidx -oac copy -ovc copy out_tmp.avi -o out_final.avi


  • OR, in one mplayer command:



    mencoder -forceidx -oac copy -ovc copy file1.avi file2.avi -o final_output.avi
  • OR, use 'avimerge':

    If on Debian/Ubuntu, "apt-get install transcode-utils" ... doing this will make sure, 'avimerge' is present in the system.

    avimerge -o output.avi -i input1.avi input2.avi


Friday, August 8, 2008

Keu Kotha Rakheni :: Shunil Gangapaddhay

-----------------------------------------------------------------------------------------------------------------
little note ::

well, after all, learning to be able to type in my own language was not
that difficult at all :P
i can't believe, in all these years of me playing with
computers, this actually is the first thing ever i typed in bengali.
so, guess what, like everything else that was/is good 'n bad in me ...
this one is for you too ...


if fonts look broken, try FireFox 3.0. it seems unicode bengali fonts
are quite broken both
with ie6 and opera. Or if you don't have Firefox, click here.
-----------------------------------------------------------------------------------------------------------------


কেউ কথা রাখেনি,তেত্রিঁশ বছর কাটলো, কেউ কথা রাখেনি
ছেলেবেলায় এক বোষ্টুমি তার আগোমনী গান হঠাৎ থামিয়ে বলেছিল
শুক্লা দ্বাদশীর দিন অন্তরা টুকু শুনিয়ে যাবে ।

তারপর কত চন্দ্রভুক অমাবশ্যা এসে চলে গেল কিন্তু সেই বোষ্টুমি
আর এলো না
পঁচিশ বছর প্রতীক্ষায় আছি ।


মামা বাড়ির মাঝি নাদের আলি বলেছিলো, বড় হও দাদা ঠাকুর
তোমাকে আমি তিনপ্রহরের বিল দেখাতে নিয়ে যাব
সেখানে পদ্মফুলের মাথায় সাপ আর ভ্রমর
খেলা করে !

নাদের আলি, আমি আর কতো বড় হব ? আমার মাথা এই ঘরের ছাদ
ফুঁড়ে আকাশ স্পর্শ করলে তারপর তুমি আমায়
তিন প্রহরের বিল দেখাবে ?


একটাও রয়্যাল গুলি কিনতে পারিনি কখনো
লাঠি-লজেন্স দেখিয়ে, দেখিয়ে চুষেছে লস্করবাড়ির ছেলেরা
ভিখারীর মত চৌধুরিদের গেটে দাঁড়িয়ে দেখেছি
ভেতরের রাস উৎসব
অবিরল রঙের ধারার মধ্যে সুবর্ণ কঙ্কণ পরা ফর্সা রমনীরা
কত রকম আমোদে হেসেছে
আমার দিকে তারা ফিরেও চায়নি ।

বাবা আমার কাঁধ ছুঁয়ে বলেছিলেন, দেখিস, একদিন আমরাও

বাবা এখন অন্ধ, আমাদের দেখা হয়নি কিছুই
সেই রয়্যাল গুলি, সেই লাঠি-লজেন্স, সেই রাস-উৎসব
আমাকে কেউ ফিরিয়ে দেবে না !


বুকের মধ্যে সুগন্ধি রুমাল রেখে বরুনা বলেছিল
যেদিন আমায় সত্যিকার ভালোবাসবে
সেদিন আমার বুকেও এরকম গন্ধ হবে !

ভালবাসার জন্যে আমি হাতের মুঠোয় প্রাণ নিয়েছি
দুরন্ত ষাঁড়ের চোখে বেঁধেছি লাল কাপড়
বিশ্ব সংসার তন্ন তন্ন খুঁজে এনেছি ১০৮টা নীলপদ্ম
তবু কথা রাখেনি বরুনা, এখন তার বুকে শুধুই মাংসের গন্ধ
এখনো সে যে কোনো নারী !

কেউ কথা রাখেনি, তেত্রিঁশ বছর কাটলো, কেউ কথা রাখনি ।।

-- সুনীল গঙ্গোপাধ্যায়

Thursday, August 7, 2008

"RE" On Linux :: Debugging stripped binaries with GDB


gdb$ info file
This will print the entry point of the file.

Symbols from "/home/babil/Desktop/Keygenme_v3/Keygenme_v3.p2".
Local exec file:
`/home/babil/Desktop/Keygenme_v3/Keygenme_v3.p2', file type elf32-i386.
Entry point: 0x8048610 0x08048114 - 0x08048127 is .interp
0x08048128 - 0x08048148 is .note.ABI-tag
0x08048148 - 0x080481dc is .hash
0x080481dc - 0x08048200 is .gnu.hash
0x08048200 - 0x08048320 is .dynsym
0x08048320 - 0x0804840e is .dynstr
0x0804840e - 0x08048432 is .gnu.version
0x08048434 - 0x08048464 is .gnu.version_r
0x08048464 - 0x08048474 is .rel.dyn
0x08048474 - 0x080484e4 is .rel.plt
0x080484e4 - 0x08048514 is .init
0x08048514 - 0x08048604 is .plt
0x08048610 - 0x08048c0c is .text
0x08048c0c - 0x08048c28 is .fini
0x08048c28 - 0x08048d76 is .rodata
0x08048d78 - 0x08048d7c is .eh_frame
0x08049000 - 0x08049008 is .ctors
0x08049008 - 0x08049010 is .dtors
0x08049010 - 0x08049014 is .jcr
0x08049014 - 0x080490fc is .dynamic
0x080490fc - 0x08049100 is .got
0x08049100 - 0x08049144 is .got.plt
0x08049160 - 0x080494e4 is .data
0x080494e4 - 0x080494f0 is .bss


Now set a temporary break on that address. (don't miss the star before 0x8048610)
gdb$ tbreak *0x8048610


"RE" On Linux :: Enable core dump


$ ulimit -c 1024
This will enable a maximum core size of 1GB.

$ gdb ./app ./core
Should get you started ;-)



Tuesday, August 5, 2008

Kaminsky's DNS bug :: solution for linux


Wednesday, July 23, 2008

Patch for "NoDelay" - GreaseMonkey script


The script can be downloaded from :: http://userscripts.org/scripts/show/6499

Changing the "Megashare" function with the following will make the script stop at the password prompt, if the file is protected by password. Otherwise it goes in an intfinite loop ...
function megashare(tld){
 if (tld!='com') return;
 try { unsafeWindow.c=0; } catch(e){};
  unsafeWindow.setTimeout(
   function() {
       try { 
    //var urlLink = getFirstXPathResult("//input[@name='auth_nm']");
    var urlLink = getFirstXPathResult("//*[contains(text(), 'Enter Password')]");
    if(!urlLink){
     findClick("//input[@value='Click Here to Download']"); 
    }

   } catch(e){}
   
   }, 1000);
 try { findClick("//input[@name='FreeDz']"); } catch(e){};
 try { findClick("//input[@name='yes']"); } catch(e){};
}

Extracting files from bin/cue images on Linux


method-1:


apt-get install bchunk

bchunk file.cue file.bin file.iso
mount -t ISO9660 -o loop file.iso /mnt/

method-2:

cdemu. packages can be downloaded and installed from - http://cdemu.sourceforge.net

method-3:

works the best for me. use acetoneiso, official website - http://www.acetoneiso.netsons.org


Change DNS cache timeout on FireFox


Type about:config in the address bar
Filter for DNS


  • network.dnsCacheEntries user set integer 512
  • network.dnsCacheExpiration user set integer 3600

The first entry shows the amount of addresses firefox will keep in cache and not try to resolve everytime.
The second entry is how long each entry will be cached for.

Happy Browsing !!


Sunday, July 20, 2008

The Ice Is Getting Thinner


We're not the same, dear
As we used to be
The seasons have changed
And so have we
And there was little we could say
And even less that we could do
To stop the ice from getting thinner
Under me and you

We buried our love
In a wintery grave
A lump in the snow
Was all that remained
Though we stayed by its side
As the days turned to weeks
And the ice kept getting thinner
With ever word that we'd speak

And when the spring arrived
We were taken by surprise
When the flows under our feet
Bled into the sea
And nothing was left
For you and me

We're not the same, dear
And it seems to me
There's nowhere we can go
With nothing underneath
And it saddens me to say
What we both knew was true
That the ice was getting thinner
Under me and you

The ice was getting thinner
Under me and you


Monday, July 14, 2008

Playing/Saving RAM files with mplayer

mplayer -dumpstream -dumpfile last_stop.rm -playlist http://boss.streamosXX.com/real/dreamworksXX/eelsXX/electroshockbluesXX/videoXX/laststop_hi.ram

The trick to play .ram file is to add -playlist, as .ram files are just textfiles containing the real url.
saving is done by -dumpstream & -dumpfile filename


Friday, July 11, 2008

Duplicating tab on Firefox-3


press ctrl + drag-n-drop the tab on tab-bar ... kool, huh ?


Khudha ...

'''
kobitar snigdhota ar chai na
kobita, aj dilam tomae chuti

khudhar jalay prithibi goddo-moy
purnimar chad jeno jholshano ruti
'''

lol true, so true. It probably comes to worse if you are not a good cook yourself. But this one I guess is even better (also helps me from feeling so miserable) - “For now are the moments that you'll definitely cherish for life!”

Tuesday, July 8, 2008

Wondering what happened to epstopdf on Ubuntu/Debian ?



apt-get install texlive-extra-utils
On latest Ubuntu Quantal (12.10) apparently the package for epstopdf is changed to texlive-font-utils. So now you have to do the following: 
apt-get install texlive-font-utils

Check hotmail/yahoo with Kmail




To install on Debian/Ubuntu:

apt-get install freepops
sudo freepops-updater-dialog

To download sent mail folder set the username as username@webmail.com?folder=Sent.
If not specified "Inbox" is assumed.

With kmail, one can create seperate directories (ex. yahoo [inbox], yahoo [sent]) and associate accounts with these folders. This way messages remain more organized and they can simply be dragged and dropped to the gmail's "all mail" directory later on, to save all the mails on google's massive servers with ever increasing inbox space forever, for a greater webmail experience and excellent searching capability.

Good Luck, Happy webmailing !!


Wednesday, June 18, 2008

Rapidshare premium download with Wget

#!/bin/bash
# Original author: Mark Sullivan

#########################################################
# I had to modify the script, actually stripped it down,#  
# gotten rid of some unnecessary stuffs. Now it works   #
# perfect on Debian/Ubuntu. -- babil, 18th june'2008.   #
#########################################################
 

RED='\e[1;31m'
CYAN='\e[1;36m'
NC='\e[0m' # No Color
cookie=cookie.txt

if [ -z $3 ] ; then 
 echo
 echo "[*] $0   " 
 echo
 exit 1  
else
 user=$1
 pass=$2
 url=$3
fi


echo -e "${RED}REALURL:${CYAN} $url${NC}"
fileName=`basename $url`
echo -e "${RED}FILENAME: ${CYAN}$fileName${NC}"

## LOGIN and save cookie ##
wget --save-cookies=$cookie -q --post-data="login=$user&password=$pass" https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi -O /dev/null
wget --load-cookies=$cookie $url -O $fileName

## CLEAN UP ##
rm $cookie


Wednesday, June 11, 2008

Vim freezes with Ctrl+S

lol ... now this is a very strange and funny problem. Most of us are used to ctrl+s for saving files, but on vim it just freezes everything. Specially if you are on a ssh session, have just added 100 lines of code to your cool new application, ctrl+s can effectively ruin all the fun all of a sudden. Well the solution to this problem was not very complicated, try pressing ctrl+q ;)

Well, found the solution to this problem somewhere here :: http://vimdoc.sourceforge.net/cgi-bin/vimfaq2html3.pl#32.1. And this is what it says ::

Many terminal emulators and real terminal drivers use the CTRL-S key to
stop the data from arriving so that you can stop a fast scrolling display
to look at it (also allowed older terminals to slow down the computer so
that it did not get buffer overflows).  You can start the output again by
pressing the CTRL-Q key.

When you press the CTRL-S key, the terminal driver will stop sending the
output data. As a result of this, it will look like Vim is hung. If you
press the CTRL-Q key, then everything will be back to normal.

You can turn of the terminal driver flow control using the 'stty' command:

$ stty -ixon -xoff

or, you can change the keys used for the terminal flow control, using the
following commands:

$ stty stop 
$ stty start 

Saturday, May 31, 2008

AC3 demystified for AppleTV (Fsck You Apple !!)

Anywayz, it just didn't have to be this complicated. "Apple" could easily make this box do a lot more than what it does now without keeping this superb-lame intention of leaving this box half crippled and restricted.

Back to the point ...

[»] AC3 works only through optical output, should also work through hdmi, but I have not tested it myself since I have only 1 hdmi cable at home.

[»] change the following keys in apple.tv by logging in as frontrow :

(1) defaults write com.cod3r.a52codec attemptPassthrough 1

if you have ATV-files installed ::
(2) defaults write net.ericiii.ATVFiles EnableAC3Passthrough 1

if you have nitoTV installed ::
(3)
defaults write com.apple.frontrow.appliance.nitoTV passthru 1


[»] nitoTV automatically installs ffmpeg at this location :: /System/Library/CoreServices/Finder.app/Contents/PlugIns/nitoTV.frappliance/Contents/Resources/ffmpeg

[»] to check if a video has ac3 :: ffmpeg -i video.avi ... it will print the audio/video informations for the input video.

[»] after changing the keys, restart frontrow or reboot appleTV and play the video with AC3, it should give you 5.1 sound output now.

Fsck you Apple, for making it so complicated, if I knew it before, I would have just bought a cheap media-center pc and would happily run mythTV on it. FSCK you again ... Either make a proper iTunes for linux or leave the damn thing out of the way, so that I can store and play my files on the device without any intervention of the fscking itunes ...

[ sorry guys, just couldn't stop myself. I kind of spent the whole last night digging into this ac3 problem, went to bed at 7am in the morning. now you tell me, who would know those correct key names to change, if you dont digg this much ... sorry once again for not being able to control my rage on Apple for making so unnecessarily complicated ]

Fuzzy check if a bash input is string or a number

Couldn't think of anything better. Please leave comments if anything better exists.

#!/bin/bash
read -p "[*] input" in

if [ $((in+1)) -eq 1 ]
then
 echo "input is a STRING"
else
 echo "input is a number"
fi


Friday, May 30, 2008

send sms from shell !!! [pennytel]


source code for my "sms.sh" with some bells and whistles ... ;-)

#!/bin/bash

db='/home/babil/scripts/sms.db'

### input password
echo
read -s -p "[*] enter password: " pass 
echo
###


### input recipient
echo
recp_no=''

while [ -z "$recp_no" ]
do
 read -p "[*] enter recipient: " recp_in
 
 if [ $((recp_in+1)) -eq 1 ]
 then
  s=''
  s=`cat $db | grep -w $recp_in`

  if [ ! -z "$s" ]
  then
   recp_name=`cat $db | grep -w $recp_in | awk '{print $1}'`
   recp_no=`cat $db | grep -w $recp_in | awk '{print $2}'`
   echo "[*] recipient number found : $recp_no"
  else
   recp_no=''
  fi
 else
  
  recp_no=$recp_in

  s=''
  s=`cat $db | grep -w $recp_in`
  if [ -z "$s" ]
  then
   read -p "[*] give recipient a name : " recp_name
   echo "$recp_name $recp_no" >> $db
   
  else
   recp_no=`cat $db | grep -w $recp_in | awk '{print $2}'`
   recp_name=`cat $db | grep -w $recp_in | awk '{print $1}'`
  fi
 fi
done
###



### input sender
echo
sender_in=''
read -p "[*] enter sender: " sender_in

if [ $((sender_in+1)) -eq 1 ]
then
 s=''
 s=`cat $db | grep -w $sender_in 2>/dev/null`

 if [ ! -z "$s" ]
 then
  sender_no=`cat $db | grep -w $sender_in | awk '{print $2}'`
  sender_name=`cat $db | grep -w $sender_in | awk '{print $1}'`
  echo "[*] sender number found : $sender_no"
 else
  sender_no=''
 fi
fi

if [ -z "$sender_no" ]
then
 echo "[*] using default sender : 614XXXXXXXX"
 sender_name='default'
 sender_no='614XXXXXXXX'
fi
###


### input message
rem=0
while [ $rem -le 0 ]
do
 echo
 read -p "[*] enter message: " msg
 msg=`echo $msg | sed -e 's/ /\+/g'`

 len=${#msg}
 rem=$((157-len))
 if [ $len -ge 157 ]
 then
  echo -n "[$len/$rem]"
 fi
done
###



### print info
echo
echo "[>] recipient  : $recp_name $recp_no"
echo "[>] sender     : $sender_name $sender_no"
echo "[>] message    : $msg"
echo "[>] length     : $len / $rem"
echo
###


### confirm with user
read -n1 -p '[?] are you happy with the setting : [y/n]  ' yn
echo

if [ "$yn" != "y" ] || [ ! "$yn" != "Y" ]
then
 exit 1
fi
###


### send message
echo
echo '[*] Trying to send ...'
echo

curl -c cookie.txt -d "username=6128XXXXXXX&password=$pass" "https://www.pennytel.com/m/login.jsp" -L 2>&1 1> /dev/null 
 
m=`curl -b cookie.txt -d "trans=SendSMS&pagecaller=SMS&smstype=Premium&recipient=$recp_no&smscount=1&message=$msg&counter=$rem&mobilenumber=%2B$sender_no&credit=%24+4.31&freesms=0&walalang=FREE" "https://www.pennytel.com/sms_sent.jsp" -L -A='Mozilla/5.0' -e='http://www.pennytel.com/m/index.jsp?error=Invalid%20Entry' -# 2>/dev/null | grep "Please enter your username and password"`
 
echo
if [ -z $m ]
then
 echo '[*] SUCCESS.'
else
 echo '[*] FAILED.'
fi
 
rm cookie.txt 2>/dev/null
echo
###