Vault7: CIA Hacking Tools Revealed
Navigation: » Latest version
How to click controls
How to use mouse and keyboard commands to input to a tool under test’s GUI:
Step-by-step guide
Examine the tool using Resource Hacker, or equivalent, to examine the structure that defines the different controls. Note the red * that appears beside the entry for Hide Password since I have selected the control in the representation of the GUI.
Things needed in your code:
from tyutils.window_and_controls_util import setup_wincon
…
workingdir = 'C:\\Users\\tester\\Desktop'
rarname = 'test.rar'
tool_app_title = 'Goldie Small'
StartButNum = 1 # This is the first occurrence of type BUTTON in the structure (not the ‘1’ in the structure)
StartButTyp = 'Button' # Type BUTTON – case is not important
ExitButNum = 2 # This is the second occurrence of type BUTTON (not the ‘2’ in the structure)
ExitButTyp = 'Button'
FileButNum = 2 # This is the second occurrence of type EDIT (5th entry)
FileButTyp = 'Edit'
PassButNum = 3 # This is the third occurrence of type BUTTON (7th entry)
PassButTyp = 'Edit'
HideButNum = 4 # This is the fourth occurrence of type BUTTON (the entry with the red *)
HideButTyp = 'Button'
PassWd = 'passwd'
…
def run(self):
# create a function to find and click on controls – return the coordinates of the center of the control
def find_click (wincon, rsend, hwnd, typ, num, time, click): # find center of rectangle and click
button = wincon.controlWait (hwnd, typ, num, time)
if button == 0:
return -1, -1
rect = wincon.getWindowRect (button)
loc_x = (rect[0] + rect[2]) / 2
loc_y = (rect[1] + rect[3]) / 2
if click > 0:
rsend.Click ("left", loc_x, loc_y, click, 20)
return loc_x, loc_y
…
target = host.createEmissary()
if not target.path_exists(workingdir):
return self.FAILURE, 'target.path_exists failure'
# Setting up Windows and Controls
Rwincon,Rsend = setup_wincon(target)
… start execution of tool under test
# Find tool
proc_hwnd = Rwincon.getWindowByAppxTitle(tool_app_title)
if proc_hwnd == 0:
return self.FAILURE, "Can't find window by title: "+tool_app_title
# Entering Fields
x, y = find_click (Rwincon, Rsend, proc_hwnd, PassButTyp, PassButNum, 5, 2) # double click Password
if x == -1:
return self.FAILURE, "Can't find passwork box"
Rsend.Send(PassWd) # Write to password control
find_click (Rwincon, Rsend, proc_hwnd, HideButTyp, HideButNum, 5, 1) # click Hide Passwd
find_click (Rwincon, Rsend, proc_hwnd, FileButTyp, FileButNum, 5, 2) # double click Filename
Rsend.Send(rarname) # Write to filename control
find_click (Rwincon, Rsend, proc_hwnd, StartButTyp, StartButNum, 5, 1) # Click start
Related articles
('contentbylabel' missing)
('details' missing)