mame82 / duck2spark

Converter for raw RubberDucky payloads to Digispark Arduino IDE Sketch source.
471 stars 95 forks source link

Language file /resources/de.properties doesn't exist or isn't readable #8

Open Staubgeborener opened 7 years ago

Staubgeborener commented 7 years ago

I tried you're duck2spark converter (and also the DuckEncoder, Python Version). But i'll get some issues: I try to convert a duckyscript (for example this one: https://github.com/hak5darren/USB-Rubber-Ducky/wiki/Payload---WiFi-password-grabber). I create a new file called "wlanscript.duck". After that, i use the duckencoder to get the german keboard layout: cat wlanscript.duck | python duckencoder.py -p -l de > inject.bin The last step: Create an Arduino Sketch: duck2spark.py -i inject.bin -l 1 -f 2000 -o sketch.ino

And here are the issues: The file sketch.ino looks a little bit weird in my Arduino IDE:

 /*
* Sketch generated by duck2spark from Marcus Mengs aka MaMe82
*
*/
#include "DigiKeyboard.h"

#define DUCK_LEN 71
const PROGMEM uint8_t duckraw [DUCK_LEN] = {
    0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x20, 0x64, 0x6f, 0x65, 0x73, 0x6e, 0x27, 0x74, 0x20, 0x65, 0x78, 0x69, 0x73, 0x74, 0x20, 0x6f, 0x72, 0x20, 0x69, 0x73, 0x6e, 0x27, 0x74, 0x20, 0x72, 0x65, 0x61, 0x64, 0x61, 0x62, 0x6c, 0x65, 0xa
};
int i = 1; //how many times the payload should run (-1 for endless loop)
bool blink=true;

void setup()
{
    // initialize the digital pin as an output.
    pinMode(0, OUTPUT); //LED on Model B
    pinMode(1, OUTPUT); //LED on Model A
    DigiKeyboard.delay(2000); //wait 2000 milliseconds before first run, to give target time to initialize
}

void loop()
{

    //should code be runned in this loop?
    if (i != 0) {
        DigiKeyboard.sendKeyStroke(0);

        //parse raw duckencoder script
        for (int i=0; i<DUCK_LEN; i+=2)
        {
            uint8_t key = pgm_read_word_near(duckraw + i);
            uint8_t mod = pgm_read_word_near(duckraw + i+1);
            if (key == 0) //delay (a delay>255 is split into a sequence of delays)
            {
                DigiKeyboard.delay(mod);
            }
            else DigiKeyboard.sendKeyStroke(key,mod);
        }
        i--;
        DigiKeyboard.delay(5000); //wait 5000 milliseconds before next loop iteration

    }
    else if (blink)
    {
        digitalWrite(0, HIGH);   // turn the LED on (HIGH is the voltage level)
        digitalWrite(1, HIGH);
        delay(100);               // wait for a second
        digitalWrite(0, LOW);    // turn the LED off by making the voltage LOW
        digitalWrite(1, LOW);
        delay(100);               // wait for a second
    }
}

Is this correct? When i try to compile this (and waited the till the 60-second 'plug your digispark now into your usb port' message appears) and to flash my digispark i'll get this message:

Starting the user app ...

Run error -1 has occured ... Please unplug the device and restart the program.

After that i watched into my inject.in file and get this message root@kali:~/duck2spark-master# cat inject.bin Language file /resources/de.properties doesn't exist or isn't readable

In my duck2spark folder is a subdirectory "resources" with the file de.properties.

I don't get where the problem is. :/

mame82 commented 7 years ago

Sorry for late reply...

This issue seems to be caused by duckencoder.py, because it fails to fetch its own path here

https://github.com/mame82/duckencoder.py/blob/master/duckencoder.py#L405

This again leads to wrong creation of the path to <path of duckencoder.py>/resources/de.properties

Unfortunately I'm not able to further dive into this the next days, so there're two suggestions:

1) Try to call duckencoder.py with absolute path cat wlanscript.duck | python /full/path/to/script/duckencoder.py -p -l de > inject.bin

2) Fall back to native duckencoder from Hak5

Please understand that I'm not developing duckencoder.py with high priority, as it is only a support project for P4wnP1 (to get rid of Java), where this issue doesn't exist. Besides the need of a Java runtime, there's no disadvantage switching to native duckencoder

Btw. if you want to stay on python have a look into https://github.com/kevthehermit/DuckToolkit.

Duck2Spark seems to work fine in your case... beside the fact that the payload bytes are generated from an ASCII error message, instead of the raw encoded ducky payload (the error message of duckencoder.py has been pipes into inject.bin)