Saturday, August 4, 2007

Undocumented 8085 Instructions

8085 undocumented instructions
These are the undocumented 8085 instructions, undocumented due to incompatibility with 8086, Use them at your discretion. (information here is not sure yet, still worth a post)

DSUB
Hex Code: 08H
Description: BC pair is subtracted from HL Pair affecting all flags.

JNK [16bit location] - Jump to Location if 'K' flag is reset
Hex code : DDH

JK [16bit location] - Jump to Location if 'K' flag is set
Hex Code: FDH

RRHL - Rotate Right HL Pair
Description: Rotates the HL pair 16 bit towards right.
Hex code : 10H
Operands : none
Flags unaffected


RLDE - Rotate Left DE Pair
Description: Rotates DE Pair to left.
Hex code: 18H
Operands : none
Carry affected : depends on Bit 15

ADI HL - Add Immidiate to HL pair
Description: Adds an 8 byte number to the HL pair.
Hex Code : 28H
Operands : 8 bit number
Flags: All affected

ADI SP - Add Immidiate to Stack Pointer
Description: Adds an 8 byte number to the SP
Hex Code : 38H
Operands : 8 bit number
Flags: All affected

RSTV
Description: Does a RST 8 instruction when the 'V' (must be overflow)flag is SET.
Hex Code: CBH

LHLX
Description: Loads HL Pair with the contents of address stored in the DE pair
Hex Code: EDH

SHLX
Description: Stores the HL Pair contents to the address specified in the DE pair.
Hex Code: D9H


Help me!
Whats this K flag ? Any Intel engineers out there ?

Monday, July 30, 2007

Laptop to TV using S-Video Out Port

This post is applicable only to those laptops that are equipped with a S Video Out port (like Compaq Presario V3000 Series). The S-Video Port looks like


S Video port can be used to connect to your TV using a S-Video to RCA Cable. The S Video end of the cable looks like this


You can buy the S-Video to RCA cable, but building it is pretty much simple and costs negligible.

All you have to do is,
connect the Pin 1 and Pin 2 of the connector in S-Video to Ground of RCA
and short the Pin 3 and Pin 4 of S-Video to the Main Pin of RCA.
Some sites recommend using a 470pF Capacitor in shorting the Pin4 to RCA, but i really don't find much of a different when skipping the capacitor. Thus its just a DIY (Do-It-Yourself) project to make your laptop a DVD/CD player or make your TV a secondary monitor screen.

Compaq Presario V3000 Settings
In order to use the S-Video port the NVidia GeForce Go Graphics Drivers must be installed and working.

Don't have an S-Video Port ?
See other options of connecting a laptop to your television

Tuesday, July 17, 2007

CAPTCHA - What ?

What is CAPTCHA ??

Seems like a weird word, but seems to be familiar ...
CAPTCHA stands for Completely Automated Public Turing test to tell Computers and Humans Apart.

Simply, its a test to check if you are a human or not. A simple form of CAPTCHA is an image that contains a language or a sign which can be easily understood by a human being. On the other hand a bot or a program or simply a machine cannot understand. Given the image to a program it cannot see into and tell what's written in it (easily). CAPTCHA's are present in most sites including here. Try posting a comment and you will be asked to enter a word as shown in the figure.

CAPTCHA's are used to prevent bots or programs to spam the site with lots of biasing information or advertisements.

Effectiveness of CAPTCHA
CAPTCHA has been here for a couple of years and hence programs defeating the CAPTCHA's have obviously been developed! So how does an effective CAPTCHA system work?
A good captcha

  • Bend, Orient or change the fonts randomly
  • Has a random background colour, which is not uniform
  • Has little contrast
  • Has minimum sharp edges


Making your own CAPTCHA system

A simple CAPTCHA system can be made with PHP and the GD Library.
The PHP-GD Library is used to make CAPTCHA images on the fly with random letters.
The original text used in the image can be hashed by one way hashing algorithms such as MD5 and SHA. These hashes must be passed through a top-secret function that alters or encrypts the text again. The text is then set as a cookie.

