【问题标题】:how to parse CISCO IPS configuration? [closed]如何解析 CISCO IPS 配置? [关闭]
【发布时间】:2012-11-05 10:04:12
【问题描述】:

我需要一个工具或脚本来解析 Cisco IPS 配置,我知道有一个名为 nipper 的工具用于解析防火墙和交换机配置,但我不支持 Cisco IPS,我在 google 上搜索了它但没有好的结果。

【问题讨论】:

  • 你能给出一个示例配置以及你试图从中解析什么吗?
  • 它就像一个普通的 IPS 配置文件,我需要一个工具来审核它并针对已知漏洞或错误配置问题检查配置。

标签: networking network-programming firewall cisco network-security


【解决方案1】:

你应该使用ciscoconfparse

以下示例使用下面的 Cisco 配置...我不能使用 IPS 配置,除非 OP 发布...这使用 Cisco IOS 配置...

以下脚本将从/tftpboot/bucksnort.conf 加载配置文件并使用CiscoConfParse.find_lines() 解析它以获取所有串行接口的名称。注意搜索字符串开头的^符号是正则表达式; ^interface Serial 告诉 python 将搜索限制在以 interface Serial 开头的行。

[mpenning@typo tmp]$ python
Python 2.6.6 (r266:84292, Sep 11 2012, 08:34:23)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ciscoconfparse import CiscoConfParse
>>> parse = CiscoConfParse("/tftpboot/bucksnort.conf")
>>> serial_intfs = parse.find_lines("^interface Serial")
>>>
>>> serial_intfs
['interface Serial1/0', 'interface Serial1/1', 'interface Serial1/2']
>>>
>>> qos_intfs = parse.find_parents_w_child( "^interf", "service-policy output QOS_1" )
>>> qos_intfs
['interface Serial1/1']

! Filename: /tftpboot/bucksnort.conf
!
policy-map QOS_1
 class GOLD
  priority percent 10
 class SILVER
  bandwidth 30
  random-detect
 class default
!
interface Ethernet0/0
 ip address 1.1.2.1 255.255.255.0
 no cdp enable
!
interface Serial1/0
 encapsulation ppp
 ip address 1.1.1.1 255.255.255.252
!
interface Serial1/1
 encapsulation ppp
 ip address 1.1.1.5 255.255.255.252
 service-policy output QOS_1
!
interface Serial1/2
 encapsulation hdlc
 ip address 1.1.1.9 255.255.255.252
!
class-map GOLD
 match access-group 102
class-map SILVER
 match protocol tcp
!
access-list 101 deny tcp any any eq 25 log
access-list 101 permit ip any any
!
access-list 102 permit tcp any host 1.5.2.12 eq 443
access-list 102 deny ip any any
!
logging 1.2.1.10
logging 1.2.1.11
logging 1.2.1.12

【讨论】:

  • 你可以举一个简短的例子,也许?
  • 它不是自动化工具,它只是让审查配置更容易,对吧??
  • @kingasmk,如果不提前了解需求,审计就无法自动化,所以是的,你是对的......这是用于构建审计脚本的脚本工具。
猜你喜欢
  • 1970-01-01
  • 2011-12-01
  • 1970-01-01
  • 2012-03-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多