The core idea of SQL injection
The hacker constructs a database query code after the normal URL to call the database, and then, based on the returned results, obtains some of the desired data.
SQL Structured Query Language, the vast majority of relational databases (MySQL, Access, Oracle, etc.) are SQL for query, management and common operations.
Environment Construction: Appserv
With Appserv, you can quickly build an environment in your Windows system
SQL INJECTION Statement:
select * from hack;#显示hack表中的所有记录
select * from hack where id=1;Records of #从hack表中查找满足条件id =1
select username,password from hack where id=1;
#从hack表中查找满足条件id =1 records and display only username and password field contents
select * from hack where id=1 and username="admin";
Records for #从hack表中查找满足条件id =1 and username= "admin"
select * from hack where id=1 or username="admin";
#从hack表中查找满足条件id =1 or username= "admin" records
select * from news where id=1 and exists(select * from hack);
#通过exists () function to determine if the hack table exists
select * from news where id =1 and exists(select username from hack);
#通过exists () function to determine if the username field exists in the hack table
select * from hack order by id;#按照hack表中的id列升序排序
select username,password from hack order by 2;
#按照查询结果中的第二列 (password column) ascending sort
The current query shows several fields through order by, and a Union Select Union query can be constructed next
Union Select Union Query
Union union queries can execute two or more queries at once and combine their results to output display
Basic Rules for Union union queries: The number of columns in all queries must be the same
Select from News Union select from hack #字段不匹配, query error (NEWS3 fields, Hack2 fields)
Select from News Union select Username,password from hack; query ok
Select from news union select from hack; field names can be replaced by numbers
Study notes for Guangping Teacher's course
Analysis and utilization of SQL Injection Vulnerability (i)