WUD-Ducky icon indicating copy to clipboard operation
WUD-Ducky copied to clipboard

'USB_VID' was not declared in this scope

Open Ciph3rCat opened this issue 3 years ago • 51 comments

I am trying to flash from active branch, and getting this error, 'USB_VID' was not declared in this scope.

How can I fix this?

The main branch does flashes successfully and wifi becomes available but webpage is not accessible at 192.168.4.1.

Ciph3rCat avatar Jan 26 '22 05:01 Ciph3rCat

hey @Ciph3rCat thanks for your feedback :+1:

You can fix that by uncommenting the declarations in USBConfig.h.

Keep in mind those declarations will be ignored (and overriden by Espressif system defaults) as soon as you enable "USBCDC on boot" in the Arduino tools menu.

tobozo avatar Jan 26 '22 10:01 tobozo

Thanks for the prompt reply. Both solutions worked (uncommenting lines and enabling cdc on boot). However now there is no wifi available, the red light is constantly on. Any ideas?

Ciph3rCat avatar Jan 26 '22 11:01 Ciph3rCat

I had this symptom a few minutes ago with cdc on boot disabled, not easy to debug this one when serial is clogged :-)

For some reason I'm trying to figure out, it can't work when the 'cdc on boot' option is disabled, which is fine since we need cdc anyway.

Here's what my menu looks like:

image

I've created a custom board folder profile in my Arduino IDE, it's a copy of the original esp32s2-dev profile, with most options prechecked and a modified pins_arduino.h file.

image

I've also pushed some minor changes.

tobozo avatar Jan 26 '22 11:01 tobozo

I matched the configuration and flashed latest commit. But got same results then I realize Windows displays 'usb does not recognised' after few minutes. I think, the culprit is 'zadig' software because I was having difficulty in putting board into flash mode and thought maybe drivers are missing and read somewhere about this tool and installed drivers using this. Now I don't know if there's anyway to revert those changes or maybe I have to do fresh Windows installation. 😕

I tried the board on mac and it displayed general error, 'unknown keyboard detected, press ant key to identify the keyboard' which is not possible, however the wifi was available and web interface was accessible.

If you have any suggestions please share with me, and I'm planning to contribute in the documentation once I'll solve the current bugs.

By the way, it turns on led, where can I update the code to disable that?

Ciph3rCat avatar Jan 26 '22 13:01 Ciph3rCat

interesting, I haven't tested much the web UI (most tests were made thru the serial interface) so I'll welcome your feedback.

I just tried to plug the WUD on a windows laptop (never plugged there before but has an installation of Arduino IDE) and the USB drive got detected, mounted and even repaired.

This only happened once, after unplugging and re-pluging the USB Pendrive can't be detected anymore and the led is always on.

I can't test much for now since the OS choose that moment to start a very long windows update process :facepalm: , but I'll check the detections status of the other USB devices as soon as it's finished.

thoughts about zadig: maybe it tried to identify dead:b33f or cafe:deca and got the wrong idea (those are dummy IDs)?

However the device descriptor in the USB packets can't lie, so zadig should at least idenfity a driver for the USBSerial interface, and not ask to install anything for mouse or keyboard since those are already part of the system.

I'm not sure about the the mac though, sending the key from the web interface would seem the obvious thing to do but I haven't tested that part much since I've implemented SpaceHuhn's WiFiDuck syntax.

Otherwise there may be something interesting to implement on the ESP side such as mocking an existing model, you can experiment with that from the pins_arduino.h file.

to turn the led off send this command: LED 0

However in a successful boot scenario it should blink a few times an turn itself off.

tobozo avatar Jan 26 '22 14:01 tobozo

You are right there's some weird behaviour on windows, and you mentioned it will turn off led after successful connection but that doesn't happen once. I have tried different operating system but it is always on, however on linux and mac the wifi connection does show and opens website fine.

Questions:

  1. How do I open serial connection with the board? (tried in putty and arduino serial monitor after putting in dev mode, always results in empty screen, also tried different baud rate and regular mode)

  2. The yesterday commit isn't compiling, USB_PID was not declared in this scope. How this can be fixed?

  3. In Linux, I tried to send keystrokes like this: http://192.168.4.1/key?=hello but those wasn't sent to linux box, just echoed in browser. From the homepage, I uploaded a text document and then click on run payload, the '6' character was sent to the box. The document contains a lot of text and only one character was sent, tried repeatedly and same results. That means, it is detected as keyboard but there's something wrong with argument parsing. Any ideas?

  4. I'm trying to learn the code but doesn't make much sense, does learning c++ syntax will help or ?

Ciph3rCat avatar Jan 28 '22 06:01 Ciph3rCat

It's been several days, can you please respond to 2nd and 3rd point at least?

