Tuesday, January 1, 2008

CGI

CGI, the Common Gateway Interface, enables your page to interact with viewers. Generally, CGI is used to process the data submitted by users and send the response back to them.

Link to CGI reource web sites:


CGI Resource Index: This site contains a ton of links to CGI Scripts on the WWW. They are well categorized and easy to browse.

Fluid Dynamics: Many useful CGI scripts are here, such as Search, Counter, etc. The documents are easy to understand and follow.

Matt's Script Archive: This site is always popular on the Net. You'll find a bunch of CGIs written in C++ and Perl. All of them are free. Matt's Script Archive provides a Guestbook, Counter, Text Counter, Search, WWW Board, FormMail, etc.

Salena Sol's CGI Script Archives: Like Matt's Script, Salena give you a bunch of useful scripts, Form Processor, Guestbook, Basic Animation Scripts, Random Banner Gennerator, Web Chat, etc. The new URL is at extropia.com. Scripts are still free, but there are now (paid) registered versions.

WebScripts: This site contains many useful scripts written by Darryl C. Burgdorf. Some examples of scripts here are WebBBS, WebSearch, WebLog, etc. All scripts are always updated!

The CGI Archive: Many useful scripts such as Message Board, URL Search Engine, Random Image Displayer, etc. Scripts are easy to install.

Also, Yahoo has a frequently updated list about CGI.

The following are sites where you can get other particular scripts that may match your needs.



Counter:


It seems like everyone wants to have one. If you're paying for hosting service, your provider should have one for you. If you're getting free hosting service from your organization such as a university, you may try to install the script by yourself, but don't forget to ask the system administrator whether he or she allows you to have CGI Script. If it isn't allowed, don't waste your time. The alternative is running a counter from other people's servers, such as commercial counter, or let Java, which doesn't require installation on a server, counts visitors for you.

WWW Homepage Access Counter and Clock!: This site provides a reliable CGI counter and clock with an explanation in great detail. You will also find JavaApplets at this site.

YAAC (Yet Another Access Counter): This site provides access counter script written in Perl.

Counter 4.0: This site provides a text counter.

Easy Counter: The alternative for people who aren't allowed to have CGI script on their own server, but you need to be able to read an access log.

Web Counter at digits.com, they used to offer a free counter, but not anymore. Their commercial counter starts at $5 a month.

Email Form:


Formmail: Located at Matt's Script site. Get results from forms and send mail to specified users.

CGIemail: Developed by MIT. CGIemail script can accept the results of forms and use a template file to build and construct an email message containning those results.

Links with Drop Down Box:


Jump Box: This redirection script uses a pull-down select box to allow users to select a site and then click a 'GO' button to visit it. This script is OK for only a few URLs, but if you have many, it can become very hard to configure, as each selection has to be configured into the CGI script.

Selection: Users choose a link from a pull down menu and then click a button to go there.

Newbie Perl Archive: Form Navigator: This script enables you to navigate your user to different pages depending on their choice from a selection box.

Running your CGI remotely:


i-Depth: Run Ad Banners, Forums, Guestbooks, Webforms to Mail, Counters, Chat, Postcards, Classified Ads, and Calculating Order Pages from this remote host.

Worldwidemart: They offer service for you to run your CGI from their site at $7 a month.

JavaScript

Java vs. JavaScript


Java is a programing language developed by Sun. Java allows programmers to create programs. One example is Java Applets, a small program embedded within a web page.

JavaScript is a scripting language developed by Netscape and later joined in a partnership with Sun. You can insert it directly to your HTML documents. Creating JavaScript is not difficult. What you need are only simple text editor and browser that supports JavaScript.

JavaScript


We are not going to show you how to write JavaScript here because useful JavaScripts are widely available for you to copy. You may not need to know how to write it unless you want customized Script for your site. If you want to learn how to write the script, try JavaScript for the world wide web book.

Shown below are some examples of useful JavaScripts and links to some JavaScript web sites

Alert message:


Here is the code for alert message:

<a href="j_script.html" onclick="alert('Reload this page?');">Click here</a>

Dynamic images and menus:


Dynamic menu can either be created by JavaScript or JavaApplet. The JavaScript version will work only on Netscape 3.0 or higher. JavaApplet version should work on both Netscape and Explorer but it will run much slower than JavaScript.

JavaScript example:

>>

example of dynamic menu

The principle is that you have two images. One will be displayed when you put your mouse on it, and the other will be displayed when the mouse is off the image.

Installation is easy. This code originally written by Nick Heinle and Athenia Associates. Follow the link to get detail instruction.

Customized Message in Status Bar


