Exemplo n.º 1
0
    def exec(self):
        if not self.ready():
            return ERROR

        self.__scan = Scan()

        process = subprocess.run(
            self._commandParams(),
            # ["cat", "scan.out"],
            # ["echo"],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)

        if process.returncode != SUCCESS:
            self._addError(process.stderr)

        excode = process.returncode

        self.__parseOutput(process.stdout)

        if len(self.__scan.rules()) > 0:
            self._smanager.saveScan(self.__scan)
        else:
            self.__scan = None
            self._addError(
                'No rules tested, discarding scan. Check xccdf file validity')
            excode = ERROR

        return excode
Exemplo n.º 2
0
 def __init__(self):
     self.piconn = pigpio.pi()
     if not self.piconn.connected:
         print('failed to connect to pigpio deamon - start it')
         exit()
     self.proximity = Proximity(self.piconn)
     self.driver = Driver(self.piconn, self.proximity)
     self.scanner = Scan(self.piconn)
Exemplo n.º 3
0
    def do_scan_seq(self, filename):
        # note:
        # this call is automated, sz makes a series of images in a specific order
        # todo: autofocus first

        # execute scan sequence
        scan = Scan()
        return scan.scan_seq(filename)
Exemplo n.º 4
0
 def append_if_better(self, p_candidate_scan: dict) -> None:
     try:
         if self.is_complete(p_candidate_scan):
             l_scan_profile_id: str = p_candidate_scan["ScanTaskProfileId"]
             if l_scan_profile_id in self.__m_scans:
                 l_new_scan_create_datetime: datetime = parser.parse(
                     p_candidate_scan["InitiatedAt"])
                 l_current_scan_create_datetime: datetime = self.__m_scans[
                     l_scan_profile_id].initiated_at_datetime
                 if l_new_scan_create_datetime > l_current_scan_create_datetime:
                     self.__m_scans[l_scan_profile_id] = Scan(
                         p_candidate_scan)
             else:
                 self.__m_scans[l_scan_profile_id] = Scan(p_candidate_scan)
     except Exception as e:
         self.__mPrinter.print("append_if_better() - {0}".format(str(e)),
                               Level.ERROR)
Exemplo n.º 5
0
 def show_scan(self):
     """
     Shows the scan page
     """
     if not self.scan_widget:
         self.scan_widget = Scan(self)
         self.scan_widget.ids.zbarcam.ids.xcamera._camera.start()
     self.clear_widgets()
     self.add_widget(self.scan_widget)
Exemplo n.º 6
0
 def __init__(self):
     """
         Constructor, no params
     """
     self.scanner = Scan()
     self.man = Manuel()
     self.prompt = "nmapshell > "
     self.hist = []
     self.start()
Exemplo n.º 7
0
    def __init__(self, target_mac, firmware_path, datfile_path):
        self.target_mac = target_mac

        self.firmware_path = firmware_path
        self.datfile_path = datfile_path
        self.scan_obj = Scan(None)
        scan_list = self.scan_obj.scan()
        self.ble_conn = pexpect.spawn(
            "gatttool -b '%s' -t random --interactive" % target_mac)
        self.ble_conn.delaybeforesend = 0
Exemplo n.º 8
0
    def get_device_name(self):
        scanner = Scan(None)
        targets = scanner.scan()
        self.listbox2.delete(0, END)

        if targets:
            for target in targets:
                index = targets.index(target)
                addr  = targets[index][:17]
                self.listbox2.insert("end", addr)
Exemplo n.º 9
0
        def __init__(self, application=None, *args, **kwargs):
            self.application = application
            wx.Frame.__init__(self, None, *args, **kwargs)
            self.Bind(wx.EVT_CLOSE, lambda x: self.Destroy())
            #self.Show()
            import sys

            def val(key):
                if key in sys.argv:
                    return sys.argv[sys.argv.index('-t') + 1]
                else:
                    return None

            def is_yaml(filename):
                ext = '.yaml'
                return filename[-len(ext):] == ext

            template_file = val('-t')
            content_file = val('-c')
            kb_file = val('-k')
            scan_file = val('-s')
            report_file = val('-r')

            if template_file and report_file:
                report = Report()
                report.template_load_xml(template_file)
                if content_file:
                    if is_yaml(content_file):
                        report.content_load_yaml(content_file)
                    else:
                        report.content_load_json(content_file)
                if kb_file:
                    if is_yaml(kb_file):
                        report.kb_load_yaml(kb_file)
                    else:
                        report.kb_load_json(kb_file)
                if scan_file:
                    report.scan = Scan(scan_file)
                report.xml_apply_meta(
                    vulnparam_highlighting=self.menu_view_v.IsChecked(),
                    truncation=self.menu_view_i.IsChecked())
                report.save_report_xml(report_file)
            else:
                print 'Usage: '
                print
                print '    ' + self.application.title + '.exe'
                print '        start GUI application'
                print
                print '    ' + self.application.title + '.exe -t template-file [-c content-file] [-k kb-file] [-s scan-file] -r report-file'
                print '        generate report'
                print
                print '    ' + self.application.title + '.exe [any other arguments]'
                print '        display usage and exit'

            self.Close()
def create_scan(scans):
    print('\n')
    print 'Adding new scan:\n'
    policies = get_policies()
    policy_id = policies['Basic Network Scan']
    scan_name = raw_input("Scan name: ")
    scan_targets = raw_input("Targets: ")
    scan_description = raw_input("Description: ")
    scan_data = add(scan_name, scan_description, scan_targets, policy_id)
    scan_id = scan_data['id']

    scan = Scan(scan_name, scan_description, scan_targets, scan_id)
    scans.append(scan)
Exemplo n.º 11
0
    def __saveScan(self, scan):
        scan_slug = datetime.now().strftime('%d.%m.%Y-%H:%M:%S')
        self.__cursor.execute(self.__mysql_templates['insert_scan'],
                              (scan_slug, ))
        self.__commitToDB()

        stored_scan = Scan({
            'id': self.__cursor.lastrowid,
            'slug': scan_slug,
        })

        for rule in scan.rules():
            stored_scan.addTestedRule(rule)

        return stored_scan
Exemplo n.º 12
0
    def getAllScans(self):
        scans = []

        if not self.ready():
            return scans

        self.__cursor.execute(self.__mysql_templates['select_all_scans'])

        raw_scans = self.__cursor.fetchall()

        for id, slug in raw_scans:
            scan = Scan({'id': id, 'slug': slug})
            self.__getScanRules(scan)
            scans.append(scan)

        return scans
Exemplo n.º 13
0
    def getScanBySlug(self, slug):
        scan = None

        if not self.ready():
            return scan

        self.__cursor.execute(self.__mysql_templates['fetch_scan_by_slug'],
                              (slug, ))

        res = self.__cursor.fetchall()
        if len(res) == 1:
            id, slug = res[0]
            scan = Scan({'id': id, 'slug': slug})
            self.__getScanRules(scan)

        return scan
Exemplo n.º 14
0
    def load_ascans(self):
        path, _ = QFileDialog.getOpenFileName(self, 'Open b-scan file', '',
                                              "B Scans (*.bin)")
        if path != "":
            self.status_bar_text.setText("Loading processed data")
            # Loading Scan
            self.scan = Scan(20000)
            self.scan.load_data(path)
            # 5000 processed ascans
            self.figure5.clear()
            ax = self.figure5.add_subplot(111)
            ax.imshow(self.scan.cut_matrix)
            self.canvas5.draw()

            self.status_bar_text.setText("Finished loading processed data")
        else:
            self.status_bar_text.setText("Path was empty!")
Exemplo n.º 15
0
 def convert(self):
     print('=== Converting Only ===')
     for date in self.date_range():
         print('>>> Start : ' + date.strftime('%Y-%m-%d'))
         stream_files = Scan().set_filter(
             date.strftime('%Y-%m-%d')).get_files()
         if len(stream_files) > 0:
             new_stream = Stream()
             for stream_file in stream_files:
                 new_stream += NewStream(stream_file).get()
             new_stream = new_stream.merge(fill_value=0)
             for index, trace in enumerate(new_stream, start=1):
                 filename = self.get_folder(trace, self._output_directory)
                 if self.file_not_exists(filename):
                     print(
                         str(index) + '. ' + str(trace) + ' | Max : ' +
                         str(abs(trace.max())))
                     self.save(trace, filename)
    def scan_item(self):
        """
        Scan item when thread looping and set item_hash, item_state
        """
        try:
            self.item, self.item_state = self.items.find(Scan().item_hash)

        except AttributeError as error:
            print(error)
            self.item, self.item_state = self.items.find('')

        if not self.item.empty and self.item_state == 'Item data found' and self.thread_is_on:
            self.Show(True)

        elif self.item.empty and self.item_state == 'Item data not found' and self.thread_is_on:
            self.Show(True)

        else:
            self.Show(False)
Exemplo n.º 17
0
def perform_scan(last_date):

    symbols = []

    filelist = [
        f for f in os.listdir(DATA_DIR) if f.endswith('.csv')
        and not f.endswith('_analysis.csv') and not f.endswith('_renko.csv')
    ]
    for f in filelist:
        sym = f.split('.')[0]
        if sym != 'SPY':
            symbols.append(sym)

    sc = Scan(last_date)
    sc.run(symbols)
    sc.percent_change(3.0, 1.5)

    f = Filter()
    f.run()
Exemplo n.º 18
0
 def __init__(self, parent=None):
     super(MyWindow, self).__init__(parent)
     self.setupUi(self)
     # 窗体图标
     self.setWindowIcon(QIcon("ip_cheat.ico"))
     self.scan = Scan()
     self.config = Config()
     self.save = Save()
     self.attack = Attack()
     self.cheat = None
     self.scan.host_scan_status.connect(self.add_host_result)
     self.scan.port_scan_status.connect(self.add_port_result)
     for val in self.config.ipv4_adp.keys():
         self.send_card.addItem(val)
     _translate = QtCore.QCoreApplication.translate
     self.need_scan_ip_T.setPlainText(_translate("MainWindow", "192.168.1.142"))
     self.save_file_path_T.setPlainText(_translate("MainWindow", "D:/PycharmProjects/IP欺骗"))
     self.cheat_port_T.setPlainText(_translate("MainWidow", "80"))
     self.send_card.setCurrentText(_translate("MainWidow", "192.168.1.1"))
Exemplo n.º 19
0
 def _open_scan(self, filename):
     self.status('Loading scan...')
     self.menu_file_save_s.Enable(False)
     if self.scan is not None:
         del self.scan
     self.scan = Scan(
         filename, requests_and_responses=self.menu_view_r.IsChecked())
     if self.menu_view_y.IsChecked():
         self.ctrl_tc_s.SetValue(
             self.scan.dump_yaml(truncate=self.menu_view_i.IsChecked()))
     else:
         self.ctrl_tc_s.SetValue(
             self.scan.dump_json(truncate=self.menu_view_i.IsChecked()))
     self.ctrl_st_s.Enable(True)
     self.menu_file_save_s.Enable(True)
     self.menu_file_save_r.Enable(True)
     #if self.ctrl_st_c.IsEnabled():
     if self.ctrl_st_t.IsEnabled():
         self.menu_tools_merge_scan_into_content.Enable(True)
     self.status('Scan loaded')
Exemplo n.º 20
0
    def scan_tcp(self, host, port):
        """scan tcp port"""
        from scan import Scan
        result = dict()
        try:
            scanner = Scan(host = host, port = port)
            if scanner.check_tcp_port():
                result['status'] = True
                result['result'] = True
                result['data'] = (('port_status', True), )
            else:
                result['status'] = True
                result['result'] = False
                result['data'] = (('port_status', False), )
        except Exception as e:
            result['status'] = False
            result['data'] = (('error:', e.message), )
            return result

        return result
Exemplo n.º 21
0
    def setPosition(self, position):
        self.stepping = True
        self.abort = False
        start = yield self.getPosition()
        stop = position
        rate = yield self.getStepRate()
        step = rate * self.duration

        def onStep(input, output):
            print 'i:%s,\to:%s' % (input, output)
            return not self.abort

        yield Scan(
            IntervalScanInput(
                compose(partial(StepperMotorClient.setPosition, self),
                        compose(int, round)), start, stop, step).next,
            lambda: None, lambda a, b: not self.abort).start()
        self.stepping = False
        position = yield self.getPosition()
        returnValue(position)
Exemplo n.º 22
0
def pts_image_to_Scan(pts_path, image_path):
    """
    Converts a pts file and Image file pair to a Scan object.
    :param pts_path: Path to pts file
    :param image_path: Path to patient image
    :return: Scan object
    """
    image = Image.open(image_path)
    pts_path = pathlib.Path(pts_path)
    pvinf = pts_path.stem.split('.')[0].split('_')
    patient = pvinf[0]
    if len(pvinf) == 2:
        visit = pvinf[1]
    else:
        visit = None
    joints = pts_to_Joints(pts_path)
    return Scan(image,
                joints,
                'b',
                patient,
                image_path=str(image_path),
                visit=visit)
Exemplo n.º 23
0
 def _multi_convert_and_plot(self, date):
     string_date = date.strftime('%Y-%m-%d')
     print('>>> Start : ' + string_date)
     stream_files = Scan().set_filter(string_date).get_files()
     if len(stream_files) > 0:
         new_stream = Stream()
         for stream_file in stream_files:
             new_stream += NewStream(stream_file).get()
         new_stream = new_stream.merge(fill_value=0)
         print('==== Saving Seismogram ' + string_date + ' ====')
         for index, trace in enumerate(new_stream, start=1):
             filename = self.get_folder(trace, self._output_directory)
             if self.file_not_exists(filename):
                 print(
                     str(index) + '. ' + str(trace) + ' | Max : ' +
                     str(abs(trace.max())))
                 self.save(trace, filename)
                 self.plot(trace, filename,
                           self.get_folder(trace, self._dayplot_directory))
                 # self.spectogram(trace, self.filename, self.get_folder(trace, self._spectogram_directory))
             sds_index(filename=self.filename,
                       trace=trace,
                       date=string_date)
Exemplo n.º 24
0
 def onStart():
     yield Scan(self.input, self.output, callback).start()
     if closedToggle.isToggled(): closedToggle.requestToggle()
     self.toggle()
Exemplo n.º 25
0
import os

from scan import Scan

sc = Scan('job_mksqueeze2_nomqw.madx',
          'squeeze2_nomqw',
          bbb=list(range(500, 140, -10)))

sc.mk_cases()
minute = 60
sc.exe_condor(runtime=40 * minute, out='result.tgz')
Exemplo n.º 26
0
import os

from scan import Scan

b5 = list(range(6000, 1000, -200) + range(1000, 490, -10))
b8 = range(10000, 1500, -500)
b2 = range(0, 100, 100 / len(b8))
b8 += [1500] * (len(b5) - len(b8))
b2 += [100] * (len(b5) - len(b2))
bbb = zip(b5, b8, b2)

sc = Scan('job_mkpresqueeze2.madx', 'presqueeze2a_lhcb', b5=b5, b2=b2, b8=b8)

sc.mk_cases()
#sc.exe_local(4)
sc.exe_condor(runtime=30 * 60, out='result.tgz')
Exemplo n.º 27
0
def test7():
    sym_list = ['CSCO']
    sc = Scan()
    sc.run(sym_list)
Exemplo n.º 28
0
def test9():
    sc = Scan()
    sym_list = sc.ibd_watch_list('ibd 50')
    sc.run(sym_list)
Exemplo n.º 29
0
import os

from scan import Scan


sc=Scan('job_mksqueeze2_thin.madx','squeeze2_thin_a',
        bbb=list(range(500,140,-10)))

sc.mk_cases()
sc.exe_condor(runtime=40*60,out='result.tgz')
Exemplo n.º 30
0
import os

from scan import Scan

sc = Scan('job_mksqueeze_lhcb.madx',
          'squeeze2_lhcb',
          bbb=list(range(1000, 140, -10)))

sc.mk_cases()
sc.exe_condor(runtime=30 * 60, out='result.tgz')