def _run_with_cl_interpreter(self): import Terminal interp_path = os.path.join(sys.exec_prefix, "Resources", "Python.app", "Contents", "MacOS", "Python") if not os.path.exists(interp_path): interp_path = os.path.join(sys.exec_prefix, "bin", "python") file_path = self.path if not os.path.exists(interp_path): # This "can happen" if we are running IDE under MacPython-OS9. raise W.AlertError, "Can't find command-line Python" cmd = '"%s" "%s" ; exit' % (interp_path, file_path) t = Terminal.Terminal() t.do_script(cmd)
def test_move_to(self): t = Terminal() t.move_to(5, 5) self.assertEqual(t.row, 5, "Should be in row five after move") self.assertEqual(t.col, 5, "Should be in column five after move") t.move_to(10, 1) # exceeds the maximum rows self.assertEqual(t.row, 9, "Should be in row nine after move") self.assertEqual(t.col, 6, "Should be in column six after move") t.move_to(0, 10) # exceeds the maximum columns self.assertEqual(t.row, 9, "Should be in row nine after move") self.assertEqual(t.col, 9, "Should be in column nine after move") t.move_to(-10, 0) # below the minimum rows self.assertEqual(t.row, 0, "Should be in row zero after move") self.assertEqual(t.col, 9, "Should still be in column nine after move") t.move_to(0, -10) # below the minimum rows self.assertEqual(t.row, 0, "Should still be in row zero after move") self.assertEqual(t.col, 0, "Should be in column zero after move") # normal moves - rows t.move_to(1, 0) self.assertEqual(t.row, 1, "Should be in row one after move") self.assertEqual(t.col, 0, "Should be in column zero after move") t.move_to(1, 0) self.assertEqual(t.row, 2, "Should be in row two after move") self.assertEqual(t.col, 0, "Should be in column zero after move") t.move_to(-1, 0) self.assertEqual(t.row, 1, "Should be in row one after move") self.assertEqual(t.col, 0, "Should be in column zero after move") # normal moves - columns t.move_to(0, 1) self.assertEqual(t.row, 1, "Should be in row one after move") self.assertEqual(t.col, 1, "Should be in column one after move") t.move_to(0, -1) self.assertEqual(t.row, 1, "Should be in row two after move") self.assertEqual(t.col, 0, "Should be in column zero after move") t.move_to(0, 1) self.assertEqual(t.row, 1, "Should be in row one after move") self.assertEqual(t.col, 1, "Should be in column one after move")
def addTerminal(self, name, **opts): #print "Node.addTerminal called. name:", name, "opts:", opts #global TETRACYCLINE #print "TETRACYCLINE: ", TETRACYCLINE #if TETRACYCLINE: #print "Creating Terminal..." name = self.nextTerminalName(name) term = Terminal(self, name, **opts) self.terminals[name] = term if term.isInput(): self._inputs[name] = term elif term.isOutput(): self._outputs[name] = term self.graphicsItem().updateTerminals() self.sigTerminalAdded.emit(self, term) return term
def test_go_to(self): t = Terminal() t.go_to(5, 5) self.assertEqual(t.row, 5, "Should be in row five after go") self.assertEqual(t.col, 5, "Should be in column five after go") t.go_to(10, 1) # exceeds the maximum rows self.assertEqual(t.row, 9, "Should be in row nine after go") self.assertEqual(t.col, 1, "Should be in column one after go") t.go_to(0, 10) # exceeds the maximum columns self.assertEqual(t.row, 0, "Should be in row zero after go") self.assertEqual(t.col, 9, "Should be in column nine after go") t.go_to(-10, -10) # below the minimums self.assertEqual(t.row, 0, "Should be in row zero after go") self.assertEqual(t.col, 0, "Should be in column zero after go") t.go_to(10, 10) # above the maximums self.assertEqual(t.row, 9, "Should be in row nine after go") self.assertEqual(t.col, 9, "Should be in column nine after go")
def test_interpret_relative_moves(self): # Up, Down, Right, and Left, leaving a character behind after the moves # # Note that the cursor moves to the right after each character, so the # additional ^l sequences back it up into the expected position for # the next write # t = Terminal() t.go_to(4, 4) t.interpret("^uU^d^d^lD^l^u^rR^l^l^lL") self.assertEqual( t.str(), """ U L R D """, "Result does not match")
def __init__(self, parent=None, network_interface="lo"): """ Derived from Ui_MainWindow """ super(MainWindow, self).__init__(parent) self.setupUi(self) self.cve_table = CveTable.CVETable_Widget(self.tabWidget) self.network_interface = network_interface self.ip_address = "" self.exploit_option_dialog = AttackOptionDialog.AttackOptionDialog( self, self.LogBrowser) self.android_option_dialog = AttackOptionDialog.AttackOptionDialog( self, self.LogBrowser) self.android_option_dialog.accepted.connect(self.runAndroidExploit) self.confighandler = CoreLoadConfig.ConfigHandler() self.uploaded_exploit_data = None self.uploaded_malware_data = None self.uploaded_cve_data = None self.db_connection_status = "Database Status: Connected" self.sql_queries = DBManipulator.SqlQueries(self.LogBrowser) self.cve_upload_dialog = CVEUpload.CVEUpload( LogBrowser=self.LogBrowser) self.exploit_upload_dialog = ExpUpload.ExpUpload( LogBrowser=self.LogBrowser) self.malware_upload_dialog = MalwareUploadDialog.MalwareUploadDialog( LogBrowser=self.LogBrowser) self.actionExploits.triggered.connect( self.exploit_upload_dialog.uploadExploitClicked) self.actionPayloads.triggered.connect( self.malware_upload_dialog.uploadMalwareClicked) self.actionCVE.triggered.connect( self.cve_upload_dialog.uploadCVEClicked) self.malware_upload_dialog.accepted.connect(self.SaveMalwareToDB) self.exploit_upload_dialog.accepted.connect(self.SaveExploitToDB) self.cve_upload_dialog.accepted.connect(self.SaveCVEToDB) self.terminal = Terminal.Terminal() self.AndroidAttack.clicked.connect(self.androidattack) self.TerminalLoader.clicked.connect(self.ShowTerminal) self.ReloadButton.clicked.connect(self.Reload) self.actionShow_CVE.triggered.connect(self.showCVE) self.Exploit_Table.itemDoubleClicked.connect(self.LaunchExploit) self.Malware_Table.itemDoubleClicked.connect(self.LaunchMalware) self.harvester = harvester.EmailHarvester() self.EHarvest.clicked.connect(self.ShowHarvester) self.actionFind_Public_Emails_2.triggered.connect(self.ShowHarvester) self.tabadder = TabAdder() self.inserter = TableInserter.QueryManager(self.LogBrowser, self.sql_queries) self.attackbrowser = AttackBrowser.AttackBrowser() self.attackbrowser.setupUi(self.attackbrowser) self.metasploit = Metasploit() self.IPLabel.setText("IP Address : %s" % self.getIP()) self.netdiscover = netdiscover.NetDiscover() self.tcpdump = tcpdump.TcpDump() self.DiscoverNetwork.clicked.connect(self.ShowNetworkDiscovery) self.MploitLoader.clicked.connect(self.ShowMetasploit) self.attackbrowser_exploit_list = [] self.attackbrowser_android_list = [] self.attackbrowser_android_counter = 0 self.harvester_option_dialog = AttackOptionDialog.AttackOptionDialog() self.harvester_option_dialog.accepted.connect(self.RunHarvester) self.harvester_title = "Email Harvester" self.harvester_module_option = None self.harvester_module_path_option = "etc/fsecurity/module_config/harvester.json" self.android_threads = [] self.android_title = "Android Exploit" self.android_module = "Attacks/exploits/android_exploit.py" self.android_module_path_option = "etc/fsecurity/module_config/android_exploit_config.json" self.android_module_option = None self.android_threads_counter = 0 self.attackbrowser_exploit_counter = 0 self.attackbrowser_malware_list = [] self.attackbrowser_malware_counter = 0 self.malware_option_dialog = AttackOptionDialog.AttackOptionDialog( self, self.LogBrowser) self.malware_option_dialog.accepted.connect(self.runMalware) self.exploit_option_dialog.accepted.connect(self.runExploit) self.actionShow_Exploit.triggered.connect(self.showExploit) self.actionShow_Malware.triggered.connect(self.showMalware) self.TcpDumpLoader.clicked.connect(self.ShowTcpDump) self.actionEdit_Configuration.triggered.connect(self.editConfig) self.actionNetwork_Mapper.triggered.connect(self.runNmap) self.OSDetector.clicked.connect(self.runNmap) self.actionExit.triggered.connect(self.Exit) #self.actionAuthors.triggered.connect(self.showAuthors) self.document_threads = [] self.malware_threads = [] self.exploit_threads = [] self.exploit_threads_counter = 0 self.malware_threads_counter = 0 self.document_threads_counter = 0 self.exploit_title = None self.active_module_counter = 0 self.active_module = [] self.malware_title = None self.exploit_module = None self.malware_module = None self.exploit_module_option = None self.malware_module_option = None self.attack_launcher = AttackLauncher.AttackLauncher(self.LogBrowser) self.tabWidget.tabCloseRequested.connect(self.tabWidget.removeTab)
def test_interpret_row_column_moves(self): # Go to X,Y and Home, Beginning of Row, Erase from cursor, and Clear all t = Terminal() t.interpret("^i^90abcdefghijkklmnop") self.assertEqual( t.str(), """ abcdefghip""", "Result does not match after last-row insert") t.interpret("^i^00==========") t.interpret("^i^40++++++++++") t.interpret("^i^90^e") t.interpret("^i^30----------") t.interpret("^i^10^^^^^^^^^^^^^^^^^^^^") t.interpret("^i^20**********") self.assertEqual( t.str(), """========== ^^^^^^^^^^ ********** ---------- ++++++++++ """, "Result does not match after inserts and clearing last row") t.interpret("^h^e^11^e^22^e^33^e^44^e") self.assertEqual( t.str(), """ ^ ** --- ++++ """, "Result does not match after making triangle of deletions") t.interpret("^b^e") self.assertEqual( t.str(), """ ^ ** --- """, "Result does not match after beginning of row/erase sequence") r_before = t.row c_before = t.col t.interpret("^c") self.assertEqual( t.str(), """ """, "Result does not match after clear-all") self.assertEqual(t.row, r_before) self.assertEqual(t.col, c_before)
def do(self, configuration, arguments): # # Parameters setup # Command.add_option(self, "-o", "--output", action="store", type="string", dest="output", help="specify output file name") Command.add_option(self, "-i", "--id", action="store", type="string", dest="id", help="specify starting node") Command.add_option(self, "-l", "--line-format", action="store", type="string", dest="line_format", help="specify line format") Command.add_option(self, "-I", "--indent-fill", action="store", type="string", dest="indent_fill", help="specify indent fill string") Command.add_option(self, "-U", "--unindent-fill", action="store", type="string", dest="unindent_fill", help="specify unindent fill string") Command.add_option(self, "-L", "--level-fill", action="store", type="string", dest="level_fill", help="specify level fill string") Command.add_option(self, "-W", "--wrap-fill", action="store", type="string", dest="wrap_fill", help="specify fill for wrapped lines") Command.add_option(self, "-w", "--width", action="store", type="string", dest="width", help="specify maximum text width") Command.add_option(self, "-F", "--filter", action="store", type="string", dest="filter", help="specify selection filter") Command.add_option(self, "-C", "--hide-collapsed", action="store_false", dest="show_collapsed", help="hide collapsed entries") Command.add_option(self, "-c", "--show-collapsed", action="store_true", dest="show_collapsed", help="show collapsed entries") Command.add_option(self, "-R", "--hide-root", action="store_false", dest="show_root", help="hide root entries") Command.add_option(self, "-r", "--show-root", action="store_true", dest="show_root", help="show root entries") Command.add_option(self, "-s", "--sort", action="store", type="string", dest="sort_criteria", help="sorting items") (opts, args) = Command.parse_args(self, arguments) if (len(args) > 0): raise Exceptions.UnknownParameter(args[0]) starting_id = opts.id if (starting_id == None): starting_id = "0" node_id = ID.ID(starting_id) # Open output file filehandle = sys.stdout if (opts.output != None): try: filehandle = open(opts.output, 'w') except: raise Exceptions.CannotWrite(opts.output) assert (filehandle != None) try: colors = configuration.get(PROGRAM_NAME, 'colors', bool) except: colors = False assert (isinstance(colors, bool)) try: verbose = configuration.get(PROGRAM_NAME, 'verbose', bool) except: verbose = False assert (isinstance(verbose, bool)) # Handling configuration width = None show_collapsed = None show_root = None line_format = None level_fill = None wrap_fill = None unindent_fill = None indent_fill = None filter_text = None sort_criteria = None # Width if (opts.width != None): try: width = int(opts.width) except: raise Exceptions.WrongParameterValue("width option must " + "be an integer") else: # Try to guess terminal width t = Terminal.Terminal(stream_out=filehandle) w = t.columns assert (isinstance(w, int)) # If width is not configured, used the guessed one width = configuration.get(self.name, 'width', int, w) assert (isinstance(width, int)) # Width has to be >= 0 anyway ... if (width < 0): raise Exceptions.WrongParameter("width must be greater " "or equal than 0") # Show collapsed if (opts.show_collapsed != None): show_collapsed = opts.show_collapsed else: show_collapsed = configuration.get(self.name, 'show_collapsed', bool, True) assert (isinstance(show_collapsed, bool)) # Root entries if (opts.show_root != None): show_root = opts.show_root else: show_root = configuration.get(self.name, 'show_root', bool, False) assert (isinstance(show_root, bool)) # Line format if (opts.line_format != None): line_format = opts.line_format else: if (verbose is True): l = "%i %t\n[%c]\n(%s, %e, %p)\n" else: l = "%i %t\n" line_format = configuration.get(self.name, 'line_format', str, l) assert (isinstance(line_format, str)) # Indent fill if (opts.indent_fill != None): indent_fill = opts.indent_fill else: indent_fill = configuration.get(self.name, 'indent_fill', str, "") assert (isinstance(indent_fill, str)) # Unindent fill if (opts.unindent_fill != None): unindent_fill = opts.unindent_fill else: unindent_fill = configuration.get(self.name, 'unindent_fill', str, "") assert (isinstance(unindent_fill, str)) # Level fill if (opts.level_fill != None): level_fill = opts.level_fill else: level_fill = configuration.get(self.name, 'level_fill', str, " ") assert (isinstance(level_fill, str)) # Level fill if (opts.wrap_fill != None): wrap_fill = opts.wrap_fill else: wrap_fill = configuration.get(self.name, 'wrap_fill', str, "") assert (isinstance(wrap_fill, str)) # Filter text if (opts.filter != None): filter_text = opts.filter else: filter_text = configuration.get(self.name, 'filter', str, "not done") assert (isinstance(filter_text, str)) # Sort method if (opts.sort_criteria != None): sort_criteria = opts.sort_criteria.lower() else: sort_criteria = configuration.get(self.name, 'sort_criteria', str, "id") assert (isinstance(sort_criteria, str)) if (not sort_criteria in [ "id", "id-", "start", "start-", "end", "end-", "priority", "priority-" ]): raise Exceptions.WrongParameterValue("option sort value " + "`" + sort_criteria + "' " + "is unknown") # Use str() in order to avoid problems with None values debug("Configured values:") debug(" starting id = `" + str(starting_id) + "'") debug(" output = `" + str(filehandle.name) + "'") debug(" width = `" + str(width) + "'") debug(" line format = `" + str(line_format) + "'") debug(" indent fill = `" + str(indent_fill) + "'") debug(" unindent fill = `" + str(unindent_fill) + "'") debug(" level fill = `" + str(level_fill) + "'") debug(" wrap fill = `" + str(wrap_fill) + "'") debug(" filter text = `" + str(filter_text) + "'") debug(" show_collapsed = `" + str(show_collapsed) + "'") debug(" show_root = `" + str(show_root) + "'") debug(" sort criteria = `" + str(sort_criteria) + "'") # Build the filter filter_obj = Filter.Filter(filter_text) assert (filter_obj != None) # # Load database from file # db_file = configuration.get(PROGRAM_NAME, 'database', str) assert (db_file != None) db = DB.Database() tree = db.load(db_file) assert (tree != None) node = Tree.find(tree, node_id) if (node == None): raise Exceptions.NodeUnavailable(str(node_id)) # # Work # cmap = { Priority.PRIORITY_VERYHIGH: ANSI.bright_red, Priority.PRIORITY_HIGH: ANSI.bright_yellow, Priority.PRIORITY_MEDIUM: ANSI.bright_white, Priority.PRIORITY_LOW: ANSI.normal_cyan, Priority.PRIORITY_VERYLOW: ANSI.normal_blue } # mark() marks the filter-matching node children (1) and the nodes # up to the root (2) root = mark(node, filter_obj, show_root, show_collapsed) # mark() returns the root node so show() descends through the # tree processing all nodes having collapsed, or parent or # visible (the others are skipped) flags printing the ones # those are marked as "visible" show(root, node, colors, verbose, cmap, filehandle, width, line_format, indent_fill, unindent_fill, level_fill, wrap_fill, 0, sort_criteria) # Avoid closing precious filehandles if ((filehandle != sys.stdout) and (filehandle != sys.stderr)): debug("Closing file `" + filehandle.name + "'") filehandle.close() debug("Success")
print("Apple 1 Simulator") print("Ram Size : ", ramsize) print("Model : ", args.model) ram = Memory.RAM(decoder, 0, ramsize) rom = Memory.ROM(decoder, rombase, romsize) rom.load(open(rompath, "rb")) if args.load != None: f = open(args.load, "rb") for i in range(0, os.fstat(f.fileno()).st_size): t = f.read(1) if t == b'': t = 0 else: t = ord(t) ram[i + 0x280] = t terminal = Terminal.Terminal(processor) pia = PIA6821.PIA6821(decoder, terminal) termthread = threading.Thread(target=terminal.run) procthread = threading.Thread(target=processor.run) procthread.daemon = True termthread.start() procthread.start()
def __init__(self): QWidget.__init__(self) """ PROCESSING ATTRIBUTES """ self.loop_simulation = False self.parameters_window = None self.term = Terminal() self.stl_model = None self.stl_model_pressure = None self.stl_model_display = None self.object_mass = DEFAULT_OBJECT_MASS self.dichotomy_precision = DEFAULT_DICHOTOMY_PRECISION self.fluid_density = DEFAULT_FLUID_DENSITY self.show_draught = DEFAULT_SHOW_DRAUGHT self.setWindowTitle("G5 SIMULATION OBJECT FLOTABILITY") self.setFixedSize(1280, 1024) self.main_layout = QVBoxLayout() self.main_layout.setMargin(0) self.main_layout.setSpacing(0) self.setLayout(self.main_layout) """ TOPBAR WIDGETS """ self.topbar_layout = QGridLayout() self.topbar_layout.setAlignment(Qt.AlignTop) self.topbar_layout.setSpacing(32) buttons_icons = [ 'stl_file', 'parameters', 'prepare_simulation', 'start_simulation', 'loop_simulation', 'stop_simulation', 'generate_animation_gif' ] group_buttons_labels = ['LOAD 3D MODEL', 'PARAMETERS', 'SIMULATION'] buttons_slots = [ self.loadSTLModel, self.displayParametersWindow, self.prepareSimulation, self.startSimulation, self.loopSimulation, self.stopSimulation, self.generateAnimationsGIF ] buttons_tooltips = [ 'Load 3d model', 'Set parameters', 'Prepare the simulation', 'Start the simulation', 'Loop the simulation', 'Stop the simulation', 'Generate animations GIF' ] self.buttons = [QPushButton() for i in range(7)] for i, button in enumerate(self.buttons): button.setIcon(QIcon(ICONS_FOLDER + buttons_icons[i] + '_icon.png')) button.setIconSize(QSize(50, 50)) button.setStyleSheet('border:none; margin-top : 24px;') button.clicked.connect(buttons_slots[i]) button.setToolTip(buttons_tooltips[i]) if i > 0: button.setDisabled(True) self.topbar_layout.addWidget(button, 0, i, 1, 1) for i, group_buttons_label in enumerate(group_buttons_labels): label = QLabel(group_buttons_label) label.setFixedHeight(32) label.setAlignment(Qt.AlignCenter) label.setStyleSheet( 'border-top : 2px solid #dfdfdf; font-family: Calibri; font-size : 10pt; color: #2C3E50;' ) self.topbar_layout.addWidget(label, 1, i, 1, 1 if i != 2 else 5) self.main_layout.addLayout(self.topbar_layout) """ BODY_WIDGETS """ self.body_layout = QGridLayout() self.body_layout.setSpacing(0) self.stl_model_graph = QLabel() self.stl_model_graph.setPixmap(QPixmap(DEFAULT_STL_MODEL_GRAPH_FOLDER)) self.stl_model_graph.setFixedSize(640, 480) self.draught_graph = QLabel() self.draught_graph.setPixmap(QPixmap(DEFAULT_DRAUGHT_GRAPH_FOLDER)) self.draught_graph.setFixedSize(640, 480) self.body_layout.addWidget(self.stl_model_graph, 0, 0, 1, 1) self.body_layout.addWidget(self.draught_graph, 0, 1, 1, 1) self.colored_parts_legend = QLabel() self.colored_parts_legend.setPixmap( QPixmap(LEGEND_FOLDER + 'colored_parts_legend.png')) self.colored_parts_legend.setStyleSheet( 'padding : 0 0 13px 24px; background : #fff') self.body_layout.addWidget(self.colored_parts_legend, 1, 0, 1, 2) self.draught_legend = QLabel() self.draught_legend.setPixmap( QPixmap(LEGEND_FOLDER + 'draught_legend.png')) self.draught_legend.setStyleSheet( 'padding : 0 0 13px 24px; background : #fff') self.draught_legend.hide() self.body_layout.addWidget(self.draught_legend, 2, 0, 1, 2) self.term.setFixedWidth(1280) self.main_layout.addLayout(self.body_layout) self.main_layout.addWidget(self.term) self.show()