snort

PortScan_preprocessor

 

向标准记录设备中记录从一个源IP地址来的端口扫描的开始和结束。如果指定了一个记录文件,在记录扫描类型的同时也记录目的IP地址和端口。端口扫描定义为在时间T(秒)之内向超过P个端口进行TCP连接尝试,或者在时间T(秒)之内向超过P个端口发送UDP数据包。端口扫描可以是对任一IP 地址的多个端口,也可以是对多个IP地址的同一端口进行。现在这个版本可以处理一对一和一对多方式的端口扫描,分布式的端口扫描(多对一或多对多)。端口扫描也包括单一的秘密扫描(stealth scan)数据包,比如NULLFINSYNFINXMAS等。如果包括秘密扫描的话,端口扫描模块会对每一个扫描数据包告警。为避免这种情况,可以在Snort标准发行版中的scan-lib文件里把有关秘密扫描数据包的小节注释掉,这样对每次扫描就只记录一次。如果使用外部记录特性,可以在记录文件中看到(端口扫描的)技术和类型。

 

支持的端口扫描大类:

- Portscan

       端口扫描是基本的一个主机对于另外一个主机的多个端口的扫描行为。如果有少数主机试图连接大量主机的大量端口或者存在大量的异常连接,我们就认为它在进行端口扫描。

- Decoy Portscan

       在大量主机试图连接同一主机的不同端口的时候我们会认为他是分布式的端口扫描,

- Distributed Portscan

       是分布式端口扫描的一种,与其不同是扫描主机试图多次连接被扫描的主机的特定端口。我们可以得到其扫描的轨迹。

- Portsweep

       是某一主机试图连接一群主机的一部分端口。如果某一主机连接了很多主机的同一端口,我们认为它在进行Portsweep

 

 

参数的详细设置:

 

typedef struct s_PS_ALERT_CONF

{

      short connection_count;        //连接通过的数据包数

    short priority_count;             //优先级

    short u_ip_count;                 // ip个数

    short u_port_count;                     // 端口个数

} PS_ALERT_CONF;

 

 

统计时间

PostSCAN.c   line:654

LOW          60s

MID             90s

HIGHT           600s

 

 

static PS_ALERT_CONF g_tcp_low_ps =       {0,5,25,5};

static PS_ALERT_CONF g_tcp_low_decoy_ps = {0,15,50,30};

static PS_ALERT_CONF g_tcp_low_sweep =    {0,5,5,15};

static PS_ALERT_CONF g_tcp_low_dist_ps =  {0,15,50,15};

 

static PS_ALERT_CONF g_tcp_med_ps =       {200,10,60,15};

static PS_ALERT_CONF g_tcp_med_decoy_ps = {200,30,120,60};

static PS_ALERT_CONF g_tcp_med_sweep =    {30,7,7,10};

static PS_ALERT_CONF g_tcp_med_dist_ps =  {200,30,120,30};

 

static PS_ALERT_CONF g_tcp_hi_ps =        {200,5,100,10};

static PS_ALERT_CONF g_tcp_hi_decoy_ps =  {200,7,200,60};

static PS_ALERT_CONF g_tcp_hi_sweep =     {30,3,3,10};

static PS_ALERT_CONF g_tcp_hi_dist_ps =   {200,5,200,10};

 

/*

**  UDP alert configurations

*/

static PS_ALERT_CONF g_udp_low_ps =       {0,5,25,5};

static PS_ALERT_CONF g_udp_low_decoy_ps = {0,15,50,30};

static PS_ALERT_CONF g_udp_low_sweep =    {0,5,5,15};

static PS_ALERT_CONF g_udp_low_dist_ps =  {0,15,50,15};

 

static PS_ALERT_CONF g_udp_med_ps =       {200,10,60,15};

static PS_ALERT_CONF g_udp_med_decoy_ps = {200,30,120,60};

static PS_ALERT_CONF g_udp_med_sweep =    {30,5,5,20};

