|
1 | 1 | import time |
2 | | -from random import randint |
3 | 2 | from attackmate.executors.baseexecutor import BaseExecutor |
4 | 3 | from attackmate.result import Result |
5 | | -from attackmate.executors.features.cmdvars import CmdVars |
6 | 4 | from attackmate.variablestore import VariableStore |
7 | 5 | from attackmate.processmanager import ProcessManager |
8 | 6 | from attackmate.executors.executor_factory import executor_factory |
|
12 | 10 | class SleepExecutor(BaseExecutor): |
13 | 11 | def __init__(self, pm: ProcessManager, cmdconfig=None, *, varstore: VariableStore): |
14 | 12 | super().__init__(pm, varstore, cmdconfig) |
15 | | - self.sleep_time = None |
16 | | - |
17 | | - def set_sleeptime(self, command): |
18 | | - self.sleep_time = CmdVars.variable_to_int('seconds', command.seconds) |
19 | | - if command.random: |
20 | | - self.sleep_time = randint( |
21 | | - CmdVars.variable_to_int('min_sec', command.min_sec), # nosec |
22 | | - CmdVars.variable_to_int('seconds', command.seconds), |
23 | | - ) # nosec |
24 | 13 |
|
25 | 14 | def log_command(self, command): |
26 | | - self.set_sleeptime(command) |
27 | | - self.logger.info(f'Sleeping {self.sleep_time} seconds') |
| 15 | + self.logger.info(f'Sleeping {command.sleep_time} seconds') |
28 | 16 |
|
29 | 17 | def _exec_cmd(self, command): |
30 | | - time.sleep(self.sleep_time) |
| 18 | + time.sleep(command.sleep_time) |
31 | 19 | return Result('Awake O_O', 0) |
0 commit comments