Wednesday, January 28, 2009

Reset XP Password

Forgot your Windows XP Password??? Or, got your hands on someone else's system but can't enter because you don't have the password. Ok, here are the simplest tricks you can use.
Trick 1
On the welcome screen press CTRL+ALT+DEL twice. Type username as Adminstrator and leave the password blank and press enter. If you're lucky then you'll enter the system. Lucky in the sense that, if the system owner didn't enter an adminstrator password while installing windows then you're lucky.
Trick 2
If you're'nt lucky according to the previous trick then this trick will forcefully let you enter inside! It works for sure. You need another computer with internet connection, a cd writer and a blank cd off course.
1. Download this file reset.zip
2. Extract the zip file to get an iso image.
3. Burn the iso image on a blank cd.
4. Boot the target computer with this CD. Follow the steps on screen and reset the password as you wish!!!
This trick works for resetting Vista too!
Trick 3
If you've access to the target computer with an account with administrator privilleges then you may use this command on command prompt to reset any user's pass
net user <username> <new password>

example:
net user administrator newpass

Saturday, January 24, 2009

Log your blog visitors

So, you've got a shiny new blog out there on blogger and getting pretty many hits as well but want to keep a record of all people visiting your blog? Well, I do! Ever noticed the 'lens image with "Logged" written' here in the right panel of this blog? Yes, thats my own visitor logger. Although there are lots of third party loggers out there like the Wowzio widget but having your own is fun when you call yourself a techno-savvy! Ok, so here I go about it how to do it on your own.
Note: I'm assuming that you know how to use FTP, what is PHP and some other simple stuff etc... If you don't know these and don't understand the post, that means you're a n00b. I'm not going to explain everything in ultimate detail.
First things first
Here we're going to use PHP to track the visitors. So, you need a PHP capable server. Freehostia is cool for this task. Just register an account there.
1. Create an account on freehostia. Setup a subdomain like "mylogs.freehostia.com" or something you wish there.
2. Create the image in mspaint or anything, that you wanna display to the user. Or if you're lazy then use the one from my blog. Name the image something like "img.jpg"
3. Create a PHP file with the following code and name it something like "logger.php":

<?php
$logged="";
$logged.="Time=".date("j/n/Y h:i:s a", time())."
";
$log2=$logged;
foreach($_ENV as $key_name => $key_value) {
$logged.= $key_name . " = " . $key_value . "
";
}
$log2.="UA: ".getenv("HTTP_USER_AGENT")."
";
$log2.="IP: ".getenv("REMOTE_ADDR")."
";
$log2.="REFERRER: ".getenv("HTTP_REFERER")."
";
$logged.="---------------------------------------------
";
$log2.="---------------------------------------------
";
$blah=fopen("logdetails.htm", "a+");
fwrite($blah, $logged);
fclose($blah);

$blah2=fopen("log.htm", "a+");
fwrite($blah2, $log2);
fclose($blah2);

$blah3=fopen("img.jpg", "rb+");
header("Content-type: image/jpg");
while(!feof($blah3)){
echo fread($blah3, 128);
}
fclose($blah3);
?>


4. Create two blank text files in notepad and rename them to "log.htm" and "logdetails.htm".
5. Now upload all these four files in the same directory in your freehostia account through FTP. chmod both the .htm files to 777.
6. Now in your blogger account, go to layout and add a new custom HTML/JS gadget. Add this code in it and place it where you wish on your blog
<img src="http://yoursubdomain.freehostia.com/logger.php" alt="Logged"/>


Over!!! Yeah, it was that simple!!!
What happens under the hood???
If you've experience of coding, you might have already understood whats going on. But for those who are too lazy to want to understand I'm explaining briefly.
You've a PHP file on your freehostia which when accessed performs two things:
1. Shows the user an image i.e. the logged image
2. Records all environment variables and the values and writes to the file logdetails.htm and the file log.htm is to store Time, UA and IP only for your quick viewing.

