-
Notifications
You must be signed in to change notification settings - Fork 1
/
signin.php
executable file
·42 lines (42 loc) · 1.5 KB
/
signin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
function check($str)
{
if (!strstr($str,'!')&&!strstr($str,'@')&&!strstr($str,'#')&&!strstr($str,'$')&&!strstr($str,'%')&&!strstr($str,'^')&&!strstr($str,'&')&&!strstr($str,'*')&&!strstr($str,'(')&&!strstr($str,')')&&!strstr($str,'-')&&!strstr($str,'_')&&!strstr($str,'=')&&!strstr($str,'+')&&!strstr($str,'[')&&!strstr($str,']')&&!strstr($str,'"')&&!strstr($str,'\'')&&!strstr($str,';')&&!strstr($str,'<')&&!strstr($str,'>')&&!strstr($str,'?')&&!strstr($str,'`')&&!strstr($str,'~')&&!strstr($str,'\\')&&!strstr($str,'/')&&!strstr($str,'|')) {
return TRUE;
}
else{
return FALSE;
}
}
$user = "ezbabyctf";
$passwd = "ezbabyctf";
$db = "ezbabyctf";
$tb = "users";
$conn = new mysqli("localhost",$user,$passwd,$db);
if($conn->connect_error){
die("Connection faild.".$conn->connect_error);
}
else{
if(isset($_GET["name"])&&isset($_GET["password"])){
$name = urldecode($_GET["name"]);
$password = urldecode($_GET["password"]);
if (!check($name)||!check($password)) {
die("Invalid call.");
}
$s2 = "select * from ".$tb." where name=\"".$name."\" and password=\"".$password."\"";
//echo $s2;
$conn->query($s2);
if(mysqli_affected_rows($conn)!=1){
exit("Wrong name or password.");
}
else{
echo "Successfully sign in!";
setcookie("salt",md5($name).time());
//header("Location:index.html");
}
}
else{
die("Invalid call.");
}
}
?>