Sunday, December 17, 2006

Firefox List of Installed Plugins

Firefox List of Installed Plugins

Last updated: Sun, 17 Dec 2006 16:23:01 GMT
User Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0

Extensions (enabled: 7, disabled: 1):

Themes (3):

Plugins (9):

  • Adobe Acrobat
  • DivX Player Netscape Plugin
  • DivX® Web Player
  • Java(TM) 2 Platform Standard Edition 5.0 Update 6
  • Microsoft® DRM
  • Mozilla Default Plug-in
  • QuickTime Plug-in 7.1.3
  • Shockwave Flash
  • Windows Media Player Plug-in Dynamic Link Library
Firefox List of Installed Plugins

SPAM and the Catch All Feature

SPAM and the Catch All Feature

One of our domains had been receiving a huge amount of SPAM. The Catch All feature had been enabled due to the fact that usernames could be created on-the-fly and used without creating inboxes.

With this "feature" enabled, a spammer could load up a dictionary with a list of usernames and blast the domain with SPAM. The reason why all email would be received is because Catch All does not bounce non-existent addresses/usernames. Instead, it forwards all incoming email to a POP email address.

We disabled the feature today and voila! SPAM levels reduced by 90%!!

SPAM and the Catch All Feature

Thursday, December 14, 2006

Procedure to Name MySQL DB's

I've been using the following method as the naming convention to name DB's/tables.

DB name-> host_dbtitle

Table name-> dbtitle_tableTopic

Foreign keys are created across all tables and _not_ on the last relation only.

Thursday, November 02, 2006

PHP Extract a String that does not Match a given String of Text

PHP Extract a String that does not Match a given String of Text

Use explode, to strip and remove a line of text or word that matches "Foo"

$string = "Test Foo Bar";
$split = explode("Foo",$string);
$strip0 = $split[0];
$strip1 = $split[1];

echo "$strip0"; => Test
echo "$strip1"; => Bar
The [0] var gets the char previous to the match
The [1] var gets the char after the match

Tracking a User Posing as You on Social Networking Sites - Orkut, Hi5 et al

Tracking a User Posing as You on Social Networking Sites - Orkut, Hi5 et al

Requirements:
Pen and a book (papers get misplaced)
Or
Create a new word/notepad file

This list is by no means complete. It is not a guarantee that you will find the user behind the fake or spoofed account. This is a checklist of to-dos, just so that you can go through before hitting the panic button.

The first step is to note the date/time when you became aware of your fake account. So, if you know about the fake account at 9 in the morning on 1st January, make sure you enter the time in the diary as January 1st, 9AM and _not_ January 1st, 12PM or whatever else comes to your mind.

This will help you backtrack a couple of days and figure out if you pissed off a friend earlier. If you _did_ create foes lately, do _not_ jump to conclusions and accuse them. What you really need is evidence.

You are trying to piece together a puzzle and not accuse.

- How to gather the evidence?

+ Begin by checking the fake profile for patterns.
Look for words and sentences and compare them with emails you received from friends, your ex etc. Check the alphabet case. Are certain words in upper or lowercase and can these be matched with previous emails or letters?

+ Repeat the steps above and check for patterns in scraps (Orkut) and emails or letters received from the creator of the fake account.

+ Note the date/time when you receive messages from the spoofed account.
Does the person reply at a certain time? Does the time correspond with your local time zone? If you send a message at 9 in the morning does the reply come in within a few minutes or at midnight? If the message is received within a short period of time, then most likely the person is in the same time zone as you.

Does the person reply on Sundays? If not, then the person is probably at work and sending the emails or messages from a work computer.

+ You could begin an email conversation with the person behind the fake account and again look for patterns in the replies. Do _not_ ask questions such as, who are you? Where you from? The person has to be a real moron to tell you who (s)he really is.

+ Photos
If the fake account contains your photos, try to think. Do all your friends and family have copies of these photos? Or did you send the photos to a group of friends or a person? Is it possible that the photos were grabbed online from a public space? If so, who had access to them and when?

+ Trace and log the IP Address
Every email sent contains an IP address. The IP address can be used to trace the source Internet Service Provider. Check the email headers for the IP address from the emails received. Trace the IP and find the name of the Internet Service Provider. Pinpoint the telephone if the IP address is in the same city as you.

Does the IP address point to a company? Try to think of people you may know who work there and see if someone can help you out.

Remember to note the IP address along with the sent and received timestamp. An email header is like a diary, it logs detailed information as it makes its way to your Inbox. The time and date that an email was sent could be different from the time and date when you received it.

+ Talk
Bring up the conversation with your friends. Look around and listen to what they say.
Does someone know more than you?
Could a buddy in your group know who is behind the fake account?
Does a person you know have a history of creating fake accounts? If so, watch him/her closely.
Ask questions, look for clues

+ Check the friend list in the fake account
Go through the friend list and check if they were added in the same day?
It is likely that the creator of the account will know those friends.
List the common friends between you and those on the fake account.
Check the messages (for patterns) that your friends received from the fake account.

+ Know your Information Technology laws
Get on a search engine (http://www.google.com) and do a search for:
your-country-name information technology law
(substitute your-country-name with your country)
This will help you better understand the issues and discuss with the authorities.

+ Law enforcement
Send an email warning the person that you take up the matter with the authorities. If (s)he does not comply then file a complaint. The email should be sent with your full name and not from the fake account.

Monday, October 16, 2006

FTP Upload Files Through Windows DOS Prompt

FTP Upload Files Through Windows DOS Prompt

Listing a huge list of directories and files from a server in a FTP client can be time consuming. This solution involves uploading files directly through the Windows FTP program.

To upload files to the server without a FTP client, create the following two files in the d:\ftp directory:

upload-ftp.bat (copy and paste the contents below)

d:\
cd ftp
ftp -s:files.txt
(Note: d: is the drive where these two files are located)

files.txt (copy and paste the contents below)
open server-name.com
username
password
bin
prompt
cd /var/www/remotedir
send file1.zip
send file2.zip
send file3.zip
send file4.zip
quit

Double click to run the file upload-ftp.bat. The zip files to be uploaded need to be in the same directory (d:\ftp\ in this case) as the two files above.

Note: Ensure that the remote directory exists before uploading the files.

CRON line 1: Unexpected EOF while looking for matching ``'

CRON line 1: Unexpected EOF while looking for matching ``'

When running a CRON job that uses the command:
NOW=`date +%B_%d_%a_%Y`

the script will abort execution and display the following error:

/bin/sh: -c: line 1: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 2: syntax error: unexpected end of file
To prevent this issue from occurring, dump the contents of the script into a .sh file and run the .sh from CRON.

Sometimes, CRON is set to use sh as opposed to the bash shell that the script needs.

The CRON shell can be modified in the /etc/crontab config file. Requires r00t privileges. Ensure that the CRON daemon is restarted after the modifications.

/sbin/service crond restart

Friday, October 13, 2006

Frequently Used .htaccess Directives in Apache

Frequently Used .htaccess Directives in Apache

# Force www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.domain\.com$ [NC]
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
or
RewriteRule ^(.*)$ http://www.domain.com/$0 [R=301,L]

# Add mod-rewrite rules (if needed)
# This checks if a file or directory exists before calling the var
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# This sends the var to the PHP file
RewriteRule ^([A-Za-z0-9_-]+) http://www.domain.com/foo/bar/get.php?var=$0 [PT]

# Disable and turn off PHP register globals
php_flag register_globals OFF

# Enable PHP errors
php_flag display_errors ON

# Disable directory listing
IndexIgnore *


# Override common PHP settings
php_value post_max_size 16M
php_value upload_max_filesize 20M
php_value memory_limit 25M
php_value max_execution_time 900
php_value session.gc_maxlifetime 7200


# Hide the directory indexes
Options All -Indexes

# Show the directory indexes
Options All +Indexes


# Disable access and prevent viewing of htaccess

opentag Files .htaccess closetag
order allow,deny
deny from all
opentag /Files closetag

Alternatively,
CHMOD .htaccess to 644 or RW-R--R--

# Disallow or prevent hotlinking of images, photos or any other file type
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]


# Redirect an old path to a new one
# Redirect an old file to a new file
Redirect /old-dir/foo.html http://www.domain.com/foo/new.html

# Redirect an old directory to a new directory
Redirect /old-dir/ http://www.domain.com/new-dir/

# Set the default index file
DirectoryIndex index.html
or

# Set multiple files as the default if the first doesn't exist
DirectoryIndex index1.html index2.php index3.shtml foo.htm

