Jump to content

[INFO] How to Make USB Rubber Ducky Scripts When Drive Letter is Unknown


Recommended Posts

How to Make USB Rubber Ducky Scripts When Drive Letter is Unknown.


Ever wanted to make script that could get a file from the USB Rubber Ducky SD card. If you have you probably have run into the problem that, every time you plug the USB Rubber Ducky into a different computer, it most likely has a different drive letter then the last computer you plugged it into. Which means you would have to go back and change the drive letter in the script. If you are having problems with this then your on the right page! What I am going to hopefully teach you in this page is how to overcoming this problem. 

Here I have an example of a script that I have wrote that uses the Twin Duck Firmware to change the wallpaper of the computer to a file on my USB Rubber Ducky SD card.

------------------------------------------

DELAY 1000
REM -----------Opens CMD-----------
WINDOWS R
DELAY 500
STRING cmd
ENTER
DELAY 600
REM -----------Sets Wallpaper to image in the DUCKY SD card-----------
STRING reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d  E:\target.bmp /f
ENTER
DELAY 200
REM -----------Refreshing the wallpaper-----------
STRING RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
ENTER
DELAY 100
STRING exit
ENTER


------------------------------------------


As you can see in the script, we open up cmd via run and then type in :

------------------------------------------------------------------------------------

reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d E:\target.bmp /f

------------------------------------------------------------------------------------

The underlined part of the the script is the path of the target.bmp image inside the USB Rubber Ducky's SD card. Now if your drive letter is always changing, your going to run into a problem when you go to execute the command on a different machine that has, lets say, made your USB Rubber Ducky's Path the letter V, your going to run into some problems.

To overcome this problem is really, really simple. And is shown here in a altered version of the script

------------------------------------------

DELAY 1000
REM -----------Opens CMD-----------
WINDOWS R
DELAY 500
STRING cmd
ENTER
DELAY 600
REM -----------Sets %ducky% to DUCKY drive letter-----------
STRING for /f %d in ('wmic volume get driveletter^, label ^| findstr "DUCKY"') do set ducky=%d
ENTER
DELAY 100
REM -----------Sets Wallpaper to image in the DUCKY SD card-----------
STRING reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d  %ducky%/target.bmp /f
ENTER
DELAY 200
REM -----------Refreshing the wallpaper-----------
STRING RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
ENTER
DELAY 100
STRING exit
ENTER

------------------------------------------

As you can see, when cmd gets opened this script is typed in straight away and is executed:

------------------------------------------------------------------------------------

for /f %d in ('wmic volume get driveletter^, label ^| findstr "DUCKY"') do set ducky=%d

------------------------------------------------------------------------------------

The first thing that this command does is finds our Storage Device which is named 'DUCKY', which should be the SD card that is plugged into the USB Rubber Ducky. If your device's name is different you can either change the SD card name to 'DUCKY' or you can edit the command. If you want to change the command all you need to do is change 'DUCKY' in the command line to the name of your SD card, in the USB Rubber Ducky. The second thing the command does is make it so when you type in '%ducky% it will automatically make it mean the drive letter of the Ducky SD Card. For Example if I type in %ducky%/target.txt. It will open 'target.txt' in the 'DUCKY' SD Card, because %ducky% equals the drive letter of the SD card.

Please note this can only be used in cmd, it will not work in another program like Run or File Explorer.

I really hope this helps you guys if you have had this problem. If there is any wrong information in this post please let me know. 


Cheers, Bingoe33 :smile:

Link to post
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.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...