Skip to content

Commit

Permalink
Merge pull request BinaryDefense#89 from corelan/master
Browse files Browse the repository at this point in the history
add config file during setup
  • Loading branch information
trustedsec authored Jan 7, 2020
2 parents b67b2eb + 7334a85 commit 0b5c31a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
25 changes: 5 additions & 20 deletions artillery.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,17 @@

# import artillery global variables
import src.globals

from src.core import *
#
# Tested on win 7/8/10 also on kali rolling. left this here for when someone tries to launch this directly before using setup.
appfile = ""
if 'win32' in sys.platform:
programfolder = os.environ["PROGRAMFILES(X86)"]
src.globals.g_apppath = programfolder + "\\Artillery"
appfile = src.globals.g_apppath + "\\artillery.py"
src.globals.g_configfile = src.globals.g_apppath + "\\config"
src.globals.g_banlist = src.globals.g_apppath + "\\banlist.txt"
src.globals.g_localbanlist = src.globals.g_apppath + "\\localbanlist.txt"

# consolidated nix* variants
if ('linux' or 'linux2' or 'darwin') in sys.platform:
src.globals.g_apppath = "/var/artillery"
appfile = src.globals.g_apppath + "/artillery.py"
src.globals.g_configfile = src.globals.g_apppath + "/config"
src.globals.g_banlist = src.globals.g_apppath + "/banlist.txt"
src.globals.g_localbanlist = src.globals.g_apppath + "/localbanlist.txt"

if not os.path.isfile(appfile):

init_globals()

if not os.path.isfile(src.globals.g_appfile):
print("[*] Artillery is not installed, running setup.py..")
import setup


from src.core import *
# from src.config import * # yaml breaks config reading - disabling

check_config()
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
try: input = raw_input
except NameError: pass

import src.globals

# Argument parse. Aimed to provide automatic deployment options
interactive = True # Flag to select interactive install, typically prompting user to answer [y/n]
parser = argparse.ArgumentParser(description='-y, optional non interactive install/uninstall with automatic \'yes\' selection. It must roon with root/admin privileges')
Expand Down Expand Up @@ -85,6 +87,7 @@
answer = "uninstall"

if answer.lower() in ["yes", "y"]:
init_globals()
if is_posix():
#kill_artillery()

Expand Down Expand Up @@ -166,13 +169,12 @@
subprocess.Popen(
"chown root:wheel /Library/LaunchDaemons/com.artillery.plist", shell=True).wait()


check_config()
if interactive:
choice = input("[*] Would you like to start Artillery now? [y/n]: ")
else:
choice = 'y'
if choice in ["yes", "y"]:
check_config()
if is_posix():
# this cmd is what they were refering to as "no longer supported"? from update-rc.d on install.
# It looks like service starts but you have to manually launch artillery
Expand Down
23 changes: 22 additions & 1 deletion src/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from urllib import urlopen

import os
import sys
import time
import shutil
import logging
Expand All @@ -46,11 +47,31 @@

import globals

# initialize global vars
def init_globals():
if 'win32' in sys.platform:
programfolder = os.environ["PROGRAMFILES(X86)"]
globals.g_apppath = programfolder + "\\Artillery"
globals.g_appfile = globals.g_apppath + "\\artillery.py"
globals.g_configfile = globals.g_apppath + "\\config"
globals.g_banlist = globals.g_apppath + "\\banlist.txt"
globals.g_localbanlist = globals.g_apppath + "\\localbanlist.txt"

# consolidated nix* variants
if ('linux' or 'linux2' or 'darwin') in sys.platform:
globals.g_apppath = "/var/artillery"
globals.g_appfile = globals.g_apppath + "/artillery.py"
globals.g_configfile = globals.g_apppath + "/config"
globals.g_banlist = globals.g_apppath + "/banlist.txt"
globals.g_localbanlist = globals.g_apppath + "/localbanlist.txt"


# grab the current time
def grab_time():
ts = time.time()
return datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')

# get hostname
def gethostname():
return socket.gethostname()

Expand Down Expand Up @@ -212,7 +233,7 @@ def check_config():
create_config(globals.g_configfile, configdefaults, keyorder)

if createnew:
msg = "A brand new config file '%s' was created. Please review the file, change as needed, and launch artillery again." % globals.g_configfile
msg = "A brand new config file '%s' was created. Please review the file, change as needed, and launch artillery (again)." % globals.g_configfile
write_console(msg)
write_log(msg,1)
sys.exit(1)
Expand Down
1 change: 1 addition & 0 deletions src/globals.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Artillery - globals

global g_apppath
global g_appfile
global g_configfile
global g_banlist
global g_localbanlist

0 comments on commit 0b5c31a

Please sign in to comment.