+ Reply to Thread
Results 1 to 9 of 9
Like Tree3Likes
  • 1 Post By Anant Shrivastava
  • 2 Post By amolnaik4

Thread: is this login code vulnerable to sqli ? Share/Save - My123World.Com!

  1. #1
    Garage Newcomer Crim3R is on a distinguished road
    Join Date
    Jun 2012
    Posts
    3
    Thanks
    8
    Thanked 0 Times in 0 Posts

    is this login code vulnerable to sqli ?



    hi all i have get this code by a source code disclosure bug tryed to login to mysql after reading config but remote access is disabled. i want to know is this login code vulnerable to sqli ?
    thanks
    Code:
    <?php session_start();?>
    <?php
    require("../dbconnect/newsite.php");
    
    $showform=true;
    if (isset($_POST['login'])){
    	if (!empty($_POST['usr'])){
    		$un=trim($_POST['usr']);
    	}
    	if (!empty($_POST['pass'])){
    		$pw=trim(md5($_POST['pass']));
    	}
    	$scode=$_POST["scode"];
    	if ( ($scode == $_SESSION["security_code"]) && (!empty($scode) && !empty($_SESSION["security_code"])) ) 
    
    {
    //echo "SELECT * FROM admins WHERE user='$un' AND pass='$pw'";
    	$rs=mysql_query("SELECT * FROM admins WHERE user='$un' AND pass='$pw'")or die("hahaha");
    	if( mysql_num_rows($rs) > 0 )
    	{
    		$row=mysql_fetch_array($rs);
    		$_SESSION['adminId']=$row['id'];	
    		$_SESSION['adminName']=$row['name'];
    		//echo"Welcome <b>".$row['name']."</b>";
    		$showform=false;
    	
    	}
    	else
    {
    	$_SESSION['adminId']=0;
    }
    }
    
    	
    else{
    		$_SESSION['adminId']=0;
    		//$showform=true;
    	}
    header("location:index.php");
    	
    }		
    ?>

  2. #2
    Security Researcher Anant Shrivastava has a spectacular aura aboutAnant Shrivastava has a spectacular aura about
    Join Date
    May 2011
    Location
    Pune, Maharashtra, India
    Posts
    226
    Blog Entries
    1
    Thanks
    75
    Thanked 91 Times in 50 Posts
    --- posted an answer but removing it coz this looks like a direct attempt to mount an attack.
    fb1h2s likes this.
    Website :
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

    Blog :
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

  3. #3
    Garage Newcomer Crim3R is on a distinguished road
    Join Date
    Jun 2012
    Posts
    3
    Thanks
    8
    Thanked 0 Times in 0 Posts
    direct attempt to mount an attack ?
    are u kidding ? there is 1000 of 0days publishing mountly.
    and ur worried about this little code ? well i should say i already hacked the target in another way i was just trying to learn something
    anyway thanks for answer

  4. #4
    Security Researcher fb1h2s has a spectacular aura aboutfb1h2s has a spectacular aura aboutfb1h2s has a spectacular aura about fb1h2s's Avatar
    Join Date
    Jul 2010
    Location
    India
    Posts
    596
    Blog Entries
    23
    Thanks
    279
    Thanked 150 Times in 76 Posts
    @anant There would't be much we[mods] would be able to do when he speaks up with so much confident , he will eventually will do what He want's .

    @crimer what anant and [We all] wanted for the forum is to keep the offensive rate low, and wann keep this place as professional as possible. So in future what ever motive you'r asking questions , please do not mention you'r intentions, or lie to us that you'r doing it for something good #simple .

    Any way it's exploitable now that u have found ur way, it does't make sense.
    Hacking Is a Matter of Time Knowledge and Patience

  5. The Following User Says Thank You to fb1h2s For This Useful Post:

    Crim3R (08-17-2012)

  6. #5
    Garage Newcomer Crim3R is on a distinguished road
    Join Date
    Jun 2012
    Posts
    3
    Thanks
    8
    Thanked 0 Times in 0 Posts
    @fb1h2s yeah ok.
    i shlould say my porpose from hacking is not bad in the first place
    Files from Crim3R ≈ Packet Storm
    ive just started bug researching in few mounts and i got few things in this little time .
    about the target i hacked it from server . but im still Curious about this code.
    and i will be thankful if u tell me how to understand these things myself

  7. #6
    Security Researcher fb1h2s has a spectacular aura aboutfb1h2s has a spectacular aura aboutfb1h2s has a spectacular aura about fb1h2s's Avatar
    Join Date
    Jul 2010
    Location
    India
    Posts
    596
    Blog Entries
    23
    Thanks
    279
    Thanked 150 Times in 76 Posts
    I can explain that code, but would not help you anyway for future .

    And here is everything you need to know on HOW TO.

    Road to Web Application Security
    Hacking Is a Matter of Time Knowledge and Patience

  8. The Following User Says Thank You to fb1h2s For This Useful Post:

    Crim3R (08-17-2012)

  9. #7
    Security Researcher "vinnu" is a jewel in the rough"vinnu" is a jewel in the rough"vinnu" is a jewel in the rough "vinnu"'s Avatar
    Join Date
    Jul 2010
    Posts
    245
    Blog Entries
    2
    Thanks
    178
    Thanked 140 Times in 72 Posts
    Namaste
    The answer is simple. And as others i too wrote but did not posted it. The code is simple to understand, If u were able to grab the code, then it will take very less effort to understand this code..."vinnu"

  10. #8
    Web Security Consultant amolnaik4 is just really niceamolnaik4 is just really niceamolnaik4 is just really niceamolnaik4 is just really niceamolnaik4 is just really nice amolnaik4's Avatar
    Join Date
    Jul 2011
    Location
    webr00t
    Posts
    269
    Blog Entries
    3
    Thanks
    24
    Thanked 180 Times in 100 Posts
    @Crim3r: The best "to do" for you is get RIPS n scan this code. It will give you report whether this is vulnerable or not to any vulnerability. And best part is it gives potential exploit code as well.

    Try it:
    RIPS - free PHP security scanner using static code analysis

    AMol NAik
    AnArKI and fb1h2s like this.

  11. The Following User Says Thank You to amolnaik4 For This Useful Post:

    Crim3R (08-17-2012)

  12. #9
    [s]
    [s] is offline
    Security Researcher [s] will become famous soon enough [s]'s Avatar
    Join Date
    Nov 2010
    Posts
    187
    Blog Entries
    2
    Thanks
    62
    Thanked 53 Times in 30 Posts
    Crim3r , You can try my tool PHP Source Code Testing Tool
    Code:
    http://www.sandeepkamble.com/skl337/2011/08/09/psa-php-source-code-testing-tool/
    all the best ..

    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

  13. The Following User Says Thank You to [s] For This Useful Post:

    Crim3R (08-19-2012)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts