You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
5.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import asyncio
import websockets
import os
import rainbow_table
import global_var
import webbrowser as wb
async def time_server(websocket):
while True:
if(await websocket.recv() == "start"):
print("""\n
欢迎使用随便做的破烂版彩虹表/生成破解程序。
使用说明如下:
1. 输入1生成彩虹表
2. 输入2破解哈希值
3. 输入3退出程序
""")
await websocket.send('''请开始操作 使用说明如下:
1. 输入1生成彩虹表
2. 输入2破解哈希值
3. 输入3退出程序''')
op = await websocket.recv()
# op = input("请输入操作选项:")
print("op1:"+op)
if op == '1':
await websocket.send("""生成命令格式如下algorithm charset min_length max_length cahin_length chain_number index
参数详解:\n
-algorithm:LM,NTLM,MD5,SHA1,SHA256\n
-charset:'numeric', 'alpha', 'alpha_numeric', 'loweralpha', 'loweralpha_numeric',\n
'mixalpha', 'mixalpha_numeric', 'ascii_32_95', 'ascii_32_65_123_4', 'alpha_numeric_symbol32_space'
具体可以看同目录下的charset.txt进行确认。
-min_length and max_length:指定想生成的表的密码范围。
-chain_length:指定单条链的长度(进行几次约简函数和哈希函数操作)。
-chain_number:指定表内总共的链数量。
-index:索引值,用于确保使用的归约函数不同。""")
print("""
生成命令格式如下algorithm charset min_length max_length cahin_length chain_number index\n
参数详解:
-algorithm:LM,NTLM,MD5,SHA1,SHA256
-charset:'numeric', 'alpha', 'alpha_numeric', 'loweralpha', 'loweralpha_numeric',
'mixalpha', 'mixalpha_numeric', 'ascii_32_95', 'ascii_32_65_123_4', 'alpha_numeric_symbol32_space'
具体可以看同目录下的charset.txt进行确认。
-min_length and max_length:指定想生成的表的密码范围。
-chain_length:指定单条链的长度(进行几次约简函数和哈希函数操作)。
-chain_number:指定表内总共的链数量。
-index:索引值,用于确保使用的归约函数不同。""")
op = await websocket.recv()
print("op2:" + op)
try:
algorithm, charset_type, min_length, max_length, chain_length, chain_number, table_index = op.split()
await websocket.send("请等待")
rainbow_table.rtgen(algorithm, charset_type, int(min_length), int(max_length), int(chain_length), int(chain_number), int(table_index)).table_generate()
await websocket.send(global_var.global_result)
except Exception as e:
result = (f'\n发生错误,请检查输入的指令格式或哈希格式是否有误.' + str(e))
await websocket.send(result)
print(f'发生错误,请检查输入的指令格式是否有误.', e)
elif op == '2':
await websocket.send("""
破解指令格式如下to_crack_hash_string rainbow_table_name\n
参数详解:
-to_ceack_hash_string:输入要查表的哈希值。
-rainbow_table_name:默认读取工作目录下'.\\output'内的文件,请确保其中存在生成的表。\n""")
print("""
破解指令格式如下to_crack_hash_string rainbow_table_name\n
参数详解:
-to_ceack_hash_string:输入要查表的哈希值。
-rainbow_table_name:默认读取工作目录下'.\\output'内的文件,请确保其中存在生成的表。\n""")
op = await websocket.recv()
print("op2:" + op)
try:
value = op.split()
hash_string, f_name = value
file_path = os.path.join(".\\output", f_name)
search = rainbow_table.rtsearch(hash_string, file_path)
await websocket.send("请等待")
search.crack()
await websocket.send(global_var.global_result)
except Exception as e:
result = (f'\n发生错误,请检查输入的指令格式或哈希格式是否有误.' + str(e))
await websocket.send(result)
print(f'\n发生错误,请检查输入的指令格式或哈希格式是否有误.', e)
elif op == '3':
await websocket.send("\n感谢您的使用^_^")
print("\n感谢您的使用^_^")
break
else:
await websocket.send("还没有定义这个操作哦。")
print("还没有定义这个操作哦。")
await websocket.recv()
await websocket.send("finish")
# print("\n键入任何值以继续程序")
# input("按任意键继续...")
start_server = websockets.serve(time_server, 'localhost', 5001)
asyncio.get_event_loop().run_until_complete(start_server)
wb.open(r"file:///C:\Users\colo\Desktop\彩虹表_工程文件V1.6.1\彩虹表_工程文件V1.6.1(html)\my.html")
asyncio.get_event_loop().run_forever()