├── .gitattributes ├── Mouse.py └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Mouse.py: -------------------------------------------------------------------------------- 1 | import ctypes 2 | from time import sleep 3 | import win32file 4 | import win32api 5 | import ctypes 6 | import ctypes.wintypes as wintypes 7 | from ctypes import windll 8 | 9 | handle = 0 10 | found = False 11 | def _DeviceIoControl(devhandle, ioctl, inbuf, inbufsiz, outbuf, outbufsiz): 12 | """See: DeviceIoControl function 13 | http://msdn.microsoft.com/en-us/library/aa363216(v=vs.85).aspx 14 | """ 15 | DeviceIoControl_Fn = windll.kernel32.DeviceIoControl 16 | DeviceIoControl_Fn.argtypes = [wintypes.HANDLE, wintypes.DWORD, wintypes.LPVOID,wintypes.DWORD,wintypes.LPVOID,wintypes.DWORD,ctypes.POINTER(wintypes.DWORD),wintypes.LPVOID] 17 | DeviceIoControl_Fn.restype = wintypes.BOOL 18 | 19 | dwBytesReturned = wintypes.DWORD(0) 20 | lpBytesReturned = ctypes.byref(dwBytesReturned) 21 | 22 | status = DeviceIoControl_Fn(int(devhandle),ioctl,inbuf,inbufsiz,outbuf,outbufsiz,lpBytesReturned,None) 23 | 24 | return status, dwBytesReturned 25 | 26 | 27 | class MOUSE_IO(ctypes.Structure): 28 | _fields_ = [("button", ctypes.c_char),("x", ctypes.c_char),("y", ctypes.c_char),("wheel", ctypes.c_char),("unk1", ctypes.c_char),] 29 | 30 | 31 | def device_initialize(device_name: str) -> bool: 32 | global handle 33 | try: 34 | handle = win32file.CreateFileW(device_name, win32file.GENERIC_WRITE, 0, None, win32file.OPEN_ALWAYS, win32file.FILE_ATTRIBUTE_NORMAL, 0) 35 | except: 36 | pass 37 | return bool(handle) 38 | 39 | def mouse_open() -> bool: 40 | global found 41 | global handle 42 | if handle: 43 | return found 44 | if device_initialize('\\??\\ROOT#SYSTEM#0002#{1abc05c0-c378-41b9-9cef-df1aba82b015}'): #Would be best to put this in a for loop and only change the 0002 45 | found = True 46 | else: 47 | if device_initialize('\\??\\ROOT#SYSTEM#0001#{1abc05c0-c378-41b9-9cef-df1aba82b015}'): #Logitech CVE thank you ekknod 48 | found = True 49 | 50 | return found 51 | 52 | def call_mouse(buffer) -> bool: 53 | global handle 54 | return _DeviceIoControl(handle, 0x2a2010, ctypes.c_void_p(ctypes.addressof(buffer)), ctypes.sizeof(buffer), 0, 0)[0] == 0 55 | 56 | 57 | def mouse_close() -> None: 58 | global handle 59 | win32file.CloseHandle(int(handle)) 60 | handle = 0 61 | 62 | def mouse_move(button, x, y, wheel) -> None: 63 | global handle 64 | 65 | io = MOUSE_IO() 66 | io.x = x 67 | io.y = y 68 | io.unk1 = 0 69 | io.button = button 70 | io.wheel = wheel 71 | print(ctypes.sizeof(io)) 72 | if not call_mouse(io): 73 | mouse_close() 74 | mouse_open() 75 | 76 | if not mouse_open(): 77 | print("Ghub is not open or something else is wrong") 78 | 79 | while 1: 80 | if win32api.GetAsyncKeyState(5): 81 | mouse_move(0, 3, 0, 0) 82 | sleep(0.1) 83 | if win32api.GetAsyncKeyState(6): 84 | mouse_move(1, 0, 0, 0) 85 | sleep(1) 86 | mouse_move(0, 0, 0, 0) 87 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GHUB-Mouse-exploit-Python 2 | Thanks Ekknod 3 | --------------------------------------------------------------------------------