-
Notifications
You must be signed in to change notification settings - Fork 36
Add new interface for adding alive test methods #329
Changes from 1 commit
2927cc7
2a24d95
a084038
384756c
4a5305b
f22f3f5
eaa4f32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these methods optional? shouldn't be added only if they are set? Not sure if it make sense to add and empty element to the options dict. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the options (imcp, tcp_ack ...) are optional. For example if you do not want icmp then you can either leave it out completely, set it to '0' or leave it empty. Everything not '1' is treated as not wanted. Should I check if child.text is None and not include it in the options dict? Just an additional remark. If <alive_test> and <alive_test_methods> is provided, <alive_test> takes precedence over <alive_test_methods>. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have now added a test for None. So if there is no text it will not be included options dict. |
||
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 | ||
|
@@ -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': | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a more descriptive param name.