-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSetup.py
More file actions
58 lines (42 loc) · 1.24 KB
/
Setup.py
File metadata and controls
58 lines (42 loc) · 1.24 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
#!/usr/bin/env python
import os
from os import path
import shutil
import subprocess
def start():
if os.geteuid() is not 0:
print "[-] Root permission required"
print "[+] Run command chmod +x ./Setup.py"
print "[+] sudo ./Setup.py "
return False
else:
return True
def write_file():
try:
os.chdir("/etc/systemd/system")
fo = open("shutdown_client.service","w")
fo.write("[Unit]\nDescription=Shutdown Client Service\nAfter=dbus.service\n"
"\n[Service]\nExecStart=/usr/local/bin/node.py\n"
"\n[Install]\nWantedBy=default.target")
fo.close()
os.chmod("shutdown_client.service",0644)
return True
except Exception as error:
print error
return False
def copy_file():
if path.exists("node.py"):
shutil.copy("node.py","/usr/local/bin/node.py")
os.chmod("/usr/local/bin/node.py",0744)
return True
else:
print "[-] File node.py no found"
print "[-] Check if same location contains 'node.py'"
return False
def initialize():
subprocess.check_output(["systemctl","daemon-reload"],stderr=subprocess.STDOUT)
subprocess.check_output(["systemctl","enable","shutdown_client.service"],stderr=subprocess.STDOUT)
if start():
if copy_file():
if write_file():
initialize()