漏洞解决

一、允许Traceroute探测

1.Q:漏洞名称:允许Traceroute探测

描述:本插件使用Traceroute探测来获取扫描器与远程主机之间的路由信息。攻击者也可以利用这些信息来了解目标网络的网络拓扑。

运维建议解决方案:在防火墙中禁用Time Exceeded类型的ICMP包
端口号:0

2.A:解决途径:

(1)如果 /etc/sysconfig/ 目录下没有 iptables 文件(就是iptables,而不是iptables-config),需要安装 iptables,安装参考链接:https://www.cnblogs.com/miracle-luna/p/13714709.html

其中是否需要设置开机自启可能还有待商讨,本文验证时未设置自启。

1、停止 firewall 服务
systemctl stop firewalld 
 
2、注销 firewall 服务
systemctl mask firewalld
 
3、安装 iptables 服务
yum install -y iptables 
yum install iptables-services
 
4、启动 iptables 服务
systemctl start iptables
或者
service iptables start
 
5、设置 iptables 开机自启动
systemctl enable iptables
 
6、查看 iptables 状态
systemctl status iptables
或者
service iptables status

(2)有了iptables 文件后,修改 iptables 文件
在/etc/sysconfig/iptables 文件中,增加如下文字内容:

#sample configuration for iptables service
#you can edit this manually or use system-config-firewall
#please do not ask us to add additional ports/services to this default configuration*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

#解决time exceeded问题
-A INPUT -p icmp --icmp-type time-exceeded -j DROP
-A OUTPUT -p icmp --icmp-type time-exceeded -j DROP

-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

(3)保存、重载、重启、查看 iptables 状态

#保存
service iptables save
#重载
service iptables reload或者systemctl reload iptables
#重启(未启动的话就启动)
service iptables restart或者systemctl restart iptables
#开机自启(是否需要开机自启还得商讨)
systemctl enable iptables
#查看状态
service iptables status或者systemctl status iptables

二、ICMP timestamp请求响应漏洞

1.Q:漏洞名称:ICMP timestamp请求响应漏洞

描述:“远程主机会回复ICMP_TIMESTAMP查询并返回它们系统的当前时间。
这可能允许攻击者攻击一些基于时间认证的协议。”

运维建议解决方案:“NSFOCUS建议您采取以下措施以降低威胁:* 在您的防火墙上过滤外来的ICMP timestamp(类型 13)报文以及外出的ICMP timestamp回复报文。”
端口号:0

2.A:解决途径:

(1)有了iptables 文件后,修改 iptables 文件
在/etc/sysconfig/iptables 文件中,增加文字内容:

#sample configuration for iptables service
#you can edit this manually or use system-config-firewall
#please do not ask us to add additional ports/services to this default configuration*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

#解决timestamp问题
-A INPUT -p ICMP --icmp-type timestamp-request -j DROP
-A INPUT -p ICMP --icmp-type timestamp-reply -j DROP
#解决time exceeded问题
-A INPUT -p icmp --icmp-type time-exceeded -j DROP
-A OUTPUT -p icmp --icmp-type time-exceeded -j DROP
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

(2)保存、重载、重启、查看 iptables 状态

#保存
service iptables save
#重载
service iptables reload或者systemctl reload iptables
#重启
service iptables restart或者systemctl restart iptables
#查看状态
service iptables status或者systemctl status iptables

三、SSH版本信息可被获取

1.Q:漏洞名称:SSH版本信息可被获取

描述:SSH服务允许远程攻击者获得ssh的具体信息,如版本号等等。这可能为攻击者发动 进一步攻击提供帮助。"

运维建议解决方案:“NSFOCUS建议您采取以下措施以降低威胁:* 修改源代码或者配置文件改变SSH服务的缺省banner。”
端口号:22

2.A:解决途径:

(1)在 /etc/下创建一个文件 ssh_banner_change,在文件中输入内容,如:welcome!
(2)修改/etc/ssh/sshd_config 文件,找到#Banner none在其下面添加以下内容:Banner /etc/ssh_banner_change

# no default banner path
#Banner none
Banner /etc/ssh_banner_change

(3)重启sshd服务
systemctl restart sshd
(4)验证是否成功
telnet localhost 22

运行该命令,若是提示~bash: telnet: command not found,则安装telnet

yum list telnet*              列出telnet相关的安装包
yum install telnet-server          安装telnet服务
yum install telnet.*           安装telnet客户端

再次运行telnet localhost 22

发现仍然打印出类似SSH-2.0.0-OpenSSH_8.3的版本信息,说明失败,若是成功打印出类似welcome的信息则成功,无需进行以下步骤

(5)上述(4)失败的话,那就需要重新编译安装,下载安装包

  • 2.1 zlib-1.2.11.tar.gz 下载地址:http://www.zlib.net/zlib-1.2.11.tar.gz
  • 2.2 openssl-1.1.1g.tar.gz 下载地址:https://www.openssl.org/source/openssl-1.1.1g.tar.gz
  • 2.3 openssh-8.3p1.tar.gz 下载地址:http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.3p1.tar.gz

下载后上传至服务器。

