Esempio n. 1
0
 def _update_uptime(self, s):
     secs = pwnagotchi.uptime()
     self._view.set('uptime', utils.secs_to_hhmmss(secs))
Esempio n. 2
0
    def next(self):
        if self.any_activity is False and self.did_handshakes is False:
            self.inactive_for += 1
            self.active_for = 0
        else:
            self.active_for += 1
            self.inactive_for = 0
            self.sad_for = 0
            self.bored_for = 0

        if self.inactive_for >= self.config['personality']['sad_num_epochs']:
            # sad > bored; cant be sad and bored
            self.bored_for = 0
            self.sad_for += 1
        elif self.inactive_for >= self.config['personality'][
                'bored_num_epochs']:
            # sad_treshhold > inactive > bored_treshhold; cant be sad and bored
            self.sad_for = 0
            self.bored_for += 1
        else:
            self.sad_for = 0
            self.bored_for = 0

        now = time.time()
        cpu = pwnagotchi.cpu_load()
        mem = pwnagotchi.mem_usage()
        temp = pwnagotchi.temperature()

        self.epoch_duration = now - self.epoch_started

        # cache the state of this epoch for other threads to read
        self._epoch_data = {
            'duration_secs': self.epoch_duration,
            'slept_for_secs': self.num_slept,
            'blind_for_epochs': self.blind_for,
            'inactive_for_epochs': self.inactive_for,
            'active_for_epochs': self.active_for,
            'sad_for_epochs': self.sad_for,
            'bored_for_epochs': self.bored_for,
            'missed_interactions': self.num_missed,
            'num_hops': self.num_hops,
            'num_deauths': self.num_deauths,
            'num_associations': self.num_assocs,
            'num_handshakes': self.num_shakes,
            'cpu_load': cpu,
            'mem_usage': mem,
            'temperature': temp
        }

        self._epoch_data['reward'] = self._reward(self.epoch + 1,
                                                  self._epoch_data)
        self._epoch_data_ready.set()

        logging.info(
            "[epoch %d] duration=%s slept_for=%s blind=%d sad=%d bored=%d inactive=%d active=%d "
            "hops=%d missed=%d deauths=%d assocs=%d handshakes=%d cpu=%d%% mem=%d%% "
            "temperature=%dC reward=%s" %
            (self.epoch, utils.secs_to_hhmmss(
                self.epoch_duration), utils.secs_to_hhmmss(self.num_slept),
             self.blind_for, self.sad_for, self.bored_for, self.inactive_for,
             self.active_for, self.num_hops, self.num_missed, self.num_deauths,
             self.num_assocs, self.num_shakes, cpu * 100, mem * 100, temp,
             self._epoch_data['reward']))

        self.epoch += 1
        self.epoch_started = now
        self.did_deauth = False
        self.num_deauths = 0
        self.did_associate = False
        self.num_assocs = 0
        self.num_missed = 0
        self.did_handshakes = False
        self.num_shakes = 0
        self.num_hops = 0
        self.num_slept = 0
        self.any_activity = False
Esempio n. 3
0
 def _update_uptime(self, s):
     secs = time.time() - self._started_at
     self._view.set('uptime', utils.secs_to_hhmmss(secs))
     self._view.set('epoch', '%04d' % self._epoch.epoch)
Esempio n. 4
0
    def next(self):
        if self.any_activity is False and self.did_handshakes is False:
            self.inactive_for += 1
            self.active_for = 0

        #if self.any_activity is False and self.did_crack is False:
        #    self.inactive_for += 1
        #    self.active_for = 0

        else:
            self.active_for += 1
            self.inactive_for = 0

        now = time.time()
        cpu = pwnagotchi.cpu_load()
        mem = pwnagotchi.mem_usage()
        temp = pwnagotchi.temperature()

        self.epoch_duration = now - self.epoch_started

        # cache the state of this epoch for other threads to read
        self._epoch_data = {
            'duration_secs': self.epoch_duration,
            'slept_for_secs': self.num_slept,
            'blind_for_epochs': self.blind_for,
            'inactive_for_epochs': self.inactive_for,
            'active_for_epochs': self.active_for,
            'missed_interactions': self.num_missed,
            'num_hops': self.num_hops,
            'num_peers': self.num_peers,
            'tot_bond': self.tot_bond_factor,
            'avg_bond': self.avg_bond_factor,
            'num_deauths': self.num_deauths,
            'num_associations': self.num_assocs,
            'num_handshakes': self.num_shakes,
            #'num_crack': self.num_crack,
            'cpu_load': cpu,
            'mem_usage': mem,
            'temperature': temp
        }

        self._epoch_data['reward'] = self._reward(self.epoch + 1,
                                                  self._epoch_data)
        self._epoch_data_ready.set()

        logging.info(
            "[epoch %d] duration=%s slept_for=%s blind=%d inactive=%d active=%d peers=%d tot_bond=%.2f "
            "avg_bond=%.2f hops=%d missed=%d deauths=%d assocs=%d handshakes=%d cpu=%d%% mem=%d%% "  #crack=%d
            "temperature=%dC reward=%s" % (
                self.epoch,
                utils.secs_to_hhmmss(self.epoch_duration),
                utils.secs_to_hhmmss(self.num_slept),
                self.blind_for,
                self.inactive_for,
                self.active_for,
                self.num_peers,
                self.tot_bond_factor,
                self.avg_bond_factor,
                self.num_hops,
                self.num_missed,
                self.num_deauths,
                self.num_assocs,
                self.num_shakes,
                #self.num_crack,
                cpu * 100,
                mem * 100,
                temp,
                self._epoch_data['reward']))

        self.epoch += 1
        self.epoch_started = now
        self.did_deauth = False
        self.num_deauths = 0
        self.num_peers = 0
        self.tot_bond_factor = 0.0
        self.avg_bond_factor = 0.0
        self.did_associate = False
        self.num_assocs = 0
        self.num_missed = 0
        self.did_handshakes = False
        #self.did_crack = False
        self.num_shakes = 0
        #self.num_crack = 0
        self.num_hops = 0
        self.num_slept = 0
        self.any_activity = False