conpot.tests package¶
Subpackages¶
Submodules¶
conpot.tests.test_bacnet_server module¶
-
class
conpot.tests.test_bacnet_server.
TestBACnetServer
(methodName='runTest')¶ Bases:
unittest.case.TestCase
All tests are executed in a similar way. We initiate a service request to the BACnet server and wait for response. Instead of decoding the response, we create an expected response. We encode the expected response and compare the two encoded data.
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_no_response_requests
()¶ When the request has apduType not 0x01, no reply should be returned from Conpot
-
test_readProperty
()¶
-
test_whoHas
()¶
-
test_whoIs
()¶
-
conpot.tests.test_base module¶
conpot.tests.test_docs module¶
conpot.tests.test_enip_server module¶
-
class
conpot.tests.test_enip_server.
TestENIPServer
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
attribute_operations
(paths, int_type=None, **kwds)¶
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_list_identity_tcp
()¶
-
test_list_identity_udp
()¶
-
test_list_interfaces_tcp
()¶
-
test_list_interfaces_udp
()¶
-
test_list_services_tcp
()¶
-
test_list_services_udp
()¶
-
test_malformend_request_tcp
()¶
-
test_malformend_request_udp
()¶
-
conpot.tests.test_ext_ip_util module¶
-
class
conpot.tests.test_ext_ip_util.
TestExtIPUtil
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_ext_util
()¶
-
test_fetch_ext_ip
()¶
-
test_ip_verify
()¶
-
conpot.tests.test_ftp module¶
-
class
conpot.tests.test_ftp.
TestFTPServer
(methodName='runTest')¶ Bases:
unittest.case.TestCase
All tests are executed in a similar way. We run a valid/invalid FTP request/command and check for valid response. Testing is done by sending/receiving files in data channel related commands. Implementation Note: There are no explicit tests for active/passive mode. These are covered in list and nlst tests
-
refresh_client
()¶ Disconnect and reconnect a client
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_abor
()¶
-
test_allo
()¶
-
test_appe
()¶
-
test_auth
()¶ Test for user, pass and quit commands.
-
test_cwd
()¶
-
test_dele
()¶
-
test_file_rename
()¶
-
test_help
()¶
-
test_list
()¶
-
test_max_retries
()¶ client should raise an error when max retries are reached.
-
test_mdtm
()¶
-
test_mkd
()¶
-
test_mode
()¶
-
test_nlist
()¶
-
test_noop
()¶
-
test_pwd
()¶
-
test_rein
()¶
-
test_rest
()¶
-
test_retr
()¶ Test retr or downloading a file from the server.
-
test_rmd
()¶
-
test_site
()¶
-
test_site_chmod
()¶
-
test_site_help
()¶
-
test_size
()¶
-
test_stat
()¶
-
test_stor
()¶
-
test_stou
()¶
-
test_stru
()¶
-
test_syst
()¶
-
test_type
()¶
-
conpot.tests.test_guardian_ast module¶
-
class
conpot.tests.test_guardian_ast.
TestGuardianAST
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_I20100
()¶
-
test_I20200
()¶
-
test_I20300
()¶
-
test_I20400
()¶
-
test_I20500
()¶
-
test_S60200
()¶
-
test_S60201
()¶
-
test_S60202
()¶
-
test_S60203
()¶
-
test_S60204
()¶
-
test_ast_error
()¶
-
conpot.tests.test_hpfriends module¶
conpot.tests.test_http_server module¶
-
class
conpot.tests.test_http_server.
TestHTTPServer
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_do_HEAD
()¶ Objective: Test the web server by sending a HTTP HEAD request. Should be responded back by the valid HTTP headers
-
test_do_OPTIONS
()¶ Objective: Test the web server by sending a valid OPTIONS HTTP request
-
test_do_POST
()¶ Objective: send a POST request to a invalid URI. Should get a 404 response
-
test_do_TRACE
()¶ Objective: Test the web server with a trace request
-
test_http_backend_databus
()¶ Objective: Test if http backend is able to retrieve data from databus
-
test_http_backend_tarpit
()¶ Objective: Test if http tarpit delays responses properly
-
test_http_request_base
()¶ Objective: Test if http service delivers data on request
-
test_http_subselect_trigger
()¶ Objective: Test if http subselect triggers work correctly
-
test_not_implemented_method
()¶ Objective: PUT HTTP method is not implemented in Conpot, should raise 501
-
conpot.tests.test_iec104_server module¶
-
class
conpot.tests.test_iec104_server.
TestIEC104Server
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_startdt
()¶ Objective: Test if answered correctly to STARTDT act
-
test_testfr
()¶ Objective: Test if answered correctly to TESTFR act
-
test_write_for_non_existing
()¶ Objective: Test answer for a command to a device that doesn’t exist (Correct behaviour of the IEC104 protocol is not known exactly. Other case is test for no answer)
-
test_write_no_relation_for_existing
()¶ Objective: Test answer for a correct command to a device that does exist and has no related sensor (Actuator 22_19 (Type 45: Single Command) will be tested, the corresponding(!) sensor is not existent)
-
test_write_relation_for_existing
()¶ Objective: Test answer for a correct command to a device that does exist and has a related sensor (Actuator 22_20 (Type 45: Single Command) will be tested, the corresponding(!) sensor 13_20 (Type 1: Single Point Information) changes the value and the termination confirmation is returned)
-
test_write_wrong_type_for_existing
()¶ Objective: Test answer for a command of wrong type to a device that does exist (Actuator 22_20 (Type 45: Single Command) will be tested, but a wrong command type (Double Commands instead of Single Command) is sent to device)
-
conpot.tests.test_ipmi_server module¶
-
class
conpot.tests.test_ipmi_server.
TestIPMI
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_boot_device
()¶ Objective: test boot device get and set
-
test_channel_get_access
()¶
-
test_chassis_status
()¶
-
test_misc
()¶
-
test_power_state
()¶ Objective: test power on/off/reset/cycle/shutdown
-
test_user_list
()¶
-
-
conpot.tests.test_ipmi_server.
run_cmd
(cmd, port)¶
conpot.tests.test_kamstrup_decoder module¶
conpot.tests.test_kamstrup_management_protocol module¶
-
class
conpot.tests.test_kamstrup_management_protocol.
TestKamstrupManagementProtocol
(methodName='runTest')¶ Bases:
unittest.case.TestCase
All tests work in similar way. We send a get command check for a valid reply. We send in set command and expect things to change in the databus.
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_access_control_command
()¶
-
test_alarm_server_command
()¶
-
test_get_config_command
()¶
-
test_get_software_version_command
()¶
-
test_help_command
()¶
-
test_request_connect_command
()¶
-
test_set_config_command
()¶
-
test_set_device_name_command
()¶
-
test_set_ip_command
()¶
-
test_set_kap1_command
()¶
-
test_set_kap2_command
()¶
-
test_set_lookup_command
()¶
-
test_set_name_server_command
()¶
-
test_set_ports_command
()¶
-
test_set_serial_command
()¶
-
test_set_watchdog_command
()¶
-
-
conpot.tests.test_kamstrup_management_protocol.
check_command_resp_help_message
(packet_type, help_msg_command, packet_msg_command, kamstrup_management_server)¶
conpot.tests.test_kamstrup_meter_protocol module¶
conpot.tests.test_logger_json module¶
conpot.tests.test_logger_mysql module¶
conpot.tests.test_mac_addr module¶
-
class
conpot.tests.test_mac_addr.
TestMacAddrUtil
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_mac
()¶ Objective: Test if the spoofer is able to change MAC address
-
conpot.tests.test_modbus_server module¶
-
class
conpot.tests.test_modbus_server.
TestModbusServer
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_modbus_logging
()¶ Objective: Test if modbus generates log messages as expected. Expected output is a dictionary with the following structure: {‘timestamp’: datetime.datetime(2013, 4, 23, 18, 47, 38, 532960),
‘remote’: (‘127.0.0.1’, 60991), ‘data_type’: ‘modbus’, ‘id’: ‘01bd90d6-76f4-43cb-874f-5c8f254367f5’, ‘data’: {‘function_code’: 1,
‘slave_id’: 1, ‘request’: ‘0100010080’, ‘response’: ‘0110ffffffffffffffffffffffffffffffff’}}
-
test_read_coils
()¶ Objective: Test if we can extract the expected bits from a slave using the modbus protocol.
-
test_read_nonexistent_slave
()¶ Objective: Test if the correct exception is raised when trying to read from nonexistent slave.
-
test_report_slave_id
()¶ Objective: Test conpot for function code 17.
-
test_response_function_43_device_info
()¶
-
test_write_read_coils
()¶ Objective: Test if we can change values using the modbus protocol.
-
conpot.tests.test_proxy module¶
conpot.tests.test_pysnmp_wrapper module¶
-
class
conpot.tests.test_pysnmp_wrapper.
TestPySNMPWrapper
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
test_compile
()¶ Tests that the wrapper can output mib files.
-
test_find
()¶ Tests that the wrapper can find mib files.
-
test_wrapper_output
()¶ Tests that the wrapper generates output that can be consumed by the command responder.
-
test_wrapper_processing
()¶ Tests that the wrapper can process a valid mib file without errors.
-
-
conpot.tests.test_pysnmp_wrapper.
check_content
(pyfile)¶
conpot.tests.test_s7_server module¶
-
class
conpot.tests.test_s7_server.
TestS7Server
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_s7
()¶ Objective: Test if the S7 server returns the values expected.
-
conpot.tests.test_snmp_server module¶
-
class
conpot.tests.test_snmp_server.
TestSNMPServer
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
mock_callback
(sendRequestHandle, errorIndication, errorStatus, errorIndex, varBindTable, cbCtx)¶
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_snmp_get
()¶ Objective: Test if we can get data via snmp_get
-
test_snmp_set
()¶ Objective: Test if we can set data via snmp_set
-
conpot.tests.test_taxii module¶
-
class
conpot.tests.test_taxii.
TestLoggers
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
test_stix_transform
()¶ Objective: Test if our STIX xml can be validated.
-
test_taxii
()¶ Objective: Test if we can transmit data to MITRE’s TAXII test server. Note: This actually also tests the StixTransformer since the event is parsed by the transformer before transmission.
-
conpot.tests.test_tftp module¶
-
class
conpot.tests.test_tftp.
TestTFTPServer
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_mkdir_upload
()¶ Testing TFTP upload files - while recursively making directories as per the TFTP path.
-
test_tftp_download
()¶
-
test_tftp_upload
()¶ Testing TFTP upload files.
-
conpot.tests.test_vfs module¶
Test core features for Conpot’s virtual file system
-
class
conpot.tests.test_vfs.
TestFileSystem
(methodName='runTest')¶ Bases:
unittest.case.TestCase
Tests related to Conpot’s virtual file system.
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_access
()¶
-
test_chmod
()¶
-
test_chown
()¶
-
test_copydir
()¶
-
test_copyfile
()¶
-
test_format_list
()¶
-
test_get_cwd
()¶
-
test_get_permissions
()¶
-
test_getmtime
()¶
-
test_jail
()¶ Test for checking chroot jail a subfilesystem
-
test_listdir
()¶
-
test_mkdir
()¶
-
test_mkdirs
()¶
-
test_movedir
()¶
-
test_movefile
()¶
-
test_open_dir
()¶
-
test_open_file
()¶
-
test_openbin_file
()¶
-
test_readlink
()¶
-
test_remove
()¶
-
test_removedir
()¶
-
test_snapshot
()¶
-
test_stat
()¶
-
test_utime
()¶
-
-
class
conpot.tests.test_vfs.
TestSubFileSystem
(methodName='runTest')¶ Bases:
unittest.case.TestCase
Tests related to Conpot’s virtual sub file system. This would test fs generated folders for each and every protocol.
-
setUp
()¶ Hook method for setting up the test fixture before exercising it.
-
tearDown
()¶ Hook method for deconstructing the test fixture after testing it.
-
test_access
()¶
-
test_chmod
()¶
-
test_chown
()¶
-
test_format_list
()¶
-
test_get_cwd
()¶
-
test_get_permissions
()¶
-
test_listdir
()¶
-
test_mkdir
()¶
-
test_mkdirs
()¶
-
test_open_file
()¶
-
test_readlink
()¶
-
test_remove
()¶
-
test_removedir
()¶
-
test_set_time
()¶ Test for changing time in the file system.
-
test_stat
()¶
-
test_utime
()¶
-