:mod:`expliot.core.tests.test` ============================== .. py:module:: expliot.core.tests.test Module Contents --------------- .. py:class:: TCategory(proto, iface, action) Bases: :class:`collections.namedtuple()` TCategory class The class that defines the category of the test case. It is part of the Test class member _category. It can be used to identify the type of test or search for a specific category. It is a namedtuple that defines three attributes (for categorizing test cases) 1. proto - What protocol does the test use 2. iface - Interface of the test i.e. whether it is for software or hardware 3. action - What action does the test perform i.e. is it an exploit or a recon test for example. .. attribute:: COAP :annotation: = coap .. attribute:: MQTT :annotation: = mqtt .. attribute:: UDP :annotation: = udp .. attribute:: MODBUS :annotation: = modbus .. attribute:: DICOM :annotation: = dicom .. attribute:: BLE :annotation: = ble .. attribute:: ZIGBEE :annotation: = zigbee .. attribute:: CAN :annotation: = can .. attribute:: UART :annotation: = uart .. attribute:: JTAG :annotation: = jtag .. attribute:: I2C :annotation: = i2c .. attribute:: SPI :annotation: = spi .. attribute:: _protocols .. attribute:: SW :annotation: = software .. attribute:: HW :annotation: = hardware .. attribute:: RD :annotation: = radio .. attribute:: _interfaces .. attribute:: RECON :annotation: = recon .. attribute:: DISCOVERY :annotation: = discovery .. attribute:: ANALYSIS :annotation: = analysis .. attribute:: FUZZ :annotation: = fuzz .. attribute:: EXPLOIT :annotation: = exploit .. attribute:: _actions .. py:class:: TTarget(name, version, vendor) Bases: :class:`collections.namedtuple()` TTarget class Class that hold details about the target of the test. It is a namedtuple and holds the below details: 1. name - Target/product name 2. version - Version of the product 3. vendor - Vendor that owns the product Please note, in case it is a generic test case that can be used for multiple products use Target.GENERIC for all attributes .. attribute:: GENERIC :annotation: = generic .. py:class:: TResult Representation of a test result. .. attribute:: defaultrsn :annotation: = No reason specified .. method:: setstatus(self, passed=True, reason=None) Set the Test result status. :param passed: True or False :param reason: Reason for failure if any :return: .. method:: exception(self) Set passed to False and reason to the exception message. :return: .. py:class:: TLog TLog Logger class for logging test case output. By default log to sys.stdout Must not instantiate. Use class methods. The logger needs to be initialized with the output file using init() class method .. attribute:: _f .. attribute:: _spre :annotation: = [+] .. attribute:: _fpre :annotation: = [-] .. attribute:: _tpre :annotation: = [?] .. attribute:: _gpre :annotation: = [*] .. classmethod:: init(cls, file=None) Initialize the file object. This method should be called in the beginning of the application to open the log output file. :param file: The file where to log Test output :return: void .. classmethod:: close(cls) Close the file object if it is not sys.stdout. :return: .. classmethod:: _p(cls, prefix, msg) The actual print methods that write the formatted message to the _f file. :param prefix: the prefix to be used for the message (defined above) :param msg: The actual message from the Test object :return: void .. classmethod:: success(cls, msg) Write a message with success prefix to the file. :param msg: The message to be written :return: void .. classmethod:: fail(cls, msg) Write a message with fail prefix to the file. :param msg: The message to be written :return: void .. classmethod:: trydo(cls, msg) Write a message with try prefix to the file. :param msg: The message to be written :return: void .. classmethod:: generic(cls, msg) Write a message with success prefix to the file. :param msg: The message to be written :return: void .. py:class:: Test(**kwargs) Test The Base class for test cases (plugins). It defines the basic interface and basic implementation for the test cases. All test case plugins need to inherit from a test class derived from this class or this class itself depending on the purpose of the test case. .. method:: pre(self) .. method:: post(self) .. method:: execute(self) .. method:: intro(self) .. method:: run(self, arglist) .. method:: _assertpriv(self) Raise an exception if the plugin needs root privileges but program is not executing as root. :return: .. method:: _setid(self) Set the Unique Test ID. The ID is the plugin class name in lower case. :return: .. method:: _logstatus(self) Handle the log status. :return: