SQL注入攻击防范技巧
SQL注入攻击防范技巧
一般的SQL注入攻击都是通过构建一条复杂的sql语句,
通过网页漏洞来执行sql语句,达到攻击数据库的目的。
如通过文章ID来查询某一篇文章的网页,
通常采用的sql语句为:
sql="select top 1 * from articles where articId="&request("id")
那么可以简单地构建一条攻击语句:
传入id变量的值为:1; select getDate(); --
从而构建了一条新的sql语句:
select top 1 * from articles where articId=1;
select getDate(); --
虽然这条语句并不能对数据库产生任何负面影响,
但是其它的攻击语句也是这样通过添加语句分隔符;和注释符号--来组成的。
我们的防范技巧,对所有可以提交传入的变量进行处理:
1、int类型的数据,如上例中的id,则使用以下方法处理:
<%
on error resume next
id = CInt(request("id"))
%>
2、字符串类型的数据,则进行常见的标点符号过滤处理:
<%
str = request("str")
str = replace(str, "´", "") ´将单引号字符过滤掉
str = replace(str, ";", "") ´将分号过滤掉
´...
%>
其他字符不一一枚举,你可以写一个字符过滤的函数,过滤一些在你的网站当中
并不常用的有危险性的符号;也可以采用正则表达式来进行过滤;
相关文档:
Group functions
SELECT [column,] group_function(column) ... from table [WHERE condition] [GROUP BY group_by_expression] [ORDER BY column];
e.g.:
SELECT department_id, job_id, SUM(salary), COUNT(employee_id) from employees GROUP BY department_id, job_id ;
SELECT [column,] group_function(column).. ......
oracle tips
Exist的用法:
select gw.ndocid from
(select ndocid from wf_doc_gw_shouwen union select ndocid from wf_doc_gw_fawen) gw
where
not exists (select null from wf_doc_gw_sn sn where sn.ndocid=gw.ndocid)
2。把GW表和SN表里相同的NDOCID显示出来
select gw.ndocid from
(se ......
1. My test: (create and grant the sysdba to a new user by SQL*Plus)
CREATE USER FJTEST1 IDENTIFIED BY JEANJEANFANG;
GRANT SYSDBA TO FJTEST;
REVOKE SYSDBA from FJTEST;
CONNECT FJTEST1/JEANJEANFANG AS SYSDBA;
2. Using ORAPWD in windows:
C:\» ORAPWD;
(show help information)
3. to see th ......
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER proc [dbo].[pr_xls_to_tb]
@path varchar(200),--EXCEL路径名
@tbName varchar(30),--表名
@stName varchar(30) --excel中要读的SHEET名
as
declare @sql varchar(500),--最后要执行的SQL
@stName_Real varchar(35),--真正的SHEET名
......