def runInstaller(options, config): try: sys.path.insert(0, options.installer_path) from installer import Installer from packageselector import PackageSelector except: raise ImportError('Installer path incorrect!') config["pkg_to_rpm_map_file"] = options.pkg_to_rpm_map_file # Check the installation type option_list_json = Utils.jsonread(options.package_list_file) options_sorted = option_list_json.items() packages = [] if 'type' in config: for install_option in options_sorted: if install_option[0] == config['type']: packages = PackageSelector.get_packages_to_install(install_option[1]['packagelist_file'], options.generated_data_path) break else: if 'packagelist_file' in config: packages = PackageSelector.get_packages_to_install(config['packagelist_file'], options.generated_data_path) if 'additional_packages' in config: packages = packages.extend(config['additional_packages']) config['packages'] = packages # Run the installer package_installer = Installer(config, rpm_path=options.rpm_path, log_path=options.log_path, log_level=options.log_level) return package_installer.install(None)
def __init__(self, srcDir, targetDir, installerDir, intermediateDir, configuration): Installer.__init__(self, srcDir, targetDir, installerDir, intermediateDir, configuration) self.specificationFileName = os.path.join(self.tempDir, 'product_specification') self.configurePath = os.path.join(self.tempDir, "configure.sh") self.unconfigurePath = os.path.join(self.tempDir, "unconfigure.sh") self.preinstallPath = os.path.join(self.tempDir, "preinstall.sh") self.postremovePath = os.path.join(self.tempDir, "postremove.sh")
def __init__(self, srcDir, targetDir, installerDir, intermediateDir, configuration): Installer.__init__(self, srcDir, targetDir, installerDir, intermediateDir, configuration) self.scriptDir = os.path.join(self.tempDir, "scripts") self.preinstallPath = os.path.join(self.scriptDir, "preinstall") self.postinstallPath = os.path.join(self.scriptDir, "postinstall") self.preupgradePath = os.path.join(self.scriptDir, "preupgrade") self.postupgradePath = os.path.join(self.scriptDir, "postupgrade") self.osverstring = str(self.configuration["pfmajor"]) + "." + self.configuration["pfminor_str"] if self.configuration["pfmajor"] == 10: if self.configuration["pfminor"] == 4: self.packageHelper = MacOS10_4PackageHelper( self.stagingRootDir, self.tempDir, self.configuration["version"], self.configuration["release"], self.scriptDir, ) elif self.configuration["pfminor"] == 5: self.packageHelper = MacOS10_5PackageHelper( self.stagingRootDir, self.tempDir, self.targetDir, self.configuration["version"], self.configuration["release"], self.preinstallPath, self.postinstallPath, self.preupgradePath, self.postupgradePath, ) else: raise scxexceptions.PlatformNotImplementedError(self.osverstring) else: raise scxexceptions.PlatformNotImplementedError(self.osverstring)
def __init__(self, srcDir, targetDir, installerDir, intermediateDir, configuration): Installer.__init__(self, srcDir, targetDir, installerDir, intermediateDir, configuration) self.controlDir = os.path.join(self.stagingRootDir, 'DEBIAN') self.controlFileName = os.path.join(self.controlDir, 'control') self.configFileName = os.path.join(self.controlDir, 'conffiles') self.preInstallPath = os.path.join(self.controlDir, 'preinst') self.postInstallPath = os.path.join(self.controlDir, 'postinst') self.preUninstallPath = os.path.join(self.controlDir, 'prerm') self.postUninstallPath = os.path.join(self.controlDir, 'postrm')
def __init__(self, srcDir, targetDir, installerDir, intermediateDir, configuration): Installer.__init__(self, srcDir, targetDir, installerDir, intermediateDir, configuration) self.prototypeFileName = os.path.join(self.tempDir, "prototype") self.pkginfoFile = PKGInfoFile(self.tempDir, self.configuration) self.depFileName = os.path.join(self.tempDir, "depend") self.preInstallPath = os.path.join(self.tempDir, "preinstall.sh") self.postInstallPath = os.path.join(self.tempDir, "postinstall.sh") self.preUninstallPath = os.path.join(self.tempDir, "preuninstall.sh") self.postUninstallPath = os.path.join(self.tempDir, "postuninstall.sh") self.iConfigFileName = os.path.join(self.tempDir, "i.config") self.rConfigFileName = os.path.join(self.tempDir, "r.config")
def finalize_system(self): Installer.finalize_system(self) self.run("mkdir -p {}/srv/rpm-ostree/repo".format(self.photon_root)) self.run("cp ./photon-base.json {}/srv/rpm-ostree/".format(self.photon_root)) self.run("ln -s /etc/yum.repos.d/photon.repo {}/srv/rpm-ostree/photon-ostree.repo".format(self.photon_root)) self.run("cp ./ostree-httpd.conf {}/srv/rpm-ostree/".format(self.photon_root)) self.run("cp ./httpd.service {}/usr/lib/systemd/system/".format(self.photon_root)) self.run("cp ./get-ip-address.sh {}/usr/bin/".format(self.photon_root)) self.run("cp ./ostree-server-greeting.txt {}/etc/issue".format(self.photon_root)) self.run("ln -s /usr/lib/systemd/system/httpd.service {}/usr/lib/systemd/system/multi-user.target.wants/httpd.service".format(self.photon_root)) self.run("tar -xf /mnt/cdrom/ostree-repo.tar.gz -C {}/srv/rpm-ostree/repo".format(self.photon_root))
def __init__(self, srcDir, targetDir, installerDir, intermediateDir, configuration): Installer.__init__(self, srcDir, targetDir, installerDir, intermediateDir, configuration) self.filesetName = self.configuration['short_name'] + '.rte' self.lppNameFileName = os.path.join(self.stagingRootDir, 'lpp_name') self.alFileName = os.path.join(self.tempDir, self.filesetName + '.al') self.cfgfilesFileName = os.path.join(self.tempDir, self.filesetName + '.cfgfiles') self.copyrightFileName = os.path.join(self.tempDir, self.filesetName + '.copyright') self.inventoryFileName = os.path.join(self.tempDir, self.filesetName + '.inventory') self.sizeFileName = os.path.join(self.tempDir, self.filesetName + '.size') self.productidFileName = os.path.join(self.tempDir, 'productid') self.liblppFileName = os.path.join(self.stagingRootDir, 'usr/lpp/' + self.filesetName +'/liblpp.a') # Need to specify new file names for scripts. self.preInstallPath = os.path.join(self.tempDir, self.filesetName + '.pre_i') self.postInstallPath = os.path.join(self.tempDir, self.filesetName + '.config') self.preUninstallPath = os.path.join(self.tempDir, self.filesetName + '.unconfig') self.preUpgradePath = os.path.join(self.tempDir, self.filesetName + '.pre_rm')
def __init__(self, buildout, name, options): self.log = logging.getLogger(name) self.egg = zc.recipe.egg.Egg(buildout, options['recipe'], options) self.buildout, self.name, self.options = buildout, name, options options['location'] = os.path.join( buildout['buildout']['parts-directory'], name) options['bin-directory'] = buildout['buildout']['bin-directory'] options.setdefault('project', 'example.com') options.setdefault('external-apps', 'apps') options.setdefault('local-apps', 'company') options.setdefault('settings', 'development') options.setdefault('libs-path', 'lib') options.setdefault('script-dir', 'bin') options.setdefault('turboengine', '') options.setdefault('webservices', 'false') options.setdefault('zipped', 'false') # Usefull when using archived versions buildout['buildout'].setdefault( 'download-cache', os.path.join(buildout['buildout']['directory'], 'downloads')) self.__installer = Installer(self.options, self.buildout, self.log, self.name)
def __init__(self, buildout, name, options): self.log = logging.getLogger(name) self.egg = zc.recipe.egg.Egg(buildout, options['recipe'], options) self.buildout, self.name, self.options = buildout, name, options options['location'] = os.path.join( buildout['buildout']['parts-directory'], name) options['bin-directory'] = buildout['buildout']['bin-directory'] options.setdefault('project', 'example.com') options.setdefault('external-apps', 'apps') options.setdefault('local-apps', 'company') options.setdefault('settings', 'development') options.setdefault('urlconf', options['project'] + '.urls') # Set this so the rest of the recipe can expect the values to be # there. We need to make sure that both pythonpath and extra-paths are # set for BBB. if 'extra-paths' in options: options['pythonpath'] = options['extra-paths'] else: options.setdefault('extra-paths', options.get('pythonpath', '')) # Usefull when using archived versions buildout['buildout'].setdefault( 'download-cache', os.path.join(buildout['buildout']['directory'], 'downloads')) # only try to download stuff if we aren't asked to install from cache self.install_from_cache = self.buildout['buildout'].get( 'install-from-cache', '').strip() == 'true' self.__installer = Installer(self.options, self.buildout, self.log, self.name)
class IDABuddy(idaapi.plugin_t): flags = 0 comment = 'IDABuddy' help = 'IDABuddy' wanted_name = 'IDABuddy' wanted_hotkey = '' def init(self): self._installer = Installer() self._installer.start() return idaapi.PLUGIN_KEEP def term(self): self._installer.stop() def run(self, arg): pass
def finalize_system(self): Installer.finalize_system(self) self.run("mkdir -p {}/srv/rpm-ostree/repo".format(self.photon_root)) self.run("cp ./photon-base.json {}/srv/rpm-ostree/".format(self.photon_root)) self.run("ln -s /etc/yum.repos.d/photon.repo {}/srv/rpm-ostree/photon-ostree.repo".format(self.photon_root)) self.run("ln -s /etc/yum.repos.d/photon-iso.repo {}/srv/rpm-ostree/photon-iso-ostree.repo".format(self.photon_root)) self.run("ln -s /etc/yum.repos.d/photon-updates.repo {}/srv/rpm-ostree/photon-updates-ostree.repo".format(self.photon_root)) self.run("ln -s /etc/yum.repos.d/photon-extras.repo {}/srv/rpm-ostree/photon-extras-ostree.repo".format(self.photon_root)) self.run("ln -s /etc/yum.repos.d/lightwave.repo {}/srv/rpm-ostree/lightwave-ostree.repo".format(self.photon_root)) self.run("cp ./ostree-httpd.conf {}/srv/rpm-ostree/".format(self.photon_root)) self.run("cp ./httpd.service {}/usr/lib/systemd/system/".format(self.photon_root)) self.run("cp ./get-ip-address.sh {}/usr/bin/".format(self.photon_root)) self.run("cp ./ostree-server-greeting.txt {}/etc/issue".format(self.photon_root)) self.run("ln -s /usr/lib/systemd/system/httpd.service {}/usr/lib/systemd/system/multi-user.target.wants/httpd.service".format(self.photon_root)) self.run("tar -xf /mnt/cdrom/ostree-repo.tar.gz -C {}/srv/rpm-ostree/repo".format(self.photon_root)) self.run("sed -i \"\\$i iptables -A INPUT -m state --state NEW,ESTABLISHED -p tcp --dport 80 -j ACCEPT\" {}/etc/systemd/scripts/iptables".format(self.photon_root)) self.run("sed -i \"\\$i iptables -A INPUT -m state --state NEW,ESTABLISHED -p tcp --dport 443 -j ACCEPT\" {}/etc/systemd/scripts/iptables".format(self.photon_root))
class GAEBuild(object): def __init__(self, buildout, name, options): self.log = logging.getLogger(name) self.egg = zc.recipe.egg.Egg(buildout, options['recipe'], options) self.buildout, self.name, self.options = buildout, name, options options['location'] = os.path.join( buildout['buildout']['parts-directory'], name) options['bin-directory'] = buildout['buildout']['bin-directory'] options.setdefault('project', 'example.com') options.setdefault('external-apps', 'apps') options.setdefault('local-apps', 'company') options.setdefault('settings', 'development') options.setdefault('libs-path', 'lib') options.setdefault('script-dir', 'bin') options.setdefault('turboengine', '') options.setdefault('webservices', 'false') options.setdefault('zipped', 'false') # Usefull when using archived versions buildout['buildout'].setdefault( 'download-cache', os.path.join(buildout['buildout']['directory'], 'downloads')) self.__installer = Installer(self.options, self.buildout, self.log, self.name) def install(self): print '\n------------------ Installing GAEBuild ------------------\n' location = self.options['location'] base_dir = self.buildout['buildout']['directory'] project_dir = os.path.join(base_dir, 'src') download_dir = self.buildout['buildout']['download-cache'] extra_path = self.__installer.get_extra_paths() requirements, ws = self.egg.working_set(['gaebuild']) self.__installer.verify_or_create_download_dir(download_dir) self.__installer.install_recipe(location) self.__installer.install_project(project_dir, self.options['project']) script_paths = self.__installer.install_scripts(project_dir, extra_path, ws) print '\n------------------ Installing GAEBuild ------------------\n' return script_paths + [location] def update(self): pass
class GAEBuild(object): def __init__(self, buildout, name, options): self.log = logging.getLogger(name) self.egg = zc.recipe.egg.Egg(buildout, options['recipe'], options) self.buildout, self.name, self.options = buildout, name, options options['location'] = os.path.join( buildout['buildout']['parts-directory'], name) options['bin-directory'] = buildout['buildout']['bin-directory'] options.setdefault('project', 'example.com') options.setdefault('external-apps', 'apps') options.setdefault('local-apps', 'company') options.setdefault('settings', 'development') options.setdefault('libs-path', 'lib') options.setdefault('script-dir', 'bin') options.setdefault('turboengine', '') options.setdefault('webservices', 'false') options.setdefault('zipped', 'false') # Usefull when using archived versions buildout['buildout'].setdefault( 'download-cache', os.path.join(buildout['buildout']['directory'], 'downloads')) self.__installer = Installer(self.options, self.buildout, self.log, self.name) def install(self): print '\n------------------ Installing GAEBuild ------------------\n' location = self.options['location'] base_dir = self.buildout['buildout']['directory'] project_dir = os.path.join(base_dir, 'src') download_dir = self.buildout['buildout']['download-cache'] extra_path = self.__installer.get_extra_paths() requirements, ws = self.egg.working_set(['gaebuild']) self.__installer.verify_or_create_download_dir(download_dir) self.__installer.install_recipe(location) self.__installer.install_project(project_dir, self.options['project']) script_paths = self.__installer.install_scripts( project_dir, extra_path, ws) print '\n------------------ Installing GAEBuild ------------------\n' return script_paths + [location] def update(self): pass
def onOK(self, event): parent = self.GetParent() i = self.box.GetSelection() ext = "" if i == 0: ext = "zip" elif i == 1: ext = "dwa" elif i == 2: ext = "mova" elif i == 3: ext = "tmx" elif i == 4: ext == "dz" from installer import Installer installer = Installer(parent, parent.app.config) installer.install(self.filePath, ext) self.Destroy()
def __init__(self, interface, log=False): """ Arguments: interface {string} -- name of interface to handle log {object} -- object of logger (default: {False}) Raises: FileNotFoundError -- raised when arptables not installed """ self.log = log if log is False: from logger import Logger self.log = Logger() self.interface = interface installer = Installer() if not os.path.isfile('/usr/bin/arptables') and not os.path.isfile('/sbin/arptables'): # Detect if arptables installed print(avalon.FM.BD + avalon.FG.R + '\nWe have detected that you don\'t have arptables installed!' + avalon.FM.RST) print('SCUTUM requires arptables to run') if not installer.sysInstallPackage("arptables"): avalon.error("arptables is required for scutum. Exiting...") raise FileNotFoundError("File: \"/usr/bin/arptables\" and \"/sbin/arptables\" not found")
def finalize_system(self): Installer.finalize_system(self) self.run("mkdir -p {}/srv/rpm-ostree/repo".format(self.photon_root)) self.run("cp ./photon-base.json {}/srv/rpm-ostree/".format( self.photon_root)) self.run( "ln -s /etc/yum.repos.d/photon.repo {}/srv/rpm-ostree/photon-ostree.repo" .format(self.photon_root)) self.run( "ln -s /etc/yum.repos.d/photon-iso.repo {}/srv/rpm-ostree/photon-iso-ostree.repo" .format(self.photon_root)) self.run( "ln -s /etc/yum.repos.d/photon-updates.repo {}/srv/rpm-ostree/photon-updates-ostree.repo" .format(self.photon_root)) self.run( "ln -s /etc/yum.repos.d/photon-extras.repo {}/srv/rpm-ostree/photon-extras-ostree.repo" .format(self.photon_root)) self.run( "ln -s /etc/yum.repos.d/lightwave.repo {}/srv/rpm-ostree/lightwave-ostree.repo" .format(self.photon_root)) self.run("cp ./ostree-httpd.conf {}/srv/rpm-ostree/".format( self.photon_root)) self.run("cp ./httpd.service {}/usr/lib/systemd/system/".format( self.photon_root)) self.run("cp ./get-ip-address.sh {}/usr/bin/".format(self.photon_root)) self.run("cp ./ostree-server-greeting.txt {}/etc/issue".format( self.photon_root)) self.run( "ln -s /usr/lib/systemd/system/httpd.service {}/usr/lib/systemd/system/multi-user.target.wants/httpd.service" .format(self.photon_root)) self.run( "tar -xf /mnt/cdrom/ostree-repo.tar.gz -C {}/srv/rpm-ostree/repo". format(self.photon_root)) self.run( "sed -i \"\\$i iptables -A INPUT -m state --state NEW,ESTABLISHED -p tcp --dport 80 -j ACCEPT\" {}/etc/systemd/scripts/iptables" .format(self.photon_root)) self.run( "sed -i \"\\$i iptables -A INPUT -m state --state NEW,ESTABLISHED -p tcp --dport 443 -j ACCEPT\" {}/etc/systemd/scripts/iptables" .format(self.photon_root))
def install(self, params): installer = None if self.install_config['type'] == "ostree_server": installer = OstreeServerInstaller(self.install_config, self.maxy, self.maxx, self.iso_installer, self.rpm_path, self.log_path, self.ks_config) else: installer = Installer(self.install_config, self.maxy, self.maxx, self.iso_installer, self.rpm_path, self.log_path, self.ks_config) return installer.install(params)
def __init__(self): self.config = Config() self.setTempFolder() self.setTempFile() # should be after setTempFolder self.compatibility = Compatibility() self.versionManager = VersionManager() self.md5sum = MD5sum() self.installer = Installer(self) self.initFTP() # should be after installer self.initLogger() self.gui = PaWGui(self)
def OnApply(self, event): self.log.AppendText('please wait...\n') for i in range(len(db[0])): if self.list.IsChecked(i): if len(db[0][i]) == 6: pass else: if len(db[0][i]) == 5: pass else: self.log.AppendText('downloading ' + str(db[0][i]) + '...\n') try: Downloader.dl(db[0][i]) except: self.log.AppendText('failed\n') self.log.AppendText('installing ' + str(db[0][i]) + '...\n') try: Installer.install(db[0][i]) except: self.log.AppendText('failed\n') else: if len(db[0][i]) == 6: self.log.AppendText('uninstalling ' + str(db[0][i]) + '...\n') try: Installer.uninstall(db[0][i]) except: self.log.AppendText('failed\n') self.log.AppendText('refreshing database...\n') global db db = Database.build() self.log.AppendText('all done\n')
def finalize_system(self): Installer.finalize_system(self) self.run("mkdir -p {}/srv/rpm-ostree/repo".format(self.photon_root)) self.run("cp ./photon-base.json {}/srv/rpm-ostree/".format(self.photon_root)) self.run("cp ./photon-minimal.json {}/srv/rpm-ostree/".format(self.photon_root)) self.run("cp ./photon-full.json {}/srv/rpm-ostree/".format(self.photon_root)) self.run("ln -s /etc/yum.repos.d/photon.repo {}/srv/rpm-ostree/photon-ostree.repo".format(self.photon_root)) self.run("ln -s /etc/yum.repos.d/photon-iso.repo {}/srv/rpm-ostree/photon-iso-ostree.repo".format(self.photon_root)) self.run("ln -s /etc/yum.repos.d/photon-updates.repo {}/srv/rpm-ostree/photon-updates-ostree.repo".format(self.photon_root)) self.run("ln -s /etc/yum.repos.d/photon-extras.repo {}/srv/rpm-ostree/photon-extras-ostree.repo".format(self.photon_root)) self.run("cp ./ostree-httpd.conf {}/srv/rpm-ostree/".format(self.photon_root)) # Use a custom httpd service file for ostree server self.run("mkdir {}/etc/systemd/system/httpd.service.d".format(self.photon_root)) self.run("cp ./10-httpd-service.conf {}/etc/systemd/system/httpd.service.d/".format(self.photon_root)) self.run("cp ./get-ip-address.sh {}/usr/bin/".format(self.photon_root)) self.run("cp ./ostree-server-greeting.txt {}/etc/issue".format(self.photon_root)) self.run("ln -s /usr/lib/systemd/system/httpd.service {}/usr/lib/systemd/system/multi-user.target.wants/httpd.service".format(self.photon_root)) self.run("tar -xf /mnt/cdrom/ostree-repo.tar.gz -C {}/srv/rpm-ostree/repo".format(self.photon_root)) self.run("sed -i \"\\$i iptables -A INPUT -m state --state NEW,ESTABLISHED -p tcp --dport 80 -j ACCEPT\" {}/etc/systemd/scripts/iptables".format(self.photon_root)) self.run("sed -i \"\\$i iptables -A INPUT -m state --state NEW,ESTABLISHED -p tcp --dport 443 -j ACCEPT\" {}/etc/systemd/scripts/iptables".format(self.photon_root)) self.run("sed -i \"s/umask[ \t]\+[0-9]\+/umask 022/g\" {}/etc/profile".format(self.photon_root))
def main(): instr = '' while instr != 'exit': db = Database.build() instr = input("\ntype mod ID (e.g. '3') or 'exit'\n") try: if instr != 'exit': inp = int(instr) dbq = db[inp] print("choose instruction (e.g. '1')") if 'installed' in dbq: inp2 = int(input("'0' - uninstall\n'1' - cancel\n")) if inp2 == 0: Installer.uninstall(dbq) elif inp2 == 1: pass elif 'downloaded' in dbq: inp2 = int( input("'0' - install\n'1' - remove\n'2' - cancel\n")) if inp2 == 0: Installer.install(dbq) elif inp2 == 1: Downloader.rm(dbq) elif inp2 == 2: pass else: inp2 = int(input("'0' - download\n'1' - cancel\n")) if inp2 == 0: Downloader.dl(dbq) elif inp2 == 1: pass elif instr == 'exit': print('exiting...') break except ValueError: print('valid ID please') continue
def install(self): installer = None if self.install_config.get('type', '') == "ostree_host": installer = OstreeInstaller(self.install_config, self.maxy, self.maxx, self.iso_installer, self.rpm_path, self.log_path, self.log_level) else: installer = Installer(self.install_config, self.maxy, self.maxx, self.iso_installer, self.rpm_path, self.log_path, self.log_level) return installer.install()
def compare(opts, conf, tmp, focus=None): dotfiles = conf.get_dotfiles(opts['profile']) if dotfiles == []: LOG.err('no dotfiles defined for this profile (\"%s\")' % (str(opts['profile']))) return False t = Templategen(base=opts['dotpath']) inst = Installer(create=opts['create'], backup=opts['backup'], dry=opts['dry'], base=opts['dotpath'], quiet=opts['quiet']) # compare only specific files selected = dotfiles if focus: selected = [] for selection in focus.replace(' ', '').split(','): df = next((x for x in dotfiles if x.dst == selection), None) if df: selected.append(df) else: LOG.err('no dotfile matches \"%s\"' % (selection)) for dotfile in selected: same, diff = inst.compare(t, tmp, opts['profile'], dotfile.src, dotfile.dst) if same: if not opts['quiet']: LOG.log('diffing \"%s\" VS \"%s\"' % (dotfile.key, dotfile.dst)) LOG.raw('same file') else: LOG.log('diffing \"%s\" VS \"%s\"' % (dotfile.key, dotfile.dst)) LOG.emph(diff) return len(selected) > 0
def main(): instr = '' while instr != 'exit': db = Database.build() instr = input("\ntype mod ID (e.g. '3') or 'exit'\n") try: if instr != 'exit': inp = int(instr) dbq = db[inp] print ("choose instruction (e.g. '1')") if 'installed' in dbq: inp2 = int(input("'0' - uninstall\n'1' - cancel\n")) if inp2 == 0: Installer.uninstall(dbq) elif inp2 == 1: pass elif 'downloaded' in dbq: inp2 = int(input("'0' - install\n'1' - remove\n'2' - cancel\n")) if inp2 == 0: Installer.install(dbq) elif inp2 == 1: Downloader.rm(dbq) elif inp2 == 2: pass else: inp2 = int(input("'0' - download\n'1' - cancel\n")) if inp2 == 0: Downloader.dl(dbq) elif inp2 == 1: pass elif instr == 'exit': print ('exiting...') break except ValueError: print ('valid ID please') continue
def cli_install(): parser = argparse.ArgumentParser(description='Create a new Launchable Application') parser.add_argument('prefix', # metavar = 'prefix', type=str, nargs='?', help='Prefix name. used to identify the icon file and the launch script eg. pychron' ) parser.add_argument('name', # metavar = 'name', type=str, nargs='?', help='Name of the application bundle eg. Pychron') parser.add_argument('--icon', type=str, nargs='?', help='icon file name') args = parser.parse_args() i = Installer(args.prefix, args.name, args.icon) root = os.path.join(os.path.expanduser('~'), 'Programming', 'mercurial', 'pychron_beta' ) i.install(root)
def OnApply(self, event): self.log.AppendText("please wait...\n") for i in range(len(db[0])): if self.list.IsChecked(i): if len(db[0][i]) == 6: pass else: if len(db[0][i]) == 5: pass else: self.log.AppendText("downloading " + str(db[0][i]) + "...\n") try: Downloader.dl(db[0][i]) except: self.log.AppendText("failed\n") self.log.AppendText("installing " + str(db[0][i]) + "...\n") try: Installer.install(db[0][i]) except: self.log.AppendText("failed\n") else: if len(db[0][i]) == 6: self.log.AppendText("uninstalling " + str(db[0][i]) + "...\n") try: Installer.uninstall(db[0][i]) except: self.log.AppendText("failed\n") self.log.AppendText("refreshing database...\n") global db db = Database.build() self.log.AppendText("all done\n")
def __init__(self, adapter, log): """ Arguments: adapter {string} -- name of adapter to handle log {object} -- object of logger (default: {False}) Raises: FileNotFoundError -- raised when arptables not installed """ self.gateway_mac = False self.interface = adapter installer = Installer() if not os.path.isfile('/usr/bin/arptables') and not os.path.isfile( '/sbin/arptables'): # Detect if arptables installed print( avalon.FM.BD + avalon.FG.R + '\nWe have detected that you don\'t have arptables installed!' + avalon.FM.RST) print('SCUTUM requires arptables to run') if not installer.sysInstallPackage('arptables'): avalon.error('arptables is required for scutum. Exiting...') raise FileNotFoundError( 'File: \"/usr/bin/arptables\" and \"/sbin/arptables\" not found' )
def runInstaller(options, install_config, working_directory): try: sys.path.insert(0, options.installer_path) from installer import Installer except: raise ImportError('Installer path incorrect!') # Run the installer installer = Installer(working_directory=working_directory, rpm_path=options.rpm_path, log_path=options.log_path) installer.configure(install_config) installer.execute()
def __init__(self, options): install_config=None self.media_mount_path = None photon_media = None ks_path = options.install_config_file # Path to RPMS repository: local media or remote URL # If --repo-path= provided - use it, # if not provided - use kernel repo= parameter, # if not provided - use /RPMS path from photon_media, # exit otherwise. repo_path = options.repo_path with open('/proc/cmdline', 'r') as f: kernel_params = shlex.split(f.read().replace('\n', '')) for arg in kernel_params: if arg.startswith("ks="): if not ks_path: ks_path = arg[len("ks="):] elif arg.startswith("repo="): if not repo_path: repo_path = arg[len("repo="):] elif arg.startswith("photon.media="): photon_media = arg[len("photon.media="):] if photon_media: self.mount_media(photon_media) if not repo_path: if self.media_mount_path: repo_path = self.media_mount_path + "/RPMS" else: print("Please specify RPM repo path.") return if ks_path: install_config=self._load_ks_config(ks_path) if options.ui_config_file: ui_config = (JsonWrapper(options.ui_config_file)).read() else: ui_config={} ui_config['options_file'] = options.options_file # Run installer installer = Installer(rpm_path=repo_path, log_path="/var/log") installer.configure(install_config, ui_config) installer.execute()
def __init__(self, options): install_config = None self.cd_mount_path = None cd_search = None ks_path = options.install_config_file repo_path = options.repo_path with open('/proc/cmdline', 'r') as f: kernel_params = shlex.split(f.read().replace('\n', '')) for arg in kernel_params: if arg.startswith("ks="): if not ks_path: ks_path = arg[len("ks="):] elif arg.startswith("repo="): if not repo_path: repo_path = arg[len("repo="):] elif arg.startswith("photon.media="): cd_search = arg[len("photon.media="):] if not repo_path: print("Please specify RPM repo path.") return if cd_search: self.mount_cd(cd_search) if ks_path: install_config = self._load_ks_config(ks_path) if options.ui_config_file: ui_config = (JsonWrapper(options.ui_config_file)).read() else: ui_config = {} ui_config['options_file'] = options.options_file # Run installer installer = Installer(rpm_path=repo_path, log_path="/var/log") installer.configure(install_config, ui_config) installer.execute()
def init(self): self._installer = Installer() self._installer.start() return idaapi.PLUGIN_KEEP
def __init__(self, args): self.__dict__.update(args) self.start_time = time.time() # setup some additional variables if self.database_host == None: self.database_host = self.client_host self.result_directory = os.path.join("results", self.name) if self.parse != None: self.timestamp = self.parse else: self.timestamp = time.strftime("%Y%m%d%H%M%S", time.localtime()) # Setup the concurrency levels array. This array goes from # starting_concurrency to max concurrency, doubling each time self.concurrency_levels = [] concurrency = self.starting_concurrency while concurrency <= self.max_concurrency: self.concurrency_levels.append(concurrency) concurrency = concurrency * 2 # Setup query interval array # starts at 1, and goes up to max_queries, using the query_interval self.query_intervals = [] queries = 1 while queries <= self.max_queries: self.query_intervals.append(queries) if queries == 1: queries = 0 queries = queries + self.query_interval # Load the latest data self.latest = None try: with open('latest.json', 'r') as f: # Load json file into config object self.latest = json.load(f) except IOError: pass self.results = None try: if self.latest != None and self.name in self.latest.keys(): with open( os.path.join(self.result_directory, str(self.latest[self.name]), 'results.json'), 'r') as f: # Load json file into config object self.results = json.load(f) except IOError: pass if self.results == None: self.results = dict() self.results['concurrencyLevels'] = self.concurrency_levels self.results['queryIntervals'] = self.query_intervals self.results['frameworks'] = [ t.name for t in self.__gather_tests() ] self.results['rawData'] = dict() self.results['rawData']['json'] = dict() self.results['rawData']['db'] = dict() self.results['rawData']['query'] = dict() self.results['weighttpData'] = dict() self.results['weighttpData']['json'] = dict() self.results['weighttpData']['db'] = dict() self.results['weighttpData']['query'] = dict() else: for x in self.__gather_tests(): if x.name not in self.results['frameworks']: self.results['frameworks'] = self.results['frameworks'] + [ x.name ] # Setup the ssh command string self.ssh_string = "ssh -T -o StrictHostKeyChecking=no " + self.client_user + "@" + self.client_host if self.identity_file != None: self.ssh_string = self.ssh_string + " -i " + self.identity_file if self.install_software: install = Installer(self) install.install_software()
if (os.path.isdir(options.working_directory)): process = subprocess.Popen( ['rm', '-rf', options.working_directory]) retval = process.wait() process = subprocess.Popen([ 'mkdir', '-p', os.path.join(options.working_directory, "photon-chroot") ]) retval = process.wait() config['working_directory'] = options.working_directory # Run the installer package_installer = Installer(config, rpm_path=options.rpm_path, log_path=options.log_path) package_installer.install(None) # Making the iso if needed if options.iso_path: rpm_list = " ".join( create_rpm_list_to_be_copied_to_iso( options.pkg_to_rpm_map_file, options.pkg_to_be_copied_conf_file, 3, options.output_data_path)) files_to_copy = " ".join( create_additional_file_list_to_copy_in_iso( os.path.abspath(options.stage_path), options.package_list_file)) live_cd = get_live_cd_status_string(options.package_list_file)
avalon.info("{}SCUTUM is {}{}{}\n".format(avalon.FM.RST, avalon.FG.R, "NOT ENABLED", avalon.FM.RST)) else: avalon.info("{}SCUTUM is {}{}{}\n".format(avalon.FM.RST, avalon.FG.G, "ENABLED", avalon.FM.RST)) exit(0) elif os.getuid() != 0: # Multiple components require root access avalon.error('SCUTUM must be run as root!') print(avalon.FG.LGR + 'It requires root privilege to operate the system' + avalon.FM.RST) exit(1) exit_code = 0 log = open(LOGPATH, 'a+') installer = Installer(CONFPATH, log=log) if args.upgrade or args.install: try: installer.check_avalon() installer.check_version(VERSION) except urllib.error.URLError: pass if args.upgrade: exit(exit_code) try: if not (args.purgelog or args.install or args.uninstall): # if program is doing normal operations, log everything # pointless if purging log, installing/removing config, interfaces, network_controllers, ufw_handled = initialize()
if not proceed: sys.exit(0) if (os.path.isdir(options.working_directory)): process = subprocess.Popen(['rm', '-rf', options.working_directory]) retval = process.wait() else: process = subprocess.Popen(['mkdir', '-p', options.working_directory]) retval = process.wait() config['working_directory'] = options.working_directory # Run the installer package_installer = Installer( config, local_install=not (options.iso_path or options.vmdk_path), tools_path=options.tools_path, rpm_path=options.tools_path + "/RPMS", log_path=options.tools_path + "/LOGS") package_installer.install(None) # Making the iso if needed if config['iso_system']: process = subprocess.Popen([ './mk-install-iso.sh', '-w', options.working_directory, options.iso_path, options.tools_path, options.package_list_file ]) retval = process.wait() # Cleaning up for vmdk if 'vmdk_install' in config and config['vmdk_install']: process = subprocess.Popen(
class Device(object): # ================================================================================================================== # FRAMEWORK ATTRIBUTES # ================================================================================================================== # Connection Parameters _ip = '' _port = '' _username = '' _password = '' _tools_local = None _portforward = None _frida_server = None _debug_server = None # App specific _is_iOS8 = False _is_iOS9 = False _is_iOS10 = False _is_iOS7_or_less = False _applist = None _device_ready = False # On-Device Paths TEMP_FOLDER = Constants.DEVICE_PATH_TEMP_FOLDER DEVICE_TOOLS = Constants.DEVICE_TOOLS # On-Server Paths APP_DB_PATH = "/tmp/applicationState.db" #for iOS 10 # Reference to External Objects conn = None app = None installer = None local_op = None remote_op = None printer = None # ================================================================================================================== # INIT # ================================================================================================================== def __init__(self, ip, port, username, password, pub_key_auth, tools): # Setup params self._ip = ip self._port = port self._username = username self._password = password self._pub_key_auth = bool(pub_key_auth) self._tools_local = tools # Init related objects self.app = App(self) self.installer = Installer(self) self.local_op = LocalOperations() self.remote_op = RemoteOperations(self) self.printer = Printer() # ================================================================================================================== # UTILS - USB # ================================================================================================================== def _portforward_usb_start(self): """Setup USB port forwarding with TCPRelay.""" # Check if the user chose a valid port if str(self._port) == '22': raise Exception( 'Chosen port must be different from 22 in order to use USB over SSH' ) # Setup the forwarding self.printer.verbose('Setting up USB port forwarding on port %s' % self._port) cmd = '{app} -t 22:{port}'.format(app=self._tools_local['TCPRELAY'], port=self._port) self._portforward = self.local_op.command_subproc_start(cmd) def _portforward_usb_stop(self): """Stop USB port forwarding.""" self.printer.verbose('Stopping USB port forwarding') self.local_op.command_subproc_stop(self._portforward) # ================================================================================================================== # UTILS - SSH # ================================================================================================================== def _connect_ssh(self): """Open a new connection using Paramiko.""" try: self.printer.verbose('Setting up SSH connection...') self.conn = paramiko.SSHClient() self.conn.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.conn.connect(self._ip, port=self._port, username=self._username, password=self._password, allow_agent=self._pub_key_auth, look_for_keys=self._pub_key_auth) except paramiko.AuthenticationException as e: raise Exception( 'Authentication failed when connecting to %s. %s: %s' % (self._ip, type(e).__name__, e.message)) except paramiko.SSHException as e: raise Exception( 'Connection dropped. Please check your connection with the device, ' 'and reload the module. %s: %s' % (type(e).__name__, e.message)) except Exception as e: raise Exception('Could not open a connection to %s. %s - %s' % (self._ip, type(e).__name__, e.message)) def _disconnect_ssh(self): """Close the connection, if available.""" if self.conn: self.conn.close() def _exec_command_ssh(self, cmd, internal): """Execute a shell command on the device, then parse/print output.""" def hotfix_67(): # TODO: replace with a more long-term fix import time timeout = 30 endtime = time.time() + timeout while not stdout.channel.eof_received: time.sleep(1) if time.time() > endtime: stdout.channel.close() break # Paramiko Exec Command stdin, stdout, stderr = self.conn.exec_command(cmd) hotfix_67() # Parse STDOUT/ERR out = stdout.readlines() err = stderr.readlines() if internal: # For processing, don't display output if err: # Show error and abort run err_str = ''.join(err) raise Exception(err_str) else: # Display output if out: map(lambda x: print('\t%s' % x, end=''), out) if err: map( lambda x: print('\t%s%s%s' % (Colors.R, x, Colors.N), end=''), err) return out, err # ================================================================================================================== # FRIDA PORT FORWARDING # ================================================================================================================== def _portforward_frida_start(self): """Setup local port forward to enable communication with the Frida server running on the device""" localhost = '127.0.0.1' self._frida_server = SSHTunnelForwarder( (self._ip, int(self._port)), ssh_username=self._username, ssh_password=self._password, local_bind_address=(localhost, Constants.FRIDA_PORT), remote_bind_address=(localhost, Constants.FRIDA_PORT), ) self._frida_server.start() def _portforward_frida_stop(self): """Stop local port forwarding""" if self._frida_server: self._frida_server.stop() # ================================================================================================================== # LLDB PORT FORWARDING # ================================================================================================================== def _portforward_debug_start(self): """Setup local port forward to enable communication with the debug server running on the device""" localhost = '127.0.0.1' self._debug_server = SSHTunnelForwarder( (self._ip, int(self._port)), ssh_username=self._username, ssh_password=self._password, local_bind_address=(localhost, Constants.DEBUG_PORT), remote_bind_address=(localhost, Constants.DEBUG_PORT), ) self._debug_server.start() def _portforward_debug_stop(self): """Stop local port forwarding""" if self._debug_server: self._debug_server.stop() # ================================================================================================================== # UTILS - OS # ================================================================================================================== def _detect_ios_version(self): """Detect the iOS version running on the device.""" if self.remote_op.file_exist(Constants.DEVICE_PATH_APPLIST_iOS8): self._is_iOS8 = True elif self.remote_op.file_exist(Constants.DEVICE_PATH_APPLIST_iOS9): self._is_iOS9 = True elif self.remote_op.file_exist(Constants.DEVICE_PATH_DB_iOS10): self._is_iOS10 = True else: self._is_iOS7_or_less = True def _list_apps(self): """List all the 3rd party apps installed on the device.""" def list_iOS_7(): raise Exception('Support for iOS < 8 not yet implemented') def list_iOS_8(applist): # Refresh UICache in case an app was installed after the last reboot self.printer.verbose("Refreshing list of installed apps...") self.remote_op.command_blocking( '/bin/su mobile -c /usr/bin/uicache', internal=True) # Parse plist file pl = self.remote_op.parse_plist(applist) self._applist = pl["User"] def list_iOS_10(applist): self.printer.verbose( "Respring if an application is not listed to rebuild the application db" ) if self._applist == None: self._applist = dict() self.printer.verbose("fetching application state db to %s" % (self.APP_DB_PATH)) #fetch the current database to parse self.pull(applist, self.APP_DB_PATH) #open the loaded db conn = sqlite3.connect(self.APP_DB_PATH) c = conn.cursor() c.execute( "SELECT id,application_identifier FROM application_identifier_tab" ) for row in c: self._applist[row[1]] = row[0] #key = application name c.close() # Dispatch self._detect_ios_version() if self._is_iOS8: list_iOS_8(Constants.DEVICE_PATH_APPLIST_iOS8) elif self._is_iOS9: list_iOS_8(Constants.DEVICE_PATH_APPLIST_iOS9) elif self._is_iOS10: list_iOS_10(Constants.DEVICE_PATH_DB_iOS10) else: list_iOS_7() def select_target_app(self): """List all 3rd party apps installed and let the user choose which one to target""" self._list_apps() self.printer.notify('Apps found:') app_name = choose_from_list(self._applist.keys()) return app_name # ================================================================================================================== # EXPOSED COMMANDS # ================================================================================================================== def is_usb(self): """Returns true if using SSH over USB.""" return self._ip == '127.0.0.1' or self._ip == 'localhost' def connect(self): """Connect to the device.""" if self.is_usb(): # Using SSH over USB, setup port forwarding first self._portforward_usb_start() # Connect self._connect_ssh() def disconnect(self): """Disconnect from the device.""" if self._portforward: # Using SSH over USB, stop port forwarding self._portforward_usb_stop() self._disconnect_ssh() def setup(self, install_tools=True): """Create temp folder, and check if all tools are available""" # Setup temp folder self.printer.verbose("Creating temp folder: %s" % self.TEMP_FOLDER) self.remote_op.dir_create(self.TEMP_FOLDER) # Install tools if install_tools: if not self._device_ready: self.printer.info("Configuring device...") self._device_ready = self.installer.configure() else: self._device_ready = True def cleanup(self): """Remove temp folder from device.""" self.printer.verbose("Cleaning up remote temp folder: %s" % self.TEMP_FOLDER) self.remote_op.dir_delete(self.TEMP_FOLDER) def shell(self): """Spawn a system shell on the device.""" cmd = 'sshpass -p "{password}" ssh {hostverification} -p {port} {username}@{ip}'.format( password=self._password, hostverification=Constants.DISABLE_HOST_VERIFICATION, port=self._port, username=self._username, ip=self._ip) self.local_op.command_interactive(cmd) def pull(self, src, dst): """Pull a file from the device.""" self.printer.info("Pulling: %s -> %s" % (src, dst)) self.remote_op.download(src, dst) def push(self, src, dst): """Push a file on the device.""" self.printer.info("Pushing: %s -> %s" % (src, dst)) self.remote_op.upload(src, dst)
# launch setup if is_configured() is True: app_ready = True else: app_ready = False # app_ready = False if app_ready: from gui.main import Base, determine_version logging.config.dictConfig(DEV_LOGGING) logger = logging.getLogger("babel") local_version = determine_version(os.getcwd()) app = Base() s = Style() s.theme_use("xpnative") s.configure(".", font=("device", 12)) app.iconbitmap("./icons/babel2.ico") app.title("Babel v.{}".format(local_version)) app.mainloop() else: app = Installer() s = Style() s.theme_use("xpnative") s.configure(".", font=("device", 12)) app.iconbitmap("./icons/babel2.ico") app.title("Babel Setup") app.mainloop()
"This will remove everything under {0}. Are you sure?".format( options.working_directory)) if not proceed: sys.exit(0) if (os.path.isdir(options.working_directory)): process = subprocess.Popen(['rm', '-rf', options.working_directory]) retval = process.wait() else: process = subprocess.Popen(['mkdir', '-p', options.working_directory]) retval = process.wait() config['working_directory'] = options.working_directory # Run the installer package_installer = Installer( config, local_install=not (options.iso_path or options.vmdk_path)) package_installer.install(None) # Making the iso if needed if config['iso_system']: process = subprocess.Popen([ './mk-install-iso.sh', '-w', options.working_directory, options.iso_path, options.tools_path ]) retval = process.wait() # Cleaning up for vmdk if 'vmdk_install' in config and config['vmdk_install']: process = subprocess.Popen( ['./mk-clean-vmdk.sh', config['disk']['disk']]) process.wait()
import idaapi idaapi.require('installer') from installer import Installer installer = Installer() installer.start()
topo = Topology(config) topo.create() logger.info('Create data cache') cache = Cache() logger.info('Start data receiver') receiver = Receiver(cache) receiver.start() logger.info('Plant collectors') nodes = topo.list_nodes() installer = Installer(cfg['node']) for node in nodes : node_ipaddress = topo.get_node_ipaddress(node) #print 'node_ipaddress = ',node_ipaddress logger.info('Planting collector to ' + node_ipaddress) if node_ipaddress : installer.set_trust(node_ipaddress) installer.install(node_ipaddress) logger.info('Start auto-scaling checker') checker = Checker(cache, topo, installer, cfg['policy']) checker.start() logger.info('Start api server') http_server = HTTPServer(('', 8001), myHttpHandler)
def install(self, version, src_dir): ins = Installer(self.name, self.prefix, icon_name=self.icon_name, bundle_name=self.bundle_name) ins.version = version self._install(ins, src_dir)
from installer import Installer install_dir = r'E:\Tutorial\Python\steam_workshop_downloader\test\testing' craft_id_file = r'E:\Tutorial\Python\steam_workshop_downloader\crafts.txt' installer = Installer(install_dir) with open(craft_id_file, 'r') as crafts: for craft_id in crafts: print(f'getting {craft_id}') installer.install(craft_id.strip()) print('Done')
def __init__(self, install_config, maxy = 0, maxx = 0, iso_installer = False, rpm_path = "../stage/RPMS", log_path = "../stage/LOGS", log_level = "info"): Installer.__init__(self, install_config, maxy, maxx, iso_installer, rpm_path, log_path, log_level) self.repo_config = {} self.repo_read_conf()
def install(self, params): installer = None installer = Installer(self.install_config, self.maxy, self.maxx, self.iso_installer, self.rpm_path, self.log_path) return installer.install(params)
def __init__(self, srcDir, targetDir, installerDir, intermediateDir, configuration): Installer.__init__(self, srcDir, targetDir, installerDir, intermediateDir, configuration) self.specFileName = os.path.join(self.tempDir, 'scx.spec') self.preInstallPath = os.path.join(self.tempDir, "preinstall.sh") self.postInstallPath = os.path.join(self.tempDir, "postinstall.sh") self.preUninstallPath = os.path.join(self.tempDir, "preuninstall.sh")
class Device(object): # ================================================================================================================== # FRAMEWORK ATTRIBUTES # ================================================================================================================== # Connection Parameters _ip, _port, _agent_port, _username, _password = '', '', '', '', '' _tools_local = None # Port Forwarding _frida_server = None _port_forward_ssh, _port_forward_agent = None, None # App specific _applist, _device_ready, _ios_version = None, None, None # Reference to External Objects ssh, agent = None, None app, installer = None, None local_op, remote_op = None, None printer = None # On-Device Paths TEMP_FOLDER = Constants.DEVICE_PATH_TEMP_FOLDER DEVICE_TOOLS = Constants.DEVICE_TOOLS # ================================================================================================================== # INIT # ================================================================================================================== def __init__(self, ip, port, agent_port, username, password, pub_key_auth, tools): # Setup params self._ip = ip self._port = port self._agent_port = agent_port self._username = username self._password = password self._pub_key_auth = bool(pub_key_auth) self._tools_local = tools # Init related objects self.app = App(self) self.installer = Installer(self) self.local_op = LocalOperations() self.remote_op = RemoteOperations(self) self.printer = Printer() self.agent = NeedleAgent(self) # ================================================================================================================== # UTILS - USB # ================================================================================================================== def _portforward_usb_start(self): """Setup USB port forwarding with TCPRelay.""" # Check if the user chose a valid port if str(self._port) == '22': raise Exception( 'Chosen port must be different from 22 in order to use USB over SSH' ) # Setup the forwarding self.printer.debug('Setting up USB port forwarding on port %s' % self._port) cmd = '{app} -t 22:{port}'.format(app=self._tools_local['TCPRELAY'], port=self._port) self._port_forward_ssh = self.local_op.command_subproc_start(cmd) def _portforward_usb_stop(self): """Stop USB port forwarding.""" self.printer.debug('Stopping USB port forwarding') self.local_op.command_subproc_stop(self._port_forward_ssh) # ================================================================================================================== # UTILS - SSH # ================================================================================================================== def _connect_ssh(self): """Open a new SSH connection using Paramiko.""" try: self.printer.verbose("[SSH] Connecting ({}:{})...".format( self._ip, self._port)) self.ssh = paramiko.SSHClient() self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.ssh.connect(self._ip, port=self._port, username=self._username, password=self._password, allow_agent=self._pub_key_auth, look_for_keys=self._pub_key_auth) self.printer.notify("[SSH] Connected ({}:{})".format( self._ip, self._port)) except paramiko.AuthenticationException as e: raise Exception( 'Authentication failed when connecting to %s. %s: %s' % (self._ip, type(e).__name__, e.message)) except paramiko.SSHException as e: raise Exception( 'Connection dropped. Please check your connection with the device, ' 'and reload the module. %s: %s' % (type(e).__name__, e.message)) except Exception as e: raise Exception('Could not open a connection to %s. %s - %s' % (self._ip, type(e).__name__, e.message)) def _disconnect_ssh(self): """Close the SSH connection, if available.""" self.printer.verbose("[SSH] Disconnecting...") if self.ssh: self.ssh.close() def _exec_command_ssh(self, cmd, internal): """Execute a shell command on the device, then parse/print output.""" def hotfix_67(): # TODO: replace with a more long-term fix import time timeout = 30 endtime = time.time() + timeout while not stdout.channel.eof_received: time.sleep(1) if time.time() > endtime: stdout.channel.close() break # Paramiko Exec Command stdin, stdout, stderr = self.ssh.exec_command(cmd) hotfix_67() # Parse STDOUT/ERR out = stdout.readlines() err = stderr.readlines() if internal: # For processing, don't display output if err: # Show error and abort run err_str = ''.join(err) raise Exception(err_str) else: # Display output if out: map(lambda x: print('\t%s' % x, end=''), out) if err: map( lambda x: print('\t%s%s%s' % (Colors.R, x, Colors.N), end=''), err) return out, err # ================================================================================================================== # UTILS - AGENT # ================================================================================================================== def _portforward_agent_start(self): """Setup local port forward to enable communication with the Needle server running on the device.""" self.printer.debug('{} Setting up port forwarding on port {}'.format( Constants.AGENT_TAG, self._agent_port)) localhost = '127.0.0.1' self._port_forward_agent = SSHTunnelForwarder( (self._ip, int(self._port)), ssh_username=self._username, ssh_password=self._password, local_bind_address=(localhost, self._agent_port), remote_bind_address=(localhost, self._agent_port), ) self._port_forward_agent.start() def _portforward_agent_stop(self): """Stop local port forwarding for Needle server.""" self.printer.debug('{} Stopping port forwarding'.format( Constants.AGENT_TAG)) if self._port_forward_agent: self._port_forward_agent.stop() def _connect_agent(self): self.agent.connect() def _disconnect_agent(self): self.agent.disconnect() # ================================================================================================================== # FRIDA PORT FORWARDING # ================================================================================================================== def _portforward_frida_start(self): """Setup local port forward to enable communication with the Frida server running on the device.""" self.printer.debug('{} Setting up port forwarding on port {}'.format( "[FRIDA]", Constants.FRIDA_PORT)) localhost = '127.0.0.1' self._frida_server = SSHTunnelForwarder( (self._ip, int(self._port)), ssh_username=self._username, ssh_password=self._password, local_bind_address=(localhost, Constants.FRIDA_PORT), remote_bind_address=(localhost, Constants.FRIDA_PORT), ) self._frida_server.start() def _portforward_frida_stop(self): """Stop local port forwarding for Frida server.""" self.printer.debug('{} Stopping port forwarding'.format("FRIDA")) if self._frida_server: self._frida_server.stop() # ================================================================================================================== # UTILS - OS # ================================================================================================================== def _list_apps(self): """Retrieve all the 3rd party apps installed on the device.""" agent_list = self.agent.exec_command_agent( Constants.AGENT_CMD_LIST_APPS) self._applist = Utils.string_to_json(agent_list) def select_target_app(self): """List all 3rd party apps installed and let the user choose which one to target.""" # List all 3rd party apps self._list_apps() # Show menu to user self.printer.notify('Apps found:') app_name = choose_from_list(self._applist.keys()) return app_name # ================================================================================================================== # EXPOSED COMMANDS # ================================================================================================================== def is_usb(self): """Returns true if using SSH over USB.""" return self._ip == '127.0.0.1' or self._ip == 'localhost' def connect(self): """Connect to the device (both SSH and AGENT).""" # Using USB, setup port forwarding first if self.is_usb(): self._portforward_usb_start() self._portforward_agent_start() # Setup channels self._connect_agent() self._connect_ssh() def disconnect(self): """Disconnect from the device (both SSH and AGENT).""" # Close channels self._disconnect_ssh() self._disconnect_agent() # Using USB, stop port forwarding first if self._port_forward_ssh: self._portforward_usb_stop() self._portforward_agent_stop() def setup(self, install_tools=True): """Create temp folder, and check if all tools are available""" # Setup temp folder self.printer.debug("Creating temp folder: %s" % self.TEMP_FOLDER) self.remote_op.dir_create(self.TEMP_FOLDER) # Detect OS version self._ios_version = self.agent.exec_command_agent( Constants.AGENT_CMD_OS_VERSION) # Install tools if install_tools: if not self._device_ready: self.printer.info("Configuring device...") self._device_ready = self.installer.configure() else: self._device_ready = True def cleanup(self): """Remove temp folder from device.""" self.printer.debug("Cleaning up remote temp folder: %s" % self.TEMP_FOLDER) self.remote_op.dir_delete(self.TEMP_FOLDER) def shell(self): """Spawn a system shell on the device.""" cmd = 'sshpass -p "{password}" ssh {hostverification} -p {port} {username}@{ip}'.format( password=self._password, hostverification=Constants.DISABLE_HOST_VERIFICATION, port=self._port, username=self._username, ip=self._ip) self.local_op.command_interactive(cmd) def pull(self, src, dst): """Pull a file from the device.""" self.printer.info("Pulling: %s -> %s" % (src, dst)) self.remote_op.download(src, dst) def push(self, src, dst): """Push a file on the device.""" self.printer.info("Pushing: %s -> %s" % (src, dst)) self.remote_op.upload(src, dst)
packages = [] packages = PackageSelector.get_packages_to_install(options_sorted, config['type'], options.output_data_path) config['packages'] = packages if (os.path.isdir(options.working_directory)): process = subprocess.Popen(['rm', '-rf', options.working_directory]) retval = process.wait() process = subprocess.Popen(['mkdir', '-p', os.path.join(options.working_directory, "photon-chroot")]) retval = process.wait() config['working_directory'] = options.working_directory # Run the installer package_installer = Installer(config, rpm_path = options.rpm_path, log_path = options.log_path) package_installer.install(None) # Making the iso if needed if options.iso_path: rpm_list = " ".join(create_rpm_list_to_be_copied_to_iso(options.pkg_to_rpm_map_file, options.pkg_to_be_copied_conf_file, 1, options.output_data_path)) files_to_copy = " ".join(create_additional_file_list_to_copy_in_iso(os.path.abspath(options.stage_path), options.package_list_file)) live_cd = get_live_cd_status_string(options.package_list_file) process = subprocess.Popen(['./mk-install-iso.sh', '-w', options.working_directory, options.iso_path, options.rpm_path, options.package_list_file, rpm_list, options.stage_path, files_to_copy, live_cd, options.json_data_path]) retval = process.wait() if options.debug_iso_path: debug_rpm_list = create_rpm_list_to_be_copied_to_iso(options.pkg_to_rpm_map_file, options.pkg_to_be_copied_conf_file, 2, options.output_data_path) make_debug_iso(options.working_directory, options.debug_iso_path, debug_rpm_list) # Cleaning up for vmdk
if not (args.enable or args.disable): printIcon() if args.version: # prints program legal / dev / version info print("Current Version: " + VERSION) print("Author: K4YT3X") print("License: GNU GPL v3") print("Github Page: https://github.com/K4YT3X/SCUTUM") print("Contact: [email protected]") print() exit(0) log = Logger(LOGPATH) installer = Installer(CONFPATH) if args.upgrade: installer.check_avalon() installer.check_version(VERSION) exit(0) try: if os.getuid() != 0: # Arptables requires root avalon.error('SCUTUM must be run as root!') print(avalon.FG.LGR + 'It needs to control the system firewall so..' + avalon.FM.RST) exit(0) if not (args.purgelog or args.install or args.uninstall): # if program is doing normal operations, log everything # pointless if purging log, installing/removing log.writeLog(str(datetime.datetime.now()) + ' ---- START ----')
def __init__(self, args): self.__dict__.update(args) self.start_time = time.time() # setup some additional variables if self.database_host == None: self.database_host = self.client_host self.result_directory = os.path.join("results", self.name) if self.parse != None: self.timestamp = self.parse else: self.timestamp = time.strftime("%Y%m%d%H%M%S", time.localtime()) # Setup the concurrency levels array. This array goes from # starting_concurrency to max concurrency, doubling each time self.concurrency_levels = [] concurrency = self.starting_concurrency while concurrency <= self.max_concurrency: self.concurrency_levels.append(concurrency) concurrency = concurrency * 2 # Setup query interval array # starts at 1, and goes up to max_queries, using the query_interval self.query_intervals = [] queries = 1 while queries <= self.max_queries: self.query_intervals.append(queries) if queries == 1: queries = 0 queries = queries + self.query_interval # Load the latest data self.latest = None try: with open('latest.json', 'r') as f: # Load json file into config object self.latest = json.load(f) except IOError: pass self.results = None try: if self.latest != None and self.name in self.latest.keys(): with open(os.path.join(self.result_directory, str(self.latest[self.name]), 'results.json'), 'r') as f: # Load json file into config object self.results = json.load(f) except IOError: pass if self.results == None: self.results = dict() self.results['concurrencyLevels'] = self.concurrency_levels self.results['queryIntervals'] = self.query_intervals self.results['frameworks'] = [t.name for t in self.__gather_tests()] self.results['duration'] = self.duration self.results['rawData'] = dict() self.results['rawData']['json'] = dict() self.results['rawData']['db'] = dict() self.results['rawData']['query'] = dict() self.results['rawData']['fortune'] = dict() self.results['rawData']['update'] = dict() self.results['rawData']['plaintext'] = dict() else: #for x in self.__gather_tests(): # if x.name not in self.results['frameworks']: # self.results['frameworks'] = self.results['frameworks'] + [x.name] # Always overwrite framework list self.results['frameworks'] = [t.name for t in self.__gather_tests()] # Setup the ssh command string self.ssh_string = "ssh -T -o StrictHostKeyChecking=no " + self.client_user + "@" + self.client_host if self.identity_file != None: self.ssh_string = self.ssh_string + " -i " + self.identity_file if self.install_software: install = Installer(self) install.install_software()
def __init__(self, install_config, maxy = 0, maxx = 0, iso_installer = False, rpm_path = "../stage/RPMS", log_path = "../stage/LOGS", ks_config = None): Installer.__init__(self, install_config, maxy, maxx, iso_installer, rpm_path, log_path, ks_config)
def install(self, params): installer = None installer = Installer(self.install_config, self.maxy, self.maxx, self.iso_installer, self.rpm_path, self.log_path, self.log_level) return installer.install(params)
class DjBuild(object): def __init__(self, buildout, name, options): self.log = logging.getLogger(name) self.egg = zc.recipe.egg.Egg(buildout, options['recipe'], options) self.buildout, self.name, self.options = buildout, name, options options['location'] = os.path.join( buildout['buildout']['parts-directory'], name) options['bin-directory'] = buildout['buildout']['bin-directory'] options.setdefault('project', 'example.com') options.setdefault('external-apps', 'apps') options.setdefault('local-apps', 'company') options.setdefault('settings', 'development') options.setdefault('urlconf', options['project'] + '.urls') # Set this so the rest of the recipe can expect the values to be # there. We need to make sure that both pythonpath and extra-paths are # set for BBB. if 'extra-paths' in options: options['pythonpath'] = options['extra-paths'] else: options.setdefault('extra-paths', options.get('pythonpath', '')) # Usefull when using archived versions buildout['buildout'].setdefault( 'download-cache', os.path.join(buildout['buildout']['directory'], 'downloads')) # only try to download stuff if we aren't asked to install from cache self.install_from_cache = self.buildout['buildout'].get( 'install-from-cache', '').strip() == 'true' self.__installer = Installer(self.options, self.buildout, self.log, self.name) def install(self): print '\n------------------ Installing DjBuild ------------------\n' version = self.options['version'] location = self.options['location'] base_dir = self.buildout['buildout']['directory'] project_dir = os.path.join(base_dir, 'src') download_dir = self.buildout['buildout']['download-cache'] # updating sys.path to find django settings sys.path.insert(0, project_dir) extra_path = self.__installer.get_extra_paths() requirements, ws = self.egg.working_set(['djbuild']) self.__installer.verify_or_create_download_dir(download_dir) self.__installer.remove_pre_existing_installation(location) self.__installer.install_django(version, download_dir, location, self.install_from_cache) self.__installer.install_recipe(location) self.__installer.install_project(project_dir, self.options['project']) script_paths = self.__installer.install_scripts(extra_path, ws) print '\n------------------ Installing DjBuild ------------------\n' return script_paths + [location] def update(self): pass