# Block or ban offline browsers or leechers
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^wget [OR]
RewriteCond %{HTTP_USER_AGENT} ^flashget [OR]
RewriteCond %{HTTP_USER_AGENT} ^getright
RewriteRule ^.* - [F,L]

# Ban traffic from a single or multiple domains
RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} foo\.com [NC]
RewriteRule .* - [F]

or

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} foo1\.com [NC,OR]
RewriteCond %{HTTP_REFERER} foo2\.com
RewriteRule .* - [F]

Monday, October 09, 2006

preg_replace(): Error - Delimiter must not be alphanumeric or backslash

preg_replace(): Error - Delimiter must not be alphanumeric or backslash

preg_replace() will output a delimiter error if the "$pattern" does not have a / delimiter or if quotes are used when calling the preg_replace() function itself.

The Error:

$patterns[0] = '/PHP/4.4.4/';
$replacements[0] = "FooBar!";

preg_replace("$patterns",$replacements,"$string[$counter]");

The above will result in the following error:
"preg_replace(): Parameter mismatch, pattern is a string while replacement in an array"


Corrected Version:

// Delimiter is /
// Note: the forward slash after PHP is to be escaped with a backslash
// The i after the / is for case-insensitive matches. This means, you can match lower case words with upper case words and vice-versa

$patterns[0] = '/PHP\/4.4.4/i';
$replacements[0] = "FooBar!";

// Double quotes are to be removed
preg_replace($patterns,$replacements,"$string[$counter]");

Sunday, October 08, 2006

CRON Fields

CRON Fields


# (Use to post in the top of your crontab)
# ------------- minute (0 - 59)
# | ----------- hour (0 - 23)
# | | --------- day of month (1 - 31)
# | | | ------- month (1 - 12)
# | | | | ----- day of week (0 - 6) (Sunday=0)
# | | | | |
# * * * * * command to be executed

* The comma (',') operator specifies a list of values, for example: "1,3,4,7,8"
* The dash ('-') operator specifies a range of values, for example: "1-6", which is equivalent to "1,2,3,4,5,6"
* The asterisk ('*') operator specifies all possible values for a field. For example, an asterisk in the hour time field would be equivalent to 'every hour'..

Source: http://en.wikipedia.org/wiki/Crontab


Delete All Email Using MUTT, Through SSH

Delete All Email Using MUTT, Through SSH

Since I login through SSH frequently, I use the MUTT email client to check email generated through automated scripts, logs etc. There were 40,000 emails that needed to be deleted quickly. I've been unable to find a "select all" option.

The solution involves, pressing the SHIFT and t key simultaneously. This will bring up the "tag messages matching feature". Enter the match that is common with all the emails. Eg: / and hit enter. (this will flag all the matching email with a *)

shift + t
Tag messages matching: /
;d
$

OR

q
yes

The $ key will sync mutt - deleted emails will be purged, mailbox updated etc.

Disable CRON Output From Flooding Email

Disable CRON Output From Flooding Email

When a script is executed through CRON, the output can quickly flood an inbox. To disable output from specific scripts, append the following at the end of the script:

# Disable output completely

*/2 * * * * /usr/local/bin/php /test/foobar.php > /dev/null 2>&1

This script runs every two minutes.
Standard output (1) is redirected to /dev/null
Standard error (2) is directed to the same as standard output (1)

# Redirect script output to a log file
*/2 * * * * /usr/local/bin/php /test/foobar.php > /localpath/log.txt

# Redirect script output to a log file, append log
*/2 * * * * /usr/local/bin/php /test/foobar.php >> /localpath/log.txt

# Redirect script output and CLI error output to the same log file
*/2 * * * * /usr/local/bin/php /test/foobar.php > /localpath/log.txt 2>&1

Note:
/localpath/log.txt - This is standard output (1)
The 2 in the 2>&1 will direct standard error (2) to standard output. In this case, log.txt

# Redirect script output and CLI error output to a different log file
*/2 * * * * /usr/local/bin/php /test/foobar.php > /localpath/log.txt 2>/localpath/cli-errors.txt

# Redirect script output and CLI error output to a different log file, append log
*/2 * * * * /usr/local/bin/php /test/foobar.php >> /localpath/log.txt 2>>/localpath/cli-errors.txt

To test:
Execute this command
ls . IS >> errors.txt 2>>errors.txt

The second alternative is to modify the MAILTO= option and set it to "". This will however, disable all output from being sent to the email address specified in the MAILTO feature.

Another option would be to redirect the output to a text file and call the text file through the browser for analysis.

Note:
The php -q flag suppresses HTTP header output.

Saturday, October 07, 2006

Find and Replace the Exact Match in a String

To find and replace the exact match in a string, use the function ereg_replace. ereg will find the exact match and not a pattern.

// Strip the extra --
$string= ereg_replace("--","-",$string);
// Replace \n with a br tag
$string = str_replace("\n","
",$string);

// Find and replace multiple needles in a haystack
$patterns[0] = '/>/';
$patterns[1] = '/1/';
$patterns[2] = "/2/";
$patterns[3] = '/3/';
$patterns[4] = '/4/';

// Escape non alpha characters
$patterns[5] = '/\"/';
$patterns[6] = '/\+/';
$patterns[7] = '/\'/';
$patterns[8] = '/\./';
$patterns[9] = '/Some Text/';

$replacements = '-';

$data = preg_replace($patterns, $replacements, $data);

PHP DOCUMENT_ROOT Include does not work with CRON

When including libraries or external files in PHP, the variable $_SERVER['DOCUMENT_ROOT'] will not call the external files if the script is run through CRON.

This is because, usually a PHP script would be executed through a /usr/local/bin/php -q directive. Since Apache does not play a role here, the DOCUMENT_ROOT variable will not work.

To ensure that the DOCUMENT_ROOT works, call the script through curl, wget or lynx. As a security measure, apps like wget are disabled on most servers. The alternative option is to get rid of the DOCUMENT_ROOT variable all together.

When including files in PHP scripts, it is best to create an includes.php in the base dir of the application. All scripts in the sub-directories can call the include file through a define path. The includes file can in turn define paths to other dependencies.

Note:

The -q flag suppresses HTTP header output. As long as your script itself does not send anything to stdout, -q will prevent cron from sending you an email every time the script runs. For example, print and echo send to stdout. Avoid using these functions if you want to prevent cron from sending you email.

Note:
The ../dirname directory include path does not work with cron too. The path needs to be included in full

Source:
http://www.modwest.com/help/kb5-125.html

Further Reference:
http://www.us2.php.net/features.commandline

Saturday, September 30, 2006

ASUS W3J and S96J/Z96J, ATI X1600 Graininess BIOS Update Patch Fix

On some notebook computers, the ATI X1600 creates a graininess issue on the screen when viewing certain shades of colors.

A BIOS update has been released for a few of the ASUS notebooks. This includes the ASUS W3J and the S96J/Z96J models.

These BIOS updates can be found on this thread on Notebook Forums. The BIOS fix has been confirmed to fix the graininess issue.

Direct links to the BIOS Updates:

S96J Beta BIOS

W3J Beta BIOS

Procedure to install the BIOS update:

1: Download NERO image files
2: Use Nero to burn the image file to the CD
3: Insert CD and when first power on the laptop press "ESC" at Intel logo screen
4: Select Optical drive at boot options screen
5: At "A:\" prompt type "Update" and press "Enter".
6: The BIOS will be updated and don't turn off or reset the computer during BIOS flash.
7: Screen will go back to "A:\" prompt when finish
8: Restart the computer and then hold F2 to enter BIOS, press F10 to save and exit BIOS.
9:Boot to Windows, it'll start to find all kinds of new hardware.

Monday, July 24, 2006

UNESCO World Heritage Sites, Agra New Delhi India

I was on a trip to New Delhi..












Red Fort, Agra Delhi - A UNESO World Heritage Site

















Red Fort, Agra Delhi















Read Fort, Agra Delhi





Taj Mahal, Wonder of the World, Agra New Delhi India






Wednesday, June 28, 2006

Google Junction, A Scam?

There seem to be no shortage of companies which create a market for people who want to generate an income from home.

The usual highlights:

- Generate income during spare time
- Plenty of opportunity
- E-commerce, internet knowledge needed
- Data Entry, clicking links etc
- Internet Business
- Involves some amount of down payment

Once such company is GoogleJunction

What's Fishy?

- The contact link contains a Pune, India address which is probably non-existent.
- The contact submit link points to websitecomplete.com. (Fill out the form, hit submit and watch the POST URL change).
- A WHOIS on the domain does not yield anything other than the DNS entries.
- The domain name itself. Why would a company NOT affiliated to Google, name itself after Google?


Oh well, Google has probably begun the process to shut them down..