Jump to content

Best way to input range of numbers 0000-9999


KoalamanX
 Share

Recommended Posts

Hi I am trying to create a script on the new rubber ducky device that will use a string to input append starting at 0000 and keep in putting it until it has the correct pin of course I could do this: DELAY 3000 STRING 0000 DELAY 2000 STRING 0001 DELAY 2000 STRING 0002 DELAY 2000 STRING 0003....

But that would take a lot of insane long work.

Im new to coding, so I was thinking of a while function, but not sure yet how to code one for the ducky.

 

Can someone help me out please?

Link to comment
Share on other sites

You could try this. Perhaps not the best way, but it gets the job done. You got advised on Discord to use the TRANSLATE extension and the code below is partly from that but stripped down to do just what's needed to get integer variable values into strings possible to "echo" out from the Ducky to the target.

ATTACKMODE HID

DELAY 3000

DEFINE PRINT_INT 0
DEFINE PRINT_HEX 1

VAR $DIGIT_PRINT_MODE = PRINT_INT
VAR $D = 0
VAR $INPUT = 0
VAR $MOD = 0
VAR $P = FALSE
VAR $NL = TRUE

FUNCTION PRINTDIGIT()
	IF ($D == 0) THEN
		STRING 0
	ELSE IF ($D == 1) THEN
		STRING 1
	ELSE IF ($D == 2) THEN
		STRING 2
	ELSE IF ($D == 3) THEN
		STRING 3
	ELSE IF ($D == 4) THEN
		STRING 4
	ELSE IF ($D == 5) THEN
		STRING 5
	ELSE IF ($D == 6) THEN
		STRING 6
	ELSE IF ($D == 7) THEN
		STRING 7
	ELSE IF ($D == 8) THEN
		STRING 8
	ELSE IF ($D == 9) THEN
		STRING 9
	ELSE IF ($DIGIT_PRINT_MODE == PRINT_HEX) THEN 
		IF ($D == 10) THEN
			STRING A
		ELSE IF ($D == 11) THEN
			STRING B
		ELSE IF ($D == 12) THEN
			STRING C
		ELSE IF ($D == 13) THEN
			STRING D
		ELSE IF ($D == 14) THEN
			STRING E
		ELSE IF ($D == 15) THEN
			STRING F
		END_IF
	ELSE 
		STRING ?
	END_IF
END_FUNCTION

FUNCTION CONSUME()
	$D = 0
	WHILE ($INPUT >= $MOD)
		$D = ($D + 1)
		$INPUT = ($INPUT - $MOD)
	END_WHILE
	IF (($D > 0) || ($P == TRUE)) THEN
		$P = TRUE
		PRINTDIGIT()
	END_IF
END_FUNCTION

FUNCTION TRANSLATE_INT() 
	$DIGIT_PRINT_MODE = PRINT_INT
	$P = FALSE
	IF ( $INPUT >= 10000) THEN
		$MOD = 10000
		CONSUME()
	END_IF
	IF (($INPUT >= 1000) || ($P == TRUE)) THEN
		$MOD = 1000
		CONSUME()
	END_IF
	IF (($INPUT >= 100) || ($P == TRUE)) THEN
		$MOD = 100
		CONSUME()
	END_IF
	IF (($INPUT >= 10) || ($P == TRUE)) THEN
		$MOD = 10
		CONSUME()
	END_IF()
	$D = $INPUT
	PRINTDIGIT()
	IF $NL THEN
		ENTER
	END_IF
END_FUNCTION

VAR $myVar = 0
WHILE ( $myVar < 10 )
    $INPUT = $myVar
    STRING 000
    TRANSLATE_INT()
    $myVar = ( $myVar + 1 )
    REM DELAY 20
END_WHILE
WHILE ( $myVar < 100 )
    $INPUT = $myVar
    STRING 00
    TRANSLATE_INT()
    $myVar = ( $myVar + 1 )
    REM DELAY 20
END_WHILE
WHILE ( $myVar < 1000 )
    $INPUT = $myVar
    STRING 0
    TRANSLATE_INT()
    $myVar = ( $myVar + 1 )
    REM DELAY 20
END_WHILE
WHILE ( $myVar < 10000 )
    $INPUT = $myVar
    TRANSLATE_INT()
    $myVar = ( $myVar + 1 )
    REM DELAY 20
END_WHILE

 

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...