|
楼主 |
发表于 2011-10-31 22:43:54
|
显示全部楼层
本帖最后由 ww111222 于 2011-10-31 23:04 编辑
02_ROS安全配置
- #===================================================================================
- #配置 用户
- #===================================================================================
- # 1、新增超级用户,设置复杂密码,并限制登录IP地址
- # 2、增加一个自定义full组test,并设置权限为最高,带!表示禁用
- # 3、将ROS系统默认组(full ,read, write)的权限全部设置为最低。
- # 4、在full组新增加一个多位账号及复杂密码的用户。
- # 5、为admin设置复杂密码,移动到 read 组,并限制登录IP地址
- #
- # 变量 LoginRosIP 可访问ROS的IP段,我这里是为了内网192.168.88.*/24和VPN拨号192.168.99.0/24都能访问
- # 变量 CustomFullGroup 自定义最高权限用户组
- # 变量 CustomAdminUserName 自定义超级用户名称(账号不能有中文)
- # 变量 CustomAdminUserPass 自定义超级用户密码(密码可以有中文,这样破解难度加大)
- :global LoginRosIP "192.168.0.0/16"
- :global CustomFullGroup "test"
- :global CustomAdminUserName "ww111222"
- :global CustomAdminUserPass "cQZAQ@wsxZ工QXsw陈cCDEN98"
- / user group
- add comment="最高权限组" \
- name=$CustomFullGroup \
- policy="local,telnet,ssh,reboot,read,test,winbox,password,web,sniff,sensitive,ftp,write,policy"
- / user group
- set read \
- comment="系统读权限组,权限改为最低" \
- policy="!local,!telnet,!ssh,!reboot,!read,!test,!winbox,!password,!web,!sniff,!sensitive,!ftp,!write,!policy"
- set write \
- comment="系统写权限组,权限改为最低" \
- policy="!local,!telnet,!ssh,!reboot,!read,!test,!winbox,!password,!web,!sniff,!sensitive,!ftp,!write,!policy"
- #不知道为什么,用脚本无法将系统自带的full权限改为全部没有!!!!
- set full \
- comment="系统所有权限组,权限改为最低" \
- policy="!local,!telnet,!ssh,!reboot,!read,!test,!winbox,!password,!web,!sniff,!sensitive,!ftp,!write,!policy"
- / user
- add name=$CustomAdminUserName \
- password=$CustomAdminUserPass \
- group=$CustomFullGroup \
- comment="实际超级用户" \
- address=$LoginRosIP \
- disable=no
- / user
- add name="ASDFAF@ZX70980@CVZXVCAasf" \
- password="asdfaf09ok913中国41*&()&%^^&(*)33345" \
- group=full \
- comment="复杂账号/密码超级用户" \
- address=$LoginRosIP \
- disable=no
- / user
- set admin \
- password="C!@#cq2cnzaqWWSXCDERf中国vbgtyhnasdfasdf" \
- group=read \
- comment="陷阱超级用户" \
- address=$LoginRosIP \
- disable=no
- #===================================================================================
- #配置 WINBOX 服务
- #===================================================================================
- # 禁止不需要的 ROS服务,加强安全
- # 将winbox服务的端口号 由 8291 改变为:自定义端口号 登录IP范围改为内网IP
- # 变量 RosPort 自定义登录ROS的端口
- # 变量 LoginRosIP 自定义登录ROS的IP段范围,在 配置用户 已定义
- # 参数 disable yes 禁止 / no 允许
- :global RosPort "9988"
- / ip service
- set telnet address=$LoginRosIP port=23 disabled=yes
- set ftp address=$LoginRosIP port=21 disabled=yes
- set www address=$LoginRosIP port=80 disabled=yes
- set ssh address=$LoginRosIP port=22 disabled=yes
- set www-ssl address=$LoginRosIP port=443 disabled=yes
- set api address=$LoginRosIP port=8728 disabled=yes
- set winbox address=$LoginRosIP port=$RosPort disabled=no
- #===================================================================================
- #配置 MAC 地址登录
- #===================================================================================
- # enable 允许MAC登录
- # disable 禁止MAC登录
- :global MacLogin "enable"
- :if ($MacLogin="enable") do={/tool mac-server mac-winbox enable 0} else={/tool mac-server mac-winbox disable 0}
- #===================================================================================
- #更改ROS名称
- #===================================================================================
- #
- / system identity set name="ROS3.30_CQ"
- #===================================================================================
- #限制TTL值为1
- #===================================================================================
- # PING IP或计算机名能探测到你电脑的一些信息。比如说用的是什么操作系统或目标主机是否存活。
- #操作系统就可以通过PING通后返回的TTL值看出。若TTL值为128,则为WINDOWS NT系列的操作系统。
- #若为64,则一般为Unix/Linux。当然这只是一般情况,因为TTL值是可以自己修改的。有些管理员通
- #过修改TTL值来迷惑入侵者,让其不能很容易判断出主机上到底安装了何种操作系统和对自己的一些
- #非法攻击。
- #下级路由器的限制
- /ip firewall mangle
- add action=change-ttl \
- chain=prerouting \
- comment="修改TTL,禁止二级路由" \
- disabled=no \
- new-ttl=decrement:1
- #===================================================================================
- #设置 ROS 服务端口
- #===================================================================================
- # 用不上的服务全部禁止掉
- # 参数 disabled yes 禁止 / no 允许
- / ip firewall service-port
- set ftp disabled=yes
- set h323 disabled=yes
- set irc disabled=yes
- set pptp disabled=yes
- set sip disabled=yes
- set tftp disabled=yes
- #===================================================================================
- #设置 ROS 访问防火墙
- #===================================================================================
- # 在些感谢 bbs.routerclub.com 论坛的 YAWPYNG 提供的脚本
- # 网址:http://bbs.routerclub.com/forum.php?mod=viewthread&tid=48223
- # 感谢 网大群 菩提祖师 提供的脚本
- # 通关密码是"*****" <---- 自定义变量里的数字
- # 在浏览器输入http://你的ROS IP:****
- # ROS 解析到"****"时 , 就自动将外网访问者的IP 加到白名单.
- # 再通过 WinBox 登录 你的ROS IP:****
- # ======== ROS本身的防火墙规则一定要在其它规则之前。 ==========
- # 变量 PassWD IP登录ROS时的通关密码
- # 变量 DropScanIPList 非法扫描IP列表名_黑名单
- # 变量 AcceptAdminIP 合法登录IP列表名_白名单
- :global PassWD "64888"
- :global DropScanIPList "DropScanIPList_List"
- :global AcceptAdminIP "AcceptAdminIP_List"
- /ip firewall filter
- add action=drop \
- chain=input \
- comment="封 非法扫描IP列表_黑名单" \
- disabled=no \
- src-address-list=$DropScanIPList
- /ip firewall filter
- add action=drop \
- chain=output \
- comment="禁止ping" \
- disabled=no \
- protocol=icmp
-
-
- /ip firewall filter
- add action=drop \
- chain=input \
- comment="封tracert路由跟踪" \
- disabled=no \
- icmp-options=11:0 \
- protocol=icmp
-
-
-
- #
- # PSD (Port scan detecting) 端口扫描检测技术是保护RouterOS路由器安全的一项有效技术。
- # 扫描开放的端口往往是黑客攻击的第一步,比如NMAP就是很好的端口扫描工具。
- # 在RouterOS加入以下规则 add chain=input protocol=tcp psd=21,3s,3,1 action=drop comment="detect and drop port scan connections" disabled=no
- # 可以有效阻断外部ip对RouterOS路由器的扫描。
- # Action中可以直接drop,或者先log,再drop, 还可以将对你进行的端口扫描的ip地址放入 address list,禁止这些ip对路由器的后续访问。
- # 但是 Psd=21,3s,3,1 这四个参数的具体含义又是什么呢?
- # iptables的官方文档是这样描述的
- # 第一个参数 21 -> Portscan detection weight threshold (端口扫描检测权重阈值)
- # 第二个参数 3s -> Portscan detection delay threshold (端口扫描检测延迟阈值)
- # 第三个参数 3 -> Privileged ports weight (1-1024端口权重)
- # 第四个参数 1 -> High ports weight (1024以上端口权重)
- #我来翻译一下,假设有一台机器对你的RouterOS路由器的不同端口持续发送一系列数据包,每两个数据包之间的时间间隔不超过3秒,这些包的目的端口如果是1024以下端口,
- #那么权重就记为3,如果目的端口是1024以上端口,则权重记为1,这些连续的包的权重将会被累加,如果累加的值超过21,将会启用以上的端口扫描检测防火墙规则,其后续的数据包将会被丢弃。
- #也就是说,对低端口连续发送7个至不同端口的数据包,或者对高端口发送21个,或者其混合权重达到21,都会触发该防火墙规则。
- #21,3s,3,1是默认参数,理解了以上参数的详细内容以后,可以根据自己的特定需求对其进行修改。
-
- /ip firewall filter
- add action=add-src-to-address-list \
- address-list=$DropScanIPList \
- address-list-timeout=2w \
- chain=input \
- comment="端口扫描 加入列表" \
- disabled=no \
- protocol=tcp \
- psd=21,3s,3,1
-
-
- /ip firewall filter
- add action=add-src-to-address-list \
- address-list=$DropScanIPList \
- address-list-timeout=2w \
- chain=input \
- comment="NMAP FIN 隐蔽扫描 加入列表" \
- disabled=no \
- protocol=tcp \
- tcp-flags=fin,!syn,!rst,!psh,!ack,!urg
-
-
-
- /ip firewall filter
- add action=add-src-to-address-list \
- address-list=$DropScanIPList \
- address-list-timeout=2w \
- chain=input \
- comment="SYN/FIN 扫描 加入列表" \
- disabled=no \
- protocol=tcp \
- tcp-flags=fin,syn
-
-
-
- /ip firewall filter
- add action=add-src-to-address-list \
- address-list=$DropScanIPList \
- address-list-timeout=2w \
- chain=input \
- comment="SYN/RST 扫描 加入列表" \
- disabled=no \
- protocol=tcp \
- tcp-flags=syn,rst
-
-
- /ip firewall filter
- add action=add-src-to-address-list \
- address-list=$DropScanIPList \
- address-list-timeout=2w \
- chain=input \
- comment="FIN/PSH/URG 扫描 加入列表" \
- disabled=no \
- protocol=tcp \
- tcp-flags=fin,psh,urg,!syn,!rst,!ack
-
-
- /ip firewall filter
- add action=add-src-to-address-list \
- address-list=$DropScanIPList \
- address-list-timeout=2w \
- chain=input \
- comment="ALL/ALL 扫描 加入列表" \
- disabled=no \
- protocol=tcp \
- tcp-flags=fin,syn,rst,psh,ack,urg
-
-
- /ip firewall filter
- add action=add-src-to-address-list \
- address-list=$DropScanIPList \
- address-list-timeout=2w \
- chain=input \
- comment="NMAP NULL 扫描IP 加入列表" \
- disabled=no \
- protocol=tcp \
- tcp-flags=!fin,!syn,!rst,!psh,!ack,!urg
-
-
-
- #通关密码功能,将外网访问者的IP 加到白名单
- #通关密码就是"64888" <---- 自己更改换成其它数字
- #在浏览器输入http://你的ROS IP:64888
- #ROS 解析到"64888"时 , 就自动将外网访问者的IP 加到address list.
- /ip firewall filter
- add action=add-src-to-address-list \
- address-list=$AcceptAdminIP \
- address-list-timeout=4w2d2h \
- chain=input \
- comment="将通关IP加入到_白名单" \
- disabled=no \
- dst-port=$PassWD \
- protocol=tcp \
- src-address-list=("!" . $AcceptAdminIP)
-
- #以下这一条是除了允许名单之外的IP 都拒绝访问自定义的 PORT
- /ip firewall filter
- add action=drop \
- chain=input \
- comment="禁止所有 非白名单 IP 访问 ROS登录端口" \
- disabled=no \
- dst-port=$RosPort \
- protocol=tcp \
- src-address-list=("!" . $AcceptAdminIP)
复制代码 |
|