How is my register page?

Results 1 to 8 of 8
  1. #1
    Enthusiast Nito is offline
    MemberRank
    Oct 2008 Join Date
    CanadaLocation
    39Posts

    Post How is my register page?

    I just want to show you my register page and I want to know if it's Anti SQL Injections. Also I have another Question does the Emisand AdminCP have Anti SQL Injections?

    Thanks to Wizkid for the register page I really appreciate what he does and like he wanted I don't remove his copyright for respect and honor.

    This is my Register Page:


    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Fear Gunz Account Creation</title>
    <link rel="icon" href="favicon.ico">
    <style type="text/css">
    </style>
    <style type="text/css">
    img { behavior: url("pngfix.htc"); }
    </style>
    </head>
    <?php
    /*
    This script was written by Wizkid.
    All rights reserved. Any support can be requested via RageZone.
    
    You're allowed to edit this script and modify the template.
    However, you are NOT allowed to remove and/or edit my copyright.
    
    Removing this copyright will be your death.
    */
    
    //Edit to fit YOUR requirements.
    $servername = "Fear Gunz";
    $accounttable = "Account";
    $logintable = "Login";
    
    //Edit these variables. If not, no regpage for you. (Or you're fuxpro with the same logins as me.)
    $host = "------\SQLEXPRESS";
    $user = "sa";
    $pass = "------------";
    $dbname = "GunzDB";
    
    $connect = odbc_connect("Driver={SQL Server};Server={$host}; Database={$dbname}", $user, $pass) or die("Can't connect the MSSQL server.");
    
    //The well-known antisql injection. Bad enough, it's needed.
    function antisql($sql) {
        $sql = preg_replace(sql_regcase("(select|union|0x|cast|exec|varchar|insert into|delete from|update account|update login|update character|ugradeid|drop table|show tables)"),"",$sql);
        $sql = trim($sql);
        $sql = strip_tags($sql);
        $sql = addslashes($sql);
        return $sql;
    }
    
    //My favorite function. Get The Fuck Off. (Nothing personally :].)
    function gtfo($wut) {
    echo "<center><table width='500' cellpadding='5' cellspacing='0' border='0' style='border: 1px ;'>
    <tr>
    <td align=center width='100%' style='border-bottom: 1px solid black;'><b>Fear Gunz Account Creation</b></td>
    </tr>
    <tr>
    <td width='100%'><center>$wut</center></td>
    </tr>
    </table>";
    die();
    }
    
    //Check email function. This to prevent fake emails. (Remember the time YOU doing that?)
    function checkemail($address) {
    list($local, $host) = explode("@", $address);
    $pattern_local = "^([0-9a-z]*([-|_]?[0-9a-z]+)*)(([-|_]?)\.([-|_]?)[0-9a-z]*([-|_]?[0-9a-z]+)+)*([-|_]?)$";
    $pattern_host  = "^([0-9a-z]+([-]?[0-9a-z]+)*)(([-]?)\.([-]?)[0-9a-z]*([-]?[0-9a-z]+)+)*\.[a-z]{2,4}$";
    $match_local = eregi($pattern_local, $local);
    $match_host = eregi($pattern_host, $host);
    if($match_local && $match_host) {
    return 1;
    }
    else {
    return 0;
    }
    }
    
    //The num_rows() function for ODBC since the default one always returns -1.
    function num_rows(&$rid) {
    
    //We can try it at least, right?
    $num= odbc_num_rows($rid);
    if ($num >= 0) {
    return $num;
    }
    
    if (!odbc_fetch_row($rid, 1)) {
    odbc_fetch_row($rid, 0);
    return 0;
    }
    
    if (!odbc_fetch_row($rid, 2)) {
    odbc_fetch_row($rid, 0);
    return 1;
    }
    
    $lo= 2;
    $hi= 8192000;
    
    while ($lo < ($hi - 1)) {
    $mid= (int)(($hi + $lo) / 2);
    if (odbc_fetch_row($rid, $mid)) {
    $lo= $mid;
    } else {
    $hi= $mid;
    }
    }
    $num= $lo;
    odbc_fetch_row($rid, 0);
    return $num;
    }
    ?>
    <html>
    <head>
    <title><?=$servername?> Registration</title>
    </head>
    <body>
    <center>
    <?php
    //Oh well. Let's create the variable $ip to start with.
    $ip = antisql($_SERVER['REMOTE_ADDR']);
    
    /*
    An extra feature. This is NOT enabled before you remove this + the comment thingy's.
    
    To ban 1 IP it will be:
    if ($ip == "xxxxxx")
    {
    gtfo("Your IP is blacklisted.");
    }
    
    For multiple IP's, use this way:
    if ($ip == "xxxxxx" OR $ip == "xxxxxx")
    {
    gtfo("Your IP is blacklisted.");
    }
    */
    
    //Get the AID out of the Login table (defined at the top of this file) where LastIP is the visitors IP.
    $query1 = odbc_exec($connect,"SELECT AID FROM $logintable WHERE LastIP = '$ip'");
    
    //Understable for the real people. Editing this without knowledge will be the death of your regpage.
    $i=1;
    while (odbc_fetch_row($query1, $i)){
    $aid = odbc_result($query1, 'AID');
    
    $query2 = odbc_exec($connect,"SELECT UGradeID FROM $accounttable WHERE AID = '$aid'");
    odbc_fetch_row($query2);
    $ugradeid = odbc_result($query2, 1);
    
    if ($ugradeid == "253")
    {
    //Get the fuck off.
    gtfo("You have one or more accounts banned here. You're not welcome anymore.");
    }
    
    $i++;
    }
    
    //The doreg part.
    if (isset($_GET['act']) AND $_GET['act'] == "doreg")
    {
    
    //Check for any shit.
    if (!is_numeric($_POST['age']) OR !checkemail($_POST['email']) OR empty($_POST['username']) OR empty($_POST['password']) OR empty($_POST['email']) OR empty($_POST['name']) OR empty($_POST['age']))
    {
    gtfo("You're not funny.");
    }
    
    //Check if the username exists already.
    $query1 = odbc_exec($connect, "SELECT AID FROM $accounttable WHERE UserID = '" . antisql($_POST['username']) . "'");
    $count1 = num_rows($query1);
    
    if ($count1 >= 1)
    {
    gtfo("Username in use.");
    }
    
    //Check if the Email is in use.
    $query2 = odbc_exec($connect, "SELECT AID FROM $accounttable WHERE Email = '" . antisql($_POST['email']) . "'");
    $count2 = num_rows($query2);
    
    if ($count2 >= 1)
    {
    gtfo("Email address in use.");
    }
    
    //Regdate
    $regdate = date("Y-m-d H:i:s");
    
    //Time for the real work. Editing this will be the end of your regpage.
    $query3 = odbc_exec($connect, "INSERT INTO $accounttable (UserID, UGradeID, PGradeID, RegDate, Email, Age, Name) VALUES ('".antisql($_POST['username'])."', '0', '0', '$regdate', '".antisql($_POST['email'])."', '".antisql($_POST['age'])."', '".antisql($_POST['name'])."')");
    
    $query4 = odbc_exec($connect, "SELECT AID FROM $accounttable WHERE UserID = '" . antisql($_POST['username']) . "'");
    odbc_fetch_row($query4);
    $aid = odbc_result($query4, 1);
    
    //If no results comes back. (Registration failed.)
    if (!$aid)
    {
    gtfo("Shit happened. Please report this bug at our forums.");
    }
    
    odbc_exec($connect, "INSERT INTO $logintable (UserID, AID, Password) VALUES ('".antisql($_POST['username'])."', '$aid', '".antisql($_POST['password'])."')");
    
    //When everything is done, show the username/password to the visitor.
    gtfo("Your account has been created.<br><br>
    Username: $_POST[username]<br>
    Password: $_POST[password]<br><br>
    Have fun at $servername!");
    }
    
    //Here the party begins. Feel free to edit this.
    echo "<table width='350'>
    <form action='" . $_SERVER['PHP_SELF'] . "?act=doreg' method='POST'>
    <b>Fear Gunz Account Creation</b><br><br>
    <tr>
    <td width='50%'><b>Username:</b></td>
    <td width='50%'><input type='text' name='username'></td>
    </tr>
    <tr>
    <td width='50%'><b>Password:</b></td>
    <td width='50%'><input type='password' name='password'></td>
    </tr>
    <tr>
    <td width='50%'><b>E-mail:</b></td>
    <td width='50%'><input type='text' name='email'></td>
    </tr>
    <tr>
    <td width='50%'><b>Name:</b></td>
    <td width='50%'><input type='text' name='name'></td>
    </tr>
    <tr>
    <td width='50%'><b>Age:</b></td>
    <td width='50%'><input type='text' name='age'></td>
    </tr>
    <tr>
    <td width='50%'><b></b></td>
    <td width='50%'><input type='submit' value='Register'></td>
    </tr>
    </table>";
    ?>
    <br>
    <!-- No you don't remove it. -->
    <font size="3">Copyright 2008 Wizkid - Fear Gamers.</font>
    <!-- See? -->
    </center>
    </body>
    </html></div>
    </select>
    </form>
    </table>
    </div>
    </body>
    </html>
    Thank you again Wizkid .

    Okay now this is my question for the Emisand Admin Panel. Does Emisand Admin Panel has Anti SQL Injections? Thank you for reply I really appreciate your help.


  2. #2
    Account Upgraded | Title Enabled! Guy is offline
    MemberRank
    Apr 2009 Join Date
    919Posts

    Re: How is my register page?

    Code:
    //The well-known antisql injection. Bad enough, it's needed.
    function antisql($sql) {
        $sql = preg_replace(sql_regcase("(select|union|0x|cast|exec|varchar|insert into|delete from|update account|update login|update character|ugradeid|drop table|show tables)"),"",$sql);
        $sql = trim($sql);
        $sql = strip_tags($sql);
        $sql = addslashes($sql);
        return $sql;
    }
    Incorrect, it is not needed - as stated, a function replacing backslashes, single quotes, and double quotes is all you need - assuming all queries involving working mainly with numbers also are making use of quotes, then that's all that's needed.

    However, in the case of MSSQL, it's a bit different:

    Code:
    function mssql_escape ( $sql ) {
        return ( str_replace( "'", "''", $sql ) );
    }
    For MSSQL, only one single quote matters, and, another single quote is used to escape it. Enjoy!

  3. #3
    Enthusiast Nito is offline
    MemberRank
    Oct 2008 Join Date
    CanadaLocation
    39Posts

    Re: How is my register page?

    Quote Originally Posted by gWX0 View Post
    Code:
    //The well-known antisql injection. Bad enough, it's needed.
    function antisql($sql) {
        $sql = preg_replace(sql_regcase("(select|union|0x|cast|exec|varchar|insert into|delete from|update account|update login|update character|ugradeid|drop table|show tables)"),"",$sql);
        $sql = trim($sql);
        $sql = strip_tags($sql);
        $sql = addslashes($sql);
        return $sql;
    }
    Incorrect, it is not needed - as stated, a function replacing backslashes, single quotes, and double quotes is all you need - assuming all queries involving working mainly with numbers also are making use of quotes, then that's all that's needed.

    However, in the case of MSSQL, it's a bit different:

    Code:
    function mssql_escape ( $sql ) {
        return ( str_replace( "'", "''", $sql ) );
    }
    For MSSQL, only one single quote matters, and, another single quote is used to escape it. Enjoy!
    I don't really understand what do I need to remplace? Thanks for your reply I really appreciate your help gWX0.

  4. #4
    Account Upgraded | Title Enabled! Guy is offline
    MemberRank
    Apr 2009 Join Date
    919Posts

    Re: How is my register page?

    Code:
    //The well-known antisql injection. Bad enough, it's needed.
    function antisql($sql) {
        $sql = preg_replace(sql_regcase("(select|union|0x|cast|exec|varchar|insert into|delete from|update account|update login|update character|ugradeid|drop table|show tables)"),"",$sql);
        $sql = trim($sql);
        $sql = strip_tags($sql);
        $sql = addslashes($sql);
        return $sql;
    }
    Replace the above, with this:

    Code:
    function antisql ( $sql ) {
        return ( str_replace( "'", "''", $sql ) );
    }

  5. #5
    Account Upgraded | Title Enabled! Kyuma is offline
    MemberRank
    Aug 2008 Join Date
    At HomeLocation
    350Posts

    Re: How is my register page?

    Wizkid Register Page , easy to sql injection.

    u must use that register page :

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Fear Gunz Account Creation</title>
    <link rel="icon" href="favicon.ico">
    <style type="text/css">
    </style>
    <style type="text/css">
    img { behavior: url("pngfix.htc"); }
    </style>
    </head>
    <?php
    /*
    This script was written by Wizkid.
    All rights reserved. Any support can be requested via RageZone.
    
    You're allowed to edit this script and modify the template.
    However, you are NOT allowed to remove and/or edit my copyright.
    
    Removing this copyright will be your death.
    */
    
    //Edit to fit YOUR requirements.
    $servername = "Fear Gunz";
    $accounttable = "Account";
    $logintable = "Login";
    
    //Edit these variables. If not, no regpage for you. (Or you're fuxpro with the same logins as me.)
    $host = "------\SQLEXPRESS";
    $user = "sa";
    $pass = "------------";
    $dbname = "GunzDB";
    
    $connect = odbc_connect("Driver={SQL Server};Server={$host}; Database={$dbname}", $user, $pass) or die("Can't connect the MSSQL server.");
    
    function antisql ( $sql ) {
        return ( str_replace( "'", "''", $sql ) );
    }
    
    //My favorite function. Get The Fuck Off. (Nothing personally :].)
    function gtfo($wut) {
    echo "<center><table width='500' cellpadding='5' cellspacing='0' border='0' style='border: 1px ;'>
    <tr>
    <td align=center width='100%' style='border-bottom: 1px solid black;'><b>Fear Gunz Account Creation</b></td>
    </tr>
    <tr>
    <td width='100%'><center>$wut</center></td>
    </tr>
    </table>";
    die();
    }
    
    //Check email function. This to prevent fake emails. (Remember the time YOU doing that?)
    function checkemail($address) {
    list($local, $host) = explode("@", $address);
    $pattern_local = "^([0-9a-z]*([-|_]?[0-9a-z]+)*)(([-|_]?)\.([-|_]?)[0-9a-z]*([-|_]?[0-9a-z]+)+)*([-|_]?)$";
    $pattern_host  = "^([0-9a-z]+([-]?[0-9a-z]+)*)(([-]?)\.([-]?)[0-9a-z]*([-]?[0-9a-z]+)+)*\.[a-z]{2,4}$";
    $match_local = eregi($pattern_local, $local);
    $match_host = eregi($pattern_host, $host);
    if($match_local && $match_host) {
    return 1;
    }
    else {
    return 0;
    }
    }
    
    //The num_rows() function for ODBC since the default one always returns -1.
    function num_rows(&$rid) {
    
    //We can try it at least, right?
    $num= odbc_num_rows($rid);
    if ($num >= 0) {
    return $num;
    }
    
    if (!odbc_fetch_row($rid, 1)) {
    odbc_fetch_row($rid, 0);
    return 0;
    }
    
    if (!odbc_fetch_row($rid, 2)) {
    odbc_fetch_row($rid, 0);
    return 1;
    }
    
    $lo= 2;
    $hi= 8192000;
    
    while ($lo < ($hi - 1)) {
    $mid= (int)(($hi + $lo) / 2);
    if (odbc_fetch_row($rid, $mid)) {
    $lo= $mid;
    } else {
    $hi= $mid;
    }
    }
    $num= $lo;
    odbc_fetch_row($rid, 0);
    return $num;
    }
    ?>
    <html>
    <head>
    <title><?=$servername?> Registration</title>
    </head>
    <body>
    <center>
    <?php
    //Oh well. Let's create the variable $ip to start with.
    $ip = antisql($_SERVER['REMOTE_ADDR']);
    
    /*
    An extra feature. This is NOT enabled before you remove this + the comment thingy's.
    
    To ban 1 IP it will be:
    if ($ip == "xxxxxx")
    {
    gtfo("Your IP is blacklisted.");
    }
    
    For multiple IP's, use this way:
    if ($ip == "xxxxxx" OR $ip == "xxxxxx")
    {
    gtfo("Your IP is blacklisted.");
    }
    */
    
    //Get the AID out of the Login table (defined at the top of this file) where LastIP is the visitors IP.
    $query1 = odbc_exec($connect,"SELECT AID FROM $logintable WHERE LastIP = '$ip'");
    
    //Understable for the real people. Editing this without knowledge will be the death of your regpage.
    $i=1;
    while (odbc_fetch_row($query1, $i)){
    $aid = odbc_result($query1, 'AID');
    
    $query2 = odbc_exec($connect,"SELECT UGradeID FROM $accounttable WHERE AID = '$aid'");
    odbc_fetch_row($query2);
    $ugradeid = odbc_result($query2, 1);
    
    if ($ugradeid == "253")
    {
    //Get the fuck off.
    gtfo("You have one or more accounts banned here. You're not welcome anymore.");
    }
    
    $i++;
    }
    
    //The doreg part.
    if (isset($_GET['act']) AND $_GET['act'] == "doreg")
    {
    
    //Check for any shit.
    if (!is_numeric($_POST['age']) OR !checkemail($_POST['email']) OR empty($_POST['username']) OR empty($_POST['password']) OR empty($_POST['email']) OR empty($_POST['name']) OR empty($_POST['age']))
    {
    gtfo("You're not funny.");
    }
    
    //Check if the username exists already.
    $query1 = odbc_exec($connect, "SELECT AID FROM $accounttable WHERE UserID = '" . antisql($_POST['username']) . "'");
    $count1 = num_rows($query1);
    
    if ($count1 >= 1)
    {
    gtfo("Username in use.");
    }
    
    //Check if the Email is in use.
    $query2 = odbc_exec($connect, "SELECT AID FROM $accounttable WHERE Email = '" . antisql($_POST['email']) . "'");
    $count2 = num_rows($query2);
    
    if ($count2 >= 1)
    {
    gtfo("Email address in use.");
    }
    
    //Regdate
    $regdate = date("Y-m-d H:i:s");
    
    //Time for the real work. Editing this will be the end of your regpage.
    $query3 = odbc_exec($connect, "INSERT INTO $accounttable (UserID, UGradeID, PGradeID, RegDate, Email, Age, Name) VALUES ('".antisql($_POST['username'])."', '0', '0', '$regdate', '".antisql($_POST['email'])."', '".antisql($_POST['age'])."', '".antisql($_POST['name'])."')");
    
    $query4 = odbc_exec($connect, "SELECT AID FROM $accounttable WHERE UserID = '" . antisql($_POST['username']) . "'");
    odbc_fetch_row($query4);
    $aid = odbc_result($query4, 1);
    
    //If no results comes back. (Registration failed.)
    if (!$aid)
    {
    gtfo("Shit happened. Please report this bug at our forums.");
    }
    
    odbc_exec($connect, "INSERT INTO $logintable (UserID, AID, Password) VALUES ('".antisql($_POST['username'])."', '$aid', '".antisql($_POST['password'])."')");
    
    //When everything is done, show the username/password to the visitor.
    gtfo("Your account has been created.<br><br>
    Username: $_POST[username]<br>
    Password: $_POST[password]<br><br>
    Have fun at $servername!");
    }
    
    //Here the party begins. Feel free to edit this.
    echo "<table width='350'>
    <form action='" . $_SERVER['PHP_SELF'] . "?act=doreg' method='POST'>
    <b>Fear Gunz Account Creation</b><br><br>
    <tr>
    <td width='50%'><b>Username:</b></td>
    <td width='50%'><input type='text' name='username'></td>
    </tr>
    <tr>
    <td width='50%'><b>Password:</b></td>
    <td width='50%'><input type='password' name='password'></td>
    </tr>
    <tr>
    <td width='50%'><b>E-mail:</b></td>
    <td width='50%'><input type='text' name='email'></td>
    </tr>
    <tr>
    <td width='50%'><b>Name:</b></td>
    <td width='50%'><input type='text' name='name'></td>
    </tr>
    <tr>
    <td width='50%'><b>Age:</b></td>
    <td width='50%'><input type='text' name='age'></td>
    </tr>
    <tr>
    <td width='50%'><b></b></td>
    <td width='50%'><input type='submit' value='Register'></td>
    </tr>
    </table>";
    ?>
    <br>
    <!-- No you don't remove it. -->
    <font size="3">Copyright 2008 Wizkid - Fear Gamers.</font>
    <!-- See? -->
    </center>
    </body>
    </html></div>
    </select>
    </form>
    </table>
    </div>
    </body>
    </html>
    Enjoy.

  6. #6
    Enthusiast ashpoh is offline
    MemberRank
    Dec 2008 Join Date
    SingaporeLocation
    27Posts

    Re: How is my register page?

    This is the problem i have Now T.T
    //Check email function. This to prevent fake emails. (Remember the time YOU doing that?)
    function checkemail($address) {
    list($local, $host) = explode("@", $address);
    $pattern_local = "^([0-9a-z]*([-|_]?[0-9a-z]+)*)(([-|_]?)\.([-|_]?)[0-9a-z]*([-|_]?[0-9a-z]+)+)*([-|_]?)$";
    $pattern_host = "^([0-9a-z]+([-]?[0-9a-z]+)*)(([-]?)\.([-]?)[0-9a-z]*([-]?[0-9a-z]+)+)*\.[a-z]{2,4}$";
    $match_local = eregi($pattern_local, $local);
    $match_host = eregi($pattern_host, $host);
    if($match_local && $match_host) {
    return 1;
    }

  7. #7
    Apprentice kerim55 is offline
    MemberRank
    Dec 2009 Join Date
    20Posts

    Re: How is my register page?

    what is thit?

    %22%20.%20$_SERVER[ ( i can't find this if i test to creating a account.

  8. #8
    人◕ ‿‿ ◕人 Forean is offline
    MemberRank
    Jul 2008 Join Date
    1,183Posts

    Re: How is my register page?

    Quote Originally Posted by ashpoh View Post
    This is the problem i have Now T.T
    //Check email function. This to prevent fake emails. (Remember the time YOU doing that?)
    function checkemail($address) {
    list($local, $host) = explode("@", $address);
    $pattern_local = "^([0-9a-z]*([-|_]?[0-9a-z]+)*)(([-|_]?)\.([-|_]?)[0-9a-z]*([-|_]?[0-9a-z]+)+)*([-|_]?)$";
    $pattern_host = "^([0-9a-z]+([-]?[0-9a-z]+)*)(([-]?)\.([-]?)[0-9a-z]*([-]?[0-9a-z]+)+)*\.[a-z]{2,4}$";
    $match_local = eregi($pattern_local, $local);
    $match_host = eregi($pattern_host, $host);
    if($match_local && $match_host) {
    return 1;
    }
    That just checks if the email has an @ in it.



Advertisement