监控与服务安全

mac2025-12-18  6

监控与服务安全

1.什么事审计?

(1)基于事先配置的规则生成的日志,记录可能发生在系统上的事件; (2)审计不会为系统提供格外的安全保护,但它会发现并记录违反安全策略的人及其对应的行为 (3)审计能够记录日志的内容 –日期与事件,事件结果 –触发事件的用户 –所有认证机构的使用都可以被记录,如ssh等 –对关键数据稳健的修改行为等

2.审计案例

监控文件访问 监控系统调用 记录用户运行命令 ausearch工具,可以根据条件过滤审计文件 aureport工具,可以生成审计报告

3.部署audit

(1).安装软件包 #yum -y install audit #cat /etc/audit/auditd.conf #systemctl start auditd #systemcl enable auditd (2).audtictl命令 #auditctl -s //查看状态 #auditctl -l //查看规则 #auditctl -D //清空所有规则

3.定义文件系统规则

#auditctl -w /etc/passwd -p wa(写,属性) -k lss_passwd #auditctl -w /etc/selinux/ -p wa -k lss_selnux #auditctl -w /usr/bin/fdisk -p x -k lss_disk

4.定义永久规则

#vim /etc/audit/rules.d/audit.rules auditctl -w /etc/passwd -p wa(写,属性) -k lss_passwd auditctl -w /etc/selinux/ -p wa -k lss_selnux auditctl -w /usr/bin/fdisk -p x -k lss_disk

5.nginx安全

#yum -y install gcc pcre-devel zlib-devel #tar -xf nginx-1.12.2.tar.gz #cd nginx-1.12.2/ #./configure --without-http_autoindex_module (–without禁止模块) #make && make install

6.修改版本信息

#vim src/http/ngx_http_header_filter_module.c static u_char ngx_http_server_string[] = “Server: nginx(需要改)” CRLF; static u_char ngx_http_server_full_string[] = “Server: (需要改)” NGINX_VER CRLF(需要改); static u_char ngx_http_server_build_string[] = “Server: (需要改)” NGINX_VER_BUILD CRLF(需要改); #curl -i http://192.168.4.203/test.html(访问时加-i,查看版本信息,这时就可以伪装成其他信息)

7.限制并发

#vim /usr/local/nginx/conf/nginx.conf http{ limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; serevr{ listen 80; server_name localhost; limit_req zone=one burst=5; } 客户端测试#ab -c 100 -n 100 http://192.168.4.5/(虽然访问100次,但是只接受6个)

8.拒绝非法请求

#vim /usr/local/nginx/conf/nginx.conf http{ server{ listen 80; if ( r e q u e s t m e t h o d !   ( G E T ∣ P O S T ) request_method !~^(GET | POST) requestmethod! (GETPOST)){ return 444; } #curl -i -X GET http://192.168.4.5

9.防止buffer溢出

#vim /usr/local/nginx/conf/nginx.conf http{ client_body_buffer_size 1K; client_header_buffer_size 1k; client_max_body_size 16K; large_client_header_buffers 4 4k;

10.数据库安全

(1)初始化 #yum -y install mariadb mariadb-server #systecmtl start mariadb #mysql_secure_installation //初始化安全脚本 (2).密码安全 #mysqldump -uxxx(用户) -pxxx(旧密码) passwd ‘xxxx(新密码)’ set password for 用户@“localhost”=password(‘新密码’) 历史记录会出卖你 #rm -rf .bash_history #rm -rf .mysql_history

11.Tomcat安全

#yum -y install java-1.8.0-openjdk-devel #cd /usr/local/tomcat/lib #vim org/apache/cataline/util/serverinfo.properties 测试 //都会隐藏软件信息 #curl -I http://192.168.2.100:8080/xx(头部信息) #curl http://192.168.2.100:8080/xx (报错界面)

最新回复(0)