To see how it works, simply put your cursor over (but don't "click") on this links and watch the status bar at the bottom of your screen.

You can get this script from "Cut-N-Paste JavaScript"

Counter:


There is no example shown here. To use this counter script, your server must support server-side includes (SSI) feature. You can get it at http://www.cris.com/~adaml/Counter.shtml. The script developed by Adam Levental.

Links to JavaScript resources:



On line JavaScript Tutorial:


Saturday, November 3, 2007

XOR-Encryption With C

Exclusive-OR encryption, while not a public-key system such as RSA, is almost unbreakable through brute force methods. It is susceptible to patterns, but this weakness can be avoided through first compressing the file (so as to remove patterns). Exclusive-or encryption requires that both encryptor and decryptor have access to the encryption key, but the encryption algorithm, while extremely simple, is nearly unbreakable.

Exclusive-OR encrytion works by using the boolean algebra function exclusive-OR (XOR). XOR is a binary operator (meaning that it takes two arguments - similar to the addition sign, for example). By its name, exclusive-OR, it is easy to infer (correctly, no less) that it will return true if one, and only one, of the two operators is true. The truth table is as follows:

A   B    A XOR B

T T F

T F T

F T T

F F F

(A truth table works like a multiplication or addition table: the top row is one list of possible inputs, the side column is one list of possible inputs. The intersection of the rows and columns contains the result of the operation when done performed with the inputs from each row and column)

The idea behind exclusive-OR encryption is that it is impossible to reverse the operation without knowing the initial value of one of the two arguments. For example, if you XOR two variables of unknown values, you cannot tell from the output what the values of those variables are. For example, if you take the operation A XOR B, and it returns TRUE, you cannot know whether A is FALSE and B is TRUE, or whether B is FALSE and A is TRUE. Furthermore, even if it returns FALSE, you cannot be certain if both were TRUE or if both were FALSE.

If, however, you know either A or B it is entirely reversible, unlike logical-AND and logical-OR. For exclusive-OR, if you perform the operation A XOR TRUE and it returns a value of TRUE you know A is FALSE, and if it returns FALSE, you know A is true. Exclusive-OR encryption works on the principle that if you have the encrypted string and the encryption key you can always decrypt correctly. If you don’t have the key, it is impossible to decrypt it without making entirely random keys and attempting each one of them until the decryption program’s output is something akin to readable text. The longer you make the encryption key, the more difficult it becomes to break it.

The actual way exclusive-OR encryption is used is to take the key and encrypt a file by repeatedly applying the key to successive segments of the file and storing the output. The output will be the equivalent of an entirely random program, as the key is generated randomly. Once a second person has access to the key, that person is able to decrypt the files, but without it, decryption is almost impossible. For every bit added to the length of the key, you double the number of tries it will take to break the encryption through brute force.

C++ uses ^ for bit-level exclusive-OR. To encrypt a single character you can use char x=x^key; if you have a key of one byte. To encrypt a string of characters with a longer key, you can use something akin to the following code:

#include 

int main()

{

char string[11]="A nice cat";

char key[11]="ABCDEFGHIJ";

for(int x=0; x<10; x++) {

string[x]=string[x]^key[x];

cout<<string[x];
}

return 0;

}

The program encrypts each character in the string using the ^ bit operator to exclusive-OR the string value with the key value for each character.

http://www.cprogramming.com

Thursday, August 16, 2007

Regular Expressions

Basic Syntax of Regular Expressions (as from PHPBuilder.com)


First of all, let's take a look at two special symbols: '^' and '$'.

What they do is indicate the start and the end of a string, respectively, like this:"^The": matches any string that starts with "The";

"of despair$": matches a string that ends in the substring "of despair";

"^abc$": a string that starts and ends with "abc" -- that could only be "abc" itself!

"notice": a string that has the text "notice" in it.


You can see that if you don't use either of the two characters we mentioned, as in the last example,
you're saying that the pattern may occur anywhere inside the string -- you're not "hooking" it to any of the edges.

There are also the symbols '*', '+', and '?', which denote the number of times a character or a sequence of
characters may occur. What they mean is: "zero or more", "one or more", and "zero or one."

Here are some examples:

Wednesday, August 15, 2007

Assembly Language

Assembly language is essentially the native language of your computer. Technically the processor of your machine understands machine code (consisting of ones and zeroes). But in order to write such a machine code program, you first write it in assembly language and then use an assembler to convert it to machine code.

However nothing is lost when the assembler does its conversion, since assembly language simply consists of mnemonic codes which are easy to remember (they are similar to words in the english language), which stand for each of the different machine code instructions that the machine is capable of executing.

Here is an example of a short excerpt from an assembly language program:

MOV EAX,1
SHL EAX,5
MOV ECX,17
SUB EAX,ECX
....

An assembler would convert this set of instructions into a series of ones and zeros (i.e. an executable program) that the machine could understand.

Because it is extremely low level, assembly language can be optimized extremely well. Therefore assembly language is used where the utmost performance is required for applications.

Assembly language is also useful for communicating with the machine at a hardware level. For this reason, it is often used for writing device drivers.

A third benefit of assembly language is the size of the resulting programs. Because no conversion from a higher level by a compiler is required, the resulting programs can be exceedingly small. For this reason, assembly language has been a language of choice for the demo scene. This involves coders writing extremely small programs which show off their creative and technical abilities to other members of the scene.

In this tutorial you will learn how to write assembly language programs and how to make use of these to do interesting things such as calculations, graphics, writing windows programs and optimizing programs written in other languages.

Monday, July 16, 2007

All about computer’s virusses

Your computer is as slow as molasses. Your mouse freezes every 15 minutes, and that Microsoft Word program just won’t seem to open.

You might have a virus.

Just what exactly is a virus? What kind is in your computer? How did it get there? How is it spreading and wreaking such havoc? And why is it bothering with your computer anyway?

Viruses are pieces of programming code that make copies of themselves, or replicate, inside your computer without asking your explicit written permission to do so. Forget getting your permission down on paper. Viruses don’t bother to seek your permission at all! Very invasive.

In comparison, there are pieces of code that might replicate inside your computer, say something your IT guy thinks you need. But the code spreads, perhaps throughout your office network, with your consent (or at least your IT guy’s consent). These types of replicating code are called agents, said Jimmy Kuo, a research fellow with McAfee AVERT, a research arm of anti-virus software-maker McAfee Inc.

In this article, though, we’re not talking about the good guys, or the agents. We’ll be talking about the bad guys, the viruses.

A long, long time ago in computer years, like five, most viruses were comprised of a similar breed. They entered your computer perhaps through an email attachment or a floppy disk (remember those?). Then they attached themselves to one of your files, say your Microsoft Word program.

When you opened your Microsoft Word program, the virus replicated and attached itself to other files. These could be other random files on your hard drive, the files furthest away from your Microsoft Word program, or other files, depending on how the virus writer wanted the virus to behave.

This virus code could contain hundreds or thousands of instructions. When it replicates it inserts those instructions, into the files it infects, said Carey Nachenberg, Chief Architect at Symantec Research Labs, an arm of anti-virus software-maker Symantec. Corp.

Because so many other types of viruses exist now, the kind just described is called a classic virus. Classic viruses still exist but they’re not quite as prevalent as they used to be. (Perhaps we could put classic viruses on the shelf with Hemingway and Dickens.)

These days, in the modern era, viruses are known to spread through vulnerabilities in web browsers, files shared over the internet, emails themselves, and computer networks.

As far as web browsers are concerned, Microsoft’s Internet Explorer takes most of the heat for spreading viruses because it’s used by more people for web surfing than any other browser.

Nevertheless, “Any web browser potentially has vulnerabilities,” Nachenberg said.

For instance, let’s say you go to a website in IE you have every reason to think is safe, Nachenberg said.

But unfortunately it isn’t. It has virus code hidden in its background that IE isn’t protecting you from. While you’re looking at the site, the virus is downloaded onto your computer, he said. That’s one way of catching a nasty virus.

During the past two years, another prevalent way to catch a virus has been through downloads computer users share with one another, mostly on music sharing sites, Kuo said. On Limewire or Kazaa, for instance, teenagers or other music enthusiasts might think they’re downloading that latest Justin Timberlake song, when in reality they’re downloading a virus straight into their computer. It’s easy for a virus writer to put a download with a virus on one of these sites because everyone’s sharing with everyone else anyway.

Here’s one you might not have thought of. If you use Outlook or Outlook Express to send and receive email, do you have a preview pane below your list of emails that shows the contents of the email you have highlighted? If so, you may be putting yourself at risk.

Some viruses, though a small percentage according to Nachenberg, are inserted straight into emails themselves.

Forget opening the attachment. All you have to do is view the email to potentially get a virus, Kuo added. For instance, have you ever opened or viewed an email that states it’s “loading”? Well, once everything is “loaded,” a virus in the email might just load onto your computer.

So if I were you, I’d click on View on the toolbar in your Outlook or Outlook Express and close the preview pane. (You have to click on View and then Layout in Outlook Express.)

On a network at work? You could get a virus that way. Worms are viruses that come into your computer via networks, Kuo said. They travel from machine to machine and, unlike, the classic viruses, they attack the machine itself rather than individual files.

Worms sit in your working memory, or RAM, Nachenberg said.

OK, so we’ve talked about how the viruses get into a computer. How do they cause so much damage once they’re there?

Let’s say you’ve caught a classic virus, one that replicates and attacks various files on your computer. Let’s go back to the example of the virus that initially infects your Microsoft Word program.

Well, it might eventually cause that program to crash, Nachenberg said. It also might cause damage to your computer as it looks for new targets to infect.
This process of infecting targets and looking for new ones could eventually use up your computer’s ability to function, he said.

Often the destruction a virus causes is pegged to a certain event or date and time, called a trigger. For instance, a virus could be programmed to lay dormant until January 28. When that date rolls around, though, it may be programmed to do something as innocuous but annoying as splash popups on your screen, or something as severe as reformat your computer’s hard drive, Nachenberg said.

There are other potential reasons, though, for a virus to cause your computer to be acting slow or in weird ways. And that leads us to a new segment – the reason virus writers would want to waste their time creating viruses in the first place.

The majority of viruses are still written by teenagers looking for some notoriety, Nachenberg said. But a growing segment of the virus-writing population has other intentions in mind.

For these other intentions, we first need to explain the “backdoor” concept.

The sole purpose of some viruses is to create a vulnerability in your computer. Once it creates this hole of sorts, or backdoor, it signals home to mama or dada virus writer (kind of like in E.T.). Once the virus writer receives the signal, they can use and abuse your computer to their own likings.

Trojans are sometimes used to open backdoors. In fact that is usually their sole purpose, Kuo said.

Trojans are pieces of code you might download onto your computer, say, from a newsgroup. As in the Trojan War they are named after, they are usually disguised as innocuous pieces of code. But Trojans aren’t considered viruses because they don’t replicate.

Now back to the real viruses. Let’s say we have Joe Shmo virus writer. He sends out a virus that ends up infecting a thousand machines. But he doesn’t want the feds on his case. So he instructs the viruses on the various machines to send their signals, not of course to his computer, but to a place that can’t be traced. Hotmail email happens to be an example of one such place, Kuo said.

OK, so the virus writers now control these computers. What will they use them for?
One use is to send spam. Once that backdoor is open, they bounce spam off of those computers and send it to other machines, Nachenberg said.

That’s right. Some spam you have in your email right now may have been originally sent to other innocent computers before it came to yours so that it could remain in disguise. If the authorities could track down the original senders of spam, they could crack down on spam itself. Spam senders don’t want that.

Ever heard of phishing emails? Those are the ones that purport to be from your internet service provider or bank. They typically request some information from you, like your credit card number. The problem is, they’re NOT from your internet service provider or your bank. They’re from evil people after your credit card number! Well, these emails are often sent the same way spam is sent, by sending them via innocent computers.

Of course makers of anti-virus software use a variety of methods to combat the onslaught of viruses. Norton, for instance, uses signature scanning, Nachenberg said.

Signature scanning is similar to the process of looking for DNA fingerprints, he said. Norton examines programming code to find what viruses are made of. It adds those bad instructions it finds to its large database of other bad code. Then it uses this vast database to seek out and match the code in it with similar code in your computer. When it finds such virus code, it lets you know!

by Kara Glover

Friday, June 8, 2007

How to Install a WebDAV Server in PHP

How to install a webdav server in PHP

It's very simple.

  • Download this package, and decompress it.
  • The inc folder contains PEAR and the HTTP_WebDAV_Server class.
  • Copy the inc folder and authenticate.php file in the include_path (see php.ini)
  • Copy webdav.php file in the root of your site.

The authenticate.php file contains a digest authentification.

The webdav.php file create a webdav server


include_once("authenticate.php");

ini_set("error_reporting", "");

# Name of your restricted area
$realm = 'Restricted area Keyphrene';
$DBUSER = "your login";
$DBPWD = "your password";
$users = array($DBUSER => $DBPWD);
# With this authentication method,
# your password is not readable when you use this service
AuthenticationDigestHTTP($realm, $users);
# AuthenticationBasicHTTP($realm, $users);

require_once "HTTP/WebDAV/Server/Filesystem.php";
$server = new HTTP_WebDAV_Server_Filesystem();
# Database configuration for the lock method
$server->db_host = $DBHOST;
$server->db_name = $DB_WEBDAV;
$server->db_user = $DBUSER;
$server->db_passwd = $DBPWD;
# Real path of your site
$server->ServeRequest($DOCUMENT_ROOT."/www/");

?>

To use this service, you must connect you at this adress http://mysite.org/webdav.php. You can configure a lot of access on your site. Becareful, if you must copy files on your server, you must use the good permissions with the FTP client.

Anton Subagja