-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclicks.py
116 lines (97 loc) · 3.07 KB
/
clicks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import pyautogui
import time
import random
import sys
import os
from multiprocessing import Process
import math
import subprocess
import chardet
seed_path = './out/.cur_input'
if len(sys.argv) > 2 and sys.argv[1] != None and sys.argv[2] != None:
target_program = sys.argv[1]
seed_path = sys.argv[2]
def task():
os.system(target_program)
process = Process(target=task)
process.start()
def sfc32(a, b, c, d):
a &= 0xFFFFFFFF
b &= 0xFFFFFFFF
c &= 0xFFFFFFFF
d &= 0xFFFFFFFF
def rng():
nonlocal a, b, c, d
t = (a + b) & 0xFFFFFFFF
a = b ^ (b >> 9)
b = (c + (c << 3)) & 0xFFFFFFFF
c = ((c << 21) | (c >> 11)) & 0xFFFFFFFF
d = (d + 1) & 0xFFFFFFFF
t = (t + d) & 0xFFFFFFFF
c = (c + t) & 0xFFFFFFFF
return t / 4294967296
return rng
def xfnv1a(string):
h = 2166136261
for char in string:
h ^= ord(char)
h = (h * 16777619) & 0xFFFFFFFF
def seed_scramble():
nonlocal h
h += h << 13
h ^= h >> 7
h += h << 3
h ^= h >> 17
h += h << 5
return h & 0xFFFFFFFF
return seed_scramble
def generateRandomNumber(seedstring):
num = xfnv1a(seedstring)
return sfc32(num(), num(), num(), num())
def getWindowCoords():
window_list = [] #start x, start y, width, height
window_command = "xwininfo -id $(xdotool getactivewindow)"
window_info = subprocess.check_output(window_command, shell=True)
window_info = window_info.decode('utf-8')
info = window_info.split("\n")
for res in info:
temp = res.split(":")
if(len(temp)>1):
match temp[0].strip():
case "Absolute upper-left X":
window_list.append(int(temp[1].strip()))
case "Absolute upper-left Y":
window_list.append(int(temp[1].strip()))
case "Width":
window_list.append(int(temp[1].strip()))
case "Height":
window_list.append(int(temp[1].strip()))
return window_list
def getScreenResolution():
resolution_command = "xdpyinfo | grep dimensions | awk '{ print $2 }'"
resol_value = subprocess.check_output(resolution_command, shell=True)
resol_value = resol_value.decode('utf-8')
resol_value_split = resol_value.split('x')
return int(resol_value_split[0])
time.sleep(3)
window_coords = getWindowCoords()
start_x = window_coords[0]
start_y = window_coords[1]
width = window_coords[2]
height = window_coords[3]
y_padding = 40
seed = ""
with open(seed_path, 'r', encoding='iso-8859-1') as f:
seed = f.read()
# Add a sleep when running in Qemu mode because the target program takes a lot of time to open
# time.sleep(25)
random_number = generateRandomNumber(seed)
for i in range(20):
val = random_number()
x_val = (start_x - 10) + width * val
y_val = (start_y + y_padding - 10) + (height - y_padding) * val
pyautogui.click(math.floor(x_val),math.floor(y_val))
time.sleep(1)
pyautogui.keyDown('ctrlleft')
pyautogui.press('q')
pyautogui.keyUp('ctrlleft')