Advertisement
Falexom

Untitled

Dec 2nd, 2022
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.23 KB | None | 0 0
  1. import subprocess
  2. import os
  3. import time
  4.  
  5. print('Try to guess a password!')
  6. guess = input()
  7. passwd = 'kali'
  8.  
  9. pwd = os.getcwd()
  10. if guess == passwd:
  11.     allowed = True
  12.     time.sleep(3)
  13.     subprocess.run(f'sudo chattr -i {pwd}/template.tbl', shell=True, check=True)
  14.     subprocess.run('sudo chmod 777 template.tbl', shell=True, check=True)
  15.  
  16.     names = []
  17.     ls = subprocess.Popen(["ls", "-p", "."], stdout=subprocess.PIPE, )
  18.     grep = subprocess.Popen(["grep", "-v", "/$"], stdin=ls.stdout, stdout=subprocess.PIPE, )  # LS + GREP
  19.     files = grep.stdout
  20.  
  21.     for line in files:
  22.         line = str(line, 'utf-8')
  23.         line = line.replace("\n", '')
  24.         names.append(line)
  25.  
  26.     table = open("template.tbl", "r")
  27.     tables = []
  28.  
  29.     for i in table:
  30.         j = str(i)
  31.         j = j.replace("\n", '')  # all strings
  32.         tables.append(j)
  33.  
  34.     for line in tables:
  35.         if line in names:
  36.             subprocess.run(f'sudo chattr -i {pwd}/{line}', shell=True, check=True)  # cmd
  37.             subprocess.run(f'sudo chmod 777 {pwd}/{line}', shell=True, check=True)
  38.     subprocess.run('kill -9 $(pgrep bash)', shell=True, check=True)
  39.     print("Congrats! You guessed a password!")
  40.  
  41. else:
  42.     print("Try again!")
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement