Exemplo n.º 1
0
    def test_decode_cookie_var_appeares_multiple_times_is_set_to_last_value(self):
        encoded = "foo=bar&baz=qux&zap=zazzle&foo=tuf"
        expected_decoded = {
          'foo': 'tuf',
          'baz': 'qux',
          'zap': 'zazzle'
        }

        actual_decoded = decode_cookie(encoded)

        self.assertEqual(expected_decoded, actual_decoded)
Exemplo n.º 2
0
    def test_decode_cookie_cryptopals_case(self):
        encoded = "foo=bar&baz=qux&zap=zazzle"
        expected_decoded = {
          'foo': 'bar',
          'baz': 'qux',
          'zap': 'zazzle'
        }

        actual_decoded = decode_cookie(encoded)

        self.assertEqual(expected_decoded, actual_decoded)
Exemplo n.º 3
0
    def test_decode_cookie_ends_with_andpercent_ignores_last_character(self):
        encoded = "foo=bar&baz=qux&zap=zazzle&"
        expected_decoded = {
          'foo': 'bar',
          'baz': 'qux',
          'zap': 'zazzle'
        }

        actual_decoded = decode_cookie(encoded)

        self.assertEqual(expected_decoded, actual_decoded)
Exemplo n.º 4
0
    def test_decode_cookie_equal_without_var_sets_empty_key(self):
        encoded = "=bar&baz=qux&zap=zazzle"
        expected_decoded = {
          '': 'bar',
          'baz': 'qux',
          'zap': 'zazzle'
        }

        actual_decoded = decode_cookie(encoded)

        self.assertEqual(expected_decoded, actual_decoded)
Exemplo n.º 5
0
    def test_decode_cookie_var_without_equal_set_to_empty(self):
        encoded = "foo&baz=qux&zap=zazzle"
        expected_decoded = {
          'foo': '',
          'baz': 'qux',
          'zap': 'zazzle'
        }

        actual_decoded = decode_cookie(encoded)

        self.assertEqual(expected_decoded, actual_decoded)
Exemplo n.º 6
0
    def test_decode_cookie_var_with_multiple_equals_ignores_extraneous(self):
        encoded = "foo=bar=tuf&baz=qux&zap=zazzle"
        expected_decoded = {
          'foo': 'bar',
          'baz': 'qux',
          'zap': 'zazzle'
        }

        actual_decoded = decode_cookie(encoded)

        self.assertEqual(expected_decoded, actual_decoded)
Exemplo n.º 7
0
def main():
    """
    build an admin profile
    this must be done only by using `encrypt_profile(profile_for(input))`
    i.e. we may only control `input`
    """
    trap_email = "10_PADDINGadmin\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"
    encrypted = encrypt_profile(profile_for(trap_email))
    admin_block = get_block_n(encrypted, 16, 1)
    valid_email = "[email protected]"
    encrypted = encrypt_profile(profile_for(valid_email))

    admin_profile_encrypted = get_block_n(encrypted, 16, 0) + \
        get_block_n(encrypted, 16, 1) + get_block_n(encrypted, 16, 2) + \
        admin_block

    print(decode_cookie(decrypt_profile(admin_profile_encrypted)))