惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
H
Help Net Security
F
Fortinet All Blogs
MyScale Blog
MyScale Blog
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
量子位
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
The Last Watchdog
The Last Watchdog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
AI
AI
WordPress大学
WordPress大学
Security Archives - TechRepublic
Security Archives - TechRepublic
Google Online Security Blog
Google Online Security Blog
U
Unit 42
V2EX - 技术
V2EX - 技术
MongoDB | Blog
MongoDB | Blog
Schneier on Security
Schneier on Security
博客园 - Franky
H
Heimdal Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Cloudbric
Cloudbric
B
Blog RSS Feed
N
News | PayPal Newsroom
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园_首页
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
雷峰网
雷峰网

博客园 - SCPlatform

windown 使用python 自动切换网络 CPU封装技术介绍 openssl unicode编译以及VC++2015环境下的问题 重新开启此博 MIFARE Classic S50技术详解 Mifare简介 如何获取JavaCard栈信息 JavaCard应用开发环境 如何获取JavaCard剩余空间 如何统合分析一张JavaCard BER-TLV数据结构 智能卡中的数据结构 加密解密算法 SCPlatform博客文章总目录 C#实现简体中文和繁体中文的转换 关于脚本注入的问题 开发Blog需注意的Blog基本特征和功能要素 java 学习步骤 CodeSmith 实体生成模板(C#版)
QueryString 整站过滤
SCPlatform · 2008-05-08 · via 博客园 - SCPlatform

51期间,网站中了木马,结果发现是QueryString没有过滤的问题,在网上查了一下找了一个比较好的办法。转一下。
                                              
                                            QueryString 整站过滤

对于QueryString的传值是每个程序员都要用到的。但是如何过滤QueryString的方法万千。下面我整理一个方法
大家继续优化讨论

第一步 web.config 加入键值

例如:
<add key="SafeRequest" value="id-int32,nid-int32,xid-int32,keyword-char" /> 

第二步 Global.asax 加入如下

void Application_BeginRequest(object source, EventArgs e)
    {
        String[] SafeRequest = System.Web.Configuration.WebConfigurationManager.AppSettings["SafeRequest"].ToString().Split(',');
        for (int i = 0; i < SafeRequest.Length; i++)
        {
            String RequestName = SafeRequest[i].Split('-')[0];
            String RequestType = SafeRequest[i].Split('-')[1];
            isValidRequest(RequestName, RequestType);
        }
       
    }
    public void isValidRequest(string parameterName, string parameterType)
    {
        string parameterValue = Request.QueryString[parameterName];
        if(parameterValue == null) return;

        if(parameterType.Equals("int32"))
        {
//future.mystring.IsNumeric是我自己做的一个类判断是不是数字。大家根据自己需要可以自行写一段(Bool)
            if(!future.mystring.IsNumeric(parameterValue)) Response.Redirect("index.aspx");
        }
        if (parameterType.Equals("char"))
        {
////future.mystring.IsNumeric是我自己做的一个类判断是不是字符,是否含有敏感字符。大家根据自己需要可以自行写一段(Bool)
            if (!future.mystring.MatchSqlString(parameterValue)) Response.Redirect("index.aspx");
        }

    }