RubotSoftware: agentWORM.py

File agentWORM.py, 2.1 KB (added by arod, 14 years ago)
Line 
1import commands
2import os
3import re
4import signal
5import sys
6import shutil
7import socket
8import subprocess
9import time
10
11from backend.addon import services
12from backend.agent import Agent
13from backend.variables import *
14from util.platform import spawn, run
15from testbed import testbed
16
17class wormAgent(Agent):
18        """
19                The wormAgent controls the propagation of a simple IRC controlled worm.
20        """
21
22        DEPENDS = []
23        SOFTWARE = []
24
25        AGENTGROUP = 'Attack'
26        AGENTTYPE = 'WORM'
27        NICENAME = 'Worm'
28        COMMANDS = [
29                'STARTIRC','STOPIRC',
30                'STARTBOT','STOPBOT']
31        VARIABLES = [
32                NodeVar('IRCHost', None, 'IRC Host', 'Select the node to run the IRC server'),   
33                NodeVar('WormStart', None, 'Worm Start', 'Select the node from which to start the worm'),       
34                NodeListVar('targets', [], 'Vulnerable Servers', 'Select the nodes to become vulnerable severs'),
35                IntfListVar('targetIP', IPList([]), 'Target IPs', 'Select the IPs for the nodes you want to be attacked')
36       
37        ]
38
39        def __init__(self): 
40                Agent.__init__(self)
41                       
42        def handleSTARTIRC(self):
43                """
44                        This method is called to start the irc server.  It starts ./ircd/ircd.rb which starts the
45                        irc server on the selected IRCHost and port 6667 by default
46                """
47
48                if self.IRCHost.myNodeMemberOf():
49                        self.pids.append(spawn("ruby /usr/rubot/ircd/ircd.rb"))
50     
51        def handleSTOPIRC(self):
52                """
53                        This method is called to stop the irc server.  It will kill the process ircd.rb
54                """
55                if self.IRCHost.myNodeMemberOf():
56                        self.pids.append(spawn("killall ircd"))
57       
58        def handleSTARTBOT(self):
59                """
60                        This will start the worm.  It runs rubot/experiments/worm.py
61                """
62               
63                if self.targets.myNodeMemberOf():
64                        self.pids.append(spawn('python /usr/rubot/experiments/vulnserv.py 2008 '+str(self.IRCHost)+' '+str(self.targetIP)))
65                               
66                if self.WormStart.myNodeMemberOf():
67                        self.pids.append(spawn('python /usr/rubot/experiments/worm.py '+str(self.targetIP)))
68               
69        def handleSTOPBOT(self):
70                """
71                        This will stop the worm by calling a script to kill all of the vulnserv.rb running on the different nodes
72                """
73                self.pids.append(spawn('killall vul'))
74                self.pids.append(spawn('killall ssh'))
75