当前位置:网站首页>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
边栏推荐
- PyQy5学习(四):QAbstractButton+QRadioButton+QCheckBox
- Dva中在effects中获取state的值
- 解决报错:ImportError: IProgress not found. Please update jupyter and ipywidgets
- Development environment EAS login license modification
- RedHat realizes keyword search in specific text types under the directory and keyword search under VIM mode
- Pytorch学习记录(十一):数据增强、torchvision.transforms各函数讲解
- Paper on Image Restoration - [red net, nips16] image restoration using very deep revolutionary encoder decoder networks wi
- 数据处理之Numpy常用函数表格整理
- The attendance client date of K / 3 wise system can only be selected to 2019
- Denoising paper - [noise2void, cvpr19] noise2void learning denoising from single noise images
猜你喜欢

Dva中在effects中获取state的值

In depth source code analysis servlet first program

String notes

类的加载与ClassLoader的理解

JVM series (3) -- memory allocation and recycling strategy

自动控制(韩敏版)
![Unsupervised denoising - [tmi2022] ISCL: dependent self cooperative learning for unpaired image denoising](/img/cd/10793445e6867eeee613b6ba4b85cf.png)
Unsupervised denoising - [tmi2022] ISCL: dependent self cooperative learning for unpaired image denoising
![Reading of denoising paper - [ridnet, iccv19] real image denoising with feature attention](/img/4e/1a51636853d11544e6f5c37a588730.png)
Reading of denoising paper - [ridnet, iccv19] real image denoising with feature attention

创建二叉树

Pytorch learning record (XII): learning rate attenuation + regularization
随机推荐
Fundamentals of digital image processing (Gonzalez) I
How to use comparative learning to do unsupervised - [cvpr22] training & [eccv20] image translation
常用编程记录——parser = argparse.ArgumentParser()
编程记录——图片旋转函数scipy.ndimage.rotate()的简单使用和效果观察
Ptorch learning record (XIII): recurrent neural network
Anaconda
CONDA virtual environment management (create, delete, clone, rename, export and import)
Pytorch introduction notes - use a simple example to observe the output size of each layer of forward propagation
PreparedStatement防止SQL注入
Pyemd installation and simple use
去噪论文阅读——[RIDNet, ICCV19]Real Image Denoising with Feature Attention
Pytorch学习记录(三):神经网络的结构+使用Sequential、Module定义模型
数字图像处理基础(冈萨雷斯)二:灰度变换与空间滤波
Reading of denoising papers - [cvpr2022] blind2blind: self supervised image denoising with visible blind spots
图解numpy数组矩阵
RedHat6之smb服务访问速度慢解决办法记录
Solve the error: importerror: iprogress not found Please update jupyter and ipywidgets
Illustrate the significance of hashcode
Treatment of tensorflow sequelae - simple example record torch utils. data. dataset. Picture dimension problem when rewriting dataset
线性代数第三章-矩阵的初等变换与线性方程组