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作。