1. On the original simple_form.html
basis, you can add a piece of JavaScript code to complete the user's decision whether to fill out the mailbox and password. The modified login_test.html
is as follows:
3.Web backend: MySQL Basics1. Enter the /etc/init.d/mysql start
MySQL service to open:
2. Enter mysql -u root -p
with root access, the default password is password
:
3. Enter update user set password=PASSWORD("新密码") where user=‘root‘;
, change password, enter flush privileges;
, update permissions:
4. Enter the exit
exit database and log in with the new password:
5. Use the create database 数据库名称;
Build database:
6. Use show databases;
to view the existing database:
7. Use use 数据库名称;
the database that we created:
8. Use create table 表名 (字段设定列表);
the Build database table and set the field basic information:
9. Use the show tables;
view table information:
10. Use insert into 表名 values(‘值1‘,‘值2‘,‘值3‘...);
Insert data:
11. Use select * from 表名;
the data in the query table:
12. Add a new user to MySQL, use the grant select,insert,update,delete on 数据库.* to 用户名@登录主机(可以是localhost,也可以是远程登录方式的IP) identified by "密码";
instructions, this sentence means 将对某数据库的所有表的select,insert,update,delete权限授予某ip登录的某用户
:
13. After adding a new user, log in with a new user name and password:
A successful login indicates a successful addition of a new user.
Back to Catalog
4.Web backend: Writing PHP Web pages1. /var/www/html
Create a new PHP test file in the directory phptest.php
to get a quick look at some of its syntax:
<?phpecho ($_GET["a"]);include($_GET["a"]);echo "This is my php test page!<br>";?>
2. Enter in the browser URL bar to localhost:80/phptest.php?a=/etc/passwd
see /etc/passwd
the contents of the file
3. Using PHP and MySQL, combined with the previously written login Web page for login identity authentication, the modified login.php
code is as follows:
<?php$uname=$_POST["Email"];$pwd=$_POST["Password"];echo $uname;$query_str="SELECT * FROM login where username='$uname' and password='$pwd';";$mysqli = new mysqli("127.0.0.1", "diweijia", "970322", "dwjDB");/* check connection */if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit();}echo "connection ok!";/* Select queries return a resultset */if ($result = $mysqli->query($query_str)) { if ($result->num_rows > 0 ){ echo "<br> {$uname}:Welcome!!! <br> "; } else { echo "<br> login failed!!!! <br> " ; } /* free result set */ $result->close();}$mysqli->close();?>
4. Enter access to 127.0.0.1/login.html
your login screen in the browser.
5. Enter the username and password to authenticate and successfully log in as shown:
Back to Catalog
5. The simplest SQL injection, XSS attack test1.SQL Injection:
SQL injection, by inserting a SQL command into a Web form to submit or entering a query string for a domain name or page request, eventually achieves a malicious SQL command that deceives the server. Specifically, it is the ability to inject (malicious) SQL commands into the background database engine execution using existing applications, which can be obtained by entering (malicious) SQL statements in a Web form to a database on a Web site that has a security vulnerability, rather than executing the SQL statement as the designer intended.
In the User name input box input ‘ or 1=1#
, password arbitrary input, can login success:
This is because the input user name and our code in the combination of the SELECT statement to become select * from users where username=‘‘ or 1=1#‘ and password=‘‘
, #相当于注释符, will be the following comments out, and 1=1
is always true, so this condition forever, so regardless of whether the password is entered correctly, can be successfully landed.
2.XSS attack:
Cross Site scripting attacks (Scripting), which are not confused with the abbreviations of cascading style sheets (cascading style Sheets, CSS). Therefore, the cross-site scripting attack is abbreviated as XSS. XSS is a computer security vulnerability that often appears in web applications, allowing malicious Web users to embed code into pages that are available to other users. For example, the code includes HTML code and client script. An attacker could bypass access control by using an XSS vulnerability-such as the Origin policy (same). This type of vulnerability is widely known as being used by hackers to write more damaging phishing attacks.
Put a picture in the /var/www/html
directory, in the User name input box input
, the password is arbitrary, you can read the picture:
Back to Catalog
Three. Practice Summary and experienceThe second-to-last experiment!! The experiment was carried out very smoothly. Unlike the previous experiment, "starting from scratch", the experiment is more like the integration and application of the previously learned knowledge. Front-end programming these knowledge, in the school period Liu Nian teacher's curriculum has roughly studied, at that time also independently completed a certain function of a small website. And the knowledge of the database in Lou Teacher's class last year has been known, the difficulty of understanding relatively small. But like "SQL injection" before also only in class to see the teacher demonstration, this hands-on practice, the principle also has a more profound understanding.
Back to Catalog
Attached: References
- Installation and configuration of Apache,php,mysql
- HTML Tutorials
2017-2018-2 20155303 "Network countermeasure technology" Exp8:web Foundation