Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Friday, October 18, 2013

Ubuntu 13.10 PHPMyAdmin - mcrypt extension is missing

I am setting up a new Drupal installation with LAMP on Ubuntu (Saucy Salamander - 13.10). Installing the LAMP server and PHPMyAdmin was like a breeze. I just needed the following command:
sudo apt-get install lamp-server^ phpmyadmin
Once I logged into the fresh PHPMyAdmin interface, I realized that "mcrypt" module is missing in default Ubuntu installation. The error I found at the bottom of the PHPMyAdmin page simply page said:

"The mcrypt extension is missing. Please check your PHP configuration."

After doing a quick "apt-cache search", I found the right php5-mcrypt module that I was missing. So I issued:
sudo apt-get install php5-mcrypt
sudo service apache2 restart
Interestingly, even after this I had the "mcrypt missing" error. So I took a quick look inside my /etc/php5/ directory and found the "mcrypt.ini" inside /etc/php5/conf.d. Now for apache2 PHP5 module, the configuration files are located inside /etc/php5/apache2/conf.d (not in /etc/php5/conf.d). So I realized that although mcrypt was installed for PHP5, it was not being loaded fro Apache.

So the fix was as shown below. Basically I am just creating a symlink for mcrypt.ini inside PHP5's Apache configuration directory.
cd /etc/php5/apache2/conf.d
sudo ln -s ../../conf.d/mcrypt.ini 30-mcrypt.ini
sudo service apache2 restart
 Hope you find it useful too!

Saturday, March 10, 2012

Recovering from repeated crash at Firefox (11 Beta 7) start-up

Quick Solution
 
Delete
  • session.js
  • sessionstore.bak
  • files inside sessions folder
from inside your Firefox profile directory. Follow this page to find out where you profile directory is located.

How I found what caused the crash
 
After quite few "unresponsive script" error inside Firebug 1.9.1 (mostly on LifeHacker.com and Boston.com) and repeatedly selecting "Stop Script" with no apparent benefit, I chose to kill Firefox from Windows Task Manager [1]. For those who don't know that it is - try pressing "CTRL+Shift+Esc" on your keyboard or just right-click on your task-bar and select "Start Task Manager". It looks like this:


I didn't realize the fun is just about to begin. To my surprise, upon the next restart Firefox started as usual and but quickly crashed. It kept happening much like flashing the Firefox's main window for a second or two and boom, it crashed! This behavior was already a good indication that it might be caused by a corrupted file, most probably a SQLite [2] database and this must have happened due to my killing Firefox forcefully using the Windows Task Manager. So, I started to digging around for a resolution.

First, I tried to start Firefox in "Safe Mode" with all add-ons disabled as suggested here [3] with "-safe-mode" flag. It didn't work! From my all previous experience, Firefox's safe-mode always seemed the best way to solve crash related problems, buggy extensions and add-ons. But, in this case it kept crashing even in safe-mode.

Then, I tried to open Firefox in "Private Browsing" mode with the "-private" flag. On Windows 7 (I guess on Vista too), this can be done with right-clicking the Firefox task-bar icon and selecting "Enter Private Browsing". Interestingly, Firefox was able to start in this so-called incognito mode! This was another strong hint that some files must be corrupted in my "Firefox Profile Folder" [4].

To try the theory, I closed all running instances of Firefox and I renamed Firefox's "profiles.ini" [5] to "profiles.ini.bak" to force Firefox into creating a fresh new profile. I started Firefox and it successfully created a new profile in my "%APPDATA%\Mozilla\Firefox" directory. The new profile directory was named "an9pz0cj.default".  By the way, if you are like me and you love your Firefox's plethora of customized settings and very longs list (77 in my case) of plugins only to profoundly avoid reinstalling them, don't forget to regularly backup your profile directory. My default previous profile directory was called "yn0z15ze.default" and I backed it up in a RAR archive.  After generating a fresh profile, which also generated a new profiles.ini, I copied all files (not folders, I decided to try them in the second iteration) from "an9pz0cj.default" and pasted them in "yn0z15ze.default". Windows 7's copy and paste is great. It kept showing me all the conflicts due to size, date-time of source and destination files. I kept the list of the files where the file-size was different. In my case, the list looked like the following:
  • cert8.db - SSL certificates are stored here.
  • chromeappsstore.sqlite -- HTML5 local data store.
  • content-perfs.sqlite -- Individual settings for pages.
  • permissions.sqlite -- Permission database for cookies, pop-up blocking, image loading and add-ons installation.
  • search.sqlite -- Information about search plugins
  • sessionstore.bak -- saved sessions.
  • sessionstore.js -- saved previous session
  • signons.sqlite -- Encrypted saved passwords
  • TestPilot.log --  Log file.
  • webappsstore.sqlite -- DOM local storage.
I Google'd up on the name of the files and got a rough idea of what they are meant for and how they are used inside Firefox. So, at this point I my preferred profile "yn0z15ze" is working but with some default files which means I must have lost some data, may be some customizations too as the list contains cert8.db, search.sqlite and signons.sqlite etc.

Now comes the final part - I have to test each of the files above one by one and figure out which one was causing the crash. As you may have gotten the idea already - I love my Firefox and my customizations. So, I wanted to make sure that I lose minimum amount of data due to the crash.

So, I renamed my previously moved "profiles.ini.bak" to "profiles.ini". By the way, profile.ini looks like below:
[General]
StartWithLastProfile=1

