Ejemplo n.º 1
0
def main():
    core = Core()

    if len(sys.argv) == 2:
        core.loadEditor(sys.argv[1])
    else:
        print '\033[31mUsage: ./editor.py new_map\033[m'
Ejemplo n.º 2
0
    def login(self):
        myMovie = QMovie("icons/loading.gif")
        myMovie.setScaledSize(QSize(18, 18))
        self.loginMsg.setMovie(myMovie)
        myMovie.start()

        coreLogic = Core()
        args = {}
        args['userid'] = self.userIDTxt.text()
        args['password'] = self.passTxt.text()
        args['entity'] = self.sysChoice.currentText()

        result, msg = coreLogic.login(args)
        if result == True:
            alert = QMessageBox()
            alert.setText('You have successfully logged in!')
            alert.exec_()

            # update parent window = login and session message
            self.parent().checkLogin()
            # close login gui
            self.closingThread = threading.Thread(
                target=self.__closeGui).start()

        else:
            self.loginMsg.setMovie(None)
            self.loginMsg.setText(msg)
            self.loginMsg.setStyleSheet("color:red")
Ejemplo n.º 3
0
Archivo: fdf.py Proyecto: MaxiCom/Fdf
def main():
    core = Core()

    if len(sys.argv) == 2:
        core.loadMap(sys.argv[1])
    else:
        print '\033[31mUsage: ./fdf.py valid_map\033[m'
Ejemplo n.º 4
0
    def __init__(self, parent=None):
        super(MainFrame, self).__init__(parent)

        # intialize the gui
        self.originalPalette = QApplication.palette()
        self.createTopGroupBox()
        self.createLeftGroupBox()
        self.createMiddleTabWidget()
        self.createProgressBar()
        self.createMenubar()
        self.createToolbar()

        # set gui layout
        mainLayout = QGridLayout()
        mainLayout.setMenuBar(self.leftMenuBar)
        mainLayout.addWidget(self.toolbar, 0, 0, 1, 3)
        mainLayout.addWidget(self.topBox, 1, 0, 1, 3)
        mainLayout.addWidget(self.leftGroupBox, 2, 0)
        mainLayout.addWidget(self.middleGroupBox, 2, 1)
        mainLayout.addWidget(self.progressBar, 3, 0, 1, 3)
        mainLayout.setRowStretch(2, 2)
        mainLayout.setColumnStretch(0, 2)
        mainLayout.setColumnStretch(1, 6)
        self.setLayout(mainLayout)
        self.setWindowTitle("ISPAPI-CLI Tool")

        # set app gui style
        QApplication.setStyle(QStyleFactory.create("Fusion"))

        # create core login instnace
        self.coreLogic = Core()

        # scrap instance
        self.scrap = Scrap()

        # check user session upon start
        self.checkLogin()

        # set focus on command input field
        self.cmdTxt.setFocus()

        # initilaize command line completer
        self.initialiseCommandCompleter()

        # initialize subuser completer
        self.initialiseSubuserCompleter()

        # command to execute
        self.commandToExecute = ""

        # set app icon
        self.setWindowIcon(QIcon(self.getIcon("logo-bgw.jpg")))
