def run(self, **kwargs): # {{{ """ Use to launch all attacks instances and all option verifications """ t = time.time() self.filteriptables(**kwargs) EModule.run(self, **kwargs) self.unfilteriptables(**kwargs) kwargs['msg'] = 'Test realised in %s seconds' % str(time.time() - t)
def do(self, **kwargs): kwargs = EModule.do(self, **kwargs) kwargs['socket'] = self.initsocket(**kwargs) if not self._hasSocket(**kwargs): self.error(msg="Can't create a socket", **kwargs) raise return kwargs
def sendmessagesocket(self, **kwargs): # {{{ """ Get a modbus response to an umas request @return: the modbus response """ rp = EModule.sendmessagesocket(self, **kwargs) return ModbusADUResponse(rp)
def do(self, **kwargs): kwargs = EModule.do(self, **kwargs) try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((kwargs['host'], self.options['PORT'][0])) kwargs['msg'] = '%s - modbus device' % kwargs['ip'], self.success(**kwargs) self.succeded = True except: pass return kwargs
def do(self, **kwargs): # {{{ """ An instance attack @return: the main dictionary @raise: a exception if no socket are created """ kwargs = EModule.do(self, **kwargs) kwargs['socket'] = self.initsocket(**kwargs) if not self._hasSocket(**kwargs): self.error(msg="Can't create a socket", **kwargs) raise return kwargs
def verify(self, **kwargs): # {{{ """ Verify some element from module class @return: False if no error is raise, else True """ error = EModule.verify(self, **kwargs) if 'PERIOD' in self.options: # {{{ p = self.options['PERIOD'][0] try: period = int(p) except: self.error(msg='"%s" is an invalid time' % p, **kwargs) error = True if period < 0: self.error(msg='"%s" is an invalid time' % p, **kwargs) error = True # }}} return error
def do(self, **kwargs): # {{{ """ An instance attack @return: the main dictionary """ kwargs = EModule.do(self, **kwargs) kwargs['seq'] = random.randint(1000000, 16000000) kwargs['id'] = random.randint(1024, 65635) # begin play function kwargs['ack'] = self.sendSYN(**kwargs) if kwargs['ack'] == 0: kwargs['msg'] = 'failed to connect with %s' % kwargs['host'] self.error(**kwargs) return kwargs kwargs['seq'] += 1 kwargs['ack'] += 1 kwargs['id'] += 1 self.sendACK(**kwargs) kwargs['request'] = self.getRequest(**kwargs) send(kwargs['request']) return kwargs
def verify(self, **kwargs): # {{{ """ Verify some element from module class @return: False if no error is raise, else True """ error = EModule.verify(self, **kwargs) print os.environ if 'SUDO_UID' not in os.environ: # {{{ kwargs['msg'] = 'You don\'t have administrator permissions.' self.warning(**kwargs) kwargs['msg'] = 'It\'s possible you encounter some issues to ' + \ 'use some parts of this script' self.warning(**kwargs) kwargs['msg'] = "We recommand you to use EASE program with 'sudo'." self.warning(**kwargs) # }}} if 'PAYLOAD' in self.options: # {{{ try: str(self.options['PAYLOAD'][0]) except: error = True # }}} return error
def sendmessagesocket(self, **kwargs): kwargs['request'].messageSize = len(kwargs['request']) if self.__hasField(field='timestamp', **kwargs): kwargs['request'].timestamp = self.getTimestamp(**kwargs) rp = EModule.sendmessagesocket(self, **kwargs) return opcuaResponseDecoder(rp)
def verify(self, **kwargs): error = EModule.verify(self, **kwargs) return error
def run(self, **kwargs): EModule.run(self, **kwargs)
def __init__(self, **kwargs): EModule.__init__(self, **kwargs)
def run(self, **kwargs): # {{{ """ Use to launch all attacks instances and all option verifications """ EModule.run(self, **kwargs)