Skip to content

Latest commit

 

History

History
92 lines (62 loc) · 2.03 KB

README.md

File metadata and controls

92 lines (62 loc) · 2.03 KB

CheckSecurityCentos

++++++++++++++++

Version 1.5

Check SSH status : user, ip & time login Check status port change : port open or close Send log terminal ( OPTION ) +++++++++++++++

A. Client

**** Check server could connect to 192.168.142.101 & iptables open output 192.168.142.101:5044

++++++++++++++++

Config send log terminal

  • Require root access

  • Edit /etc/bashrc

    $ vi /etc/bashrc

Add in last line

export PROMPT_COMMAND='RETRN_VAL=$?;logger -p local6.debug "[$(echo $SSH_CLIENT | cut -d" " -f1)] # $(history 1 | sed "s/^[ ]*[0-9]\+[ ]*//" )"'
  • Edit /etc/rsyslog.conf

    $ vi /etc/rsyslog.conf

Add in last line

local6.debug                /var/log/cmdlog.log
  • $ service rsyslog restart
  • $ chmod 644 /var/log/cmdlog.log

Set logrotate ( option)

  • $ vi /etc/logrotate.d/cmdlog

    /var/log/cmdlog.log {
     create 0644 root root
     compress
     weekly
     rotate 12
     sharedscripts
     postrotate
      /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
     endscript
    

    }

++++++++++++

B. Server : Logstash, Elasticsearch, Kibana

++ Config logstash

filter {
    if [type] == "attt_monitor_cmdlog" {
        grok {
            match => { "message" => "(?<timestamp>%{MONTH}  %{MONTHDAY} %{TIME}) +(?<hostnameserver>%{WORD}) +(?<username>%{WORD}): \[+(?<src_ip>%{IP})\] \[++(?<dest_ip>(?:[0-9\|\.])*[A-Z0-9\|\.])\] \# +(?<terminal>%{GREEDYDATA})"}
        }
    }
    if [type] == "attt_monitor_login" {
        date {
            match => [ "time_stamp", "ISO8601" ]
        }
    }
    if [type] == "attt_monitor_port" {
        date {
            match => [ "time_stamp", "ISO8601" ]
        }
    }
}