Source

imalse / scenario / infecting / client_cmd.py

Full commit
"""

This file contains the Client Command Meta Description for the infecting
scenario.

"""

from core.real.node import PhysicalNode
from core.nodes.client import ClientCMD as CCMD

CLIENT_DESC = {
        'initial' : 'disconn',
        'start_action' : 'request_connect',
        'srv_addr':'127.0.0.1',
        # 'srv_addr':'10.0.0.0',
        'srv_port':3333,
        'request_timeout':10,
        }

class ClientCMD(CCMD):
    
    """This class is a subclass of ClientCMD."""
    
    def __init__(self, desc=None):
        """Initialize."""
        if desc == None:
            desc = CLIENT_DESC
            
        CCMD.__init__(self, desc)

    def find_vul_machines(self):
        """Find vulnerable machines and return the ip addresses."""
        pass

    def infect(self):
        """Try to infect a neighbor."""

    def send_ping(self, sock, data):
        """Send a ping."""
        self.node.ping(sock, data, threaded=True)

    def stop_ping(self, sock):
        """Stop sending pings."""
        self.node.stop_app(sock, 'ping')

if __name__ == "__main__":
    cmd = ClientCMD()
    node = PhysicalNode()
    cmd.install(node)
    node.start()