firmware icon indicating copy to clipboard operation
firmware copied to clipboard

JS Interpreter issues

Open AnoNy-Sec opened this issue 7 months ago • 4 comments

Describe the bug: When I try to run JS scripts "ir_brute.js", "rf_brute.js", "wifi_brute.js" by @eadmaster from sd_files/interpreter/ library, instead of working properly it opens script's menu for a less than a second and then it crashes to the main menu. All three scripts run with the same problem, no error message or anything, it just crashes the script

Steps To Reproduce: JS Interpreter > Load... > Select one of the scripts > Experience the bug.

  • Device used: T-Embed CC1101 (Beta Release)

Expected behavior: I expected all three JS scripts to run smoothly (some do)

Actual behavior: After running them I see script's menu for a second and then it crashes me to main menu for some reason

AnoNy-Sec avatar May 19 '25 16:05 AnoNy-Sec

followup https://github.com/pr3y/Bruce/issues/1168#issuecomment-2889470336

It should be something affecting to the loopOptions function

eadmaster avatar May 19 '25 18:05 eadmaster

For what I could see, the dialogChoice fuction had changed, and need to update the scripts to match the new parameters

https://github.com/bmorcelli/Bruce/blob/d72209a5cd3a38d3910434953530b934230b996e/src/modules/bjs_interpreter/gui_js.cpp#L76

duk_ret_t native_dialogChoice(duk_context *ctx) {
    // usage: dialogChoice(choices : string[] | {[key: string]: string})
    // legacy version dialogChoice takes ["choice1", "return_val1", "choice2",
    // "return_val2", ...] new version dialog.choice takes ["choice1", "choice2"
    // ...] or {"choice1": "return_val1", "choice2": "return_val2", ...} returns:
    // string ("return_val1", "return_val2", ...), or empty string if cancelled
...
}

bmorcelli avatar May 27 '25 15:05 bmorcelli

it is bailing out here:

https://github.com/pr3y/Bruce/blob/d72209a5cd3a38d3910434953530b934230b996e/src/core/display.cpp#L537

In the last changes, the main menu, menus and etc are running all inside loopOptions.. need to find a way to handle it

bmorcelli avatar May 27 '25 19:05 bmorcelli

Fixed the dialogChoice functionality by patching the loopOptions function.

Updated the rf_brute.js, ir_brute.js and wifi_brute.js

Available on Beta for testing

bmorcelli avatar May 27 '25 20:05 bmorcelli