Ejemplo n.º 5
0
def run():
    # Destruction of the temporary directory on completion
    with tempfile.TemporaryDirectory() as tmp_dir:

        # Create core object instace
        core = Core(tmp_dir)

        # Checks
        file_checks(core.argv.input_file)
        file_checks(core.argv.metadata)
        path_checks(core.argv.output_folder)
        dependencies_checks()

        # Retrieve ISBN
        json_file = os.path.abspath(core.argv.metadata)
        with open(json_file) as json_data:
            isbn = json.load(json_data)['isbn'].replace('-', '')

        # Create object instaces
        metadata = Metadata(isbn)
        pdf = Pdf(core.argv.input_file, tmp_dir)

        page_ranges = []
        output_file_names = []

        # Iterate over chapters metadata
        for chapter_data in metadata.chapters_data:
            page_ranges.append(chapter_data['page'].split('-'))
            output_file_names.append(chapter_data['DOI'].split('/')[1] +
                                     '.pdf')

        # Merge PDFs
        with concurrent.futures.ProcessPoolExecutor() as executor:
            executor.map(pdf.merge_pdfs, page_ranges, output_file_names)

        # Write metadata
        for output_file_name, chapter_data in zip(output_file_names,
                                                  metadata.chapters_data):
            output_file_path = os.path.join(tmp_dir, output_file_name)
            Metadata.write_metadata(chapter_data, output_file_path)

        # PDFs are temporarely stored in tmp_dir
        if core.argv.compress:
            # Output a zip archive
            core.output_archive(metadata.get_doi_suffix())
        else:
            # Output loose PDFs
            core.output_pdfs()
Ejemplo n.º 6
0
cors = CORS(app) # Needed to make us CORS compatible

""" Create the various cogs of the machinery """
parser   = SetupParser()
setup = {}
if not parser.load("conf/setup.conf", setup):
  logging.error('Failed to load "setup.conf"')
  sys.exit(255)

if cmdline.host is not None:
  if (":%d" % cmdline.port) not in setup['OPTIONS']["ux-server"] or not setup['OPTIONS']["ux-server"].endswith('/ux') or not setup['OPTIONS']["ux-server"].endswith('/ux/'):
    logging.warning("You're using hosted UX, make sure \"%s\" points to the right server", setup['OPTIONS']["ux-server"])
    logging.warning('It should use port %d and end with /ux/' % cmdline.port)

remotes = RemoteManager()
core    = Core(setup, remotes)
router  = Router(core)
ssdp    = SSDPHandler(setup['OPTIONS']["ux-server"], cmdline.port)


""" Tracking information """
event_subscribers = []

def notifySubscribers(zone, message):
  for subscriber in event_subscribers:
    if zone is None or core.getRemoteZone(subscriber.remoteId) == zone:
      logging.info("Informing remote %s about \"%s\"", subscriber.remoteId, message)
      subscriber.write_message(message)
    else:
      logging.info("Skipped remote %s", subscriber.remoteId)
Ejemplo n.º 7
0
#!/usr/bin/env python3
import argparse

from modules.core import Core
from interfaces.cmdline import Cmdline

from config import CONFIG

if __name__ == "__main__":
    c = Core(**CONFIG)

    parser = argparse.ArgumentParser()
    parser.add_argument("-g",
                        "--gui",
                        help="Run with graphical interface",
                        action="store_true")
    args = parser.parse_args()

    if args.gui:
        from interfaces.gtk3.gtk3_fault_analyzer import Gtk3FaultAnalyzer
        interface = Gtk3FaultAnalyzer(c)
        interface.start_interface()
    else:
        interface = Cmdline(c)
        interface.cmdloop()
Ejemplo n.º 8
0
def main(args):

    # create core logic object
    core_obj = Core()
    # get the python standard parser initialised
    parser = core_obj.initParser()
    # overwrite defualt error function of the parser with our local function
    parser.error = errorFunction
    # clean extra spaces, leave only single spaces among commands
    original_args = ' '.join(args)
    # remove extra spaces around the = cases are ' =', '= ', ' = '
    original_args = original_args.replace(" = ", "=")
    original_args = original_args.replace(" =", "=")
    original_args = original_args.replace("= ", "=")
    print("Command entered: " + original_args)
    print("----------------")
    # split args in an array
    splitted_args = original_args.split()
    try:
        # get main commands such as "-c checkdomain"
        args = vars(parser.parse_args(splitted_args))
        # get other parameters such as "limit=5"
        reminderargs = args['args']
        # execute the command and show the results
        result, data = core_obj.parseArgs(args)

        # case gui requested
        if result == 'gui':
            startGUI()

        # case show help requested
        elif result == 'help':
            print('\n')
            print(
                textwrap.dedent('''\
                ISPAPI - Commandline Tool
                ------------------------------------------------------------
                The tool can be used in two modes:
                 - By using '=' sign e.g. --command=QueryDomainList limit=5
                 - By using spaces e.g. --command QueryDomainList limit 5
                ------------------------------------------------------------

                '''))
            parser.print_help()

        # case command requested
        elif result == 'cmd':
            # append reminder args with the command
            params_list = core_obj.parseParameters(reminderargs)
            cmd = data
            # add them to data which is the command list
            cmd.update(params_list)
            response = core_obj.request(cmd)
            result = response.getPlain()
            print(result)
        # update current commands
        elif result == 'update':
            scraper = Scrap()
            scraper.scrapCommands()
        # cases for msg
        else:
            print(data)

        sys.exit(0)

    except Exception as e:
        print("Command failed due to: " + str(e))
