So you want to create a printer-friendly pages for your website users? Writing the content directly into the popup windows and promting the print command? Want to control how the output looks and feels too? Well you have come to the right place. Lets begin by using this script where the pop up window can be created using javascript which holds the...
Written by GentleGiant on 01/22/12 at 22:25:20 EST
In C this includes the popen(), and system() commands, all of which invoke a /bin/sh subshell to process the command. In Perl this includes system(), exec(), and piped open() functions as well as the eval() function for invoking the Perl interpreter itself. In the various shells, this includes the exec and eval commands. Backtick quotes,...
Written by GentleGiant on 01/22/12 at 14:18:26 EST
Are compiled languages such as C safer than interpreted languages like Perl and shell scripts? The answer is "yes", but with many qualifications and explanations. First of all is the issue of the remote user's access to the script's source code. The more the hacker knows about how a script works, the more likely he is to find bugs to...
Written by GentleGiant on 01/22/12 at 14:18:10 EST
Is it better to store scripts in the cgi-bin directory, or to store them anywhere in the document tree and identify them to the server using the .cgi extension? Although there's nothing intrinsically dangerous about scattering CGI scripts around the document tree, it's better to store them in the cgi-bin directory. Because CGI scripts are such...
Written by GentleGiant on 01/22/12 at 14:18:06 EST
The problem with CGI scripts is that each one presents yet another opportunity for exploitable bugs. CGI scripts should be written with the same care and attention given to Internet servers themselves, because, in fact, they are miniature servers. Unfortunately, for many Web authors, CGI scripts are their first encounter with network programming. ...
Written by GentleGiant on 01/22/12 at 14:16:35 EST
The CGI security FAQ, maintained by Paul Phillips ( paulp@cerf.net), can be found at: http://www.go2net.com/people/paulp/cgi-security/safe-cgi.txt This document contains a great deal of useful advice, but has not been updated since September 1995. More recently, Selena Sol has published an excellent article on the risks of...
Written by GentleGiant on 01/22/12 at 14:16:28 EST
In Perl, you can invoke external programs in many different ways. You can capture the output of an external program using backticks: $date = `/bin/date`; You can open up a pipe to a program: open (SORT, " /usr/bin/sort /usr/bin/uniq"); You can invoke an external program and wait for it to return with system(): ...
Written by GentleGiant on 01/22/12 at 14:16:23 EST
As we've seen, one of the most frequent security problems in CGI scripts is inadvertently passing unchecked user variables to the shell. Perl provides a "taint" checking mechanism that prevents you from doing this. Any variable that is set using data from outside the program (including data from the environment, from standard input, and...
Written by GentleGiant on 01/22/12 at 14:16:17 EST
I turned on taint checks and now my script dies with the message: "Insecure $ENV{PATH} at line XX" every time I try to run it! Even if you don't rely on the path when you invoke an external program, there's a chance that the invoked program might. Therefore you need to include the following line towards the top of your script whenever...
Written by GentleGiant on 01/22/12 at 14:16:09 EST
A frequent task for Perl CGI scripts is to take a list of keywords provided by the remote user and to use them in a patttern matching operation to fetch a list of matching file names (or something similar). This, in and of itself, isn't dangerous. What is dangerous is an optimization that many Perl programmers use to speed up the pattern matching...
Written by GentleGiant on 01/22/12 at 14:16:03 EST
Ran into some issues with cross site scripting attacks today. CERT® has an excellent article that show exactly how you should be filtering input from forms. Specifically, it mentions that just filtering *certain* characters in user supplied input isn’t good enough. Developers should be doing the opposite and only explicitly allowing certain...
Written by GentleGiant on 01/22/12 at 14:15:57 EST
If you are concerned about your queries showing up in server logs, or those of Web proxies along the way, this is true. Queries submitted with POST usually don't appear in logs, while GET queries do. In other respects, however, there's no substantial difference in security between the two methods. It is just as easy to intercept unencrypted GET...
Written by GentleGiant on 01/22/12 at 13:18:20 EST
They sure can! The hidden variable is visible in the raw HTML that the server sends to the browser. To see the hidden variables, a user just has to select "view source" from the browser menu. In the same vein, there's nothing preventing a user from setting hidden variables to whatever he likes and sending it back to your script. Don't...
Written by GentleGiant on 01/22/12 at 13:18:17 EST
Nothing can automatically make CGI scripts completely safe, but you can make them safer in some situations by placing them inside a CGI "wrapper" script. Wrappers may perform certain security checks on the script, change the ownership of the CGI process, or use the Unix chroot mechanism to place the script inside a restricted part of the...
Written by GentleGiant on 01/22/12 at 13:17:54 EST
Not really. One favorite hacker's trick is to alter the PATH environment variable so that it points to the program he wants your script to execute rather than the program you're expecting. In addition to avoiding passing unchecked user variables to external programs, you should also invoke the programs using their full absolute pathnames rather...
Written by GentleGiant on 01/22/12 at 13:17:51 EST
But if I avoid eval(), exec(), popen() and system(), how can I create an interface to my database/search engine/graphics package? You don't have to avoid these calls completely. You just have to understand what you're doing before you call them. In some cases you can avoid passing user-supplied variables through the shell by calling external...
Written by GentleGiant on 01/22/12 at 13:17:48 EST
A MAJOR source of security holes has been coding practices that allowed character buffers to overflow when reading in user input. Here's a simple example of the problem: #include <stdlib.h> #include <stdio.h> static char query_string[1024]; char* read_POST() { int query_size; ...
Written by GentleGiant on 01/22/12 at 13:17:44 EST
The basics for perl include Parsing form for the data with a subroutine. Ready here we go... 1. Create a form Create a new Web page with this code: Dream Car
Lets write a simple Random Number Subroutine using perl. Ready? Lets go.... Create a Web page with this code: Really Random
Written by GentleGiant on 01/20/12 at 12:15:53 EST
HTML5 has garnered plenty of attention in the last two years, and for good reasons. The internet as we know it is changing, and HTML5 is at the forefront of those changes. If you are eager to jump into the HTML5 mix, you will be interested in the tools we have found for creating websites and web apps using HTML5. At the moment, there are two...
Written by GentleGiant on 12/27/11 at 20:16:22 EST
CSS is simple enough to control a few page elements. CSS is a very powerful tool. Stretch your imagination, with CSS you can create what you really want your page, layout, or site to look like is only limited to the amount of time you want to spend designing. In CSS there is many tricks that will spare you and others some time. Using these...
Have you ever been to a website to look for something, but you have no idea where to look, and you wished they had a search bar? Well, adding a search bar in ASP is easy enough with Bing. Sign up for an application ID and build the request and response handlers. Let’s look at the basics of setting up Bing for your site and follow up with a few...
jQuery Cycle Plugin is a lightweight jQuery plugin which offers an easy way to create a slideshow of images for your website. The plugin provides a bunch of different effects for cycling between each slide, from a simple fade to the more elaborate ’shuffle effect’, you can choose to cycle through each slide on a time delay or for it to be...
There are many blogs and websites that are being hacked and infected by Malware each day. The hacker embeds malicious code and links to websites that are deemed as bad neighbors or malicious. The hacker will use the attribute display=none so that the site owner and visitors can’t see the anchor text and or links to these malicious sites. The...