Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Commit

Permalink
Add new interface for adding alive test methods
Browse files Browse the repository at this point in the history
Instead of using a bit flag which entails all
alive tests we can now also use xml elements for
every alive test method.
  • Loading branch information
ArnoStiefvater committed Aug 31, 2020
1 parent a903784 commit 2876c6b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions ospd/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,32 @@ def process_credentials_elements(cred_tree: Element) -> Dict:

return credentials

@staticmethod
def process_alive_test_methods(cred_tree: Element, options: Dict) -> None:
""" Receive an XML object with the alive test methods to run
a scan with. Methods are added to the options Dict.
@param
<alive_test_methods>
</icmp></icmp>
</tcp_ack></tcp_ack>
</tcp_syn></tcp_syn>
</arp></arp>
</consider_alive>0</consider_alive>
</alive_test_methods>
"""
for child in cred_tree:
if child.tag == 'icmp':
options['icmp'] = child.text
if child.tag == 'tcp_ack':
options['tcp_ack'] = child.text
if child.tag == 'tcp_syn':
options['tcp_syn'] = child.text
if child.tag == 'arp':
options['arp'] = child.text
if child.tag == 'consider_alive':
options['consider_alive'] = child.text

@classmethod
def process_target_element(cls, scanner_target: Element) -> Dict:
"""Receive an XML object with the target, ports and credentials to run
Expand Down Expand Up @@ -222,6 +248,9 @@ def process_target_element(cls, scanner_target: Element) -> Dict:
ports = child.text
if child.tag == 'credentials':
credentials = cls.process_credentials_elements(child)
if child.tag == 'alive_test_methods':
options['alive_test_methods'] = '1'
cls.process_alive_test_methods(child, options)
if child.tag == 'alive_test':
options['alive_test'] = child.text
if child.tag == 'alive_test_ports':
Expand Down

0 comments on commit 2876c6b

Please sign in to comment.