Jump to content

burnsoft

Active Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by burnsoft

  1. I created a shell script to help manage my ducky scripts and to copy what i wanted to use to the root of the drive.  After creating it, i wanted to post it just incase anyone else might find it useful and came across this thread.  I made this shell script on a mac, and also tested it out on another linux based box and didn’t have any problems.  The only thing I had to do on the mac was download the “dialog” command via brew.

     

    Currently my SD card contains the following directory structure: 

     

    dirStructure.png

     

    As you can see, some of these scripts are from the repository.  The Directories are the same name as the script, each directory has the script and the compiled version of the script ready for the duck.

     

    When i put in the SD card, i run the menu.sh to bring up the “script manager”

    what is does is just read the contents of the directory structure and puts it in a menu.

     

    menu.png

     

    I find the one i want and hit enter

     

    menu1.png

     

    and it will copy it to the root drive

     

    file_copied.png

     

    and the script exits.

     

    if the inject.bin does not exist where the script is located at, then it will compile it.

    A lot of the top vars can be changed if you need to.  I mostly created it based on how i run and manage the scripts.

     

    GitHub for DuckMenu

     

    Source:

     

    #!/bin/bash
    #ducky_menu.sh
    #Version: 1.0.5
    #by JM
    MainFile="inject.bin";  #the compiled file for the rubber ducky
    CurrentPath=$PWD;		#The path of were the menu.sh was ran, this can be hardcoded if needed
    ScriptsPath="$CurrentPath/scripts";	 #path of where the scripts are at, usually a sub folder of the current
    EncoderPath="$CurrentPath/Encoder/encoder.jar"; #location of the encoder
    MakeDirMoveFiles=true;	#if you have the code in the scripts director and what it to be in it's own directory
    ScriptExt="txt";		#the extenstion of the script
    PathName="";			#global var, leave blank
    choices="";				#global var, leave blank
    
    MakeDirFromFiles()
    {
    	cd $ScriptsPath
    	for file in *.$ScriptExt; 
    		do 
    			mkdir -- "${file%.$ScriptExt}"; mv -- "$file" "${file%.$ScriptExt}"; 
    		done
    	cd $CurrentPath
    }
    DoCopy()
    {
    	cpFrom="$ScriptsPath/${PathName[@]}/$MainFile"
    	cpTo="$CurrentPath/$MainFile"
    	cp "$cpFrom" "$cpTo"
    	dialog --title 'File Copied' --msgbox "$cpFrom was copied to $enTo" 6 60
    }
    RunEncoder()
    {
    	enFrom="$ScriptsPath/${PathName[@]}/${PathName[@]}.$ScriptExt"
    	enTo="$CurrentPath/$MainFile"
    	java -jar $EncoderPath -i "$enFrom" -o $enTo
    	dialog --title 'File Compiled' --msgbox "$cpFrom was comiled to $enTo" 8 60
    }
    DoMenu()
    {
    	i=0
    	x=1
    	while read line
    	do
    		array[ $i ]="$line" 
    		if [[ -n "$options" ]]; then
    			options=("${options[@]}" "$x" "\"$line\"" "off")
    		else
    			options=("$x" "\"$line\"" "off")
    		fi
    		(( i++ ))
    		(( x++ ))
    	done < <(ls $ScriptsPath)
    	cmd=(dialog --separate-output --checklist "Select options:" 22 76 16)
    	choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
    	if [ -z "$choices"] ; then
    		choices=0
    	fi
    	if (($choices > 0)) ; then
    		arrayID=`expr $choices - 1`
    		PathName="${array[$arrayID]}"
    		if [ -f "$ScriptsPath/$PathName/$MainFile" ]; then
    			DoCopy $PathName
    		else
    			RunEncoder $PathName
    		fi
    		clear
    		echo "Good Bye Happy Ducking!"
    	else
    		clear
    		echo "No Options selected..Good Bye!"
    	fi
    }
    if $MakeDirMoveFiles ; then
    	MakeDirFromFiles;
    fi
    DoMenu;
    

     

  2. Sorry the pictures didn't come through. and I can't edit

     

    Currently my SD card contains the following directory structure:

    dirStructure.png

    As you can see, some of these scripts are from the repository.  The Directories are the same name as the script, each directory has the script and the compiled version of the script ready for the duck.

     

    When i put in the SD card, i run the menu.sh to bring up the “script manager”

    what is does is just read the contents of the directory structure and puts it in a menu.

     

    menu.png

     

    I find the one i want and hit enter

     

    menu1.png

     

    and it will copy it to the root drive

     

    file_copied.png

     

    and the script exits.

     

    if the inject.bin does not exist where the script is located at, then it will compile it.

    A lot of the top vars can be changed if you need to.  I mostly created it based on how i run and manage the scripts.

  3. I created a shell script to help manage my ducky scripts and to copy what i wanted to use to the root of the drive.  After creating it, i wanted to post it just incase anyone else might find it useful and came across this thread.  I made this shell script on a mac, and also tested it out on another linux based box and didn’t have any problems.  The only thing I had to do on the mac was download the “dialog” command via brew.

     

    Currently my SD card contains the following directory structure: 

    As you can see, some of these scripts are from the repository.  The Directories are the same name as the script, each directory has the script and the compiled version of the script ready for the duck.

     

    When i put in the SD card, i run the menu.sh to bring up the “script manager”

    what is does is just read the contents of the directory structure and puts it in a menu. 

    I find the one i want and hit enter

    and it will copy it to the root drive 

    and the script exits.

     

    if the inject.bin does not exist where the script is located at, then it will compile it.

    A lot of the top vars can be changed if you need to.  I mostly created it based on how i run and manage the scripts.

     

    menu.sh  or ducky_menu.sh (call it whatever you want )

     

     

    #!/bin/bash
    #ducky_menu.sh
    #Version: 1.0.5
    #by JM
    MainFile="inject.bin";  #the compiled file for the rubber ducky
    CurrentPath=$PWD;        #The path of were the menu.sh was ran, this can be hardcoded if needed
    ScriptsPath="$CurrentPath/scripts";     #path of where the scripts are at, usually a sub folder of the current
    EncoderPath="$CurrentPath/Encoder/encoder.jar"; #location of the encoder
    MakeDirMoveFiles=true;    #if you have the code in the scripts director and what it to be in it's own directory
    ScriptExt="txt";        #the extenstion of the script
    PathName="";            #global var, leave blank
    choices="";                #global var, leave blank
    
    MakeDirFromFiles()
    {
        cd $ScriptsPath
        for file in *.$ScriptExt; 
            do 
                mkdir -- "${file%.$ScriptExt}"; mv -- "$file" "${file%.$ScriptExt}"; 
            done
        cd $CurrentPath
    }
    DoCopy()
    {
        cpFrom="$ScriptsPath/${PathName[@]}/$MainFile"
        cpTo="$CurrentPath/$MainFile"
        #echo "copy from $cpFrom $cpTo"
        #rm $MainFile
        cp "$cpFrom" "$cpTo"
        dialog --title 'File Copied' --msgbox "$cpFrom was copied to $enTo" 6 60
    }
    RunEncoder()
    {
        enFrom="$ScriptsPath/${PathName[@]}/${PathName[@]}.$ScriptExt"
        enTo="$CurrentPath/$MainFile"
        java -jar $EncoderPath -i "$enFrom" -o $enTo
        dialog --title 'File Compiled' --msgbox "$cpFrom was comiled to $enTo" 8 60
    }
    DoMenu()
    {
        i=0
        x=1
        while read line
        do
            array[ $i ]="$line" 
            #options="${options} ${x} \"$line\" off"$'\n'
            if [[ -n "$options" ]]; then
                options=("${options[@]}" "$x" "\"$line\"" "off")
            else
                options=("$x" "\"$line\"" "off")
            fi
            #options=("${options[@]}" "$x" "$line")
            (( i++ ))
            (( x++ ))
        done < <(ls $ScriptsPath)
        cmd=(dialog --separate-output --checklist "Select options:" 22 76 16)
        choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
        if [ -z "$choices"] ; then
            choices=0
        fi
        if (($choices > 0)) ; then
            arrayID=`expr $choices - 1`
            PathName="${array[$arrayID]}"
            if [ -f "$ScriptsPath/$PathName/$MainFile" ]; then
                DoCopy $PathName
            else
                RunEncoder $PathName
            fi
            clear
            echo "Good Bye Happy Ducking!"
        else
            clear
            echo "No Options selected..Good Bye!"
        fi
    }
    if $MakeDirMoveFiles ; then
        MakeDirFromFiles;
    fi
    DoMenu;
    

     

  4. I started with the duckencode.jar but noticed it hated blank lines in the script, the encoder.jar didn't care about the blank lines between the commands so i started to use the encoder.jar script.

    I normally use  

    java -jar encoderpath/encoder.jar -i filepath/filename.txt -o /filepath/inject.bin

     Since you are using Mac, I've been using CodeRunner for the scripts, in the Preference/Language settings, you can create a new Language ( i called my DuckyScript ) with file extension of txt,  You can also put in the encoder parameters in this setting, so when you click on run it will compile it, it will compile it in the same path as the script

    The encoder parameters that I used are:

    java -jar /RubberDucky/Encoder/encoder.jar -i "$filename" -o inject.bin

×
×
  • Create New...