Skip to content

Commit

Permalink
Merge pull request trustedsec#448 from Kell0x/master
Browse files Browse the repository at this point in the history
Added support to self-hosted gitlab and list of modules
  • Loading branch information
trustedsec authored Jun 3, 2019
2 parents 22b5a64 + 6678977 commit 76866af
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 15 deletions.
4 changes: 4 additions & 0 deletions modules/listes/list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
burp
metasploit
zaproxy
nmap
88 changes: 73 additions & 15 deletions src/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import readline
import os
import time
import getpass
import pexpect

# python 2 compatibility
try: input = raw_input
Expand Down Expand Up @@ -169,11 +171,19 @@ def show_new_modules():
" " + filename_short + " " * temp_number + description)
print("\n")

# this is here if you need to access to a gitlab with a password for your keyphrase
def get_password_gitlab():
if not 'password_gitlab' in globals():
global password_gitlab
password_gitlab = ""
if password_gitlab == "":
password_gitlab = getpass.getpass('Enter passphrase for Gitlab modules key (let blank if no passphrase) : ')

# this is when a use <module> command is initiated
def use_module(module, all_trigger):
prompt = ("")
# if we aren't using all
if not "install_update_all" in module and not "update_installed" in module and not "__init__" in module:
if not "install_update_all" in module and not "update_installed" in module and not "__init__" in module and not "listes" in module:

