內容:.
自己寫一個登陸頁面,并能實作對接資料庫,判斷用戶名與密碼是否正確,
練習sql-map-master的1-7關
test.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<H2>歡迎來到西安歐鵬</H2>
<body>
<P>登錄</P>
<form name="input" action="welcome.php" method="get">
user:<input type="text" name="user">
password:<input type="password" name="password">
<input type="submit" value="登錄">
</form>
</body>
</html>
welcome.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
</html>
<?php
$username=$_GET['user'];
$password=$_GET['password'];
if($username==NULL or $password==null)
{
echo "用戶名或密碼不得為空";
}
else
{
$conn=mysqli_connect('127.0.0.1','root','cangshu123@','test');
}
if(!$conn)
{
die("連接失敗:" .mysql_connect_error());
}
echo"資料庫連接成功";
$sql="select users,password from test.users where users='$username' and password='$password'";
$result=mysqli_query($conn,$sql);
$row=mysqli_fetch_assoc($result);
if ($row)
{
echo "登錄成功,歡迎來到西安歐鵬.$username";
}
else
{
echo "登錄失敗<a href='test.php'>重新登錄";
}
mysql部分:
先建立庫test
create database test;
再建立users表
mysql> create table users
-> (
-> users varchar(20),
-> password varchar(30) not null
-> )
-> ;
再向users表插入資料
insert into users (users,password) values('admin','123456');
最后再查詢資料是否插入成功

測驗
在url輸入127.0.0.1/test.php


發現密碼正確
練習sql-map-master
第一關:

然后注入列數


在查詢在那個庫下

再查詢表

第二關:

第三關:

第四關:

第五關
使用floor報錯注入

第六關

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/404065.html
標籤:其他