注意:
别卸载原版本的ssh,就算下载新版本后也别卸载;按资料说是:如果是远程连接升级,不能卸载旧版本,否则连接会断开。安装新版本后也不能卸载老版本,否则要到服务器直连重新安装。(未验证) 在修复前多开几个连接窗口,防止操作过程产生的影响导致再也连接不上。这样就只能去服务器直连,无法远程连接。(经后续验证后,确实会出现重新打开连接时连接不上的问题,所以务必提前多开几个连接窗口)

(6)安装 zlib-1.2.11.tar.gz

#解压
tar -xvf zlib-1.2.11.tar.gz

#进入解压后的目录
cd zlib-1.2.11

#编译,该目录自己选择
./configure --prefix=/usr/local/zlib 

make && make install

注意:
若是有失败,则是gcc未安装,安装gcc后重复上述步骤(下面其他解压安装时同理,若失败了,也考虑gcc的问题):
yum -y install gcc automake autoconf libtool make

(7)安装 openssl-1.1.1g.tar.gz

#解压
tar -xvf openssl-1.1.1g.tar.gz

#进入解压后的目录
cd openssl-1.1.1g

#编译,该目录自己选择
./config --prefix=/usr/local/ssl -d shared 

make && make install

#安装后查看信息是否成功
ldconfig -v

#或者
#查看 openssl 版本命令
openssl version

(8)安装 openssh-8.3p1.tar.gz

#解压
tar -xvf openssh-8.3p1.tar.gz

#进入解压后的目录
cd openssh-8.3p1

#修改 version.h 文件内容
找到类似  #define SSH_VERSION “OpenSSH_8.3(视你下载的版本而定)”  ,将版本信息改为(如:welcome),即改为 #define SSH_VERSION “OpenSSH_welcome”

#编译,该prefix目录自己选择,后面的ssl目录、zlib目录都要与前面解压时对应上
./configure --prefix=/usr/local/openssh --with-ssl-dir=/usr/local/ssl --with-zlib=/usr/local/zlib 

若是有报错,如:
configure: error: *** working libcrypto not found, check config.log ***
或者
configure: error: *** OpenSSL headers missing - please install first or check config.log ***
则将ssl目录改为其上级目录再重新尝试,如--with-ssl-dir=/usr/local/ssl改为--with-ssl-dir=/usr/local
若是还不行,则在上面改动的基础上,yum安装openssl-devel包再重新尝试,命令:
yum install -y openssl-devel
(报错参考链接:https://www.cnblogs.com/wholj/p/10944407.html)
实验时在改动基础上安装openssl-devel包后成功

make && make install

#修改 /usr/local/openssh/etc/sshd_config 文件:
①找到 #PermitRootLogin prohibit-password 在下一行添加 PermitRootLogin yes,启用允许root 远程登录;
②找到 #PubkeyAuthentication yes 在下一行添加 PubkeyAuthentication yes,启用公钥身份验证;
③找到 #PasswordAuthentication yes 在下一行添加 PasswordAuthentication yes,启用隧道明文密码

#备份 /etc/ssh 原有文件(原来没有的文件,mv 命令提示 :No such file or directory,则跳#过 mv 备份),并将新的配置复制到指定目录:
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
cp -f /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config
mv /usr/sbin/sshd /usr/sbin/sshd.bak
cp -f /usr/local/openssh/sbin/sshd /usr/sbin/sshd
mv /usr/bin/ssh /usr/bin/ssh.bak
cp -f /usr/local/openssh/bin/ssh /usr/bin/ssh 
mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen.bak
cp -f /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
mv /etc/ssh/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub.bak
cp -f /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub

#重启,查看版本
systemctl restart sshd
sshd -v (或者ssh -V)

#启动服务后,配置开机启动(需要开机自启)
systemctl enable sshd.service

#验证是否成功
telnet localhost 22
若是提示:SSH-2.0.0-OpenSSH_welcome(你自己配置的),则说明成功

(9)xshell新开窗口连接不上
setsebool -P authlogin_shadow on

该命令具体意思还得调查,-p是永久修改的意思
运行该命令后,再次连接发现成功

(10)Xshell 连接虚拟机出现 “The remote SSH server rejected X11 forwarding request”

#修改ssh配置
vi /etc/ssh/sshd_config
以及vi /usr/local/openssh/etc/sshd_config (openssh-8.3p1.tar.gz的安装目录中)

或者

单纯修改vi /usr/local/openssh/etc/sshd_config,
然后cp -f /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config

修改内容:
将文件中的 X11Forwarding 参数改为 yes;

保存退出后即可成功,当然最好重启systemctl restart sshd
再次连接发现无此提示

但此种解决还有问题,OpenSSH Server未启动,有待解决

四、远端WEB服务器上存在/robots.txt文件

1.Q:漏洞名称:远端WEB服务器上存在/robots.txt文件

描述:一些WEB服务器通过设置/robots.txt使得一些搜索引擎或者索引工具更方便有效地工 作。但/robots.txt中往往存在一些系统信息,可能使攻击者获得该系统的额外信息。

运维建议解决方案:NSFOCUS建议您采取以下措施以降低威胁:* 如果您的robots.txt中包含敏感信息,删除该文件。
端口号:50075

2.A:解决途径:有待补充

#查找该文件
find / -name robots.txt

按资料是可以直接删除

  • 5
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值