systemctl start apache2
打开apache2并使用netstat -aptn
查看端口号,确认apache正确开启(80端口就是Apache)
javascript
而后利用kali自带的浏览器访问(本机地址)登陆Apache首页
php
Apache的工做目录是/var/www/html
,能够测试apache是否可读取工做目录下的文件vi /var/www/html/test.txt
,而后随意输入一串字符,浏览器打开 ip/text.txt,可看到测试用txt的内容。
html
编写一个HTML做为前端的登陆页面 (代码)前端
<html> <head> <title>login</title> </head> <body> <form name=“form” action="20155231.php" method="post"> Username:<input type="text" name="user"><p> Password:<input type="password" name="pw"><p> <input type="submit" value="submit"> </form> </body> </html>
<?php $user=($_POST["user"]); $psw=($_POST["pw"]); echo "welcome "; echo $user; ?>
<html> <head> <title>login</title> <meta charset="utf-8"/> <script language="javascript"> function check(form){ var Username =form.user.value; var pwd =form.pw.value; if((Username == "")||(pwd == ""))//若是用户名为空 { alert("用户名或密码不能为空"); return false; } if (pwd.length > 16 || pwd.length < 6) { alert("密码长度应该在 6 - 16 位"); return false; } form.submit(); } </script> </head> <body> <form name="form" method="post" action="20155231.php"> Username:<input type="text" name="user"><p> Password:<input type="password" name="pw"><p> <input type="button" value="submit" onclick="check(form)"> </form> </body> </html>
登陆界面
java
密码错误提示
mysql
apt-get install mysql
/etc/init.d/mysql start
mysql -u root -p
,并根据提示输入密码,默认密码为p@ssw0rd
进入MySQLCREATE SCHEMA TestLogin;
USE TestLogin
create table `users`( `userid` int not null comment '', `username` varchar(45) null comment '', `password` varchar(256) null comment '', `enabled` varchar(5) null comment '', primary key (`userid`) comment '');
输入insert into users(userid,username,password,enabled) values( 1,'20155210',password("20155210"),"TRUE");
添加信息
web
输入select * from users
进行查询
sql
<?php $user=($_POST["user"]); $psw=($_POST["pw"]); if($user==""||$psw=="") { echo"<script>alert('Please enter your name and password!');history.go(-1);</script>" } else { $link=mysqli_connect(“192.168.147.144”,“root”,“p@ssw0rd”,“TestLogin”); mysqli_select_db($link,"TestLogin"); mysqli_query($link,'setname utf8'); $sql="select username,password from users where username='$_POST[user]' and password=password('$psw') "; $result=mysqli_query($link,$sql); $row=mysqli_fetch_array($result); if($num=mysqli_num_rows($result)) { echo "welcome "; echo $user; } else { echo"<script>alert('Wrong username or password!');history.go(-1);</script>"; } } ?>
因此咱们的后台语句:SELECT username,password FROM users WHERE username='' and password=('')要被变为select username,password from users where username=' 'or 1=1#' and password=(''),在用户名框中输入 'or 1=1#,密码随便,能够看到登录成功
数据库
或者在用户名框中输入';insert into users(userid,username,password,enabled) values(2,'1552',password("1552"),"TRUE");#,就能够直接在数据库中添加用户信息apache
在用户名输入框中输入<img src="5231.jpg" />
读取图片,图片和网页代码在同一文件夹下
本次实验中实践了网页编程中利用脚本登陆帐户,要这样作须要知道网页编程的语言描述,而后就很容易的进入了帐户,不论密码的对错。在实践过程当中因为kuil数据库连不通换成了Windows作。