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 "unzip",
39 ]
40
41 classname = create_unicode_buffer(50)
42 USER32.GetClassNameW(hwnd, classname, 50)
43
44
45 if classname.value == "Button":
46
47 length = USER32.SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0)
48 text = create_unicode_buffer(length + 1)
49 USER32.SendMessageW(hwnd, WM_GETTEXT, length + 1, text)
50
51
52 for button in buttons:
53 if button in text.value.lower():
54 log.info("Found button \"%s\", clicking it" % text.value)
55 USER32.SetForegroundWindow(hwnd)
56 KERNEL32.Sleep(1000)
57 USER32.SendMessageW(hwnd, BM_CLICK, 0, 0)
58
59 return False
60 else:
61
62 return True
63
64
65
72
74 x = random.randint(0, RESOLUTION["x"])
75 y = random.randint(0, RESOLUTION["y"])
76
77
78
79
80
81
82
83 USER32.SetCursorPos(x, y)
84
93
94 -class Human(Auxiliary, Thread):
95 """Human after all"""
96
98 Thread.__init__(self)
99 self.do_run = True
100
103
110