Jump to content

Deprecated syntax for Random Int


HandyGeek
 Share

Recommended Posts

Hello

  Not sure if I am missing something, but every time I try and use $_RANDOM_INT I get just a $ to print out instead of a random integer. I have been trying to figure it out for a bit now and just realized with the update to Studio Pro that it is a Deprecated syntax. I checked and I do have Allow DEPRECATED Duckyscript 1.0 Fallback Syntax checked and with it unchecked it does not even recognize the syntax. I have not read anywhere about updated syntax for Random in the documentation, and it seems a lot of the Random Variables do not work in the same way. I am sure I am missing something  just unsure what If anyone has an idea it would be super helpful 🙂 thank you

Link to comment
Share on other sites

Duh sorry lol I added the REMs for the post I have tried several different ways

    REM Function to have the program randomly select a number
        REM FUNCTION CHOOSE_A_NUMBER()
            REM $_RANDOM_INT
        REM END_FUNCTION

    REM List of Variables and Constants
        REM VAR $MACHINE_NUMBER = $_RANDOM_INT

    REM $_RANDOM_INT

and with the new 1.2.0 of Payload studio it shows just using the internal variable with a exclamation triangle that says Deprecated Syntax will only (sic) the first character: $

If I turn off Allow DEPRECATED Duckyscript 1.0 Fallback Syntax That warning turns to an Error "Unrecognized syntax - Key not found in language file: $_RANDOM_INT

I get that warning/error with all RANDOM variables it seems except MIN and MAX.

I have Persist language file enabled and Display DUCKY_LANG above editor off. But changing those setting does not fix the error

Thank you for Replying

 

Link to comment
Share on other sites

I believe that is what I was trying to do first

This is the code I wrote that will successfully compile but where $MACHINE_NUMBER is called it just prints a $

    REM Attackmode, Startup Delay, and LED Set to Off
        REM ATTACKMODE HID STORAGE
        REM DELAY 2000
        REM LED_OFF
        REM $_RANDOM_MIN = 1
        REM $_RANDOM_MAX = 10

    REM Button Def to Restart the Payload
        REM BUTTON_DEF
            REM RESTART_PAYLOAD
        REM END_BUTTON

    REM List of Variables and Constants
        REM VAR $MACHINE_NUMBER = $_RANDOM_INT

    REM Opens Notepad with Windows Run Command and Makes it Full Screen
        REM GUI r
        REM DELAY 200
        REM STRINGLN notepad
        REM DELAY 1000
        REM ALT SPACE
        REM DOWNARROW
        REM DOWNARROW
        REM DOWNARROW
        REM DOWNARROW
        REM ENTER

    REM Prompt for user input
        REM STRINGLN I'm thinking of a number between 1 and 10
        REM DELAY 1000
        REM STRINGLN Try and guess the number I have selected. Please type one number

        REM between and 10 now.
        REM DELAY 2000
            REM $MACHINE_NUMBER

Thanks again for your time 🙂

Link to comment
Share on other sites

You can't just echo out the variable since it's not a string, it's still a variable containing an integer value. You will have to "force" it to print a string. There are functions available that I've used to echo out strings based on what a variable is containing. Check this post for some possible inspiration.

I said before that you have to assign the output of $_RANDOM_INT to a variable, but that's not entirely true. You could use it without doing that in a function but it's not documented as far as I know.

Link to comment
Share on other sites

That is a bit out of my league lol I am super new I am taking the course and it has an example of something similar that I was trying to do for the assignment.

REM Example Random Integer Example with Range

REM LED_OFF

REM $_RANDOM_MIN = 20

REM $_RANDOM_MAX = 50

REM VAR $A = $_RANDOM_INT

REM WHILE ($A > 0)

REM LED_G

REM DELAY 500

REM LED_OFF

REM DELAY 500

REM END_WHILE

Is it because the variable is being called as a parameter in the While loop that it works there?

Link to comment
Share on other sites

Well, I guess you got some answers on Discord.

$_RANDOM_MIN and $_RANDOM_MAX isn't really the same as $_RANDOM_INT and that's why you can use $_RANDOM_MIN and $_RANDOM_MAX in the payload code in a different way than $_RANDOM_INT. $_RANDOM_MIN and $_RANDOM_MAX just "sets the scene" for $_RANDOM_INT, and $_RANDOM_INT does more than just hold some values since it is doing the actual randomization and returns a randomized value.

You were correct on Discord about needing to decrement $A, otherwise the while loop will run forever (which I previously had commented about on Discord).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...