emergency_tool.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import json
  2. import sqlite3
  3. import bcrypt
  4. import hashlib
  5. import threading
  6. from func import *
  7. from mark import load_conn2, namumark
  8. json_data = open('set.json').read()
  9. set_data = json.loads(json_data)
  10. conn = sqlite3.connect(set_data['db'] + '.db', check_same_thread = False)
  11. curs = conn.cursor()
  12. load_conn(conn)
  13. print('1. backlink reset')
  14. print('2. recaptcha delete')
  15. print('3. ban delete')
  16. print('4. change port')
  17. print('5. change skin')
  18. print('6. change password')
  19. print('select : ', end = '')
  20. what_i_do = input()
  21. if what_i_do == '1':
  22. def parser(data):
  23. namumark(data[0], data[1], 1)
  24. curs.execute("delete from back")
  25. conn.commit()
  26. curs.execute("select title, data from data")
  27. data = curs.fetchall()
  28. num = 0
  29. for test in data:
  30. num += 1
  31. t = threading.Thread(target = parser, args = [test])
  32. t.start()
  33. t.join()
  34. if num % 10 == 0:
  35. print(num)
  36. elif what_i_do == '2':
  37. curs.execute("delete from other where name = 'recaptcha'")
  38. curs.execute("delete from other where name = 'sec_re'")
  39. elif what_i_do == '3':
  40. print('ip or name : ', end = '')
  41. user_data = input()
  42. if re.search("^([0-9]{1,3}\.[0-9]{1,3})$", user_data):
  43. band = 'O'
  44. else:
  45. band = ''
  46. curs.execute("insert into rb (block, end, today, blocker, why, band) values (?, ?, ?, ?, ?, ?)", [user_data, load_lang('release', 1), get_time(), load_lang('tool', 1) + ':emergency', '', band])
  47. curs.execute("delete from ban where block = ?", [user_data])
  48. elif what_i_do == '4':
  49. print('port : ', end = '')
  50. port = input()
  51. curs.execute("update other set data = ? where name = 'port'", [port])
  52. elif what_i_do == '5':
  53. print('skin name : ', end = '')
  54. skin = input()
  55. curs.execute("update other set data = ? where name = 'skin'", [skin])
  56. elif what_i_do == '6':
  57. print('1. sha256')
  58. print('2. bcrypt')
  59. print('select : ', end = '')
  60. what_i_do = input()
  61. print('user name : ', end = '')
  62. user_name = input()
  63. print('user password : ', end = '')
  64. user_pw = input()
  65. if what_i_do == '1':
  66. hashed = hashlib.sha256(bytes(user_pw, 'utf-8')).hexdigest()
  67. elif what_i_do == '2':
  68. hashed = bcrypt.hashpw(bytes(user_pw, 'utf-8'), bcrypt.gensalt()).decode()
  69. curs.execute("update user set pw = ? where id = ?", [hashed, user_name])
  70. conn.commit()
  71. print('ok')