Ciph3rCat avatar Feb 01 '22 04:02 Ciph3rCat

Hi, sorry about that, I got carried away by the Web UI changes.

I suggest you try the latest changes on the secondary branch after clearing up your spiffs partition.

How do I open serial connection with the board

Same as you did, putty, arduino, serial monitor. but there's no welcome message and the port number may change on every reboot. Did you try to issue the "help" command ?

The yesterday commit isn't compiling, USB_PID was not declared in this scope.

This was fixed a couple of commits ago

something wrong with argument parsing.

Tried to fix that too but playing with the URL bar on a smartphone isn't my favourite QA activity so I'll probably go with a live-quacker and add a textarea plus a send button.

I've added the possibility to edit SPIFFS files from the webUI, so you should be able to play with that at least.

I'm trying to learn the code but doesn't make much sense, does learning c++ syntax will help or ?

Sure, be careful it's highly addictive :wink:

tobozo avatar Feb 01 '22 08:02 tobozo

Thanks for the reply, the latest changes fixed the USB_PID bug and the web interface was accessible.

When I try to create serial connection in arduino ide, it does open and I can type commands but the content disappear when I press 'send' button.

And in putty, it opens blank screen where I can't type or do anything. However I noticed, it does establish connection because when I open in putty and then in arduino, it says "port is busy". Not sure, what I'm missing here. ☹️

I tried to run a simple payload: PrintLine : hello and it send some text to the machine but it was just some gibberish, not the actual text. Does this works fine in serial mode and what could be wrong here?

Ciph3rCat avatar Feb 01 '22 12:02 Ciph3rCat

but the content disappear when I press 'send' button.

Try to press enter instead of the send button? dunno why it fails with the button though, could be a \r\n vs \n separator issue in the PrintLine command.

Also I'm using this serial console option

image

I'll probably remove the PrintLine command soon. The String command works fine anyway, and the : isn't required any more since it's now using the same ducky commands as Spacehuhn's WiFiDuck.

tobozo avatar Feb 01 '22 13:02 tobozo

Awesome it worked almost fine with the String, except the casing, "Hello" was printed as "hELLO".

I tried with the enter key but same issue, maybe it is due to some windows issue, I'll try on linux after setting up dev environment.

Ciph3rCat avatar Feb 01 '22 16:02 Ciph3rCat

"Hello" was printed as "hELLO"

lol pwned by CAPSLOCK command :-)

tobozo avatar Feb 01 '22 20:02 tobozo

Last commit moved the webserver filesystem from SPIFFS to the more reliable LittleFS partitions, you may want to re-upload the data folder as LittleFS to prevent weird behaviour if you're using this version.

There's also a new text field at the bottom (with auto suggest) to send ducky commands, it's not multiline though.

image

tobozo avatar Feb 04 '22 20:02 tobozo

That's good to know, but something is breaking from latest commit. I'm getting a generic error: "unable to compile for esp32".

Ciph3rCat avatar Feb 05 '22 10:02 Ciph3rCat

