Skip to content

Commit

Permalink
add tests and notes for challenge 13 in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
appills committed Feb 17, 2024
1 parent 69680b2 commit 409f17a
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/fixtures/set_2_challenge13.key
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
75dfa8b6e29a435c714b574431aa3024
48 changes: 48 additions & 0 deletions tests/src/test_UserProfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import unittest
import src.utils.bytecodec as bytecodec

from secrets import token_bytes
from src.UserProfile import urlencode_to_dict, profile_for, UserProfile

class UserProfileTest(unittest.TestCase):

def test_urlencode_to_dict(self):
expected = {
'foo': 'bar',
'baz': 'qux',
'zap': 'zazzle'
}
actual = urlencode_to_dict('foo=bar&baz=qux&zap=zazzle')
self.assertEqual(expected, actual)

def test_profile_for(self):
expected = 'email=foo@bar.com&uid=10&role=user'
actual = profile_for('foo@bar.com')
self.assertEqual(expected, actual)
expected = 'email=foo@bar.comroleadmin&uid=10&role=user'
actual = profile_for('foo@bar.com&role=admin')
self.assertEqual(expected, actual)

def test_attack_profile(self):
key = self.get_static_key()
profile = UserProfile(key)
encrypted = profile.encrypted_profile_for('foo@bar.com')
decrypted = profile.decrypt_profile(encrypted)
expected = {
'email': 'foo@bar.com',
'uid': '10',
'role': 'user'
}
self.assertEqual(expected, decrypted)
'''
email=fooooooooo
@bar.commmmmmmmm
&uid=10&role=use
r
'''

def get_static_key(self):
with open('./tests/fixtures/set_2_challenge13.key', 'r') as fh:
hex_key = fh.read()
key = bytecodec.hex_to_bytes(hex_key)
return key
12 changes: 12 additions & 0 deletions tests/test_set2.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ def test_set2_challenge12(self):
plaintext = b''.join([i.to_bytes() for i in plaintext_bytes])
self.assertEqual(expected, plaintext) # cool af

def test_set2_challenge13(self):

return

def test_set2_challenge14(self):
'''
find your bytes like a canary, make sure your blocks span 3 blocks
e.g. any number of random bytes || yours || target
'''





Expand Down

0 comments on commit 409f17a

Please sign in to comment.