Example #1
0
    def process(self, dumpdir):
        print "[%s] Processing %s" % (time.asctime(), dumpdir)

        extrafd = open(os.path.join(dumpdir, 'extra.json'))
        extra = json.load(extrafd)
        extrafd.close()

        dumps = ['plugin']
        if 'additional_minidumps' in extra:
            dumps.extend(extra['additional_minidumps'].split(','))

        waitfuncs = [self.processsingle(os.path.join(dumpdir, 'minidump_%s.dmp' % dump)) for dump in dumps]
        for f in waitfuncs:
            f()

        reportFile = os.path.join(dumpdir, 'report.html')
        fd = open(reportFile, 'w')
        fd.write(generateReport(dumpdir))
        fd.close()

        if self.config.reporting_server and self.config.reporting_directory:
            uuid = os.path.basename(dumpdir)
            year = uuid[3:7]
            month = uuid[7:9]
            day = uuid[9:11]
            remoteDir = os.path.join(self.config.reporting_directory, year, '%s-%s' % (month, day))
            remoteFile = os.path.join(remoteDir, uuid + '.html')

            fd = open(reportFile)
            subprocess.check_call(['ssh', self.config.reporting_server, 'mkdir', '-p', remoteDir, '&&', 'cat', '>', remoteFile], stdin=fd)
            fd.close()
def main():

    # clears the output of the testCaseEvaluations.txt and
    # testCaseOutputs.txt files
    os.system('cat /dev/null > temp/testCaseEvaluations.txt')
    os.system('cat /dev/null > temp/testCaseOutputs.txt')

    # list for the test case files
    testFiles = []

    # loop for grabbing the directory info with the testcase
    # files
    for f in os.walk('testCases'):
        testFiles.append(f)

    # this takes the output of the list which is first a
    # tuple, and then takes the third argument (the list of
    # the files), casts them to a list, and then sorts them

    testFiles = sorted(list(testFiles[0][2]))

    # helper file that parses the testcases and then returns
    # a dictionary with the following format:
    # {'testCaseID': [testcaseID, requirement tested, driver name,
    #  class being tested, function being tested, parameters,
    #  expected oracle]}

    tests = parser.parse(len(testFiles) + 1)

    # generates a list of the testcases as keys for running individual
    # tests

    testCases = list(tests.keys())

    # loop to run the testcases

    for i in range(len(testCases)):

        tester.runTest(tests[testCases[i]])

    # generate a professional grade report based on the testcases that
    # have been run
    report.generateReport(tests, testCases)
Example #3
0
        option_xss = "xss" in confActions
        option_backup = "backup" in confActions
        option_include = "include" in confActions
        option_js = "javascript" in confActions
        option_crystal = "crystal" in confActions
        option_session = "session" in confActions

    # default to localhost ?
    archives_url = "http://localhost"
    if option_url:
        archives_url = option_url
    root = archives_url
    createStructure()
    depth = 1

    generateReport(archives_url, False)
    filename = "file:///Applications/XAMPP/xamppfiles/htdocs/grabber/results/report.html"
    webbrowser.get('macosx').open(filename, 0, False)

    definition_headers(option_cookie)
    if option_cookie != None:
        appendToReport(
            archives_url, "<h4><div class='label label-default'>Cookie: " +
            escape(option_cookie) + "</div></h4>")
    try:
        depth = int(option_spider.strip().split()[0])
    except (ValueError, IndexError, AttributeError):
        depth = 0

    try:
        try:
