Skip to content

Conversation

@kaitozaw
Copy link
Collaborator

Pull Request

Category

Bug

Feature/Issue Description

Q: Please give a brief summary of your feature/fix
A:
This PR fixes the Google phishing module failing on first run when executed via ARE. The module was generating runtime ReferenceError exceptions because required functions were not available in the execution context used by ARE and by inline event handlers.

Q: Give a technical rundown of what you have changed (if applicable)
A:
(1) Moved all module logic and helper functions inside beef.execute(function () { ... })
ARE can execute/evaluate only the beef.execute block (instead of evaluating the entire command.js file like normal UI module execution), so any functions defined outside the block may not exist at runtime, leading to “first run does nothing / second run works” behaviour.

(2)Exposed functions called by inline HTML event handlers to the global scope
The following changes were made because inline HTML event handlers (e.g. onclick="...") resolve function names from the global (window) scope:

  • function clickedSubmitButton() => window.clickedSubmitButton = function ()
  • function redirect() => window.redirect = function ()

(3)Replaced string-based setTimeout("...") usage with function references
The following changes were made to avoid string-based global evaluation and to ensure scheduled callbacks work correctly when functions are defined within beef.execute:

  • setTimeout('logoutGoogle()', ...) => setTimeout(logoutGoogle, ...)
  • setTimeout("redirect()", ...) => setTimeout(window.redirect, ...)

Test Cases

Q: Describe your test cases, what you have covered and if there are any use cases that still need addressing.
A:

  1. Create beef/arerules/enabled/gmail_phishing.json
{
  "name": "Google Phishing",
  "author": "jking",
  "modules": [
    {
      "name": "gmail_phishing",
      "condition": null,
      "code": null,
      "options": {
        "xss_hook_url": "https://myaccount.google.com/",
        "logout_gmail_interval": 10000,
        "wait_seconds_before_redirect": 1000
      }
    }
  ],
  "execution_order": [0],
  "execution_delay": [0],
  "chain_mode": "sequential"
}
  1. Start beef, open demo page and check if the Google phishing module is executed on first run. Also check if the module is executed correctly without the ARE.

@kaitozaw kaitozaw temporarily deployed to Integrate Pull Request December 24, 2025 03:51 — with GitHub Actions Inactive
@kaitozaw kaitozaw force-pushed the issue/3073-fix-google-phishing-module branch from 21486c2 to e227ea7 Compare December 30, 2025 04:19
@kaitozaw kaitozaw temporarily deployed to Integrate Pull Request December 30, 2025 04:19 — with GitHub Actions Inactive
@kaitozaw kaitozaw force-pushed the issue/3073-fix-google-phishing-module branch from e227ea7 to f6f2def Compare December 31, 2025 05:14
@kaitozaw kaitozaw temporarily deployed to Integrate Pull Request December 31, 2025 05:14 — with GitHub Actions Inactive
@zinduolis zinduolis linked an issue Jan 2, 2026 that may be closed by this pull request
@kaitozaw kaitozaw force-pushed the issue/3073-fix-google-phishing-module branch from f6f2def to 15d2acf Compare January 2, 2026 23:34
@kaitozaw kaitozaw temporarily deployed to Integrate Pull Request January 2, 2026 23:34 — with GitHub Actions Inactive
Copy link
Contributor

@zinduolis zinduolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there's a mix of indentation styles in this file now. The new code blocks use 2 spaces, while lines 42-44 (and the file originally) used tabs/4 spaces.

Looking at other modules (e.g., ajax_fingerprint/command.js, port_scanner/command.js), the project seems to consistently favor tabs (or 4 spaces).

Could you please update the indentation to match the rest of the file and project? Thanks

@zinduolis
Copy link
Contributor

Verification Report

I verified this fix against Issue #3073 using the following test plan:

1. Reproduction (Master Branch)

  • Created an ARE rule to trigger gmail_phishing automatically on hook.
  • Result: The browser tab title changed to "Google Mail...", but the page content remained on the original hook page (Butcher demo). The module failed to fully execute.

2. Verification (PR Branch)

  • Applied the changes from this PR.
  • Restarted BeEF and re-hooked the browser.
  • Result: Success. The page content immediately updated to the fake Gmail login screen, the title was correct, and the module functioned as expected.

Conclusion
This PR fixes the issue where the module would not execute properly when triggered via ARE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Google Phishing module doesn't execute properly as an ARE Rule

2 participants