forked from trustedsec/artillery
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
executable file
·105 lines (89 loc) · 5.21 KB
/
setup.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
#!/usr/bin/python
#
# quick script for installing artillery
#
#
import subprocess,re,os,shutil
from src.core import *
print '''
Welcome to the Artillery installer. Artillery is a honeypot, file monitoring, and overall security tool used to protect your nix systems.
Written by: Dave Kennedy (ReL1K)
'''
if os.path.isfile("/etc/init.d/artillery"):
answer = raw_input("Artillery detected. Do you want to uninstall [y/n:] ")
if answer.lower() == "yes" or answer.lower() == "y":
answer = "uninstall"
if not os.path.isfile("/etc/init.d/artillery"):
answer = raw_input("Do you want to install Artillery and have it automatically run when you restart [y/n]: ")
if answer.lower() == "y" or answer.lower() == "yes":
if is_posix():
kill_artillery()
print "[*] Beginning installation. This should only take a moment."
# if directories aren't there then create them
if not os.path.isdir("/var/artillery/logs"):
os.makedirs("/var/artillery/logs")
if not os.path.isdir("/var/artillery/database"):
os.makedirs("/var/artillery/database")
if not os.path.isdir("/var/artillery/src/program_junk/"):
os.makedirs("/var/artillery/src/program_junk/")
# install to rc.local
print "[*] Adding artillery into startup through init scripts.."
if os.path.isdir("/etc/init.d"):
if not os.path.isfile("/etc/init.d/artillery"):
fileopen = file("src/startup_artillery", "r")
config = fileopen.read()
filewrite = file("/etc/init.d/artillery", "w")
filewrite.write(config)
filewrite.close()
print "[*] Triggering update-rc.d on artillery to automatic start..."
subprocess.Popen("chmod +x /etc/init.d/artillery", shell=True).wait()
subprocess.Popen("update-rc.d artillery defaults", shell=True).wait()
# remove old method if installed previously
if os.path.isfile("/etc/init.d/rc.local"):
fileopen = file("/etc/init.d/rc.local", "r")
data = fileopen.read()
data = data.replace("sudo python /var/artillery/artillery.py &", "")
filewrite = file("/etc/init.d/rc.local", "w")
filewrite.write(data)
filewrite.close()
if is_windows():
program_files = os.environ["ProgramFiles"]
os.makedirs(program_files + "\\Artillery\\logs")
os.makedirs(program_files + "\\Artillery\\database")
os.makedirs(program_files + "\\Artillery\\src\\program_junk")
install_path = os.getcwd()
shutil.copytree(install_path, program_files + "\\Artillery\\")
if is_posix():
choice = raw_input("Do you want to keep Artillery updated? (requires internet) [y/n]: ")
if choice == "y" or choice == "yes":
print "[*] Checking out Artillery through github to /var/artillery"
# if old files are there
if os.path.isdir("/var/artillery/"):
shutil.rmtree('/var/artillery')
subprocess.Popen("git clone https://github.com/trustedsec/artillery /var/artillery/", shell=True).wait()
print "[*] Finished. If you want to update Artillery go to /var/artillery and type 'git pull'"
else:
print "[*] Copying setup files over..."
subprocess.Popen("cp -rf * /var/artillery/", shell=True).wait()
# if os is Mac Os X than create a .plist daemon - changes added by contributor - Giulio Bortot
if os.path.isdir("/Library/LaunchDaemons"):
# check if file is already in place
if not os.path.isfile("/Library/LaunchDaemons/com.artillery.plist"):
print "[*] Creating com.artillery.plist in your Daemons directory"
filewrite = file("/Library/LaunchDaemons/com.artillery.plist", "w")
filewrite.write('<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n<dict>\n<key>Disabled</key>\n<false/>\n<key>ProgramArguments</key>\n<array>\n<string>/usr/bin/python</string>\n<string>/var/artillery/artillery.py</string>\n</array>\n<key>KeepAlive</key>\n<true/>\n<key>RunAtLoad</key>\n<true/>\n<key>Label</key>\n<string>com.artillery</string>\n<key>Debug</key>\n<true/>\n</dict>\n</plist>')
print "[*] Adding right permissions"
subprocess.Popen("chown root:wheel /Library/LaunchDaemons/com.artillery.plist", shell=True).wait()
choice = raw_input("Would you like to start Artillery now? [y/n]: ")
if choice == "yes" or choice == "y":
if is_posix():
subprocess.Popen("/etc/init.d/artillery start", shell=True).wait()
if is_posix():
print "[*] Installation complete. Edit /var/artillery/config in order to config artillery to your liking.."
if answer == "uninstall":
if is_posix():
os.remove("/etc/init.d/artillery")
subprocess.Popen("rm -rf /var/artillery", shell=True)
subprocess.Popen("rm -rf /etc/init.d/artillery", shell=True)
kill_artillery()
print "[*] Artillery has been uninstalled. Manually kill the process if it is still running."