1
2
3
4
5
6 import random
7 import logging
8 from threading import Thread
9 from ctypes import WINFUNCTYPE, POINTER
10 from ctypes import c_bool, c_int, create_unicode_buffer
11
12 from lib.common.abstracts import Auxiliary
13 from lib.common.defines import KERNEL32, USER32
14 from lib.common.defines import WM_GETTEXT, WM_GETTEXTLENGTH, BM_CLICK
15
16 log = logging.getLogger(__name__)
17
18 EnumWindowsProc = WINFUNCTYPE(c_bool, POINTER(c_int), POINTER(c_int))
19 EnumChildProc = WINFUNCTYPE(c_bool, POINTER(c_int), POINTER(c_int))
20
21 RESOLUTION = {
22 "x": USER32.GetSystemMetrics(0),
23 "y": USER32.GetSystemMetrics(1)
24 }
25
27 buttons = [
28 "yes",
29 "ok",
30 "accept",
31 "next",
32 "install",
33 "run",
34 "agree",
35 "enable",
36 "don't send",
37 "continue",
38 ]
39
40 classname = create_unicode_buffer(50)
41 USER32.GetClassNameW(hwnd, classname, 50)
42
43
44 if classname.value == "Button":
45
46 length = USER32.SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0)
47 text = create_unicode_buffer(length + 1)
48 USER32.SendMessageW(hwnd, WM_GETTEXT, length + 1, text)
49
50
51 for button in buttons:
52 if button in text.value.lower():
53 log.info("Found button \"%s\", clicking it" % text.value)
54 USER32.SetForegroundWindow(hwnd)
55 KERNEL32.Sleep(1000)
56 USER32.SendMessageW(hwnd, BM_CLICK, 0, 0)
57
58 return False
59 else:
60
61 return True
62
63
64
71
73 x = random.randint(0, RESOLUTION["x"])
74 y = random.randint(0, RESOLUTION["y"])
75
76
77
78
79
80
81
82 USER32.SetCursorPos(x, y)
83
92
93 -class Human(Auxiliary, Thread):
94 """Human after all"""
95
97 Thread.__init__(self)
98 self.do_run = True
99
102
109