温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

是谁在撩动着我的服务器

发布时间:2020-04-07 09:54:07 来源:网络 阅读:4647 作者:凛冬一壶酒 栏目:建站服务器

            安全--怎样才能追根朔源

    有人说安全,安全是什么,怎么做,怎么才能做好,其实是个永无止境的话题。

浅谈下工作中那些方法:

1、所有的操作都必须流程化,可控化。

2、考核机制。

3、相应的技术手段,提升安全的门槛<系统权限管理、堡垒机、跳板机、防火墙设置>。

4、主动防御。<蜜罐、waf>

5、探测技术。<nmap zmap>

6、告警响应机制。

7、调查告警原因。


那就谈谈怎么实现:

原理图

是谁在撩动着我的服务器



  • 怎么监控恶意行为

工欲善其事,必先利其器


怎么监控 Windows server服务器  配置安全-高级审核策略,怎么配置,请听我慢慢到来。

实例如下:《可根据生产环境,斟酌采取各种日志,一下只是实例》



帐户登录事件(此类别中的事件帮助文档域尝试对帐户数据、域控制器或本地安全帐户管理器 (SAM)  进行身份验证。与登录和注销事件(它们跟踪访问特殊计算机的尝试)不同,此类别中的事件报告正在使用的帐户数据库。)凭据验证
审核由对用户帐户登录凭据的验证测试生成的事件。成功、失败
Kerberos 身份验证服务
审核  Kerberos 服务票证请求生成的事件。失败、成功
Kerberos服务票证操作
审核由响应为用户帐户登录提交的凭据请求(非凭据验证或  Kerberos 票证)生成的事件。成功、失败
其他帐户登录事件
审核由  Kerberos 身份验证票证授予票证 (TGT) 请求生成的事件。成功、失败
帐户管理事件(可以使用此类别中的设置监视对用户和计算机帐户和组的更改。)用户帐户管理
审核对用户帐户的更改。成功、失败
计算机帐户管理
审核由对计算机帐户的更改(如当创建、更改或删除计算机帐户时)生成的事件。成功、失败
安全组管理
审核由对安全组的更改生成的事件。成功、失败
通讯组管理
审核由对通讯组的更改生成的事件。注意:仅在域控制器上记录此子类别中的事件。成功、失败
应用程序组管理
审核由对应用程序组的更改生成的事件。成功、失败
其他帐户管理事件
审核由此类别中不涉及的其他用户帐户更改生成的事件。成功、失败



  • 本地会产生日志,怎么将日志发送到远端日志服务器,简单图上面已经标明,利用evtsys.exe 发送到指定的log服务器。


  • Linux 服务器开启审计策略

1.1    命令时间戳记录

    /etc/bashrc文件中增加如下行

    export  HISTTIMEFORMAT="%F %T "


2.1    日志审计策略配置


    /etc/audit/audit.rules

        实现监控所有用户的登录行为,包含用户所有操作,以及shell脚本中的命令

    -a exit,always-F arch=b64 -S execve -k exec

    -a exit,always -Farch=b32 -S execve -k exec

2.2  实现对重点配置文件的监控(根据实际应用额外添加文件列表)    

    -w /etc/crontab -p wa -kcrontab

    -w /etc/hosts -p wa -khosts

    -w /etc/hosts.allow-p wa -k hosts-allow

    -w /etc/hosts.deny-p wa -k hosts-deny

    -w /etc/fstab -p wa -k fstab

    -w /etc/passwd-p wa -k passwd

    -w /etc/shadow-p wa -k shadow

    -w /etc/group-p wa -k group


3.1    

    配置audit日志,audit日志文件自动保存在/var/log/audit/目录中。

    num_logs = 4       #个数

    max_log_file = 50   # 大小(MB)



4.1    添加无用日志过滤规则:

    

    /etc/rsyslog.d/目录添加audit_filter.conf文件,并在文件中添加如下内容:

:msg, ereregex,"(bin|sbin|sa)\/(ping|top|mpstat|iostat|iotop|vmstat|sar|sadc|sh)\""~

:msg, ereregex,"(sbin|udev)\/(fstab_import|udisks-part-id|path_id|edd_id|scsi_id)\""~

:msg, ereregex,"(bin|sbin)\/(tr|sort|wc|cut|awk|gawk|grep|fgrep|egrep|sed|head|tail|tailf)\""~

:msg, ereregex,"(bin|sbin)\/(sleep|ls|expr|nohup|date|cat|du|dirname|tar|gzip|df|sg_persist|ip)\""~

:msg, ereregex,"(bin|sbin)\/(basename|hostname|readlink|bc|touch|dmesg)\"" ~

:msg, ereregex,"(bin|sbin)\/(consoletype|blkid|lsblk)\"" ~

:msg, ereregex,"\"(ping|top|mpstat|iostat|iotop|vmstat|sar|sadc|sh)\"" ~

:msg, ereregex,"\"(fstab_import|udisks-part-id|path_id|edd_id|scsi_id)\""~

:msg, ereregex,"\"(tr|sort|wc|cut|awk|gawk|grep|fgrep|egrep|sed|head|tail|tailf)\""~

