Jump to content

MD5 - Accepts any password, why?


3raser

Recommended Posts

On my site, http://domination.comyr.com/progress/login.php, it's accepting any password. Why is it doing that?

 

<?php require "global_navigation.php"; ?>
<?php

session_start();

$username = $_POST['username'];
$password = $_POST['password'];
$secret_password = md5("password");

if ($_SESSION['username'])
   die("You're currently logged in already! <a href='index.php'>Return home</a>");

if (!$username)
die("
<font face='arial' size='2'>
<html><center><br /><br /><h3>Login</h3>
      <form action='login.php' method='POST'>
      <div class='box'>Username: <input type='text' name='username'></div>
      <div class='box'>Password: <input type='password' name='password'></div>
      <div class='box'><input type='submit' value='Login'></div>
      </form></center>
");

//protection
$before = array('(', ')', '^', '<', '>', '`', '*', '<script>', '</script>', ';DROP TABLE users;', 'users', 'DROP', 'TABLE');
$after   = array('', '', '', '', '', '', '', '', '', '', '', '', '');
$output  = str_replace($before, $after, $username);


if ($username&&$password)
{

$connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!");
mysql_select_db("$db") or die("Database fail!");

$query = mysql_query("SELECT * FROM users WHERE username='$output'");

$numrows = mysql_num_rows($query);

if ($numrows!=0)
{

  while ($row = mysql_fetch_assoc($query))
  {
        $dbusername = $row['username'];
        $dbpassword = $row['password'];     
  }
  
  if ($output==$dbusername&&$secret_password==$dbpassword)
  {
     echo "<div class='box'>Successfully logged in! <a href='index.php'>Return home</a></div>";
     $_SESSION['username']=$output;
     
  }
  else 
      echo "<div class='box'><span style='color:red'>Incorrect password!</span></div>";

}
else
    die("<div class='box'><span style='color:red'>That user doesn't exist!</span></div>");
}
else
    die("<div class='box'><span style='color:red'>Please enter a username and password</span></div>");




?><?php require("global_footer.php") ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.