emergency_tool.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. try:
  9. f = open('set.json', 'r')
  10. except FileNotFoundError as e:
  11. print('Error: set.json is not found. please run setup script first.')
  12. exit()
  13. else:
  14. f.close()
  15. json_data = open('set.json').read()
  16. set_data = json.loads(json_data)
  17. conn = sqlite3.connect(set_data['db'] + '.db', check_same_thread = False)
  18. curs = conn.cursor()
  19. load_conn(conn)
  20. print('1. backlink reset')
  21. print('2. recaptcha delete')
  22. print('3. ban delete')
  23. print('4. change host')
  24. print('5. change port')
  25. print('6. change skin')
  26. print('7. change password')
  27. print('8. reset version')
  28. print('select : ', end = '')
  29. what_i_do = input()
  30. if what_i_do == '1':
  31. def parser(data):
  32. namumark(data[0], data[1], 1)
  33. curs.execute("delete from back")
  34. conn.commit()
  35. curs.execute("select title, data from data")
  36. data = curs.fetchall()
  37. num = 0
  38. for test in data:
  39. num += 1
  40. t = threading.Thread(target = parser, args = [test])
  41. t.start()
  42. t.join()
  43. if num % 10 == 0:
  44. print(num)
  45. elif what_i_do == '2':
  46. curs.execute("delete from other where name = 'recaptcha'")
  47. curs.execute("delete from other where name = 'sec_re'")
  48. elif what_i_do == '3':
  49. print('ip or name : ', end = '')
  50. user_data = input()
  51. if re.search("^([0-9]{1,3}\.[0-9]{1,3})$", user_data):
  52. band = 'O'
  53. else:
  54. band = ''
  55. 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])
  56. curs.execute("delete from ban where block = ?", [user_data])
  57. elif what_i_do == '4':
  58. print('host : ', end = '')
  59. host = input()
  60. curs.execute("update other set data = ? where name = 'host'", [host])
  61. elif what_i_do == '5':
  62. try:
  63. print('port : ', end = '')
  64. port = int(input())
  65. except ValueError:
  66. print('Error: Please input int value')
  67. exit()
  68. curs.execute("update other set data = ? where name = 'port'", [port])
  69. elif what_i_do == '6':
  70. print('skin name : ', end = '')
  71. skin = input()
  72. curs.execute("update other set data = ? where name = 'skin'", [skin])
  73. elif what_i_do == '7':
  74. try:
  75. print('1. sha256')
  76. print('2. sha3')
  77. print('3. bcrypt')
  78. print('select : ', end = '')
  79. what_i_do = int(input())
  80. except ValueError:
  81. print('Error: Please input int value')
  82. exit()
  83. print('user name : ', end = '')
  84. user_name = input()
  85. print('user password : ', end = '')
  86. user_pw = input()
  87. if what_i_do == '1':
  88. hashed = hashlib.sha256(bytes(user_pw, 'utf-8')).hexdigest()
  89. elif what_i_do == '2':
  90. hashed = sha3_256(bytes(user_pw, 'utf-8')).hexdigest()
  91. elif what_i_do == '3':
  92. hashed = bcrypt.hashpw(bytes(user_pw, 'utf-8'), bcrypt.gensalt()).decode()
  93. curs.execute("update user set pw = ? where id = ?", [hashed, user_name])
  94. elif what_i_do == '8':
  95. curs.execute("update other set data = '00000' where name = 'ver'")
  96. conn.commit()
  97. print('ok')