Exemple #1
0
def foreach_child(hwnd, lparam):
    buttons = [
        "yes",
        "ok",
        "accept",
        "next",
        "install",
        "run",
        "agree",
        "enable",
        "don't send",
        "continue",
    ]

    classname = create_unicode_buffer(50)
    USER32.GetClassNameW(hwnd, classname, 50)

    # Check if the class of the child is button.
    if classname.value == "Button":
        # Get the text of the button.
        length = USER32.SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0)
        text = create_unicode_buffer(length + 1)
        USER32.SendMessageW(hwnd, WM_GETTEXT, length + 1, text)

        # Check if the button is "positive".
        for button in buttons:
            if button in text.value.lower():
                log.info("Found button \"%s\", clicking it" % text.value)
                USER32.SetForegroundWindow(hwnd)
                KERNEL32.Sleep(1000)
                USER32.SendMessageW(hwnd, BM_CLICK, 0, 0)
Exemple #2
0
def foreach_child(hwnd, lparam):
    # List of buttons labels to click.
    buttons = [
        "yes", "oui",
        "ok",
        "accept", "accepter",
        "next", "suivant",
        "install", "installer",
        "run",
        "agree", "j'accepte",
        "enable", "activer",
        "don't send", "ne pas envoyer",
        "don't save",
        "continue", "continuer",
        "unzip", "dezip",
        "open", "ouvrir",
        "close the program",
        "execute", "executer",
        "launch", "lancer",
        "later",
        "finish",
        "end",
        "allow access",
        "remind me later",
        "save", "sauvegarder"
    ]

    # List of buttons labels to not click.
    dontclick = [
        "don't run",
    ]

    classname = create_unicode_buffer(50)
    USER32.GetClassNameW(hwnd, classname, 50)

    # Check if the class of the child is button.
    if "button" in classname.value.lower():
        # Get the text of the button.
        length = USER32.SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0)
        text = create_unicode_buffer(length + 1)
        USER32.SendMessageW(hwnd, WM_GETTEXT, length + 1, text)

        # Check if the button is set as "clickable" and click it.
        textval = text.value.replace("&", "").lower()
        for button in buttons:
            if button in textval:
                for btn in dontclick:
                    if btn in textval:
                        break
                else:
                    log.info("Found button \"%s\", clicking it" % text.value)
                    USER32.SetForegroundWindow(hwnd)
                    KERNEL32.Sleep(1000)
                    USER32.SendMessageW(hwnd, BM_CLICK, 0, 0)

    # Recursively search for childs (USER32.EnumChildWindows).
    return True
Exemple #3
0
def foreach_child(hwnd, lparam):
    # List of partial buttons labels to click.
    buttons = [
        "yes", "oui", "ok", "i accept", "next", "suivant", "new", "nouveau",
        "install", "installer", "file", "fichier", "run", "start", "marrer",
        "cuter", "extract", "i agree", "accepte", "enable", "activer",
        "accord", "valider", "don't send", "ne pas envoyer", "don't save",
        "continue", "continuer", "personal", "personnel", "scan", "scanner",
        "unzip", "dezip", "open", "ouvrir", "close the program", "execute",
        "executer", "launch", "lancer", "save", "sauvegarder", "download",
        "load", "charger", "end", "fin", "terminer"
        "later", "finish", "end", "allow access", "remind me later", "save",
        "sauvegarder"
    ]

    # List of complete button texts to click. These take precedence.
    buttons_complete = [
        "&Ja",  # E.g., Dutch Office Word 2013.
    ]

    # List of buttons labels to not click.
    dontclick = ["don't run", "i do not accept"]

    classname = create_unicode_buffer(50)
    USER32.GetClassNameW(hwnd, classname, 50)

    # Check if the class of the child is button.
    if "button" in classname.value.lower():
        # Get the text of the button.
        length = USER32.SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0)
        text = create_unicode_buffer(length + 1)
        USER32.SendMessageW(hwnd, WM_GETTEXT, length + 1, text)

        if text.value in buttons_complete:
            log.info("Found button %r, clicking it" % text.value)
            click(hwnd)
            return True

        # Check if the button is set as "clickable" and click it.
        textval = text.value.replace("&", "").lower()
        for button in buttons:
            if button in textval:
                for btn in dontclick:
                    if btn in textval:
                        break
                else:
                    log.info("Found button %r, clicking it" % text.value)
                    click(hwnd)

    # Recursively search for childs (USER32.EnumChildWindows).
    return True