Example #4
0
    def __init__(self, *args):
        Qt.QMainWindow.__init__(self, *args)

        self.resize(800, 600)
        self.setWindowTitle("PlotMeNow")

        centralWidget = QtGui.QWidget(self)
        gridLayout = QtGui.QGridLayout(centralWidget)
        gridLayout.setMargin(0)
        plot = CartesianPlot(centralWidget)
        gridLayout.addWidget(plot, 0, 0, 1, 1)
        self.setCentralWidget(centralWidget)

        def addToolBar(parent, name):
            toolBar = QtGui.QToolBar(parent)
            toolBar.setWindowTitle(name)
            parent.addToolBar(QtCore.Qt.TopToolBarArea, toolBar)
            return toolBar

        toolBar = addToolBar(self, u'Сессия')

        def genButton(name, res, *args):
            return toolBar.addAction(QtGui.QIcon(QtGui.QPixmap(":/image/%s.png" % res)), name, *args)

        def projSaveAs():
            print 'projSaveAs()', pc.isChanged()
            fileName = QtGui.QFileDialog.getSaveFileName(self, u'Сохранить сессию', '.', 'PlotMeNow (*.pmn)')
            if not fileName.isNull():
                return pc.save(unicode(fileName))

            return False

        def projSave():
            print 'projSave()', pc.isChanged()
            if not pc.onDisk():
                return projSaveAs()

            return pc.save()

        def projNew():
            print 'projNew()', pc.isChanged()
            if pc.isChanged():
                reply = QtGui.QMessageBox.question(self, u'Несохраненные изменения', u'Сохранить текущую сессию?', QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel)
                if reply == QtGui.QMessageBox.Save:
                    projSave()
                elif reply == QtGui.QMessageBox.Cancel:
                    return

            self.e.setAB(None, None)
            print '1', pc.getElements()
            ret = pc.new()
            print '2', pc.getElements()
            if ret:
                for i in xrange(comboBoxF.count()):
                    comboBoxF.setItemData(i, None)
                print '3', pc.getElements()
                print 'comboBoxF.clear()'
                comboBoxF.clear()

                print '4', pc.getElements()
                self.l.destroy()
                del self.l
                self.l = None

                print '5', pc.getElements()
                self.l = pc.create(Lagrange.__name__)
                self.l.setEditing()
                print '6', pc.getElements()
                self.e.setAB(None, self.l)
                print 'Control elems', pc.getElements()

                self.e.reconnect()
                self.e.setB(self.l)

                plot.replot()
            else:
                if comboBoxF.count() > 0:
                    index = comboBoxF.currentIndex()
                    obj = comboBoxF.itemData(index).toPyObject()
                    self.e.setAB(obj, self.l)

            return ret

        def projOpen():
            print 'projOpen()', pc.isChanged()
            fileName = QtGui.QFileDialog.getOpenFileName(self, u'Открыть сессию', '.', 'PlotMeNow (*.pmn)')
            if not fileName.isNull():
                if pc.isChanged() and QtGui.QMessageBox.Save == QtGui.QMessageBox.question(self, u'Несохраненные изменения', u'Сохранить текущую сессию?', QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard, QtGui.QMessageBox.Save):
                    projSave()
                #return pc.load(unicode(fileName))

                self.e.setAB(None, None)
                print '1', pc.getElements()
                ret = pc.load(unicode(fileName))
                print '2', pc.getElements()
                if ret:
                    """
                    self.l.destroy()
                    self.ep.destroy()
                    pc.detach(self.l)
                    pc.detach(self.ep)
                    del self.l
                    del self.ep
                    self.l = None
                    self.ep = None
                    self.l = pc.getElementsByClassName(Lagrange.__name__).pop()
                    self.ep = pc.getElementsByClassName(EvalPlot.__name__).pop()
                    self.e.setAB(self.ep, self.l)
                    plot.replot()
                    """

                    """
                    for ep in pc.getElementsByClassName(EvalPlot.__name__):
                        pc.detach(ep)
                        ep.destroy()
                        del ep
                        ep = None
                    self.l.destroy()
                    pc.detach(self.l)
                    del self.l
                    self.l = None
                    """
                    self.l = pc.getElementsByClassName(Lagrange.__name__).pop()
                    print '3', pc.getElements()

                    print 'comboBoxF.clear()'
                    comboBoxF.clear()
                    print '4', pc.getElements()

                    print 'for ep in pc.getElementsByClassName(EvalPlot.__name__)'
                    for ep in pc.getElementsByClassName(EvalPlot.__name__):
                        f = ep.getExpression()
                        if f is None:
                            print 'Warning!', ep, 'has None function'
                        else:
                            comboBoxF.addItem(f, ep)
                    print '5', pc.getElements()

                if comboBoxF.count() > 0:
                    index = comboBoxF.currentIndex()
                    obj = comboBoxF.itemData(index).toPyObject()
                    self.e.setA(obj)
                self.e.reconnect()
                self.e.setB(self.l).replot()
                return ret

            return False

        projectNew = genButton(u"Новый", "new", projNew)
        projectOpen = genButton(u"Открыть", "open", projOpen)
        projectSave = genButton(u"Сохранить", "fileSave", projSave)
        projectSaveAs = genButton(u"Сохранить как", "fileSaveAs", projSaveAs)

        toolBar = addToolBar(self, u'Навигация')
        #toolBar.addSeparator()
        editUndo = genButton(u"Отменить действие", "editUndo", lambda: pc.undo())
        editRedo = genButton(u"Вернуть действие", "editRedo", lambda: pc.redo())

        toolBar = addToolBar(self, u'Выражения')
        #toolBar.addSeparator()
        comboBoxF = QtGui.QComboBox(toolBar)
        comboBoxF.setMinimumSize(QtCore.QSize(220, 0))
        #comboBoxF.addItems(['4*pi*sin(x)*cos(x)^2', 'x^2', 'e^(-x^2)'])
        comboBoxF.setEditable(True)
        comboBoxF.setIconSize(QtCore.QSize(16, 16))
        toolBar.addAction("f(x):")
        toolBar.addWidget(comboBoxF)
        #QtCore.QObject.connect(comboBoxF, QtCore.SIGNAL("editTextChanged(QString)"), lambda x: self.ep.setExpression(x))
        #QtCore.QObject.connect(comboBoxF, QtCore.SIGNAL("currentIndexChanged(QString)"), lambda x: self.ep.setExpression(x))
        #QtCore.QObject.connect(comboBoxF, QtCore.SIGNAL("currentIndexChanged(int)"), lambda i: self.e.setA(comboBoxF.itemData(i).toPyObject()).replot())
        def currentIndexChanged(index):
            print 'currentIndexChanged', index
            if index > -1:
                obj = comboBoxF.itemData(index).toPyObject()
                if obj is None:
                    obj = pc.create(EvalPlot.__name__, comboBoxF.itemText(index))
                    comboBoxF.setItemData(index, obj)
                    self.e.reconnect()
                self.e.setA(obj)
            else:
                self.e.setA(None)

            self.e.replot()
        #def editTextChanged(text):
        QtCore.QObject.connect(comboBoxF, QtCore.SIGNAL("currentIndexChanged(int)"), currentIndexChanged)
        #QtCore.QObject.connect(comboBoxF, QtCore.SIGNAL("editTextChanged(QString)"), editTextChanged)
        deleteButtonF = QtGui.QPushButton(QtGui.QIcon(QtGui.QPixmap(":/image/editDelete.png")), '', toolBar)
        deleteButtonF.setIconSize(QtCore.QSize(12, 12))
        deleteButtonF.setMaximumSize(QtCore.QSize(22, 22))
        #QtCore.QObject.connect(deleteButtonF, QtCore.SIGNAL("clicked()"), lambda: comboBoxF.removeItem(comboBoxF.currentIndex()))
        def deleteEP():
            if comboBoxF.count() == 0:
                return
            index = comboBoxF.currentIndex()
            obj = comboBoxF.itemData(index).toPyObject()
            pc.detach(obj)
            obj.destroy()
            del obj
            comboBoxF.removeItem(index)
        QtCore.QObject.connect(deleteButtonF, QtCore.SIGNAL("clicked()"), deleteEP)
        toolBar.addWidget(deleteButtonF)

        toolBar = addToolBar(self, u'Отчет')
        #toolBar.addSeparator()
        #generateReportAction = genButton(u"Составить отчет", "fileResource", lambda: generateReport(self, plot, [unicode(comboBoxF.itemText(i)) for i in xrange(comboBoxF.count())], [l]))
        generateReportAction = genButton(u"Составить отчет", "fileResource", lambda: generateReport(self, plot, pc.getElementsByClassName(EvalPlot.__name__), pc.getElementsByClassName(Lagrange.__name__)))

        toolBar = addToolBar(self, u'Справка')
        #toolBar.addSeparator()
        helpAction = genButton(u"Справка", "help", lambda: HelpDialog(self).show())
        aboutAction = genButton(u"О программе", "helpAbout", lambda: AboutDialog(self).show())

        pc = PlotControl(plot, editUndo.setEnabled, editRedo.setEnabled)

        #self.ep = EvalPlot(plot, '4*pi*sin(x)*cos(x)^2')
        self.l = Lagrange(plot)
        #self.e = Epsilon(plot, self.ep, self.l)
        self.l.setEditing()

        self.e = Epsilon(plot, None, self.l)
        func = ['4*pi*sin(x)*cos(x)^2', 'x^2', 'e^(-x^2)']
        for f in func:
            comboBoxF.addItem(f, pc.create(EvalPlot.__name__, f))
        self.e.reconnect()

        pc.attach(self.l)
        #pc.attach(self.ep)

        picker = Qwt.QwtPlotPicker(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft,
                    Qwt.QwtPicker.DragSelection,
                    Qwt.QwtPlotPicker.CrossRubberBand, Qwt.QwtPicker.AlwaysOn,
                    plot.canvas())
