当前位置:网站首页>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
边栏推荐
- Dans la recherche de l'intelligence humaine ai, Meta a misé sur l'apprentissage auto - supervisé
- What are the main investment products of bond funds and what are they
- Contest3145 - the 37th game of 2021 freshman individual training match_ G: Score
- Site favorites
- [UE4] parse JSON string
- Save Private Ryan - map building + voltage dp+deque+ shortest circuit
- The automatic control system of pump station has powerful functions and diverse application scenarios
- MySQL workbench use
- Unity knapsack system (code to center and exchange items)
- Jenkins continuous integration environment construction V (Jenkins common construction triggers)
猜你喜欢

Crawler practice website image batch download

Libcblas appears when installing opencv import CV2 so. 3:cannot open shared object file:NO such file or directory

The "message withdrawal" of a push message push, one click traceless message withdrawal makes the operation no longer difficult

中電資訊-信貸業務數字化轉型如何從星空到指尖?

Imperial cms7.5 imitation "D9 download station" software application download website source code

Node write API

Dare to climb here, you're not far from prison, reptile reverse actual combat case

Unity controls the selection of the previous and next characters

Redis transaction

Dans la recherche de l'intelligence humaine ai, Meta a misé sur l'apprentissage auto - supervisé
随机推荐
Is online futures account opening safe and reliable? Which domestic futures company is better?
Network communication basic kit -- IPv4 socket structure
Imperial cms7.5 imitation "D9 download station" software application download website source code
Global and Chinese market of contour projectors 2022-2028: Research Report on technology, participants, trends, market size and share
Format character%* s
PMP daily three questions (February 14, 2022)
How to subcontract uniapp and applet, detailed steps (illustration) # yyds dry goods inventory #
C # learning notes: structure of CS documents
Short math guide for latex by Michael downs
PTA tiantisai l1-079 tiantisai's kindness (20 points) detailed explanation
Yyds dry goods inventory override and virtual of classes in C
[untitled] the relationship between the metauniverse and digital collections
Johnson–Lindenstrauss Lemma
查詢效率提昇10倍!3種優化方案,幫你解决MySQL深分頁問題
The "two-way link" of pushing messages helps app quickly realize two-way communication capability
Li Chuang EDA learning notes IX: layers
What are the conditions for the opening of Tiktok live broadcast preview?
Enhanced for loop
Chapter 3.4: starrocks data import - Flink connector and CDC second level data synchronization
7 * 24-hour business without interruption! Practice of applying multiple live landing in rookie villages