Beispiel #1
0
    def _create_round_samplesets(self):
        state = {
            'knownalphabet': self._round.knownalphabet,
            'knownsecret': self._round.knownsecret
        }

        self._round.batch += 1
        self._round.save()

        candidate_alphabets = self._build_candidates(state)

        alignmentalphabet = ''
        if self._round.check_block_align():
            alignmentalphabet = list(
                self._round.victim.target.alignmentalphabet)
            random.shuffle(alignmentalphabet)
            alignmentalphabet = ''.join(alignmentalphabet)

        logger.debug('\tAlignment alphabet: {}'.format(alignmentalphabet))

        for candidate in candidate_alphabets:
            SampleSet.create_sampleset({
                'round': self._round,
                'candidatealphabet': candidate,
                'alignmentalphabet': alignmentalphabet,
                'batch': self._round.batch
            })
Beispiel #2
0
    def _create_round_samplesets(self):
        state = {
            'knownalphabet': self._round.knownalphabet,
            'knownsecret': self._round.knownsecret
        }

        self._round.batch += 1
        self._round.save()

        candidate_alphabets = self._build_candidates(state)

        alignmentalphabet = ''
        if self._round.check_block_align():
            alignmentalphabet = list(self._round.victim.target.alignmentalphabet)
            random.shuffle(alignmentalphabet)
            alignmentalphabet = ''.join(alignmentalphabet)

        logger.debug('\tAlignment alphabet: {}'.format(alignmentalphabet))

        for candidate in candidate_alphabets:
            SampleSet.create_sampleset({
                'round': self._round,
                'candidatealphabet': candidate,
                'alignmentalphabet': alignmentalphabet,
                'batch': self._round.batch
            })
Beispiel #3
0
 def _handle_sampleset_success(self, capture, sampleset):
     '''Save capture of successful sampleset
     or mark sampleset as failed and create new sampleset for the same element that failed.'''
     if capture:
         sampleset.success = True
         sampleset.data = capture['data']
         sampleset.records = capture['records']
         sampleset.save()
     else:
         SampleSet.create_sampleset({
             'round': self._round,
             'candidatealphabet': sampleset.candidatealphabet,
             'alignmentalphabet': sampleset.alignmentalphabet,
             'batch': sampleset.batch
         })
Beispiel #4
0
 def _handle_sampleset_success(self, capture, sampleset):
     '''Save capture of successful sampleset
     or mark sampleset as failed and create new sampleset for the same element that failed.'''
     if capture:
         sampleset.success = True
         sampleset.data = capture['data']
         sampleset.records = capture['records']
         sampleset.save()
     else:
         SampleSet.create_sampleset({
             'round': self._round,
             'candidatealphabet': sampleset.candidatealphabet,
             'alignmentalphabet': sampleset.alignmentalphabet,
             'batch': sampleset.batch
         })
Beispiel #5
0
    def _mark_current_work_completed(self, capture=None):
        sampleset = self._get_current_sampleset()
        sampleset.completed = timezone.now()

        if capture:
            sampleset.success = True
            sampleset.data = capture
        else:
            # Sampleset data collection failed,
            # create a new sampleset for the same attack element
            s = SampleSet(
                round=sampleset.round,
                candidatealphabet=sampleset.candidatealphabet,
                alignmentalphabet=sampleset.alignmentalphabet
            )
            s.save()

        sampleset.save()
Beispiel #6
0
    def _create_round_samplesets(self):
        state = {
            'knownalphabet': self._round.knownalphabet,
            'knownsecret': self._round.knownsecret
        }

        candidate_alphabets = self._build_candidates(state)

        alignmentalphabet = list(self._round.victim.target.alignmentalphabet)
        random.shuffle(alignmentalphabet)
        alignmentalphabet = ''.join(alignmentalphabet)
        logger.debug('\tAlignment alphabet: {}'.format(alignmentalphabet))

        for candidate in candidate_alphabets:
            sampleset = SampleSet(
                round=self._round,
                candidatealphabet=candidate,
                alignmentalphabet=alignmentalphabet
            )
            sampleset.save()