Exemple #4
0
def foreach_child(hwnd, lparam):
    # List of buttons labels to click.
    buttons = [
        "yes",
        "ok",
        "accept",
        "next",
        "install",
        "run",
        "agree",
        "enable",
        "don't send",
        "continue",
        "unzip",
        "open",
    ]

    # List of buttons labels to not click.
    dontclick = [
        "don't run",
    ]

    classname = create_unicode_buffer(50)
    USER32.GetClassNameW(hwnd, classname, 50)

    # Check if the class of the child is button.
    if classname.value == "Button":
        # Get the text of the button.
        length = USER32.SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0)
        text = create_unicode_buffer(length + 1)
        USER32.SendMessageW(hwnd, WM_GETTEXT, length + 1, text)

        # Check if the button is set as "clickable" and click it.
        textval = text.value.replace("&", "").lower()
        for button in buttons:
            if button in textval:
                for btn in dontclick:
                    if btn in textval:
                        return False

                log.info("Found button \"%s\", clicking it" % text.value)
                USER32.SetForegroundWindow(hwnd)
                KERNEL32.Sleep(1000)
                USER32.SendMessageW(hwnd, BM_CLICK, 0, 0)
        # Don't search for childs (USER32.EnumChildWindows).
        return False
    else:
        # Recursively search for childs (USER32.EnumChildWindows).
        return True
Exemple #5
0
    def run(self):
        seconds = 0
        nohuman = self.options.get("nohuman")
        if nohuman:
            return True
        file_type = self.config.file_type
        file_name = self.config.file_name
        officedoc = False
        if "Rich Text Format" in file_type or "Microsoft Word" in file_type or \
            "Microsoft Office Word" in file_type or file_name.endswith((".doc", ".docx", ".rtf")):
            officedoc = True
        elif "Microsoft Office Excel" in file_type or "Microsoft Excel" in file_type or \
            file_name.endswith((".xls", ".xlsx")):
            officedoc = True
        elif "Microsoft PowerPoint" in file_type or \
            file_name.endswith((".ppt", ".pptx", ".pps", ".ppsx", ".pptm", ".potm", ".potx", ".ppsm")):
            officedoc = True

        while self.do_run:
            if officedoc and seconds == 30:
                # send ALT+F4 equivalent
                USER32.SendMessageW(USER32.GetForegroundWindow(), WM_CLOSE, None, None)

            click_mouse()
            move_mouse()
            USER32.EnumWindows(EnumWindowsProc(foreach_window), 0)
            KERNEL32.Sleep(1000)
            seconds += 1
def get_office_window(hwnd, lparam):
    if USER32.IsWindowVisible(hwnd):
        text = create_unicode_buffer(1024)
        USER32.GetWindowTextW(hwnd, text, 1024)
        if "- Microsoft" in text:
            # send ALT+F4 equivalent
            USER32.SendMessageW(hwnd, WM_CLOSE, None, None)
    return True
def foreach_child(hwnd, lparam):
    buttons = ["&yes", "&ok", "&accept", "&next", "&install", "&run", "&agree"]

    classname = create_unicode_buffer(50)
    USER32.GetClassNameW(hwnd, classname, 50)

    # Check if the class of the child is button.
    if classname.value == "Button":
        # Get the text of the button.
        length = USER32.SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0)
        text = create_unicode_buffer(length + 1)
        USER32.SendMessageW(hwnd, WM_GETTEXT, length + 1, text)

        # Check if the button is "positive".
        for button in buttons:
            if text.value.lower().startswith(button):
                log.info("Found button \"%s\", clicking it" % text.value)
                KERNEL32.Sleep(1000)
                USER32.SendMessageW(hwnd, BM_CLICK, 0, 0)
def foreach_child(hwnd, lparam):
    # List of buttons labels to click.
    buttons = [
        "yes", "ok", "accept", "next", "install", "run", "agree", "enable",
        "don't send", "don't save", "continue", "unzip", "open",
        "close the program", "save"
    ]

    # List of buttons labels to not click.
    dontclick = [
        "don't run",
    ]

    classname = create_unicode_buffer(50)
    USER32.GetClassNameW(hwnd, classname, 50)

    # Check if the class of the child is button.
    if classname.value == "Button":
        # Get the text of the button.
        length = USER32.SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0)
        text = create_unicode_buffer(length + 1)
        USER32.SendMessageW(hwnd, WM_GETTEXT, length + 1, text)
        textval = text.value.replace('&', '')
        # Check if the button is set as "clickable" and click it.
        for button in buttons:
            if button in textval.lower():
                dontclickb = False
                for btn in dontclick:
                    if btn in textval.lower():
                        dontclickb = True
                if not dontclickb:
                    log.info("Found button \"%s\", clicking it" % text.value)
                    USER32.SetForegroundWindow(hwnd)
                    KERNEL32.Sleep(1000)
                    USER32.SendMessageW(hwnd, BM_CLICK, 0, 0)
                    # only stop searching when we click a button
                    return False
    return True
Exemple #9
0
def click(hwnd):
    USER32.SetForegroundWindow(hwnd)
    KERNEL32.Sleep(1000)
    USER32.SendMessageW(hwnd, BM_CLICK, 0, 0)
