当前位置:网站首页>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
边栏推荐
- (column 23) typical C language problem: find the minimum common multiple and maximum common divisor of two numbers. (two solutions)
- Li Chuang EDA learning notes IX: layers
- Hospital network planning and design document based on GLBP protocol + application form + task statement + opening report + interim examination + literature review + PPT + weekly progress + network to
- MySQL advanced SQL statement (1)
- Question C: Huffman tree
- The automatic control system of pump station has powerful functions and diverse application scenarios
- Global and Chinese market of cell scrapers 2022-2028: Research Report on technology, participants, trends, market size and share
- [Valentine's Day confession code] - Valentine's Day is approaching, and more than 10 romantic love effects are given to the one you love
- CSCI 2134
- Keep an IT training diary 054- opening and closing
猜你喜欢
C language black Technology: Archimedes spiral! Novel, interesting, advanced~
Pagoda SSL can't be accessed? 443 port occupied? resolvent
Node write API
MySQL workbench use
I stepped on a foundation pit today
Node solves cross domain problems
Practical multifunctional toolbox wechat applet source code / support traffic master
Final consistency of MESI cache in CPU -- why does CPU need cache
Measurement fitting based on Halcon learning [4] measure_ arc. Hdev routine
This function has none of DETERMINISTIC, NO SQL..... (you *might* want to use the less safe log_bin_t
随机推荐
Tsinghua University product: penalty gradient norm improves generalization of deep learning model
Keep an IT training diary 055- moral bitch
This function has none of DETERMINISTIC, NO SQL..... (you *might* want to use the less safe log_bin_t
Save Private Ryan - map building + voltage dp+deque+ shortest circuit
Network communication basic kit -- IPv4 socket structure
Optimization theory: definition of convex function + generalized convex function
Yyds dry goods inventory hand-in-hand teach you the development of Tiktok series video batch Downloader
A brief talk on professional modeler: the prospect and professional development of 3D game modeling industry in China
Global and Chinese markets for electroencephalogram (EEG) devices 2022-2028: Research Report on technology, participants, trends, market size and share
VRRP+BFD
60 year old people buy medical insurance and recommend a better product
Bugku Zhi, you have to stop him
Mysql to PostgreSQL real-time data synchronization practice sharing
Contest3145 - the 37th game of 2021 freshman individual training match_ F: Smallest ball
The automatic control system of pump station has powerful functions and diverse application scenarios
1day vulnerability pushback skills practice (3)
Unity knapsack system (code to center and exchange items)
ZABBIX API batch delete a template of the host
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
The first spring of the new year | a full set of property management application templates are presented, and Bi construction is "out of the box"