6. 2.SQL注入 – 危害字符串填空绕过登录鉴权 select * from user where name=‘’ or ‘1’=‘1’ and pw=‘’ or ‘1’=‘1’执行任意SQL,利用注释,select * from item whre item=‘’;your sql--’或整型字段,select * from item where item_id=0;your sql;篡改系统账号 alter login sa with password=‘123456’用户隐私外泄 select * from user系统细节外泄 select * from sys.tables控制操作系统 xp_cmdshell “net stop iisadmin”损害硬盘宕机 xp_cmdshell “FORMAT C:”埋入XSS漏洞insert into comment(cnt) values(‘<script>…</script>’)
8. 2.SQL注入 – iBatis 1尽量使用#,避免使用$根据彩种ID和彩期名得到一个彩期,inttype=123; String title=“123”。 结果:select * from itemwhere type=123 and title=‘123’ $不过滤直接文本替换:select * from item where type=$type$ and title=‘$title$’ #根据变量类型来替换:select * from item where type=#type# and title=#title#
9. 2.SQL注入 – iBatis 2尽量使用#,避免使用$若不能避免$,则带上元数据标识SQL中需要用户提交的ASC、DESC等SQL关键字select * from user order by gmt_create $ordertype:SQLKEYWORD$SQL中需要用户提交的字段名、表名等元数据select * from user order by $orderByColumn:METADATA$
10. 2.SQL注入 – iBatis 3尽量使用#,避免使用$若不能避免$,则带上元数据标识用迭代替换IN关键字中的$int orderStatus = {0,1,2,3} List orders = sqlMap.queryForList(“OrderDAO.findLlOrder", orderStatus); <select id=“findOrder” parameterClass=“java.lang.Array” resultClass=“java.lang.Object”> select * from order where order_status in <iterate open=“(“ close=“)” conjunction=“,”> #orderStatus[]# </iterate> </select>