ducky.tools.vm module¶
-
class
ducky.tools.vm.
DuckyProtocol
(logger, options, config)[source]¶ Bases:
autobahn.twisted.websocket.WebSocketServerProtocol
Protocol handling communication between VM and remote terminal emulator.
Parameters: - logger (logging.Logger) –
Logger
instanceto use for logging. - options – command-line options, as returned by option parser.
- config (ducky.config.MachineConfig) – VM configuration.
-
_machines
= []¶
-
onClose
(wasClean, code, reason)[source]¶ Called when connection ends. Tell VM to halt, and wait for its thread to finish. Then, print some VM stats.
-
onMessage
(payload, isBinary)[source]¶ Called when new data arrived from client. Feeds the data to VM’s input stream.
See
autobahn.twisted.websocket.WebSocketServerProtocol.onMessage()
.
- logger (logging.Logger) –
-
class
ducky.tools.vm.
DuckySocketServerFactory
(logger, options, config, *args, **kwargs)[source]¶ Bases:
autobahn.twisted.websocket.WebSocketServerFactory
-
class
ducky.tools.vm.
WSInputStream
(protocol, *args, **kwargs)[source]¶ Bases:
ducky.streams.InputStream
Websocket input stream, receiving bytes from opened websocket, and pushing them to keyboard frontend device.
Stream has an internal LIFO buffer that is being fed by protocol, and consumed by VM frontend device.
Parameters: protocol (DuckyProtocol) – protocol instance with opened websocket. -
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 39¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
enqueue
(buff)[source]¶ Called by protocol instance, to add newly received data to stream’s buffer.
Parameters: buff (bytearray) – recerived bytes.
-
-
class
ducky.tools.vm.
WSOutputStream
(protocol, *args, **kwargs)[source]¶ Bases:
ducky.streams.OutputStream
Websocket output stream, receiving bytes from TTY frontend, and pushing them to protocol’s socket.
Parameters: protocol (DuckyProtocol) – protocol instance with opened websocket. -
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 39¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
-
ducky.tools.vm.
process_config_options
(logger, options, config_file=None, set_options=None, add_options=None, enable_devices=None, disable_devices=None)[source]¶ Load VM config file, and apply all necessary changes, as requested by command-line options.
Parameters: - logger (logging.Logger) –
Logger
instance to use for logging. - options – command-line options, as returned by option parser.
- config_file (string) – path to configuration file.
Return type: Returns: VM configuration.
- logger (logging.Logger) –