当前位置:网站首页>mysql advanced (twenty-four) method summary of defense against SQL injection
mysql advanced (twenty-four) method summary of defense against SQL injection
2022-08-03 11:40:00 【InfoQ】
一、前言
二、Demonstrate the classicSQL注入

select id,no from user where id=2;
String sql = "select id,no from user where id=" + id;
select id,no from user where id=2 or 1=1;

三、sql注入的原因
String sql = "select id,no from user where id=" + id;
or 1=1
where id=
四、sql注入的防御
String sql = "select id, no from user where id=?";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setInt(1, id);
ps.executeQuery();
PreparedStatement
select id, no from user where id=?
select ,from ,where ,and, or ,order by
String sql = "select id,no from user where id=" + id;
MySQLCodec codec = new MySQLCodec(Mode.STANDARD);
name = ESAPI.encoder().encodeForSQL(codec, name);
String sql = "select id,no from user where name=" + name;
ESAPI.encoder().encodeForSQL(codec, name)
五、总结
ibatis,mybatis,hibernate
ibatis/mybatis
#{name}
${name}
边栏推荐
猜你喜欢
通过组策略安装软件和删除用户配置文件
[Star Project] Little Hat Plane Battle (9)
"Global Digital Economy Conference" landed in N World, Rongyun provides communication cloud service support
【一起学Rust】Rust包管理工具Cargo初步了解
深度学习中数据到底要不要归一化?实测数据来说明!
云原生 Dev0ps 实践
fast planner中拓扑路径搜索
redis基础知识总结——数据类型(字符串,列表,集合,哈希,集合)
基于PHP7.2+MySQL5.7的回收租凭系统
4500字归纳总结,一名软件测试工程师需要掌握的技能大全
随机推荐
shell编程-测试
技术总监需要会些什么?也太难了!
MySQL之json数据操作
后台图库上传功能
Redis发布订阅和数据类型
字符串本地化和消息字典(二)
永寿 永寿农特产品-苹果
Go 语言快速入门指南: 介绍及安装
日常开发写代码原则
【TypeScript】为什么要选择 TypeScript?
What is a smart contract?
FR9811S6 SOT-23-6 23V,2A同步降压DC/DC转换器
4500字归纳总结,一名软件测试工程师需要掌握的技能大全
【MySQL】数据库进阶之索引内容详解(上篇 索引分类与操作)
2022年五面蚂蚁、三面拼多多、字节跳动最终拿offer入职拼多多
Android 技术面试准备(含面试题及答案)
LeetCode刷题笔记:105.从前序与中序遍历序列构造二叉树
LP流动性挖矿DAPP系统开发丨流动性挖矿功能原理及说明
基于Sikuli GUI图像识别框架的PC客户端自动化测试实践
Traceback (most recent call last): File