| from string import Template |
| from TdcPlugin import TdcPlugin |
| print("Unable to import the scapy python module.") |
| print("\nIf not already installed, you may do so with:") |
| print("\t\tpip3 install scapy==2.4.2") |
| class SubPlugin(TdcPlugin): |
| self.sub_class = 'scapy/SubPlugin' |
| if 'scapy' not in self.args.caseinfo: |
| print('{}.post_execute: no scapy info in test case'.format(self.sub_class)) |
| # Check for required fields |
| scapyinfo = self.args.caseinfo['scapy'] |
| scapy_keys = ['iface', 'count', 'packet'] |
| print('{}: Scapy block present in the test, but is missing info:' |
| print('{}'.format(missing_keys)) |
| pkt = eval(scapyinfo['packet']) |
| if '$' in scapyinfo['iface']: |
| tpl = Template(scapyinfo['iface']) |
| scapyinfo['iface'] = tpl.safe_substitute(NAMES) |
| for count in range(scapyinfo['count']): |
| sendp(pkt, iface=scapyinfo['iface']) |