AlgoSec修改天融信取配置命令

来源:互联网 发布:linux重启网络 编辑:程序博客网 时间:2024/06/04 19:22

1. 问题原因

AlgoSec对于天融信支持不是太好,不能做防火墙规则分析不说,连仅有的查看变更历史的功能都有问题。原因是,AlgoSec在天融信上取配置的命令是show,会把--More--这样的提示符当成配置给取走。于是在变更分析时,会像下面这样:
More...上下被认为是变更
EXM?就因为加了个对象导致某一行从--More--上面移到下面,就多出一处变更?囧……而且天融信也没办法像Juniper那样进行全局设置,使得执行show时默认显示所有策略。所以只能从AlgoSec上想办法了。
另外,AlgoSec取完配置之后,不能成功退出。如果取配置的时间间隔小于天融信的用户登录超时时间,就会导致其他用户无法登录。

2. 解决方案

AlgoSec里有个功能,叫自定义防火墙品牌,即对于AlgoSec不支持的防火墙,也可以通过写配置文件、添加自定义防火墙品牌的方式进行纳管。实际上,AlgoSec内置支持的防火墙品牌也是通过这种方式添加的。
首先要找到天融信的配置文件:

[root@SEC_AFA_1 ~]# find / -name topsec
/usr/share/fa/data/plugins/topsec
[root@SEC_AFA_1 ~]# ls /usr/share/fa/data/plugins/topsec
brand_config.xml brand_config.xml.md5 icon_topsec_big.gif icon_topsec.gif
[root@SEC_AFA_1 ~]# cd /usr/share/fa/data/plugins/topsec/
[root@SEC_AFA_1 topsec]# cat brand_config.xml.md5
9e7c227e03748d1e5b9ec45165ff1f5c 1.35

这里配置文件就是brand_config.xml,注意到这里还有一个brand_config.xml.md5计算了配置文件的md5,并且加了盐。所以直接改配置文件肯定是不可以的。继续查找,发现了这么一个文件:

[root@SEC_AFA_1 plugins]# pwd
/usr/share/fa/data/plugins
[root@SEC_AFA_1 plugins]# cat brand_configuration_template.xml
<!–
DEVICE - main tag for device
id - id of device brand (the name of directory of the file have to be equal to device id , don’t change it )
name - name of brand, optional
title - title of brand, appear on data collection page of gui, optional
–>


<!– General Notes
There are default parametrs %<attribute name>% : “password”, “user_name”, “host_name”
For install new device brand :
- create configuration file
- put small and big images for the brand to directory of configuration file with names
icon_<brand_id>.gif and icon_<brand_id>_big.gif
- run fa_install_plugin <configuration file path>
–>

看到这里就简单了。我们把原来天融信的配置复制为一个新品牌,修改后导入。方法为:

[root@SEC_AFA_1 plugins]# mkdir tianrongxin
[root@SEC_AFA_1 plugins]# cp topsec/* tianrongxin/
[root@SEC_AFA_1 plugins]# cd tianrongxin/
[root@SEC_AFA_1 tianrongxin]# ls
brand_config.xml brand_config.xml.md5 icon_topsec_big.gif icon_topsec.gif
[root@SEC_AFA_1 tianrongxin]# mv icon_topsec_big.gif icon_tianrongxin_big.gif
[root@SEC_AFA_1 tianrongxin]# mv icon_topsec.gif icon_tianrongxin.gif
[root@SEC_AFA_1 tianrongxin]# rm -f brand_config.xml.md5
[root@SEC_AFA_1 tianrongxin]# vim brand_config.xml

修改:

  • 所有topsec字样都替换为tianrongxin
  • 修改执行的命令:
<COMMANDS_SEQUENCE>    <CMD id="1" command="network route show" save_output="yes" use_listener="yes" skip_on_def="yes" extra_timeout="3"/>    <CMD id="2" command="show nostop" save_output="yes" use_listener="yes" skip_on_def="yes"/>    <CMD id="3" command="system version" save_output="yes" use_listener="yes" skip_on_def="yes"/>    <CMD id="4" command="exit" save_output="yes" use_listener="yes" skip_on_def="yes" prompt="Save system config\?\[Y/N\]:" /></COMMANDS_SEQUENCE><!-- Command to finish connection --><EXIT_COMMAND command="N"/>

这里主要的改动为:
1. 把CMD2的show改为了show nostop
2. 增加了CMD4作为退出命令,因为天融信即使是审计账号,退出时也会问题是否要保存配置,所以要更改提示符;
3. 注意,这里的提示符需要输入正则表达式,Save system config?[Y/N]:中的特殊字符要进行转义,否则无法匹配。
4. 退出命令由exit改为N,即不保存配置。
保存之后导入:

[root@SEC_AFA_1 plugins]# /usr/share/fa/bin/fa_install_plugin tianrongxin/brand_config.xml
Check correctness of tianrongxin/brand_config.xml
Installing plugin for tianrongxin

此后,所有的天融信设备都改为tianrongxin这一类型即可。

阅读全文
0 0