[Profile0]
Name=default
IsRelative=1
Path=Profiles/an9pz0cj.default
Default=1
So, I could have just replaced "an9pz0cj" with "yn0z15ze" and saved profile.ini to achieve switching between profiles. Anyways, I did that anyhow and started copying files as shown on the bulletted list above from  "yn0z15ze" RAR archive to now running "yn0z15ze" with some fresh files of "an9pz0cj". I kept restarting Firefox each time to check if Firefox is crashing. After a few iterations of stopping Firefox, copying fresh files into "yn0z15ze" and restarting, I stopped at "sessionstore.js". I copied this file and Firefox crashed!

Wow, so now I know which file was causing my Firefox to crash! Also, now that I know this file only contains a list of my tabs which I was browsing before the very initial task-manager kill, I can safely disregard this file now ;). Phew, so the case is solved. If you happen to come across a situation like mine, try deleting the "session.js" and/or "sessionstore.bak" and/or files inside "sessions" folder. It's weird that even in Firefox's safe-mode the problem managed to persist. Time for a bug report I guess :). Hope you find it useful.

[1] http://en.wikipedia.org/wiki/Windows_Task_Manager
[2] http://en.wikipedia.org/wiki/Sqlite
[3] http://kb.mozillazine.org/Safe_Mode
[4] http://kb.mozillazine.org/Profile_folder_-_Firefox
[5] http://kb.mozillazine.org/Profiles.ini_file

Friday, September 2, 2011

Forcing Vim's syntax highlighting (for odd file extensions)

I often tend to keep backup copies of my C/C++ source files with odd extensions (i.e. something that does not end with CC or C). If these files are opened with Vim, they wouldn't be recognized as they should, which means my CTAGS extension and colored syntax highlighting would both refrain to work. The quick solution to this problem is to tell Vim explicitly about the file type. Here is how one can do it:
:setfiletype c
More information on it, as always:
:help setfiletype

Monday, September 6, 2010

Installing Ubuntu with AARNET mirror

This post applies to you, only if ...
  • you are in Australia 
  • and you want to use AARNET's  mirror (which for many people would work a lot faster than the standard Australian Ubuntu mirror)
 Default Ubuntu installation provides the standard AU mirror for Australians. To use AARNET, you have to enter the following details manually during installation:
  1. Protocol: http (ftp should also be supported but I haven't tested it)
  2. Mirror address: mirror.aarnet.edu.au
  3. Mirror path: /pub/ubuntu/archive/ (don't drop the slashes, type them as shown)




Monday, May 3, 2010

Splitting 4 GB or bigger files for Fat32

Fat32 can not handle files bigger than 4 gigabytes. Surprisingly Fat32 still prevails on almost every USB stick. 'Split' command in Linux can be very handy to transfer files bigger than 4 gig using USB sticks.

Copy & paste the following to split file on Linux:

split --verbose --numeric-suffixes --bytes=3990000000 'large_input_file.mkv' 'output_'
Joining can be done by 'cat' or 'copy /B' on Windows.

Tuesday, April 13, 2010

Ubuntu/Debian: Flash not responding to any click

I found the fix here: http://helpforlinux.blogspot.com/2009/11/i-cannot-click-on-flash-in-ubuntu.html

As instructed, perform the following and restart your firefox:
  • Hit ALT+F2 and enter
  • gksudo gedit /usr/lib/nspluginwrapper/i386/linux/npviewer
  • add the following line BEFORE the last line of text
  • export GDK_NATIVE_WINDOWS=1
  • Save.
  • Restart any applications using flash

Wednesday, March 31, 2010

Ubuntu (jaunty/9.04) - Delay in print dialog

We use a 'Konica Minolta c451' printer at work and I have been having this issue since I upgraded to Ubuntu 9.04 (Jaunty). The bug has been reported here: https://bugs.launchpad.net/ubuntu/+source/gtk+2.0/+bug/475845

The temporary recommended solution is to comment out the following in /etc/cups/cupsd.conf:
##Listen /var/run/cups/cups.sock

Tuesday, February 9, 2010

Automate downloading from hotfile.com

    1 #!/bin/bash
2
3 RED='\e[1;31m'
4 CYAN='\e[1;36m'
5 NC='\e[0m' # No Color
6
7 if [ -z "$1" ]
8 then
9 echo
10 echo -e "${RED}[+] usage: ${CYAN}`basename $0` http://hotfile.com/...
11 /filename.rar.html${NC}"
12 echo
13 exit
14 fi
15
16 url="$1"
17
18 echo
19 echo -e "[+] Input URL : ${RED}$url${NC}"
20
21 tm_='1245072880'
22 tmhash_='e5b845119f0055c5d8554ee5f2ffc7b2d5ef86d7'
23 wait_='30'
24 waithash_='3bf07c5d83f2e652ff22eeaee00a6f08d4d2409a'
25 action_='capt'
26
27 line_with_url='http://hotfile.com/get/'
28
29 url2=`wget -q "$url" --post-data "tm=${tm_}&tmhash=${tmhash_}&wait=${wait_}
30 &waithash=${waithash_}&action=${action_}" -O - | grep "$line_with_url" |
31 sed -s 's/.*<a href="\([^"]*\)".*$/\1/g'`
32
33 echo -e "[+] Real URL : ${RED}$url2 ${NC}"
34 echo
35
36 if [ ! -z "$url2" ]
37 then
38 wget "$url2"
39 fi
40

Tuesday, January 13, 2009

100% cpu on Gmail.com with Ubuntu+Compiz


I have both greasemonkey and stylish installed and yet I fell for "Better Gmail 2" extenstion. Apparently it turns my firefox into a total memory hog when I'm checking my mails at Gmail.com. Just incase anybody is having the same problem, disabling or uninstalling the extension fixes the problem for me.


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


Monday, October 27, 2008

Extract audio stream from a video file by "mencoder"


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


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


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.

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

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


Tuesday, July 8, 2008

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