:msg, ereregex,"\"(sleep|ls|expr|nohup|date|cat|du|dirname|tar|gzip|df|sg_persist|ip)\""~

:msg, ereregex,"\"(basename|hostname|readlink|bc|touch|dmesg)\"" ~

:msg, ereregex,"\"(consoletype|blkid|lsblk)\"" ~

:msg, ereregex,"(type=PATH)" ~

:msg, ereregex,"(key=\"exec\"|type=EXECVE)" @x.x.x.x:514


启动服务

# service auditd start

  # service rsyslog start


5.1     附上一个批量部署的脚本

            

#!/bin/bash
#
# Description: Linux audit and syslog/rsyslog autoconfig Scripts.
#
# Author: ldyhj <qiongfei@vip.qq.com>
#
# ver 1.0
# --------------------------------------------------------------------------------

OS_VERSION=""
uname -r | grep el5 > /dev/null && OS_VERSION=el5
uname -r | grep el6 > /dev/null && OS_VERSION=el6
uname -r | grep el7 > /dev/null && OS_VERSION=el7

if [ "$OS_VERSION" = "el7" -o "$OS_VERSION" = "el6" ];then
    FILENAME=/etc/rsyslog.conf
    SERVER=rsyslog
elif [ "$OS_VERSION" = "el5" ];then
    FILENAME=/etc/syslog.conf
    SERVER=syslog	
fi

unset ret
ret=`egrep ^active[[:space:]]*= /etc/audisp/plugins.d/syslog.conf 2> /dev/null |wc -l`
if [ "$ret" -eq 0 ];then
    echo "active = yes" >> /etc/audisp/plugins.d/syslog.conf
    service auditd restart
elif [ "$ret" -eq 1 ];then
    ret1=`egrep ^active[[:space:]]*= /etc/audisp/plugins.d/syslog.conf |awk -F'=' '{print $NF}' |awk 'gsub(/^ *| *$/,"")'`
    if [ "$ret1" != "yes" ];then
        sed -i 's/^\(active[[:space:]]*=\).*/\1 yes/g' /etc/audisp/plugins.d/syslog.conf
        service auditd restart
	fi
elif [ "$ret" -gt 1 ];then
    sed -i 's/^\(active[[:space:]]*=.*\)/#\1/g' /etc/audisp/plugins.d/syslog.conf
    echo "active = yes" >> /etc/audisp/plugins.d/syslog.conf
    service auditd restart
fi
egrep ^active[[:space:]]*= /etc/audisp/plugins.d/syslog.conf

unset ret
unset ret1

ret=`egrep "^\*\.\*[[:space:]]*@" $FILENAME 2> /dev/null |wc -l`
if [ "$ret" -eq 0 ];then
    echo "*.* @x.x.x.x:514" >> $FILENAME
    service $SERVER restart
elif [ "$ret" -eq 1 ];then
    ret1=`egrep "^\*\.\*[[:space:]]*@" $FILENAME |awk -F'@' '{print $2}' |awk 'gsub(/^ *| *$/,"")'`
	if [ "$ret1" != "x.x.x.x:514" ];then
        sed -i 's/^\(\*\.\*[[:space:]]*@\).*/\x.x.x.x:514/g' $FILENAME
        service $SERVER restart
    fi
elif [ "$ret" -gt 0 ];then
    sed -i 's/^\(\*\.\*[[:space:]]*@.*\)/#\1/g' $FILENAME
    echo "*.* @x.x.x.x:514" >> $FILENAME
    service $SERVER restart
fi
	
egrep "\*\.info[[:space:]]*@" $FILENAME > /dev/null
if [ $? -eq 0 ];then
    sed -i 's/^\(\*\.info[[:space:]]*@.*\)/#\1/g' $FILENAME
    service $SERVER restart
fi

egrep "^\*\.\*[[:space:]]*@" $FILENAME



6.1    linux rsyslog服务器  配置

    /etc/rsyslog.conf

    配置模板

   

$templatepipeformat,"%TIMESTAMP% %fromhost-ip%%syslogtag%%msg:::drop-last-lf%\n"

$templateevtsysformat,"%TIMESTAMP% %fromhost-ip% %pri-text% %FROMHOST%%fromhost-ip% %syslogtag%%msg:::drop-last-lf%\n"

$templateruncmdformat,"%TIMESTAMP% %HOSTNAME% %fromhost-ip%%msg:::drop-last-lf%\n"

                根据需求进行摘选模板存放位置

                

if$fromhost-ip == 'IP' or $fromhost-ip == '接收来自客户端IP' or $fromhost-ip== '接收IP' or $fromhost-ip == '接收客户端IP' or $fromhost-ip =='接收客户端IP' or $fromhost-ip == '接收客户端IP' or $fromhost-ip =='接收客户端IP' then |/var/tmp/log


    配置完成后,检查语法  rsyslogd -N1

    重启服务


有了数据,你想实现什么样的告警都需要去摸索

目前,我采用的是电视屏幕展示,加事件风险等级做报警短信告警,因为采用了固定的rsyslog模板,可以使用 AWK  python 取你想要的东西做参数;这样实现谁操作了服务器,做了什么都是一目了然。



附件、附上本次需要设计到的文档,软件



附件:http://down.51cto.com/data/2366760
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI