当前位置:编程学习 > 网站相关 >>

DDOS 七层 差一些的完美解决方案

在此本人,希望大家多提意见,也帮我完善DDOS, 七层的防御,当然防御方法要与公司的业务特点要结合,才能符合自己公司的防御的方法

最近,我在做一个ddos行业检测的系统(七层 http),我负责后端。
\
请各位朋友位,看一下,我还应该加一些哪些功能,我公司的网站比较多,全站:与分站的意思,就是 是否区分站点
\

我在这里,无法判断,大的出口IP的DDOS,因为混合了正常攻击,1,不敢封此IP,2不好判断出来

实现方法
1、采集数据,通过在web服务器上部署相应的模块,实现数据采集
2、发送相应的数据,到MSMQ上
3、按用户访问网站的时间,一分钟为单位时间,写入文件
4、另一个模块,通过读取文件1分钟大约70M左右的数据,写入hash_map,然后做大量的运算。

 
5、写入图上的功能的相关数据到数据中判定DDOS是的方法
void CUserHashMap::DDOS()
{
    User_Hash::iterator hash_site=HashSite.begin();
    for (;hash_site!=HashSite.end();hash_site++)
    {
        hash_map<string,SessionAndUrl>::iterator hash_ip_iter=hash_site->second.HashIP.begin();
        for (;hash_ip_iter!=hash_site->second.HashIP.end();hash_ip_iter++)
        {
            bitvec.reset();
            if (hash_ip_iter->second.sessionamount0)//第一种抓虫或黑客扫描工具
            {
                //准备写入数据库中,数据中结构为
                bitvec[0]=1;
            }
            if (ceil(hash_ip_iter->second.sessionamount1*1.0*100/hash_ip_iter->second.ipcount)>=95&&hash_ip_iter->second.ipcount>=60)
            {
                //第二种情况,ddos工具,发送原始socket,session值各不相同,全为1
                bitvec[1]=1;
            }
            if (hash_ip_iter->second.sessiontop1>=hash_ip_iter->second.ipcount&&hash_ip_iter->second.ipcount>=60)
            {
                //第三种情况session全部都相同的情况 www.zzzyk.com
                bitvec[2]=1;
            }
            if(ceil(hash_ip_iter->second.urltop5*1.0*100/hash_ip_iter->second.ipcount)>=100&&hash_ip_iter->second.ipcount>=60)
            {
                //第四种情况,ddos,访问的url top 5以内=100%
                bitvec[3]=1;
            }
            if(ceil(hash_ip_iter->second.referrtop1*1.0*100/hash_ip_iter->second.ipcount)==100&&hash_ip_iter->second.ipcount>=60)
            {
                //第五种情况,refer,全部都相同,前五,全部相同
                bitvec[4]=1;
            }
            if(bitvec.to_string()!="00000000")
            {
                //[VanclSiteName],[IPaddress],[IPCount],[AttackType],[Time],[TopSessionTen],[TopUrlTen],,[ReferTen],[Reason]
                string sql="insert into [test].[dbo].[Exception] values ('0%','1%',2%,'3%','4%','5%','6%','7%');";
                odbc.replace(sql,"0%",hash_site->first.c_str());//站点名称
                odbc.replace(sql,"1%",hash_ip_iter->first.c_str());//IP地址
                odbc.replace(sql,"2%",hash_ip_iter->second.ipcount);//IP访问次数
                odbc.replace(sql,"3%",bitvec.to_string().c_str());//攻击类型
                odbc.replace(sql,"4%",filetime.c_str());//时间
                odbc.replace(sql,"5%",hash_ip_iter->second.sessiontop10.c_str());//session top 10
                odbc.replace(sql,"6%",hash_ip_iter->second.urltop10.c_str());//url top 10
                odbc.replace(sql,"7%",hash_ip_iter->second.reffer10.c_str());//refer top 10
                odbc.ExecuteNonQuery(sql.c_str());
            }
           
 
        }
    }
}
 
//实现所有的功能后(70M大小文件,近30w条数据)
//以上是测试数据代码
 
int _tmain(int argc, _TCHAR* argv[])
{
CUserHashMap hash;
DWORD num1=GetTickCount();
CUserReadFile file("2012-07-04_14.58.log");
char *buff=NULL;
buff=file.ReadFile();
//////////////////分割字符串开始//////////////////////
char delims[] = "\n";
char *result = NULL;
result = strtok( buff, delims );
//取第一行的时候。
string m_time=result;
hash.SetFileTime(m_time.substr(0,m_time.find_first_of("\t")));
while( result != NULL ) {
hash.SplitBlack(result);//插入数据
result = strtok( NULL, delims );
}  
//////////////////分割字
补充:综合编程 , 安全编程 ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,