SQL注入问题
2021/5/16 19:55:32
本文主要是介绍SQL注入问题,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
SQL注入问题
SQL存在漏洞,会被攻击导致数据泄露。SQL会被拼接 or
下方代码可以查询全部数据库内容:
import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class SQL注入 { public static void main(String[] args) { // 正常登录 login("saxon","123456"); login(" 'or' 1=1"," 'or' 1=1"); //查出了所有数据 } public static void login(String username,String password) { Connection conn = null; Statement st = null; ResultSet rs = null; try { conn = jdbcUtils.getConnection(); st = conn.createStatement(); //select * from users where `NAME` = ''or' 1=1' AND `password` = ''or' 1=1' String sql = "select * from users where `NAME` = '" + username +"' AND `password` = '"+ password + "' "; rs = st.executeQuery(sql); while (rs.next()) { System.out.println(rs.getString("NAME")); System.out.println(rs.getString("password")); System.out.println("============="); } } catch (SQLException e) { e.printStackTrace(); } } }
这篇关于SQL注入问题的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-28AI给的和自己写的Python代码,都无法改变输入框的内容,替换也不行
- 2024-09-27Sentinel配置限流资料:新手入门教程
- 2024-09-27Sentinel配置限流资料详解
- 2024-09-27Sentinel限流资料:新手入门教程
- 2024-09-26Sentinel限流资料入门详解
- 2024-09-26Springboot框架资料:初学者入门教程
- 2024-09-26Springboot框架资料详解:新手入门教程
- 2024-09-26Springboot企业级开发资料:新手入门指南
- 2024-09-26SpringBoot企业级开发资料新手指南
- 2024-09-26Springboot微服务资料入门教程