static PS_ALERT_CONF g_udp_med_dist_ps =  {200,30,120,30};

 

static PS_ALERT_CONF g_udp_hi_ps =        {200,3,100,10};

static PS_ALERT_CONF g_udp_hi_decoy_ps =  {200,7,200,60};

static PS_ALERT_CONF g_udp_hi_sweep =     {30,3,3,10};

static PS_ALERT_CONF g_udp_hi_dist_ps =   {200,3,200,10};

 

/*

**  IP Protocol alert configurations

*/

static PS_ALERT_CONF g_ip_low_ps =        {0,10,10,50};

static PS_ALERT_CONF g_ip_low_decoy_ps =  {0,40,50,25};

static PS_ALERT_CONF g_ip_low_sweep =     {0,10,10,10};

static PS_ALERT_CONF g_ip_low_dist_ps =   {0,15,25,50};

 

static PS_ALERT_CONF g_ip_med_ps =        {200,10,10,50};

static PS_ALERT_CONF g_ip_med_decoy_ps =  {200,40,50,25};

static PS_ALERT_CONF g_ip_med_sweep =     {30,10,10,10};

static PS_ALERT_CONF g_ip_med_dist_ps =   {200,15,25,50};

 

static PS_ALERT_CONF g_ip_hi_ps =         {200,3,3,10};

static PS_ALERT_CONF g_ip_hi_decoy_ps =   {200,7,15,5};

static PS_ALERT_CONF g_ip_hi_sweep =      {30,3,3,7};

static PS_ALERT_CONF g_ip_hi_dist_ps =    {200,3,11,10};

 

/*

**  ICMP alert configurations

*/

static PS_ALERT_CONF g_icmp_low_sweep =   {0,5,5,5};

static PS_ALERT_CONF g_icmp_med_sweep =   {20,5,5,5};

static PS_ALERT_CONF g_icmp_hi_sweep =    {10,3,3,5};

 

 

 

如何认定扫描和扫描类型

 

对于某一priority_count大于规定的IPSET节点

在规定的时间间隔内:

Ps      scanned          少于u_ip_count个主机,多于u_port_coun个连接

decoy_ps    scanned   大于u_ip_count个主机,多于u_port_coun个连接

dist_ps scanned  少于u_ip_count个主机,多于u_port_coun个连接

g_ip_low_sweepscanner  大于u_ip_count个主机,多于u_port_coun个连接

 

 

scanned 被扫描的主机

scanner 发起扫描的主机

 

priority_count的计算

TCP

       关心三种类型的TCP数据包

       开始的数据包:(注意,这里并不关心flags,只是关心流(FLOW)最开始收到的那个数据包)

       TCP三次握手的数据包

       未确立的stream中的reset数据包

 

开始的数据包

       开始的数据包的有效性由stream4预处理器确定,我们在这里只是在确定发起者和相应者。

 

如果是开始的数据包,建立一个session

如果是结束的数据包(FIN),减少一个session

如果是RSTpriority_count ++

如果sever回应,open ports 1

如果是ICMP unreachable priority_count ++

如果不满足以上条件,session中通过的数据包加1

IP

如果是ICMP

如果收到ICMP_DEST_UNREACH&& ICMP_PROT_UNREACH   priority_count ++

如果属于某一个流

如果源自初始方,session中通过的数据包加1

如果源自应答方,session中通过的数据包减1

 

UDP

如果是ICMP

如果收到ICMP_DEST_UNREACH&& ICMP_PROT_UNREACH   priority_count ++

如果属于某一个流

如果源自初始方,session中通过的数据包加1

如果源自应答方,session中通过的数据包减1

 

 

 

ICMP

case ICMP_ECHO:

case ICMP_TIMESTAMP:

case ICMP_ADDRESS:

case ICMP_INFO_REQUEST:

 

session中通过的数据包加1

 

case ICMP_DEST_UNREACH:

priority_count ++

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值