Example #5
0
def main():

   ip_ranges_final = []
   alteredSessions_final = []
   hosts = []
   db_h_final = defaultdict()
   sessions_final = defaultdict()
   attacks_final = defaultdict()
   hierarchy_final = defaultdict()
   host_list_final = defaultdict()
   db_s_final = defaultdict()
   exploitsRun_final = defaultdict()
   existing = 0

   shared_util.defineGlobals()
   prop_file_gen = False if "-init" in sys.argv else True

   ## user prompt
   (server_ip, server_passwd, ip_ranges, target_ip, severity) = \
      user_input_handler.prompt_user(prop_file_gen)

   exploit_file_gen = 0

   ## service startup
   if len(sys.argv) > 1:
      for arg in sys.argv:
         if arg == "-init":
            service_startup.init(server_ip, server_passwd)
            exploit_file_gen = 1
         if arg == "-update":
            service_startup.update()
            exploit_file_gen = 1
         if arg == "-h" or arg == "--help":
            user_input_handler.print_header()
            quit()

   print "Prop file name: " + str(shared_util.prop_file_name)

   scan = nmap_scan.scan_location_setup()
   if scan == "y" or scan == "Y":
      host_list = nmap_scan.scan(ip_ranges, [], [])
   else:
      host_list = shared_util.parseIPRanges(ip_ranges);

   #print host_list

   ## exploit gathering
   db_e = exploit_db_gen.determine_db(exploit_file_gen)
   #exploit_db_gen.print_db(db_e)

   user_input_ranges = ip_ranges

   while True:
      ## service gathering
      db_s = service_db_gen.generate_db(host_list)
      #service_db_gen.print_db(db_s)

      ## host gathering
      (db_h, host_list) = host_db_gen.generate_db(host_list)
      #host_db_gen.print_db(db_h)

      ## attack generation
      attacks = atk_gen.determineAttackVectors(db_e, db_s, db_h, host_list, severity)
      #atk_gen.print_attacks(attacks)
      (session_db, exploitsRun, existing) = atk_gen.generate_attacks(attacks, server_ip, severity, existing)
      #print session_db
      #print "-------------------------------------"
      #print exploitsRun
      ## privilege escalation module (combine with pivoting)
      #session_db = shared_util.parseSessionData(sessions)
      #print session_db

      (session_db, new_networks, hierarchy, alteredSessions, exclude) = post_exploit.searchForTarget(session_db, db_h, host_list)

      #copy data into final structures
      ip_ranges_final = copy.copyIPRanges(ip_ranges_final, ip_ranges)
      db_h_final = copy.copyHosts(db_h_final, db_h)
      sessions_final = copy.copySessions(sessions_final, session_db)
      attacks_final = copy.copyAttacks(attacks_final, attacks)
      hierarchy_final = copy.copyHierarchy(hierarchy_final, hierarchy)
      alteredSessions_final = copy.copyAlteredSessions(alteredSessions_final, alteredSessions)
      db_s_final = copy.copyServices(db_s_final, db_s)
      exploitsRun_final = copy.copyExploitsRun(exploitsRun_final, exploitsRun)

      # conduct new scan or quit
      if len(new_networks) > 0:
         ip_ranges = new_networks
         hosts = copy.copyHostsForScanning(hosts, host_list, exclude)
         temp_host_list = nmap_scan.use_scanners(ip_ranges, hosts)
         #temp_host_list = nmap_scan.scan(ip_ranges, exclude, host_list_final)
         host_list_final = copy.copyHostList(host_list_final, host_list, temp_host_list, hierarchy)
         host_list = temp_host_list
      else:
         host_list_final = copy.copyHostList(host_list_final, host_list, [], hierarchy)
         break

   ## exploit db updater
   exploit_db_gen.update_db(db_e, db_h_final, sessions_final, exploitsRun_final)

   ## reporting module
   targetTree = target.getTargetTree(host_list_final, target_ip)
   report.generateReport(ip_ranges_final, host_list_final, db_h_final, sessions_final,
      hierarchy_final, alteredSessions_final, targetTree, user_input_ranges,
      target_ip, severity, db_e, db_s_final, attacks_final)

   ## close all open sessions
   post_exploit.closeSessions()
   print "Done"
