Advertisement
Guest User

sqli_challenge

a guest
May 6th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5.  
  6. $link = mysql_connect('localhost', 'root', '');
  7. if (!$link) {
  8. die('Could not connect: ' . mysql_error());
  9. }
  10. mysql_select_db("ctf");
  11. echo 'Connected successfully';
  12. //error_reporting(0);
  13.  
  14. $black_list = "/admin|guest|limit|by|substr|mid|like|or|char|union|select|greatest|%00|\'|";
  15. $black_list .= "=|_| |in|<|>|-|chal|_|\.|\(\)|#|and|if|database|where|concat|insert|having|sleep/i";
  16. if(preg_match($black_list, $_GET['user'])) exit(":P");
  17. if(preg_match($black_list, $_GET['pw'])) exit(":P");
  18.  
  19.  
  20. $query="select user from chal where user='$_GET[user]' and pw='$_GET[pw]'";
  21.  
  22. $result = mysql_query($query);
  23. $result = mysql_fetch_array($result); echo(mysql_error($link));
  24. $admin_pass = mysql_fetch_array(mysql_query("select pw from chal where user='admin'")); echo(mysql_error($link));
  25. echo "<h1>query : <strong><b>{$query}</b></strong><br></h1>";
  26. if($result['user']) echo "<h2>Welcome {$result['user']}</h2>";
  27. if(($admin_pass['pw'])&&($admin_pass['pw'] === $_GET['pw'])){
  28. echo $flag;
  29. }
  30.  
  31. highlight_file(__FILE__);
  32.  
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement