def repl(argv): run = True table = eval.SymbolTable() if len(argv) == 2: try: source = open(argv[1], 'r').read() tokenizer = Tokenizer(source) tokens = tokenizer.lex() ast = Parser(tokens).parse() if DEBUG: tokenizer.print_tokens() print(str(ast) + '\n') evaluator = eval.Evaluator(ast, table, False) evaluator.evaluate() except FileNotFoundError: repl_error(f"Can not find file: \"{argv[1]}\"") else: print("Tevas Language Shell") line = 1 while run: try: eval.Evaluator( Parser( Tokenizer(input(">> ").replace('\n', ''), line).lex()).parse(), table, True).evaluate() except KeyboardInterrupt: repl_error() line += 1
def main(): statistics = Statistics() parser = Parser(statistics, debug) parser.parse() statistics.generate_statistics() statistics.output_statistics()
def compile_file(file_to_compile): with open(file_to_compile) as f: try: lexer = Lexer(''.join(f.readlines()), file_to_compile) lexer.lex_all() parser = Parser(lexer.tokens) ast_root = parser.parse() ast_root.resolve_includes() error_counter.reset() ast_root.resolve_names(Scope(None)) ast_root.resolve_types() ast_root.check_for_entry_point() is_parsing_successful = error_counter.counter == 0 if not is_parsing_successful: printer.error('', f'{error_counter.counter} errors found', header_len=80) return else: printer.success('', f'Compilation successful', header_len=80) code_writer = CodeWriter() ast_root.write_code(code_writer) with FileOutput('instructions.f12b') as output: code_writer.print_instructions(output) with FileOutput('output.f12b') as output: code_writer.dump_code(output) del ast_root vm = VM(code_writer.code) vm.exec() except ValueError as e: print(e) pass
def run(self, id, url): self.id = id self.url = url print("") Log.init_log_id(id) Log.Info(f"[*] Start: {url}") try: self.parser = Parser(self.url) if not self.parser.run(): return self.error_length = self.get_error_length() username_dict, password_dict = gen_dict(url) username, password = self.crack_task(username_dict, password_dict) # 万能密码爆破 if not username and not password: if self.parser.cms: sqlin_dict_enable = self.parser.cms["sqlin_able"] else: sqlin_dict_enable = generatorConfig["dict_config"][ "sqlin_dict"]["enable"] if sqlin_dict_enable: Log.Info(f"[*] {url} 启动万能密码爆破模块") sqlin_user_dict, sqlin_pass_dict = gen_sqlin_dict() username, password = self.crack_task( sqlin_user_dict, sqlin_pass_dict) if username and password: Log.Info(f"[*] Rechecking... {url} {username} {password}") recheck_flag = self.recheck(username, password) if recheck_flag: Log.Success(f"[+] Success: {url} {username}/{password}") return else: Log.Info( f"[-] Recheck failed: {url} {username}/{password}") Log.Error("[-] Failed: " + url) except Exception as e: Log.Error(f"{str(e)}")