-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsric_script.py
More file actions
55 lines (42 loc) · 1.46 KB
/
sric_script.py
File metadata and controls
55 lines (42 loc) · 1.46 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
import subprocess
from Modules.file_parse.__file_parse__ import obt_login
from Modules.file_parse.__file_parse__ import obt_pass
from Modules.file_parse.__file_parse__ import obt_message
# The IP of the server we're downloading/uploading things to/from
server = 192.168.1.1
# The names of the files were dealing with
creds = 'credentials.txt'
upload = 'upload-package.txt'
# Download creds
down_user = 'tmp'
down_pass = 'tmp'
# Upload Creds
up_user = 'tmp'
up_pass = 'tmp'
up_mess = 'tmp'
# Loop forever!
while True:
# Verify connection
output = subprocess.check_output(['ping', '-n', '1', server])
if output = 'tmp string for network down':
continue
# Using SFPT because I'm not sure if we can use SCP
with pysftp.Connection('http://' + server, username = down_user, password = down_pass) as sftp:
# Get the download payload
sftp.get(creds, '/creds.txt')
# Open download file
cred_file = open(creds)
# Parse it mytext reads all lines of the file contents
# up_usr and up_pass defined in file contents
text = cred_file.readlines()
up_user = obt_login(text)
up_pass = obt_pass(text)
up_mess = obt_message(text)
with pysftp.Connection(server, username = up_user, password = up_pass) as sftp:
# Put the upload payload
sftp.put(uplpad)
# Close cred_file (After the put since we need to get that done as fast as possible)
cred_file.close()
# End this script to save resources for other things
break
# Not currently connected... Time to try again