UNKNOWN =************************************** = Name: MySQL Sign up Script = Description:The code adds a username and a password to a MySQL database with abit of messin you can make Login scripts, Mailing scripts easy to update site faster etc = By: Damian myerscough = = = Inputs:Username and Password = = Returns:Username and Password added to the MySQL database = =Assumes:You will need to create a web page which will have a form on with to text areas for the username and passwd = =Side Effects:you will need: Crypt::CBC Crypt::Blowfish Crypt::khazad Crypt::Rijndael =This code is copyrighted and has limited warranties. =Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.490/lngWId.6/qx/vb/scripts/ShowCode.htm =for details. =************************************** #!/usr/bin/perl -w # # This script is a sign up script which uses MySQL # Also I have added Encryption So no one can see the # password. # # Encryption used: # [*] Blowfish[*] # [*] RC4[*] # [*] khazad [*] # [*] Rijndael[*] # [*] MD5[*] # [*] Crypt [*] # ################## # Coded By; Damian Myerscough 2003 # ~~~~~~~~~~~~~~~~~~~~~~~ # use DBI; use Crypt::CBC; use Crypt::Blowfish; use Crypt::RC4; use Crypt::Rijndael; use Digest::MD5 ('md5', 'md5_hex', 'md5_base64'); use CGI qw(:standard); print"Content-type: text/html\n\n"; $username = param('username'); $password = param('password'); if($password =~ m/[`\$\\"';& ... + % < > * | ? : ( ) # { } ~ !]/) { &Error; } if($username =~ m/[`\$\\"';& ... + % < > * | ? : ( ) # { } ~ !]/) { &Error; } sub Error() { print"Error you have tryed to use an illegal character<br>"; print"Illegal Characters List:<br>"; print"`<br>\n". "\x5C <br>\n". "\x22 <br>\n". "'<br>\n". ";<br>\n". "&<br>\n". ".<br>\n". "+<br>\n". "\$<br>\n". "%<br>\n". "< > <br>\n". "*<br>\n". "|<br>\n". "?<br>\n". ":<br>\n". "[ ] <br>\n". "( ) <br>\n". "#<br>\n". "{ } <br>\n". "~<br>\n". "!<br>\n"; print"These Characters Have Been Filtered Out To Stop SQL Injection<br>". "And Any Tampering With The Way The Script Works.<br>"; } $Cipher = Crypt::CBC->new({'key'=> '007xDamox700', 'cipher' => 'Blowfish', 'iv' => '![$`2}%q', 'regenerate_key' => 0, 'padding'=> 'space', 'prepend_iv' => 0 }); $etext = $Cipher->encrypt("$password"); my $key = 'xDam0x'; my $IV = pack("H16", 0); my $cipher = Crypt::CBC->new({'key' => $key, 'cipher' => 'Khazad', 'iv' => $IV, 'regenerate_key' => 1, 'padding' => 'standard', 'prepend_iv' => 0 }); $text = $cipher->encrypt("$etext"); $encrypted = RC4($etext, $text); $CIpher = new Crypt::Rijndael "XdAmOiAnLkInxYtA", Crypt::Rijndael::MODE_CBC; $CIpher->set_iv($IV); $Plain = "$encrypted"; $Plain128 = get128($Plain); $ciphered = $CIpher->encrypt($Plain128); sub get128 { my $data = shift; return "\0" x ( 128 - length($data)%128 ) . $data; } $Finalx = md5($ciphered); $Finalz = md5_hex($Finalx); $Final = md5_base64($Finalz); $Finished = crypt("$Final", F1n4l); our ($dbh, $sth); my $sql = "(\x4E\x55\x4C\x4C, \x22$username\x22, \x22$Finished\x22)"; $dbh = DBI->connect("DBI:mysql:host=localhost;database=infos", "contact", "sh311B", {PrintError => 0, RaiseError => 1}); $sth = $dbh->prepare("INSERT INTO users VALUES $sql"); $sth->execute(); $sth->finish(); print"username $username added \n"; $dbh->disconnect(); exit(0);