Advertisement
Guest User

interesting_chest

a guest
Apr 24th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.10 KB | None | 0 0
  1. import string
  2. import random
  3.  
  4. # generate alhpanumeric char
  5.  
  6.  
  7. def alphanumeric():
  8.     for i in string.printable[:62]:
  9.         yield i
  10.  
  11. # chest diinisiasi, key nya random.
  12. # hintnya alphanumeric dan ngasih tauin jumlah benar jika key yg dimasukin benar
  13.  
  14.  
  15. class chest:
  16.     def __init__(self):
  17.         self.raw_key = list('V3r1t4Spr0b1t4SJust1t14')
  18.         random.shuffle(self.raw_key)
  19.         self.right_key = ''.join(self.raw_key)
  20.         print(self.right_key)
  21.  
  22.     def open(self, key):
  23.         # padding, fill key to same lenght as self.right_key
  24.         key = key.ljust(len(self.right_key), '@')
  25.  
  26.         assert len(key) == len(self.right_key)
  27.  
  28.         right = 0
  29.  
  30.         for r, rk in zip(key, self.right_key):
  31.             if r == rk:
  32.                 right += 1
  33.             # right -= 1
  34.             # bisa ditambah challange kurangin kalo salah wkkk
  35.  
  36.         if right == len(self.right_key):
  37.             return 'Chest terbuka!'
  38.         return ('Chest masih tertutup, ayo coba lagi sebelum giliran berikutnya!  benar:', right)
  39.  
  40.  
  41. def bruteforcer(chest, key, right_counted):
  42.     buka = chest.open(key)
  43.     if 'terbuka' in buka:
  44.         return 'Done'
  45.     if buka[1] > right_counted:
  46.         return 'Process'
  47.  
  48.  
  49. def main():
  50.     # hint key: alphanumeric.
  51.     # tiap kali chest di-inisiasi alias pergiliran, akan dirandom keynya.
  52.     some_interesting_chest = chest()
  53.     # bisa diterapin di pwn.
  54.  
  55.     print([x for x in alphanumeric()])
  56.     key_bruteforced = ''
  57.     right_counted = 0
  58.     run = True
  59.  
  60.     while run:
  61.         for i in alphanumeric():
  62.             right_counted = len(key_bruteforced)
  63.             check = key_bruteforced + i
  64.             status = bruteforcer(
  65.                 some_interesting_chest, check, right_counted)
  66.  
  67.             if status is not None:
  68.                 key_bruteforced += i
  69.                 print(key_bruteforced)
  70.  
  71.                 if status is 'Process':
  72.                     break
  73.  
  74.                 elif status is 'Done':
  75.                     run = False
  76.                     break
  77.  
  78.     print(key_bruteforced)
  79.  
  80.  
  81. if __name__ == '__main__':
  82.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement