当前位置:网站首页>SQL injection
SQL injection
2022-04-23 06:00:00 【hanyc..】
1、 Normal landing :
package com.hyc.study02;
import com.hyc.study02.utils.JDBCUtils;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class PourIntoSql {
public static void main(String[] args) {
login("zxzb", "123456");
}
public static void login(String username, String psw) {
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
try {
connection = JDBCUtils.getConnection();
statement = connection.createStatement();
String sql = "SELECT * FROM `users` WHERE `NAME`='" + username + "'AND `PASSWORD`='" + psw + "'";
resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
System.out.println(resultSet.getInt("id"));
System.out.println(resultSet.getString("NAME"));
System.out.println(resultSet.getString("PASSWORD"));
System.out.println(resultSet.getString("email"));
System.out.println(resultSet.getDate("birthday"));
System.out.println("===========================================");
}
} catch (SQLException throwables) {
throwables.printStackTrace();
} finally {
JDBCUtils.release(connection, statement, resultSet);
}
}
}
result :

2、SQL Information leakage caused by injection :
package com.hyc.study02;
import com.hyc.study02.utils.JDBCUtils;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class PourIntoSql {
public static void main(String[] args) {
login(" ' or '1=1", "' or '1=1");
}
public static void login(String username, String psw) {
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
try {
connection = JDBCUtils.getConnection();
statement = connection.createStatement();
String sql = "SELECT * FROM `users` WHERE `NAME`='" + username + "'AND `PASSWORD`='" + psw + "'";
resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
System.out.println(resultSet.getInt("id"));
System.out.println(resultSet.getString("NAME"));
System.out.println(resultSet.getString("PASSWORD"));
System.out.println(resultSet.getString("email"));
System.out.println(resultSet.getDate("birthday"));
System.out.println("===========================================");
}
} catch (SQLException throwables) {
throwables.printStackTrace();
} finally {
JDBCUtils.release(connection, statement, resultSet);
}
}
}
result :

SQL The reason for injection is that when the background server receives relevant parameters, it does not directly bring them into the database for query without filtering .
adopt 1、2 From these two comparisons, we can see ,2 After string splicing in , Without filtering in the background, it is directly brought into the database for query, resulting in sql Inject .
版权声明
本文为[hanyc..]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230541159596.html
边栏推荐
- String notes
- Pytorch learning record (XII): learning rate attenuation + regularization
- Pytorch学习记录(五):反向传播+基于梯度的优化器(SGD,Adagrad,RMSporp,Adam)
- Implementation of displaying database pictures to browser tables based on thymeleaf
- 深入源码分析Servlet第一个程序
- EditorConfig
- PyQy5学习(二):QMainWindow+QWidget+QLabel
- Comparative study paper - [Moco, cvpr2020] momentum contract for unsupervised visual representation learning
- SQL注入
- Illustrate the significance of hashcode
猜你喜欢

Pytorch學習記錄(十三):循環神經網絡((Recurrent Neural Network)

Font shape `OMX/cmex/m/n‘ in size <10.53937> not available (Font) size <10.95> substituted.

线性代数第二章-矩阵及其运算

In depth understanding of the relationship between dncblevel and noise denoising in the paper
![去噪论文阅读——[RIDNet, ICCV19]Real Image Denoising with Feature Attention](/img/4e/1a51636853d11544e6f5c37a588730.png)
去噪论文阅读——[RIDNet, ICCV19]Real Image Denoising with Feature Attention

PyQy5学习(三):QLineEdit+QTextEdit

Pytorch学习记录(十一):数据增强、torchvision.transforms各函数讲解

Manually delete registered services on Eureka

Opensips (1) -- detailed process of installing opensips

Paper on LDCT image reconstruction: edge enhancement based transformer for medical image denoising
随机推荐
How to use comparative learning to do unsupervised - [cvpr22] training & [eccv20] image translation
protected( 被 protected 修饰的成员对于本包和其子类可见)
线代第四章-向量组的线性相关
去噪论文阅读——[RIDNet, ICCV19]Real Image Denoising with Feature Attention
Pytorch学习记录(五):反向传播+基于梯度的优化器(SGD,Adagrad,RMSporp,Adam)
Multithreading and high concurrency (1) -- basic knowledge of threads (implementation, common methods, state)
sklearn之 Gaussian Processes
SQL基础:初识数据库与SQL-安装与基本介绍等—阿里云天池
Understand the current commonly used encryption technology system (symmetric, asymmetric, information abstract, digital signature, digital certificate, public key system)
The official website of UMI yarn create @ umijs / UMI app reports an error: the syntax of file name, directory name or volume label is incorrect
深入理解去噪论文——FFDNet和CBDNet中noise level与噪声方差之间的关系探索
深入源码分析Servlet第一个程序
编程记录——图片旋转函数scipy.ndimage.rotate()的简单使用和效果观察
Graphic numpy array matrix
Gaussian processes of sklearn
SQL注入
RedHat6之smb服务访问速度慢解决办法记录
Solve the error: importerror: iprogress not found Please update jupyter and ipywidgets
Write your own redistemplate
Contrôle automatique (version Han min)