# set terminal title
set_title("ptf - %s" % module)
Expand Down Expand Up @@ -360,7 +370,8 @@ def use_module(module, all_trigger):
if os.path.isdir(install_location):
if install_type.lower() == "git":
print_status("Updating the tool, be patient while git pull is initiated.")
proc = subprocess.Popen("cd %s;git pull" % (install_location), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
proc = subprocess.Popen("cd %s;git pull" % (install_location), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)

# check launcher
launcher(filename, install_location)

Expand All @@ -377,6 +388,32 @@ def use_module(module, all_trigger):
if update_counter == 0:
after_commands(filename, install_location)

if install_type.lower() == "gitlab":
print_status("Updating the tool, be patient while git pull is initiated.")
get_password_gitlab()
proc = pexpect.spawn('git -C %s pull' % (install_location))
proc.expect('passphrase')
proc.sendline('%s' % password_gitlab)
proc.expect(pexpect.EOF)

# check launcher
launcher(filename, install_location)

# here we check to see if we need anything we need to
# run after things are updated
update_counter = 0
i = proc.expect(['Already up-to-date!', pexpect.EOF])
if i == 1:
after_commands(filename, install_location)
update_counter = 1
elif i == 0:
print_status("Tool already up-to-date!")
print_status("Finished Installing! Enjoy the tool installed under: " + (install_location))

# run after commands
if update_counter == 0:
after_commands(filename, install_location)

if install_type.lower() == "svn":
print_status("Updating the tool, be patient while svn pull is initiated.")
proc = subprocess.Popen("cd %s;svn update" % (install_location), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
Expand Down Expand Up @@ -469,21 +506,35 @@ def use_module(module, all_trigger):
install_location, shell=True).wait()

# if we are using git
if install_type.lower() == "git":
if install_type.lower() in ["git","gitlab"]:
# if there are files in the install_location, we'll update.
if os.listdir(install_location):
print_status("Installation already exists, going to git pull then run after commands..")
subprocess.Popen("cd %s;git pull" % (install_location), stderr=subprocess.PIPE, shell=True).wait()
if install_type.lower() == "gitlab":
get_password_gitlab()
proc = pexpect.spawn('git -C %s pull' % (install_location))
proc.expect('passphrase')
proc.sendline('%s' % password_gitlab)
proc.expect(pexpect.EOF)
else:
proc = subprocess.Popen("cd %s;git pull" % (install_location), stdin=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
print_status("Finished updating the tool located in:" + install_location)
else:
print_status("GIT was the selected method for installation... Using GIT to install.")
print_status("%s was the selected method for installation... Using %s to install." % (install_type.upper(), install_type.upper()))
print_status("Installing now.. be patient...")
proc = subprocess.Popen("git clone %s %s" % (repository_location, install_location), stderr=subprocess.PIPE, shell=True).wait()
if install_type.lower() == "gitlab":
get_password_gitlab()
proc = pexpect.spawn('git clone %s %s' % (repository_location, install_location))
proc.expect('passphrase')
proc.sendline('%s' % password_gitlab)
proc.expect(pexpect.EOF)
else:
proc = subprocess.Popen("git clone %s %s" % (repository_location, install_location), stdin=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)

print_status("Finished Installing! Enjoy the tool located under: " + install_location)
after_commands(filename, install_location)
launcher(filename, install_location)


# if we are using svn
if install_type.lower() == "svn":
print_status(
Expand Down Expand Up @@ -584,7 +635,7 @@ def handle_prompt(prompt, force=False):
prompt = prompt.split(" ")

# do a quick sanity check to see if the module is there first
if "install_update_all" in prompt[1]:
if "install_update_all" in prompt[1] or "listes" in prompt[1]:
counter = 3
try:
if not force:
Expand All @@ -601,7 +652,10 @@ def handle_prompt(prompt, force=False):
# do auto update check first
auto_update()

modules_path = definepath() + "/" + (prompt[1])[:-18]
if not "listes" in prompt[1]:
modules_path = definepath() + "/" + (prompt[1])[:-18]
else:
modules_path = definepath() + "/modules/"
# base holder for all debian packages
deb_modules = ""
# base holder for all arch packages
Expand All @@ -619,7 +673,9 @@ def handle_prompt(prompt, force=False):

for path, subdirs, files in os.walk(modules_path):
for name in files:
# join the structure
if "listes" in prompt[1] and name[:-3] not in open(definepath() + "/" + prompt[1] + ".py").read():
break
# join the structure
filename = os.path.join(path, name)
# strip un-needed files
if not "__init__.py" in filename and not ignore_module(filename) and include_module(filename) and ".py" in filename and not ".pyc" in filename and not ignore_update_all_module(filename):
Expand All @@ -632,14 +688,14 @@ def handle_prompt(prompt, force=False):
ostype = profile_os()

if ostype == "DEBIAN":
if not "install_update_all" in filename_short:
if not "install_update_all" in filename_short and not "listes" in filename:
from src.platforms.debian import base_install_modules
# grab all the modules we need
deb_modules = deb_modules + "," + module_parser(filename_short, "DEBIAN")

# archlinux
if ostype == "ARCHLINUX":
if not "install_update_all" in filename_short:
if not "install_update_all" in filename_short and not "listes" in filename:
from src.platforms.archlinux import base_install_modules
# grab all the modules we need
arch_modules = ""
Expand All @@ -648,14 +704,14 @@ def handle_prompt(prompt, force=False):
filename_short, "ARCHLINUX")
# fedora
if ostype == "FEDORA":
if not "install_update_all" in filename_short:
if not "install_update_all" in filename_short and not "listes" in filename:
from src.platforms.fedora import base_install_modules
# grab all the modules we need
fedora_modules = fedora_modules + "," + \
module_parser(filename_short, "FEDORA")
# openbsd
if ostype == "OPENSBD":
if not "install_update_all" in filename_short:
if not "install_update_all" in filename_short and not "listes" in filename:
from src.platforms.openbsd import base_install_modules
# grab all the modules we need
openbsd_modules = openbsd_modules + "," + \
Expand Down Expand Up @@ -691,9 +747,11 @@ def handle_prompt(prompt, force=False):

for path, subdirs, files in os.walk(modules_path):
for name in files:
if "listes" in prompt[1] and name[:-3] not in open(definepath() + "/" + prompt[1] + ".py").read():
break
# join the structure
filename = os.path.join(path, name)
if not "__init__.py" in filename and not ignore_module(filename) and include_module(filename) and ".py" in filename and not ".pyc" in filename and not "install_update_all" in filename and not "__init__" in filename:
if not "__init__.py" in filename and not ignore_module(filename) and include_module(filename) and ".py" in filename and not ".pyc" in filename and not "install_update_all" in filename and not "__init__" in filename and not "listes" in filename:
# strip un-needed files
# if not "__init__.py" in filename and not ignore_module(filename):
# shorten it up a little bit
Expand Down

0 comments on commit 76866af

Please sign in to comment.