-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction_page1.php
More file actions
85 lines (79 loc) · 1.73 KB
/
Copy pathaction_page1.php
File metadata and controls
85 lines (79 loc) · 1.73 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
$uname = $_POST['uname'];
$passwordwithout=$_POST['psw'];
$userhash = sha1($uname);
$passhash=sha1( $passwordwithout );
//echo sha1("admin' or '1'='1'#");
//echo sha1("or 1=1");
//echo $passhash;
include 'connect.php';
$i=0;
$j=0;
//sql attack checking
$file2=fopen("hashes2.txt", "r");
while(!feof($file2))
{
$word1=fgets($file2). "<br />";
$word1=substr($word1,0,40);
if ($userhash == $word1)
{
$j = $j+1;
break;
}
}
if ($j == 1)
{
echo '<script language="javascript">';
echo 'alert("Possible sql attack")';
echo '</script>';
header("Location: sqldetect.html");
}
/* else
{
echo '<script language="javascript">';
echo 'alert("")';
echo '</script>';
}*/
fclose($file2);
//db checking
$sql = "SELECT username FROM maindb WHERE username ='$uname' and passhash='$passhash'";
$found=mysqli_query($connect,$sql) or die("Possible SQL injection attack.");
//username verification
if (mysqli_num_rows($found) != null )
{
echo '<script language="javascript">';
echo 'alert("Username Exists")';
echo '</script>';
$i=1;
} else {
echo '<script language="javascript">';
echo 'alert("Username Does not exist")';
echo '</script>';
}
//password verification
$file=fopen('hashes1.txt', 'r');
while(!feof($file))
{
$word=fgets($file). "<br />";
$word=substr($word,0,40);
if ($passhash == $word)
{
$i = $i+1;
break;
}
}
if ($i == 2)
{
echo '<script language="javascript">';
echo 'alert("User successfully logged in")';
echo '</script>';
header("Location: success.html");
}
else
{
echo '<script language="javascript">';
echo 'alert("Invalid password")';
echo '</script>';
}
fclose($file);
?>