nginx 安装最新版
# 安装环境并把编译环境也安装上
yum -y install epel-release gcc gcc-c++ pcre pcre-devel zlib zlib-devel
# 设置nginx安装最新版本源
新建文件在 vi /etc/yum.repos.d/nginx.repo 内容如下
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
# 安装nginx
yum install -y nginx
# 开机启动
systemctl enable nginx
# 启动
nginx
# 软连接
mkdir -p /root/nginx && ln -s /etc/nginx/ /root/nginx
可通过HTTP获取远端WWW服务信息
整改前后比较,Response响应头去掉Server
详细描述
本插件检测远端HTTP Server信息。这可能使得攻击者了解远程系统类型以便进行下一步的攻击。该漏洞仅是为了信息获取,建议隐藏敏感信息。如果banner未包含敏感信息,则表明该漏洞已经不具备暴露敏感信息风险,可以不用修复。
# 前提是已安装nginx,否则看上一步安装nginx
# 进入nginx目录
cd /etc/nginx
# 修复漏洞【可通过HTTP获取远端WWW服务信息】
wget https://ghproxy.cc/https://github.com/openresty/headers-more-nginx-module/archive/refs/tags/v0.37.tar.gz
tar -zxvf v0.37.tar.gz
# 下载最新版nginx
export NGINXVERSION="1.26.2"
wget -c https://nginx.org/download/nginx-${NGINXVERSION}.tar.gz
tar -zxvf nginx-${NGINXVERSION}.tar.gz
cd nginx-${NGINXVERSION}
# 获取nginx配置信息,拷贝 configure arguments 后的安装参数,如下面 ./configure后面
nginx -V
# 添加上add-module模块路径,注意最后是添加了新模块路径
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' --add-module=/etc/nginx/headers-more-nginx-module-0.37
# 编译,千万不能执行make install或者会安装nginx应用程,只make编译就行,我们要拿到objs/nginx文件即可
make
# 备份和替换nginx可执行文件,输入y替换
cp /usr/sbin/nginx /usr/sbin/nginx.bak
cp -rf /etc/nginx/nginx-${NGINXVERSION}/objs/nginx /usr/sbin/
# /etc/nginx/nginx.conf 的 http 中添加 more_clear_headers 'Server';
more_clear_headers 'Server';
# 停止、启动nginx
nginx -s stop
# 如果上面nginx停止失败,则杀掉nginx主进程
killall nginx
nginx
SSH版本信息可被获取
处理参考:www.cnblogs.com/niway/p/168…
# 添加自定义sshBanner
echo "Welcome to ssh" > /etc/ssh/ssh_banner
vi /etc/ssh/sshd_config
# 找到 #Banner none 在下面添加
Banner /etc/ssh/ssh_banner
# 重启 ssh
systemctl restart sshd
详细描述
SSH服务允许远程攻击者获得ssh的具体信息,如版本号等等。这可能为攻击者发动进一步攻击提供帮助。
如果banner包含敏感信息,NSFOCUS建议您采取以下几类措施以降低威胁:
- 修改源代码或者配置文件改变SSH服务的缺省banner。
- 配置防火墙策略,阻断ssh banner信息外泄。
如果已经采取了以上几类措施,则表明该漏洞已经不具备暴露敏感信息风险,可以不用修复。
探测到SSH服务器支持的算法
无法处理,只能它禁用某些较旧或不安全的算法,并启用一组推荐的算法,注意第一句ctr同下面CBC模式信息泄露解决方式一样,也解决下面CBC问题了
echo 'Ciphers aes256-ctr,aes192-ctr,aes128-ctr' >> /etc/ssh/sshd_config
echo 'KexAlgorithms diffie-hellman-group-exchange-sha256' >> /etc/ssh/sshd_config
echo 'MACs hmac-sha2-256,hmac-sha2-512' >> /etc/ssh/sshd_config
systemctl restart sshd
OpenSSH CBC模式信息泄露漏洞(CVE-2008-5161)【原理扫描】
处理参考:www.cnblogs.com/fengguozhon…
echo 'Ciphers aes128-ctr,aes192-ctr,aes256-ctr' >> /etc/ssh/sshd_config
systemctl restart sshd
详细描述
OpenSSH是一种开放源码的SSH协议的实现,初始版本用于OpenBSD平台,现在已经被移植到多种Unix/Linux类操作系统下。
如果配置为CBC模式的话,OpenSSH没有正确地处理分组密码算法加密的SSH会话中所出现的错误,导致可能泄露密文中任意块最多32位纯文本。在以标准配置使用OpenSSH时,攻击者恢复32位纯文本的成功概率为2^{-18},此外另一种攻击变种恢复14位纯文本的成功概率为2^{-14}。
检测到远端RPCBIND/PORTMAP正在运行中(CVE-1999-0632)
处理参考:www.dongmanai.cn/post/55c8EF…
systemctl stop nfs-server.service
systemctl stop rpcbind.service
systemctl disable rpcbind.service
systemctl disable nfs-server.service
systemctl stop iptables.service
systemctl disable iptables.service
# 最后重启,也可以不重启
reboot
# 确认portmap已关闭,如果rpcbind.service没有运行,则portmap已关闭。
systemctl status rpcbind.service