By the way, do we need to manually upload data folder? (doesn't it automatically update when flashing)

Ciph3rCat avatar Feb 05 '22 10:02 Ciph3rCat

unable to compile for esp32"

Maybe you need to select "esp32-s2" from the boards menu ?

doesn't it automatically update when flashing

Nope, it only calculates the partition geometry and writes the firmware in the application partition, leaving the rest unchanged.

Flashing the LittleFS partition requires to put the ESP32-S2/WUD in flash mode using the magnet though, and manually resetting after.

image

image

tobozo avatar Feb 05 '22 11:02 tobozo

I have selected "ESP32S2 Dev Module" board and it use to work with previous commit.

Your tools menu looks slightly different, I don't see any option for flashing data. The board options start right after wifi option. Do I need to enable/install anything to get those options?

Ciph3rCat avatar Feb 05 '22 16:02 Ciph3rCat

I need to enable/install anything to get those options?

hmm maybe, I've had those tools for a while so I can't remember how they landed in my IDE.

here's my $HOME/Arduino folder for what it's worth. Note this the same folder from the Arduino IDE Preferences for "Sketchbook location" (the first property in the preferences window).

I've unfolder everything under the $HOME/Arduino/tools folder, those files can be found on github, most are managed by me-no-dev.

https://github.com/me-no-dev/arduino-esp32fs-plugin https://github.com/me-no-dev/EspExceptionDecoder

The one you're looking for is probably $home/Arduino/tools/ESP32FS/tool/esp32fs.jar. I've found the Exception decoder completely useless with the WUD though.

Once you've unzipped the jar files in the right place (triple-check the path with the screenshot), restart the IDE and check your tools menu, the options should be there.

image

tobozo avatar Feb 05 '22 18:02 tobozo

Any idea on: "unable to compile for esp32"?

Thanks, I was able to upload data using plugin.

Ciph3rCat avatar Feb 06 '22 07:02 Ciph3rCat

Any idea on: "unable to compile for esp32"?

not without additional information, output verbosity and compiler warnings need to be enabled to see more on that error.

image

I haven't changed anything since last commit and it compiles in my IDE.

tobozo avatar Feb 06 '22 11:02 tobozo

Here is the error log:

[snip] 
In file included from C:\Users\Ciph3rCat\Documents\WUD-Ducky\WiFiDuck\WebServer.cpp:30,
Multiple libraries were found for "WiFi.h"
 Used: C:\Users\Ciph3rCat\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\WiFi
                 from C:\Users\Ciph3rCat\WUD-Ducky\arduino-esp32-2.0.2\WUD-Ducky\WUD-Ducky.ino:37:
 Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
 C:\Users\Ciph3rCat\Documents\WUD-Ducky\WiFiDuck\WebUI.cpp:46:10: fatal error: ArduinoJson.h: No such file or directory
Multiple libraries were found for "SD.h"
 #include <ArduinoJson.h>
 Used: C:\Users\Ciph3rCat\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\SD
          ^~~~~~~~~~~~~~~
 Not used: C:\Program Files (x86)\Arduino\libraries\SD
compilation terminated.
Using library SD at version 2.0.0 in folder: C:\Users\Ciph3rCat\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\SD 
Using library FS at version 2.0.0 in folder: C:\Users\Ciph3rCat\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\FS 
Using library SPI at version 2.0.0 in folder: C:\Users\Ciph3rCat\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\SPI 
Using library USB at version 2.0.0 in folder: C:\Users\Ciph3rCat\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\USB 
Using library LittleFS at version 2.0.0 in folder: C:\Users\Ciph3rCat\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\LittleFS 
Using library Preferences at version 2.0.0 in folder: C:\Users\Ciph3rCat\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\Preferences 
Using library ESPmDNS at version 2.0.0 in folder: C:\Users\Ciph3rCat\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\ESPmDNS 
Using library WiFi at version 2.0.0 in folder: C:\Users\Ciph3rCat\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\WiFi 
Using library WebServer at version 2.0.0 in folder: C:\Users\Ciph3rCat\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\WebServer 
exit status 1
Error compiling for board ESP32S2 Dev Module.

Ciph3rCat avatar Feb 06 '22 14:02 Ciph3rCat

fatal error: ArduinoJson.h: No such file or directory

This is basic Arduino troubleshooting, so I'll only give a basic hint: use a search engine and paste the error message in the search field :stuck_out_tongue_winking_eye:

tobozo avatar Feb 06 '22 14:02 tobozo

I have this problem: And it's all set up correctly (or so it seems). I tried esp32s2-WUD and got this error, and I tried with esp32s2-dev Module getting a different error (error: 'class fs::SDFS' has no member named 'sectorSize'; did you mean 'cardSize'? size_t sectorSize = SD.sectorSize();)

Attached image of the error using esp32s2-WUD.

tanks.

j1t077 avatar Mar 18 '22 11:03 j1t077

@j1t077 the lack of disabled choice indicates your platform.local.txt contains an older version of the esp32s2_WUD board definition.

If in doubt, just use the esp32s2_dev profile.

fs::SDFS' has no member named 'sectorSize';

this error is odd, maybe some older version of the SD library is interferring ?

tobozo avatar Mar 18 '22 12:03 tobozo

(error: 'class fs::SDFS' has no member named 'sectorSize'; did you mean 'cardSize'? size_t sectorSize = SD.sectorSize();)

@j1t077 Hi, I decided to come back after a short break and now I have the same error. Have you already solved this problem?

GippokratOA avatar Mar 21 '22 15:03 GippokratOA

Changing of SD version didn't help me..

GippokratOA avatar Mar 21 '22 15:03 GippokratOA

I just found the source of the error and pushed a fix, sorry about the mess.

tobozo avatar Mar 21 '22 15:03 tobozo

Ok, it is gone. But now there is one more. error: 'class fs::SDFS' has no member named 'numSectors' size_t numSectors = SD.numSectors();

GippokratOA avatar Mar 21 '22 16:03 GippokratOA

sorry I just realized was using a locally modified version of SD, since I forgot to submit the changes on the espressif repo those aren't documented :facepalm:

I've pushed a fix for the missing numSectors() method but the sector size is now hardcoded (512), and it'll break with non standard partitions.

Let's hope this PR gets approved.

tobozo avatar Mar 21 '22 16:03 tobozo

Well, compilation went succesfully. Now I have some problems with uploading files on ducky. When I trying upload some file, it doesnt appear in this list. image image

GippokratOA avatar Mar 21 '22 18:03 GippokratOA