Jump to content

Convert your existing bash scripts & batch files to ducky script


Xsoc

Recommended Posts

I wrote a simple script for both windows and linux, txt2ducky that will turn this

@echo off
@echo Super cool awesome batch file
ipconfig

into this

STRING @echo off
ENTER
STRING @echo Super cool awesome batch file
ENTER
STRING ipconfig
ENTER

Nothing earth shattering, but I find it useful anyway. I'm sure it's been done before, but I couldn't find any examples soooo... whatever, here it is.

 

Download
Windows: txt2ducky.cmd
Linux/etc: txt2ducky.sh

 

Usage

txt2ducky inputfile [outputfile]

 

Roll Your Own

If you want to use the code in another (batch file) project, all you really need is

FOR /F "usebackq delims=" %%I IN ("%FILEIN%") DO (
    @echo STRING %%I >> "%FILEOUT%"
    @echo ENTER      >> "%FILEOUT%"
)

or in a bash script, go for...

while read -r line; do
    echo STRING $line >> $fileout
    echo ENTER        >> $fileout
done < $filein

 

Just RegEx It!

You can of course achieve the same thing was a simple RegEx find and replace...
Find: .*
Replace: STRING $0\nENTER

 

Wrapping Up

Hopefully someone else finds it useful.

More details available on the GitHub Repo.

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.

  • Recently Browsing   0 members

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