Ejemplo n.º 9
0
from modules.core import Core
import logging

# logging.basicConfig(level=logging.DEBUG)
Core(hostname_or_path="payment.rate-one.de", configuration="analysis_test.json")
Ejemplo n.º 10
0
    def __start_analysis(self, args):
        """
        Starts the analysis of the TLSA module.

        :param args: the arguments provided to the module
        :type args: argparse.Namespace
        """
        logging.basicConfig(
            level=logging.DEBUG if args.verbosity else logging.INFO)
        self.__logging.debug("Started anaylsis with verbosity on.")
        self.__logging.debug("Initializing Core element.")
        if isinstance(args.configuration,
                      str) and args.configuration == "default":
            args.configuration = (
                f"default{'_android.json' if args.apk else '_server.json'}")
        config_or_modules = args.configuration

        if args.apply_fix or args.file:
            # checks for openssl and ignore-openssl flag
            if not args.ignore_openssl and not args.openssl:
                raise AssertionError(
                    f"\n{Color.WARNING}OpenSSL is required to fix the TLSA records.{Color.ENDC}"
                    f"\nIgnore the checks with \n\t{Color.CBEIGE}--ignore-openssl{Color.ENDC}\n"
                    f"or insert an openssl version with\n\t{Color.CBEIGE}--openssl [VERSION]{Color.ENDC}"
                )

        if args.server:
            Core(
                hostname_or_path=args.server,
                configuration=config_or_modules,
                output=args.output,
                output_type=self.__to_report_type(args.output_type),
                to_exclude=args.exclude,
                type_of_analysis=Core.Analysis.HOST,
                group_by=args.group_by,
                apply_fix=args.apply_fix,
            )
        elif args.apk:
            Core(
                hostname_or_path=args.apk,
                configuration=config_or_modules,
                output=args.output,
                output_type=self.__to_report_type(args.output_type),
                to_exclude=args.exclude,
                type_of_analysis=Core.Analysis.APK,
                group_by=args.group_by,
            )
        elif args.domain_file:
            Core(
                hostname_or_path=load_list_of_domains(args.domain_file),
                configuration=config_or_modules,
                output=args.output,
                output_type=self.__to_report_type(args.output_type),
                to_exclude=args.exclude,
                type_of_analysis=Core.Analysis.DOMAINS,
                group_by=args.group_by,
            )
        elif args.file:
            if isinstance(args.configuration, list):
                self.__logging.warning(
                    "Ignoring module list. Try to exclude the modules with -e module1 module2"
                )
            Core(
                hostname_or_path=args.file,
                configuration="default_file.json",
                output=args.output,
                output_type=self.__to_report_type(args.output_type),
                type_of_analysis=Core.Analysis.CONFIGURATION,
                to_exclude=args.exclude,
                group_by=args.group_by,
                apply_fix=args.apply_fix,
                openssl_version=args.openssl,
                ignore_openssl=args.ignore_openssl,
            )

        else:  # must be args.list, unless argparse throws error.
            self.__print_module(args.list)