-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate_cnc.py
48 lines (38 loc) · 1.28 KB
/
update_cnc.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
import paramiko.ssh_exception
import paramiko.util
import paramiko
import threading
import time
import sys
import os
CNC_HOSTNAME = "127.0.0.1"
CNC_PASSWORD = "my cool ssh password xd"
if sys.platform == "win32":
paramiko.util.log_to_file("nul")
elif sys.platform in ["linux", "linux2"]:
paramiko.util.log_to_file("/dev/null")
def cnc_update():
try:
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(hostname=CNC_HOSTNAME, username="root", password=CNC_PASSWORD, timeout=10)
sftp_client = ssh_client.open_sftp()
sftp_client.put("netro_cnc.py", "netro_cnc.py")
sftp_client.put("netro_bot.py", "netro_bot.py")
sftp_client.put("cnc_help.txt", "cnc_help.txt")
ssh_client.close()
except paramiko.ssh_exception.AuthenticationException:
print(f"Wrong password at {CNC_HOSTNAME}.")
return
except paramiko.ssh_exception.SSHException:
print(f"SSH protocol error has occured at {CNC_HOSTNAME}.")
return
def main():
print("Updating NetroCNC...")
cnc_update()
print(f"NetroCNC has successfully been updated.")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
exit()