当前位置:网站首页>SQL injection (1) -- determine whether there are SQL injection vulnerabilities
SQL injection (1) -- determine whether there are SQL injection vulnerabilities
2022-07-04 02:52:00 【qq_ fifty-one million five hundred and fifty thousand seven hun】
What is? SQL Inject
Whether learning back-end development / database / Network security ,SQL Injecting potential safety hazards has been mentioned repeatedly
What exactly is SQL?
The definition of Wikipedia :
(1) What is? SQL?
SQL Is a language used to manipulate databases
(2) For example , Now we need to check the movie “ Changjin Lake ” Box office data :
First imagine how developers write code to get data from a database :
How to think as a hacker ?
SQL Injection range practice - DVWA(1)
【1】 First of all, will security Adjustable for low:
( Remember to click “submit”)
【2】 Then challenge the module SQL Injection
First try normal
【3】 Try to check the source code :
I pasted the source code below :
SQL Injection Source
vulnerabilities/sqli/source/low.php
<?php
if( isset( $_REQUEST[ 'Submit' ] ) ) {
// Get input
$id = $_REQUEST[ 'id' ];
switch ($_DVWA['SQLI_DB']) {
case MYSQL:
// Check database
$query = "SELECT first_name, last_name FROM users WHERE user_id = '$id';";
$result = mysqli_query($GLOBALS["___mysqli_ston"], $query ) or die( '<pre>' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)) . '</pre>' );
// Get results
while( $row = mysqli_fetch_assoc( $result ) ) {
// Get values
$first = $row["first_name"];
$last = $row["last_name"];
// Feedback for end user
echo "<pre>ID: {
$id}<br />First name: {
$first}<br />Surname: {
$last}</pre>";
}
mysqli_close($GLOBALS["___mysqli_ston"]);
break;
case SQLITE:
global $sqlite_db_connection;
#$sqlite_db_connection = new SQLite3($_DVWA['SQLITE_DB']);
#$sqlite_db_connection->enableExceptions(true);
$query = "SELECT first_name, last_name FROM users WHERE user_id = '$id';";
#print $query;
try {
$results = $sqlite_db_connection->query($query);
} catch (Exception $e) {
echo 'Caught exception: ' . $e->getMessage();
exit();
}
if ($results) {
while ($row = $results->fetchArray()) {
// Get values
$first = $row["first_name"];
$last = $row["last_name"];
// Feedback for end user
echo "<pre>ID: {
$id}<br />First name: {
$first}<br />Surname: {
$last}</pre>";
}
} else {
echo "Error in fetch ".$sqlite_db->lastErrorMsg();
}
break;
}
}
?>
It's a lot of stuff , But just pay attention SQL sentence select
$query = "SELECT first_name, last_name FROM users WHERE user_id = '$id';";
Focus on :
SELECT first_name, last_name FROM users WHERE user_id = ‘$id’;
$id That's what the user entered Content .
Judge whether there is SQL Inject holes :
The data entered by the user is 1’ and 1=1 #
Now SQL The statement has changed , After the original query Will judge on the basis 1 = 1( This is obviously true ), If the judgment is correct, there will be output
# The function is to comment ( remove ) follow-up SQL sentence , Remove those that may cause impact later SQL sentence
The data entered by the user is 1’ and 1=2 #
Now SQL The statement will judge after the original query 1=2( This is obviously wrong ), If the judgment is correct, there will be output
There is no echo at this time , It shows that the judgment is wrong , At this time, it is certain that SQL Inject holes
summary :
Two attempts 1=1 Normal output ,1=2 Error output , prove SQL The statement takes effect , There is SQL Inject holes
边栏推荐
- Mysql-15 aggregate function
- 7 * 24-hour business without interruption! Practice of applying multiple live landing in rookie villages
- The boss said: whoever wants to use double to define the amount of goods, just pack up and go
- Contest3145 - the 37th game of 2021 freshman individual training match_ F: Smallest ball
- [Yugong series] February 2022 attack and defense world advanced question misc-83 (QR easy)
- Node solves cross domain problems
- 3D game modeling is in full swing. Are you still confused about the future?
- Dans la recherche de l'intelligence humaine ai, Meta a misé sur l'apprentissage auto - supervisé
- Enhanced for loop
- Global and Chinese market of cell scrapers 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
Remember another interview trip to Ali, which ends on three sides
What is cloud primordial?
7 * 24-hour business without interruption! Practice of applying multiple live landing in rookie villages
WordPress collection WordPress hang up collection plug-in
Redis transaction
Solve the problem that the tabbar navigation at the bottom of vantui does not correspond to the page (window.loading.hash)
The 37 year old programmer was laid off, and he didn't find a job for 120 days. He had no choice but to go to a small company. As a result, he was confused
MySQL advanced SQL statement (1)
Bugku Zhi, you have to stop him
Record a problem that soft deletion fails due to warehouse level error
随机推荐
Learn these super practical Google browser skills, girls casually flirt
[software implementation series] software implementation interview questions with SQL joint query diagram
Network communication basic kit -- IPv4 socket structure
16. System and process information
What are the conditions for the opening of Tiktok live broadcast preview?
Design and implementation of redis 7.0 multi part AOF
Unity knapsack system (code to center and exchange items)
Summarize the past to motivate yourself to move on
Global and Chinese market for travel wheelchairs 2022-2028: Research Report on technology, participants, trends, market size and share
ZABBIX API pulls the values of all hosts of a monitoring item and saves them in Excel
How to subcontract uniapp and applet, detailed steps (illustration) # yyds dry goods inventory #
STM32 key content
Take you to master the formatter of visual studio code
[Yugong series] February 2022 attack and defense world advanced question misc-84 (MySQL)
Global and Chinese markets for electroencephalogram (EEG) devices 2022-2028: Research Report on technology, participants, trends, market size and share
Contest3145 - the 37th game of 2021 freshman individual training match_ F: Smallest ball
Unspeakable Prometheus monitoring practice
Contest3145 - the 37th game of 2021 freshman individual training match_ 1: Origami
Site favorites
機器學習基礎:用 Lasso 做特征選擇