Whenever anyone visits your blog, his/her browser requests for the image. The request reaches your freehostia account alongwith headers sent by the browser. The headers are trapped by the PHP script which shows an image to the user. Thats it! As simple as that!!!

Saturday, January 17, 2009

File Fetcher in PHP

My net connection is too slow and inconsistent to download large files from a non-resume capable server. So I thought of creating a PHP file fetcher program, that I could upload on a fast PHP capable web server and it would download the file itself within a minute and then I could download from there in many sessions by resuming broken downloads. Here's what I coded:

<?php
$blah=fopen("dload", "a+");
$fp = fsockopen("host.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)
\n";
} else {
$out = "GET /filepath.ext HTTP/1.1\r\n";
$out .= "Host: host.com\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
$temp=fgets($fp, 128);
fwrite($blah, $temp);
}
fclose($fp);
fclose($blah);
}
?>


In the above code host.com is the hostname or IP of the server I'm trying to fetch the file from, and filepath.ext is the path and filename with extension of the file to be downloaded from there.
It works fine for files upto around 50MB on my server but for larger size it doesn't work. After thinking for a while I figured out that it may be due to the maximum execution time setting of 30 seconds in php.ini file. The server I used has practical speeds around 1.5MB/s and so it downloads a 45-50MB file in 30 seconds and then stops.
The only obvious way is to edit the php.ini file and increase the maximum execution time to something like 300 seconds. But I don't have access to php.ini on my server. What should I do now???? Well, if you've any solution then do post a comment here please.

Thursday, January 15, 2009

Linux, Bluetooth, GPRS and Internet

The other day I was messing up with my brand new Dell notebook under Linux(Ubuntu), I needed to get online quickly. I looked for my phone's data cable but couldn't locate it in the room. And in this freezing cold weather prevailing here I can't afford to get outta the quilt!! So, I thought about connecting using bluetooth. A little bit fiddling, and I figured out how do I hook myself to the Internet!! Ok, so here goes the tutorial. It should work perfectly on Ubuntu 8.10 and 8.04 and also on several other latest linux distributions, but I haven't tested it on anything except Ubuntu 8.04 Hardy Heron and Ubuntu 8.10 Intrepid Ibex.

1. Hit Alt+F2, type
xterm
and press enter.
2. Then jump into root mode by typing
sudo -s
and entering the root password when prompted.
3. Turn on the bluetooth on your phone and the notebook/PC and type
hcitool scan
and hit the enter.
4. Your notebook will search for bluetooth devices in range. And it will respond with your phone's MAC address and name. Now use this command to search the Dial Up Networking channel on your phone
sdptool search --bdaddr <your phone's MAC address here> DUN

example:
sdptool search --bdaddr 00:1B:3C:4D:5E:6F DUN
5. You'll get a response of around 10 lines. Search for the channel number in it. For my SE P1i it was channel 7. On a Nokia6681 it was on channel 3.
6. Now use this command to create a bluetooth modem
rfcomm bind /dev/rfcomm0 <phone's MAC address> <DUN channel>

example:
rfcomm bind /dev/rfcomm0 00:1B:3C:4D:5E:6F 7
You may be prompted by the PC to pair device. Do so by entering same BT pin in ur PC and phone.
7. Now configure your wvdial.conf file as follows.
gedit /etc/wvdial.conf

Append the following text below any existing settings in the file that opens up.
[Dialer bt]
Modem = /dev/rfcomm0
Phone = *99#
Username = 919815098150
Password = 12345
New PPPD = Yes
Init1 = AT+CGDCONT=1,"ip","airtelgprs.com"

Note that the above setting varies depending on your operator. But you just need to change the username, password and access point(airtelgprs.com) to your operator specific.
8. Now to connect to net just type
wvdial bt
on terminal and press enter. Allow your phone to connect when prompted.

After a reboot, if you need to connect then perform only steps 6 and 8.
Enjoy!!