powermolelib package¶
Submodules¶
powermolelib.bootstrapagent module¶
Main code for bootstrapping agent.
NOTE: The BootstrapAgent class is responsible to purge the stream (ie. index in stream is at COMMAND_PROMPT)
-
class
powermolelib.bootstrapagent.BootstrapAgent(tunnel, group_ports, deploy_path='/tmp')[source]¶ Bases:
powermolelib.logging.LoggerMixinResponsible for executing the python agent module.
powermolelib.instructor module¶
Main code for instructor.
-
class
powermolelib.instructor.ForInstructor(group_ports)[source]¶ Bases:
powermolelib.instructor.InstructorProvides interaction with the Agent, which resides on target destination host, to accommodate FOR mode.
Functions: - forwards connections (FOR) implicitly, because SSH is responsible for forwarding connections, not the Agent - interaction with the heartbeat responder - provide access to OS services (COMMAND) - transfer files (TRANSFER)
-
class
powermolelib.instructor.Instructor(group_ports)[source]¶ Bases:
abc.ABC,powermolelib.logging.LoggerMixinModels an Instructor to interact with the Agent residing on target destination host.
Note: As the Agent sits on top of target destination hosts’ OS, many functions can be performed more effectively.
-
class
powermolelib.instructor.PlainInstructor(group_ports)[source]¶ Bases:
powermolelib.instructor.InstructorProvides interaction with the Agent, which resides on target destination host, to accommodate FOR mode.
Functions: - interaction with the heartbeat responder - provide access to OS services (COMMAND) - transfer files (TRANSFER)
-
class
powermolelib.instructor.TorInstructor(group_ports, outbound_address, inbound_address='localhost')[source]¶ Bases:
powermolelib.instructor.InstructorProvides interaction with the Agent, which resides on target destination host, to accommodate Tor mode.
Functions: - proxify internet traffic (TOR) - interaction with the heartbeat responder - provide access to OS services (COMMAND) - transfer files (TRANSFER)
powermolelib.logging module¶
Main code for logging.
powermolelib.miscellaneous module¶
Main code for miscellaneous.
-
class
powermolelib.miscellaneous.Configuration(config_file)[source]¶ Bases:
powermolelib.logging.LoggerMixinParses the configuration file and composes the local forwarding string (SSH -L).
-
class
powermolelib.miscellaneous.Heartbeat(local_heartbeat_port, heartbeat_interval=10)[source]¶ Bases:
powermolelib.logging.LoggerMixinDetermines periodically the state of the tunnel.
An KeyboardInterrupt, which is an exception, will propagate through this class and exits this class.
Note: Research if threading with Event.wait or multiprocessing is a better approach.
-
class
powermolelib.miscellaneous.StateManager[source]¶ Bases:
powermolelib.logging.LoggerMixinCleans up objects (eg. Tunnel, Assistant) when exiting.
An KeyboardInterrupt, which is an exception, will be caught by this class, or specifically, by __exit__(). Consequently, this method will invoke the _clean_up() to stop all instantiated objects.
-
powermolelib.miscellaneous.start_application(binary_name, binary_location)[source]¶ Starts the application.
-
powermolelib.miscellaneous.write_ssh_config_file(path_ssh_cfg_minitor, gateways, destination)[source]¶ Writes the configuration file with ProxyJump directives for ssh.
The IdentityFile cannot be given as a run-time parameter. Therefore, we resort to a directive in a config file
Returns: True on success, False otherwise. Return type: bool
powermolelib.powermolelibexceptions module¶
Custom exception code for minitorcorelib.
-
exception
powermolelib.powermolelibexceptions.InvalidConfigurationFile[source]¶ Bases:
ExceptionThe configuration file provided is not valid.
powermolelib.transferagent module¶
Main code for transferagent.
NOTE: The TransferAgent class is responsible to purge the stream (ie. index in stream is at COMMAND_PROMPT)
-
class
powermolelib.transferagent.TransferAgent(path_ssh_cfg, all_host_addr, deploy_path='/tmp')[source]¶ Bases:
powermolelib.logging.LoggerMixinEstablishes a connection to the target destination host via one or more intermediaries.
powermolelib.tunnel module¶
Main code for tunnel.
NOTE: The Tunnel classes are responsible to purge the stream (ie. index in stream is at COMMAND_PROMPT)
-
class
powermolelib.tunnel.Tunnel(path_ssh_cfg, mode, all_host_addr, group_ports, forward_connections=None)[source]¶ Bases:
powermolelib.logging.LoggerMixinEstablishes a connection to the target destination host via one or more intermediaries.
Be aware, the child’s buffer needs to be purged periodically. This can be done by invoking periodically_purge_buffer(). As verbose mode is enabled for SSH (the child process), it will slowly fill up the buffer, so this has to be taken care of. But don’t invoke this method before having start()’ed BootstrapAgent.
-
periodically_purge_buffer()[source]¶ Purges the child’s (SSH) output buffer due to buffer limitations.
-
start(debug=None)[source]¶ Establishes an SSH tunnel.
It determines along the way if the authentication process is successful.
In addition, this method and mines for ‘Authenticated’ keywords, so we can keep track which hosts have been connected through.
SSH is here a ‘child application’.
Parameters: debug (basestring) – if True, TIMEOUT will not be raised and may block indefinitely. Use only for debugging purposes to capture the output of the child, which is essentially, hidden ‘under the hood’, and write it to a file.
-
Module contents¶
Import all parts from all modules here.