Eg:

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 25 Nov 1987 12:00:00 GMT"); // Date in the past
// Set the content-type
header("Content-type: image/png");
error_reporting(0);
// Create the image
$im = imagecreatetruecolor(200, 40);

// Create some colors
$colors = array(
imagecolorallocate($im, 0, 0, 0),
imagecolorallocate($im, 128, 0, 0),
imagecolorallocate($im, 0, 128, 0),
imagecolorallocate($im, 0, 0, 128),
imagecolorallocate($im, 0, 128, 128),
imagecolorallocate($im, 128, 128, 0),
imagecolorallocate($im, 128, 0, 128),
imagecolorallocate($im, 255, 0, 128),
imagecolorallocate($im, 128, 0, 255),
imagecolorallocate($im, 0, 255, 128),
imagecolorallocate($im, 255, 0, 0),
imagecolorallocate($im, 255, 0, 0),
imagecolorallocate($im, 255, 255, 255)
);
imagefilledrectangle($im, 0, 0, 199, 39, $colors[12]);

// The text to draw
$text = randomkeys(rand(6,8));

setcookie("secrethash",secret_function($text),time()+3600,"/"); // make your own secret function
// Replace path by your own font path

$font = 'tahoma.ttf';

$thsc=$colors[rand(0,11)];
// Add the text
$x=0;
for($i=0;$i < 6; $i++){
$angle=rand(-2,5);
$x+=18;
imagettftext($im, 24, $angle*2, 10+$x, 24, $thsc, $font, $text[$i]);//Add some tilts to make bots tough to read
}
// Using imagepng() results in clearer text compared with imagejpeg()
imagecolortransparent($im,$colors[12]);
imagepng($im); //Outputs the PNG
imagedestroy($im);?>


This CAPTHCA uses no background and hence only moderately secure (ie Keeps the kids away)

Now on the checking part the users text is passed through the same hashing function and top-secret function. Then the cookie value and the newly calculated value is compared to catch the bot ;).

...
A disadvantage of using CAPTCHA is for the visually challenged people. People with unclear eyesights colour blindness etc may face a problem in reading the CAPTCHA code. So the other CAPTCHA method is to use an AUDIO file, an MP3 instead of a JPEG or PNG.

Currently I do not know of any PHP libraries that makes MP3's on the fly. If anyone has any information on similar info, Please share ...

Happy filling in the CAPTCHA
;)

Saturday, July 7, 2007

e-Mail structure and Mail Dir File format

The MAIL Dir Format
MAIL Directory format is a format followed to store emails as files.
The Mail Dir format has 3 directories

  • new
  • cur
  • tmp


The new directory contains all the new mails, ie unread mails.
The cur directory contains all the read mails.
The tmp directory is a temporary directory used to store mails that are being received.
When a mail is read it is moved from new to cur.

All the emails are stored in files with a unique name (usually the message id).

The emails are stored as plain text in these files with the full headers and content.

The e-Mail Structure

Emails stored in the file with full headers and content.
The Email structure can be divided into
the head and body.
The head contains all the email related information

Return-path:
Envelope-to:
Delivery-date:
Received:
Message-ID:
Date:
From:
To:
Subject:
In-Reply-To:
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_Part_21969_10709103.1184337589825"
References:


The body actually contains the contents it can be of many parts
HTML Part, Plain Text Part, Attachments , etc...

The various parts are divided by a boundary which is a unique string that appears nowhere else in the content.

Wednesday, July 4, 2007

cPanel Mail Forwarder

Forwarder

This handly little program forwardes all emails coming to a certain specified email address and forwards to a forwarding list.

Setting up the email capturing

e-Mail can be captured using a PERL script. The contents of the email must be pipped in. The capturing an passing of the email can be done through cPanel.


Click Mail

Click Forwarders

Add Forwarder


In the text box to the right side, you can provide an email address or a path to your PERL program that can process your email and extract relevant information.

In order to send the contents of the email to a PERL program we have to PIPE it to the program. PIPING is just redirection of standard output of the mail receiving program to your custom PERL script.
Eg:


"|perl /home/domain/scripts/process.pl"



#!/usr/bin/perl
use strict;


my $Email = join '',<STDIN>;

$Email // has your email contents