Exemple #10
0
def foreach_child(hwnd, lparam):
    # List of buttons labels to click.
    buttons = [
        # english
        "yes",
        "ok",
        "accept",
        "next",
        "install",
        "run",
        "agree",
        "enable",
        "don't send",
        "don't save",
        "continue",
        "unzip",
        "open",
        "close the program",
        "save",
        "later",
        "finish",
        "end",
        "allow access",
        "remind me later",
        # german
        "ja",
        "weiter",
        "akzeptieren",
        "ende",
        "starten",
        "jetzt starten",
        "neustarten",
        "neu starten",
        "jetzt neu starten",
        "beenden",
        "oeffnen",
        "schliessen",
        "installation weiterfuhren",
        "fertig",
        "beenden",
        "fortsetzen",
        "fortfahren",
        "stimme zu",
        "zustimmen",
        "senden",
        "nicht senden",
        "speichern",
        "nicht speichern",
        "ausfuehren",
        "spaeter",
        "einverstanden"
    ]

    # List of buttons labels to not click.
    dontclick = [
        # english
        "check online for a solution",
        "don't run",
        "do not ask again until the next update is available",
        "cancel",
        "do not accept the agreement",
        "i would like to help make reader even better",
        # german
        "abbrechen",
        "online nach losung suchen",
        "abbruch",
        "nicht ausfuehren",
        "hilfe",
        "stimme nicht zu"
    ]

    classname = create_unicode_buffer(128)
    USER32.GetClassNameW(hwnd, classname, 128)

    # Check if the class of the child is button.
    if "button" in classname.value.lower(
    ) or classname.value == "NUIDialog" or classname.value == "bosa_sdm_msword":
        # Get the text of the button.
        length = USER32.SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0)
        if not length:
            return True
        text = create_unicode_buffer(length + 1)
        USER32.SendMessageW(hwnd, WM_GETTEXT, length + 1, text)
        textval = text.value.replace('&', '')
        if "Microsoft" in textval and (classname.value == "NUIDialog" or
                                       classname.value == "bosa_sdm_msword"):
            log.info("Issuing keypress on Office dialog")
            USER32.SetForegroundWindow(hwnd)
            # enter key down/up
            USER32.keybd_event(0x0d, 0x1c, 0, 0)
            USER32.keybd_event(0x0d, 0x1c, 2, 0)
            return False

        # we don't want to bother clicking any non-visible child elements, as they
        # generally won't respond and will cause us to fixate on them for the
        # rest of the analysis, preventing progress with visible elements

        if not USER32.IsWindowVisible(hwnd):
            return True

        # Check if the button is set as "clickable" and click it.
        for button in buttons:
            if button in textval.lower():
                dontclickb = False
                for btn in dontclick:
                    if btn in textval.lower():
                        dontclickb = True
                if not dontclickb:
                    log.info("Found button \"%s\", clicking it" % text.value)
                    USER32.SetForegroundWindow(hwnd)
                    KERNEL32.Sleep(1000)
                    USER32.SendMessageW(hwnd, BM_CLICK, 0, 0)
                    # only stop searching when we click a button
                    return False
    return True
Exemple #11
0
def foreach_child(hwnd, lparam):
    # List of buttons labels to click.
    buttons = [
        "yes",
        "ok",
        "accept",
        "next",
        "install",
        "run",
        "agree",
        "enable",
        "don't send",
        "don't save",
        "continue",
        "unzip",
        "open",
        "close the program",
        "save",
        "later",
        "finish",
        "end",
        "allow access",
    ]

    # List of buttons labels to not click.
    dontclick = [
        "don't run",
        "do not ask again until the next update is available",
    ]

    classname = create_unicode_buffer(128)
    USER32.GetClassNameW(hwnd, classname, 128)

    # Check if the class of the child is button.
    if "button" in classname.value.lower() or classname.value == "NUIDialog":
        # Get the text of the button.
        length = USER32.SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0)
        if not length:
            return True
        text = create_unicode_buffer(length + 1)
        USER32.SendMessageW(hwnd, WM_GETTEXT, length + 1, text)
        textval = text.value.replace('&', '')
        if classname.value == "NUIDialog" and "Microsoft" in textval:
            log.info("Issuing keypress on Office dialog")
            USER32.SetForegroundWindow(hwnd)
            # enter key down/up
            USER32.keybd_event(0x0d, 0x1c, 0, 0)
            USER32.keybd_event(0x0d, 0x1c, 2, 0)
            return False

        # Check if the button is set as "clickable" and click it.
        for button in buttons:
            if button in textval.lower():
                dontclickb = False
                for btn in dontclick:
                    if btn in textval.lower():
                        dontclickb = True
                if not dontclickb:
                    log.info("Found button \"%s\", clicking it" % text.value)
                    USER32.SetForegroundWindow(hwnd)
                    KERNEL32.Sleep(1000)
                    USER32.SendMessageW(hwnd, BM_CLICK, 0, 0)
                    # only stop searching when we click a button
                    return False
    return True