当前位置:网站首页>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
边栏推荐
- Solve the error: importerror: iprogress not found Please update jupyter and ipywidgets
- Opensips (1) -- detailed process of installing opensips
- Pytorch notes - observe dataloader & build lenet with torch to process cifar-10 complete code
- Illustrate the significance of hashcode
- 深入理解去噪论文——FFDNet和CBDNet中noise level与噪声方差之间的关系探索
- Multithreading and high concurrency (3) -- synchronized principle
- String notes
- 域内用户访问域外samba服务器用户名密码错误
- Paper on LDCT image reconstruction: edge enhancement based transformer for medical image denoising
- 实操—Nacos安装与配置
猜你喜欢
PyQy5学习(四):QAbstractButton+QRadioButton+QCheckBox
Linear algebra Chapter 1 - determinant
Pytorch notes - complete code for linear regression & manual or automatic calculation of gradient code comparison
delete和truncate
Implementation of displaying database pictures to browser tables based on thymeleaf
JVM series (3) -- memory allocation and recycling strategy
Opensips (1) -- detailed process of installing opensips
Pytorch学习记录(三):神经网络的结构+使用Sequential、Module定义模型
实操—Nacos安装与配置
Pytorch学习记录(十二):学习率衰减+正则化
随机推荐
图解HashCode存在的意义
Font shape `OMX/cmex/m/n‘ in size <10.53937> not available (Font) size <10.95> substituted.
Linear algebra Chapter 1 - determinant
rsync实现文件服务器备份
JSP语法及JSTL标签
编程记录——图片旋转函数scipy.ndimage.rotate()的简单使用和效果观察
去噪论文——[Noise2Void,CVPR19]Noise2Void-Learning Denoising from Single Noisy Images
线性规划问题中可行解,基本解和基本可行解有什么区别?
PyTorch笔记——通过搭建ResNet熟悉网络搭建方式(完整代码)
C3P0数据库连接池使用
Get the value of state in effects in DVA
K/3 WISE系统考勤客户端日期只能选到2019年问题
Pytorch学习记录(三):神经网络的结构+使用Sequential、Module定义模型
Programming record - picture rotation function SciPy ndimage. Simple use and effect observation of rotate()
Linear algebra Chapter 2 - matrices and their operations
自定义异常类
Common programming records - parser = argparse ArgumentParser()
深度学习基础——简单了解meta learning(来自李宏毅课程笔记)
Conda 虚拟环境管理(创建、删除、克隆、重命名、导出和导入)
Pytoch -- data loading and processing