Leonardo HID and windows scripting.

Hi, I'm using my Leonardo as an HID (keyboard) device. I am trying to find out how to write a sketch or script so that when the Leo is plugged it check for a file name (I.E. /desktop/random_file_name.txt ) And if it finds that file then it launches the Arduino IDE and if the file is not present then it launches my keyboard command script. I would like to do this outside of CMD or powershell if possible, otherwise if not possible I would need help in figuring out how to code this to happen. I imagine an if statement is involved here but I am novice at best when it comes to code and do not know windows scripting at all.

The principal behind this is when the Leo is placed in it's "home" PC it will check for random_file_name.txt and if it finds it, then it will not execute the preprogrammed keystrokes however if it does not find the file it will execute the preprogrammed key strokes. Launching the Arduino IDE is optional, but added it above just to convey that I'm aiming at the Leo going into a pseudo programming mode when plugged up to it's home PC.

I would greatly appreciate any assistance. Thanks in advanced!

When you post to the Arduino Forum and another site, such as Stack Exchange you should always post links to each so we don't waste our time asking you questions or giving answers that were already on the other side. Please use the chain links icon on the toolbar to make the URL clickable when you post a link.

As was said on Arduino Stack Exchange, this is not an Arduino question as you have asked it. There is nothing you can do in your Arduino code to accomplish your goal.

I suspect that adding this feature to your windows script will decrease the efficacy of your device for "pen testing" because you want to inject the attack as quickly as possible, rather than running some extra unnecessary commands.

I have a couple of alternative suggestions:

  • Configure your computer to be resistant to the attack. That's the whole point of "pen testing".
  • Put a switch on your Leonardo that disables "attack mode".