Example #6
0
        age = model_class(maxBin, maxBin2)
        print('model: {}'.format(age.name()))

        # train model
        print('train model...')
        start = time.time()
        training_history = age.model.fit(trainx,
                                         trainy,
                                         epochs=epochcnt,
                                         batch_size=batch)
        print(type(training_history))
        training_time = (time.time() - start) / 60
        print('training time taken: {} minutes'.format(training_time))

        results, acc = generateReport(age.model, testx, testy, targetNames,
                                      training_history, training_time,
                                      crop_time, age.params)
        notify.mail('{} Finished: {}'.format(acc * 100, age.name()), results)
        with open('{}-results.txt'.format(age.name()), 'w') as f:
            f.write(results)

        # Test pictures
        result = age.model.evaluate(kx, ky)
        r = ''
        for i, value in enumerate(result):
            r += '  - {} \t:  {}\n'.format(age.model.metrics_names[i], value)
        notify.mail('results', r)

        #except Exception as e:
        #	print('Error!')
        #	print(e)
Example #7
0
     print("""
     Bienvenido a la pizzería
     1. Para subir archivo
     2. Para generar reporte
     0. Salir""")
     menuOption = int(input("Elija una opción: "))
     if menuOption == 0:
         break
     elif menuOption == 1:
         pizzaList = fileToObject(searchForFilePath())
         if pizzaList is None:
             print("Archivo no válido")
         else:
             showOrders(pizzaList)
     elif menuOption == 2:
         generateReport(searchForReportPath())
 """
 myPizza = Pizza([10, 15, 20], 'Familiar')
 jamon = Ingredient([1.5, 1.75, 2], 'jamón')
 champinones = Ingredient([1.75, 2.05, 2.5], 'champiñones')
 pimenton = Ingredient([1.5, 1.75, 2], 'pimentón')
 myPizza = Decorator(myPizza, jamon)
 myPizza = Decorator(myPizza, jamon)
 myPizza = Decorator(myPizza, jamon)
 myPizza = Decorator(myPizza, pimenton)
 myPizza = Decorator(myPizza, pimenton)
 myPizza = Decorator(myPizza, pimenton)
 myPizza = Decorator(myPizza, pimenton)
 myPizza = Decorator(myPizza, pimenton)
 myPizza = Decorator(myPizza, champinones)
 myPizza = Decorator(myPizza, champinones)
        option_xss = "xss" in confActions
        option_backup = "backup" in confActions
        option_include = "include" in confActions
        option_js = "javascript" in confActions
        option_crystal = "crystal" in confActions
        option_session = "session" in confActions

        # default to localhost ?
    archives_url = "http://localhost"
    if option_url:
        archives_url = option_url
    root = archives_url
    createStructure()
    depth = 1

    generateReport(archives_url, False)
    filename = "file:///Applications/XAMPP/xamppfiles/htdocs/grabber/results/report.html"
    webbrowser.get("macosx").open(filename, 0, False)

    definition_headers(option_cookie)
    if option_cookie != None:
        appendToReport(
            archives_url, "<h4><div class='label label-default'>Cookie: " + escape(option_cookie) + "</div></h4>"
        )
    try:
        depth = int(option_spider.strip().split()[0])
    except (ValueError, IndexError, AttributeError):
        depth = 0

    try:
        try: