import ctypes as C import os class uid: def __init__(self) -> None: path="./creat_uid.dll" try: if os.path.exists(path): self.dll=C.windll.LoadLibrary(path) else: print(f"dll {path} not found.") self.dll=None except Exception as e: print("load dll faled.",str(e)) self.dll=None def info(self): if(self.dll is None): return "" p_info=C.create_string_buffer(50) self.dll.info(p_info,C.c_int(50)) return p_info.value.decode() def shell_to_uid_gen1(self,shell:bytearray,year:bytearray): if(self.dll is None): return "" p_info=C.create_string_buffer(50) self.dll.shell_to_uid_gen1(p_info,C.c_char_p(shell),C.c_char_p(year)) # print(len(p_info.value)) return p_info.value.decode() def uid_to_save_psw_gen1(self,shell:bytearray,year:bytearray): uid=self.shell_to_uid_gen1(shell,year) p_save=C.create_string_buffer(50) p_psw=C.create_string_buffer(50) self.dll.uid_to_save_psw_gen1(p_save,p_psw,C.c_char_p(uid.encode())) return p_save.value.hex(),p_psw.value.hex() def shell_to_uid_gen2(self,shell:bytearray,year:bytearray): if(self.dll is None): return "" p_info=C.create_string_buffer(50) self.dll.shell_to_uid_gen2(p_info,C.c_char_p(shell),C.c_char_p(year)) # print(len(p_info.value)) return p_info.value.decode() def uid_to_save_psw_gen2(self,shell:bytearray,year:bytearray): uid=self.shell_to_uid_gen2(shell,year) p_save=C.create_string_buffer(50) p_psw=C.create_string_buffer(50) self.dll.uid_to_save_psw_gen2(p_save,p_psw,C.c_char_p(uid.encode())) return p_save.value.hex(),p_psw.value.hex() if __name__ == "__main__": u=uid() for i in range(10000): u.shell_to_uid_gen1(b"6640124G08001J",b"2024") u.shell_to_uid_gen2(b"6640124G08001J",b"2024") u.uid_to_save_psw_gen1(b"6640124G08001J",b"2024")[1] u.uid_to_save_psw_gen2(b"6640124G08001J",b"2024")[1] print("end")