20145211 "Cyber Confrontation" EXP8 Web Foundation

Source: Internet
Author: User

20145211 "Cyber Confrontation" EXP8 Web Foundation The specific requirements of this practice are:

(1). Web front-end HTML (1 points)

    • Can install normally, start and stop Apache. Understand the HTML, understand the form, understand the get and post methods, and write an HTML containing the form.

(2). Web Front end Javascipt (1 points)

    • Understand the basic JavaScript functionality and understand the DOM. Write JavaScript to verify the user name, password rules.

(3). Web backend: MySQL Foundation: normal installation, start MySQL, build library, create user, change password, build table (1 points)

(4). Web backend: Writing PHP Web pages, connecting databases, authenticating users (1 points)

(5). Simplest SQL injection, XSS attack test (1 points)

    • Function Description: User can login, login user name password saved in the database, login successfully display welcome page.
Answer questions after the experiment

(1) What is a form

    • HTML forms are used to collect different types of user input.
    • The form contains table cells--different types of input elements, checkboxes, radio buttons, submit buttons, and so on.

    • There are three basic components of the form: Form labels, form fields, form buttons;
      • Form label ( <form> ): Here The bread contains the URL of the CGI program used to process the form data and the method by which the data is submitted to the server;
      • form field: Contains text box, Password box, hidden field, multiline text box, check box, Radio box, drop-down selection box and file upload box;
      • Form buttons: Include the Submit button, reset button, and General button, which can be used to transfer data to CGI scripts on the server, or to cancel input, and to use form buttons to control other processing tasks that define the processing script.

(2) What language does the browser have to parse and run?

    • such as html5,xml,python,php,cgi,jsp.

(3) What dynamic languages are supported by webserver

    • Some support PHP, ASP, NET, Java, Ruby, etc.
Experiment Summary and experience
    • This is the main attempt to use the PHP scripting language, before we learn the Java Web, also wrote the page code, there are front-end, backstage, database, but we were using JSP. Then I thought about it, only with Exclipse enable Apache service, local to open JSP page, and later I think, if we do PHP for JSP, in Kali inside, should also be able to run. But this time is more busy, and there is no time to try ...
    • See SQL and XSS can easily attack, which makes me wonder why before writing code, the teacher always let us continue to test the boundary, it is the imperfect code, it will lead to later run the problem, or be careful.
Practice process Recording Apache
    • /etc/apache2/ports.confthe port in the modification is 5211, and the command is turned on apachectl start Apach, which avoids the problem of port occupancy.
    • The input in the browser localhost:5211 can be opened normally and ready for completion.
A simple form page
    • Write a login page with the form function, open in the browserlocalhost:5211/5211.html,用了css架构,而且这个云是可以左右移动的,此处无法添加视频,只有静态画面。

Javascript
    • Related concepts: JavaScript is a widely used scripting language for client Web development, often used to add dynamic functionality to HTML pages, such as responding to user actions.
    • Document Object model, or DOM, is the standard programming interface recommended by the organization to handle extensible flag languages.
    • Write a rule that validates the user name and password: (for example, the user name and password must consist of letters or numbers, cannot contain illegal characters, and the password length cannot exceed 10)

<script type= "Text/javascript" >
function Check () {
var User=document.getelementbyid ("username"). Value;
var reg_user=/^[a-za-z0-9]{1,10}$/;
var Pwd=document.getelementbyid ("password"). Value;
var reg_pwd=/^[a-za-z0-9]{1,10}$/;
if (reg_user.test (user) ==false) {
Alert ("username wrong");
return false;
}
else if (reg_pwd.test (pwd) ==false) {
Alert ("Password cannot contain illegal characters, length between 1-10");
return false;
}
Else
return true;
}
</script>

PHP test
    • PHP, a nested abbreviated name, is an abbreviation for the English Super Text preprocessing language (Php:hypertext preprocessor). PHP is an HTML embedded language, PHP and Microsoft's ASP quite a bit similar, is a server-side implementation of embedded HTML document scripting language, language style has similar to C language, is now widely used by many web site programmers.

    • A simple PHP test code:

<?php  echo ($_GET["A"]); include($_GET["A"]); echo "this is my first php page!<br>";?>20145211
    • Open localhost:5211/login.php :

Mysql
    • To /etc/init.d/mysql start Open the MySQL service with a command
    • Input mysql -u root -p , and follow the prompts to enter the password, the default password is [email protected], into MySQL:
Create a new table
    • Use the following two commands to create a new table:
CREATESCHEMA' Name of the library table ';CREATETABLE' Name of the library table '.' Users ' (' UserID 'IntNotNullcomment  ",  ' username ' varchar (45) null comment  ",  ' password ' varchar (256) null comment  ",  ' enabled ' 
    • Add content to the table:

use 刚刚建立的库表的表名

insert into users(userid,username,password,enabled) values(1,‘用户id‘,password("用户密码"),"TRUE");

    • Create a table as follows, be sure to note in SQL, do not forget to add ";", otherwise it will not come out, only forcibly quit

Php+mysql Writing Web pages
    • PHP pages linked to the database:

    • Enter login information and log in successfully:

    • In the process of doing the experiment, I found that the name of the data table can not be called users, because it conflicts with the default, so you have to change the name, or the login is unsuccessful

SQL injection
    • The class teacher said is eternal injection, but now generally normal website login has taken into account this problem, injection is invalid
      ‘ or 1=1#
    • Injection success:

    • This is because the query SQL statement after injection is: The SELECT * FROM users where username=‘‘ or 1=1#‘ and password=password(‘‘); same idea of forming a constant set of conditions can also be injected by SQL injection to save the user name password to the database:‘;insert into users values(“52110”,"52110"));#,  

    • 查看数据表,发现新添加了一个用户    

  

    • At this time on login, success

XSS attack
    • XSS attacks: 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. For cross-site scripting attacks, the hacker consensus is that cross-site scripting attacks are a new type of "buffer overflow attack", and JavaScript is the new "ShellCode".

    • Input 20145211</a> to read the picture in the Web directory:

20145211 "Cyber Confrontation" EXP8 Web Foundation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.