特殊字符的过滤方法,防sql防注入代码的过滤方法
特殊字符的过滤方法
function strFilter($str){
//特殊字符的过滤方法
$str = str_replace('`', '', $str);
$str = str_replace('·', '', $str);
$str = str_replace('~', '', $str);
$str = str_replace('!', '', $str);
$str = str_replace('!', '', $str);
$str = str_replace('@', '', $str);
$str = str_replace('#', '', $str);
$str = str_replace('$', '', $str);
$str = str_replace('¥', '', $str);
$str = str_replace('%', '', $str);
$str = str_replace('^', '', $str);
$str = str_replace('……', '', $str);
$str = str_replace('&', '', $str);
$str = str_replace('*', '', $str);
$str = str_replace('(', '', $str);
$str = str_replace(')', '', $str);
$str = str_replace('(', '', $str);
$str = str_replace(')', '', $str);
$str = str_replace('-', '', $str);
$str = str_replace('_', '', $str);
$str = str_replace('——', '', $str);
$str = str_replace('+', '', $str);
$str = str_replace('=', '', $str);
$str = str_replace('|', '', $str);
$str = str_replace('\\', '', $str);
$str = str_replace('[', '', $str);
$str = str_replace(']', '', $str);
$str = str_replace('【', '', $str);
$str = str_replace('】', '', $str);
$str = str_replace('{', '', $str);
$str = str_replace('}', '', $str);
$str = str_replace(';', '', $str);
$str = str_replace(';', '', $str);
$str = str_replace(':', '', $str);
$str = str_replace(':', '', $str);
$str = str_replace('\'', '', $str);
$str = str_replace('"', '', $str);
$str = str_replace('“', '', $str);
$str = str_replace('”', '', $str);
$str = str_replace(',', '', $str);
$str = str_replace(',', '', $str);
$str = str_replace('<', '', $str);
$str = str_replace('>', '', $str);
$str = str_replace('《', '', $str);
$str = str_replace('》', '', $str);
$str = str_replace('.', '', $str);
$str = str_replace('。', '', $str);
$str = str_replace('/', '', $str);
$str = str_replace('、', '', $str);
$str = str_replace('?', '', $str);
$str = str_replace('?', '', $str);
//防sql防注入代码的过滤方法
$str = str_replace('and','',$str);
$str = str_replace('execute','',$str);
$str = str_replace('update','',$str);
$str = str_replace('count','',$str);
$str = str_replace('chr','',$str);
$str = str_replace('mid','',$str);
$str = str_replace('master','',$str);
$str = str_replace('truncate','',$str);
$str = str_replace('char','',$str);
$str = str_replace('declare','',$str);
$str = str_replace('select','',$str);
$str = str_replace('create','',$str);
$str = str_replace('delete','',$str);
$str = str_replace('insert','',$str);
$str = str_replace('or','',$str);
return trim($str);
}
特殊字符的过滤方法,防sql防注入代码的过滤方法的更多相关文章
- asp.net防SQL/JS注入攻击:过滤标记
/// <summary>/// 过滤标记/// </summary>/// <param name="NoHTML">包括HTML,脚本,数据 ...
- C#防SQL注入代码的实现方法
对于网站的安全性,是每个网站开发者和运营者最关心的问题.网站一旦出现漏洞,那势必将造成很大的损失.为了提高网站的安全性,首先网站要防注入,最重要的是服务器的安全设施要做到位. 下面说下网站防注入的几点 ...
- php防sql注入过滤代码
防止sql注入的函数,过滤掉那些非法的字符,提高sql安全性,同时也可以过滤XSS的攻击. function filter($str) { if (empty($str)) return false; ...
- 【转载】C#防SQL注入过滤危险字符信息
不过是java开发还是C#开发或者PHP的开发中,都需要关注SQL注入攻击的安全性问题,为了保证客户端提交过来的数据不会产生SQL注入的风险,我们需要对接收的数据进行危险字符过滤来防范SQL注入攻击的 ...
- .Net防sql注入的方法总结
#防sql注入的常用方法: 1.服务端对前端传过来的参数值进行类型验证: 2.服务端执行sql,使用参数化传值,而不要使用sql字符串拼接: 3.服务端对前端传过来的数据进行sql关键词过来与检测: ...
- mysql之数据库连接的方法封装及防sql注入
一.定义数据库和表 create database animal; CREATE TABLE `pet` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name ...
- .net 过滤 sql防注入类,省地以后每次都要重新弄!
/// <summary> /// 过滤不安全的字符串 /// </summary> /// <param name="Str"&g ...
- 【荐】PDO防 SQL注入攻击 原理分析 以及 使用PDO的注意事项
我们都知道,只要合理正确使用PDO,可以基本上防止SQL注入的产生,本文主要回答以下几个问题: 为什么要使用PDO而不是mysql_connect? 为何PDO能防注入? 使用PDO防注入的时候应该特 ...
- SQL防注入程序 v1.0
/// ***************C#版SQL防注入程序 v1.0************ /// *使用方法: /// 一.整站防注入(推荐) /// 在Global.asax.cs中查找App ...
随机推荐
- B. Grow The Tree Codeforces Round #594 (Div. 2)
Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on t ...
- C学习笔记-数组
数组的概念 数组是一组具有相同数据类型的变量集合,这里要注意两点,数组只能存储相同的数据类型和数组的内存是连续的,这位数组和指针的联系奠定了基础. 一维数组 定义及初始化 一维数组指的是只有一个下标的 ...
- win10下查看进程,杀死进程
参考链接:https://blog.csdn.net/qq_36819098/article/details/80262482
- lua调用shell 脚本
Lua中,os.execute可以执行dos命令,但是返回的是系统状态码,默认输出.io.popen()也可以执行dos命令,但是返回一个文件.eg: 复制代码 代码如下: local t = io. ...
- Linux文件权限基础知识
一.文件权限概述 Linux中每个文件或目录都有一组一组9个基础权限位,每三位字符被分为一组,他们分别是属主权限位(占三个字符).用户组权限位(占三个字符).其他用户权限位(占三个字符).比如rwxr ...
- [bzoj2597][Wc2007]剪刀石头布_费用流
[Wc2007]剪刀石头布 题目大意:https://www.lydsy.com/JudgeOnline/problem.php?id=2597 题解: 发现直接求三元环不好求,我们考虑任选三个点不是 ...
- [CF544E]Remembering Strings_状压dp
E. Remembering Strings 题目大意: You have multiset of n strings of the same length, consisting of lowerc ...
- 2019-07-30 C#基础知识学习
继承和多态 接口与抽象类的区别:1.在接口中仅能定义成员,但是不能有具体的实现:抽象类除了抽象成员以外,其他成员有具体的实现.2.在接口中不能声明字段,并且不能声明任何私有成员,成员不能包含任何修饰符 ...
- python 下安装pymysql应用
前言 pymsql是Python中操作MySQL的模块,其使用方法和MySQLdb几乎相同.但目前pymysql支持python3.x而后者不支持3.x版本. 本文测试python版本:2.7.11. ...
- GCD and LCM HDU - 4497(质因数分解)
Problem Description Given two positive integers G and L, could you tell me how many solutions of (x, ...