How to use print_error method in Molotov

Best Python code snippet using molotov_python

attack.py

Source:attack.py Github

copy

Full Screen

...49 report_headers["User-Agent"] = user_agent50 try:51 res = ses.get("https://www.facebook.com/", timeout=10)52 except:53 print_error("Bağlantı hatası oluştu! (FacebookRequestsError)")54 return55 if (res.status_code != 200):56 print_error("Bağlantı hatası oluştu! (STATUS CODE:", res.status_code, ")")57 return58 if ('["_js_datr","' not in res.text):59 print_error("Bağlantı hatası oluştu! (CookieErrorJSDatr)")60 return61 62 try:63 js_datr = res.text.split('["_js_datr","')[1].split('",')[0]64 except:65 print_error("Bağlantı hatası oluştu! (CookieParsingError)")66 return67 page_cookies = {68 "_js_datr": js_datr69 }70 try:71 res = ses.get("https://help.instagram.com/contact/497253480400030", cookies=page_cookies, headers=page_headers, timeout=10)72 except:73 print_error("Bağlantı hatası oluştu! (InstagramRequestsError)")74 return75 if (res.status_code != 200):76 print_error("Bağlantı hatası oluştu! (STATUS CODE:", res.status_code, ")")77 return78 79 if ("datr" not in res.cookies.get_dict()):80 print_error("Bağlantı hatası oluştu! (CookieErrorDatr)")81 return82 83 if ('["LSD",[],{"token":"' not in res.text):84 print_error("Bağlantı hatası oluştu! (CookieErrorLSD)")85 return86 if ('"__spin_r":' not in res.text):87 print_error("Bağlantı hatası oluştu! (CookieErrorSpinR)")88 return89 if ('"__spin_b":' not in res.text):90 print_error("Bağlantı hatası oluştu! (CookieErrorSpinB)")91 return92 if ('"__spin_t":' not in res.text):93 print_error("Bağlantı hatası oluştu! (CookieErrorSpinT)")94 return95 if ('"server_revision":' not in res.text):96 print_error("Bağlantı hatası oluştu! (CookieErrorRev)")97 return98 if ('"hsi":' not in res.text):99 print_error("Bağlantı hatası oluştu! (CookieErrorHsi)")100 return101 try:102 lsd = res.text.split('["LSD",[],{"token":"')[1].split('"},')[0]103 spin_r = res.text.split('"__spin_r":')[1].split(',')[0]104 spin_b = res.text.split('"__spin_b":')[1].split(',')[0].replace('"',"")105 spin_t = res.text.split('"__spin_t":')[1].split(',')[0]106 hsi = res.text.split('"hsi":')[1].split(',')[0].replace('"',"")107 rev = res.text.split('"server_revision":')[1].split(',')[0].replace('"',"")108 datr = res.cookies.get_dict()["datr"]109 except:110 print_error("Bağlantı hatası oluştu! (CookieParsingError)")111 return112 report_cookies = {113 "datr": datr114 }115 report_form = {116 "jazoest": "2723",117 "lsd": lsd,118 "instagram_username": username,119 "Field241164302734019_iso2_country_code": "TR",120 "Field241164302734019": "Türkiye",121 "support_form_id": "497253480400030",122 "support_form_hidden_fields": "{}",123 "support_form_fact_false_fields": "[]",124 "__user": "0",125 "__a": "1",126 "__dyn": "7xe6Fo4SQ1PyUhxOnFwn84a2i5U4e1Fx-ey8kxx0LxW0DUeUhw5cx60Vo1upE4W0OE2WxO0SobEa81Vrzo5-0jx0Fwww6DwtU6e",127 "__csr": "",128 "__req": "d",129 "__beoa": "0",130 "__pc": "PHASED:DEFAULT",131 "dpr": "1",132 "__rev": rev,133 "__s": "5gbxno:2obi73:56i3vc",134 "__hsi": hsi,135 "__comet_req": "0",136 "__spin_r": spin_r,137 "__spin_b": spin_b,138 "__spin_t": spin_t139 }140 try:141 res = ses.post(142 "https://help.instagram.com/ajax/help/contact/submit/page",143 data=report_form,144 headers=report_headers,145 cookies=report_cookies,146 timeout=10147 )148 except:149 print_error("Bağlantı hatası oluştu! (FormRequestsError)")150 return151 152 if (res.status_code != 200):153 print_error("Bağlantı hatası oluştu! (STATUS CODE:", res.status_code, ")")154 return155 156 print_success("Successfully reported!")157def report_video_attack(video_url, proxy):158 ses = Session()159 if (proxy != None):160 ses.proxies = {161 "https": "https://" + proxy,162 "http": "https://" + proxy163 }164 165 user_agent = get_user_agent()166 page_headers["User-Agent"] = user_agent167 report_headers["User-Agent"] = user_agent168 try:169 res = ses.get("https://www.facebook.com/", timeout=10)170 except Exception as e:171 print_error("Bağlantı hatası oluştu! (FacebookRequestsError)", e)172 return173 if (res.status_code != 200):174 print_error("Bağlantı hatası oluştu! (STATUS CODE:", res.status_code, ")")175 return176 if ('["_js_datr","' not in res.text):177 print_error("Bağlantı hatası oluştu! (CookieErrorJSDatr)")178 return179 180 try:181 js_datr = res.text.split('["_js_datr","')[1].split('",')[0]182 except:183 print_error("Bağlantı hatası oluştu! (CookieParsingError)")184 return185 page_cookies = {186 "_js_datr": js_datr187 }188 try:189 res = ses.get("https://help.instagram.com/contact/497253480400030", cookies=page_cookies, headers=page_headers, timeout=10)190 except:191 print_error("Bağlantı hatası oluştu! (InstagramRequestsError)")192 return193 if (res.status_code != 200):194 print_error("Bağlantı hatası oluştu! (STATUS CODE:", res.status_code, ")")195 return196 197 if ("datr" not in res.cookies.get_dict()):198 print_error("Bağlantı hatası oluştu! (CookieErrorDatr)")199 return200 201 if ('["LSD",[],{"token":"' not in res.text):202 print_error("Bağlantı hatası oluştu! (CookieErrorLSD)")203 return204 if ('"__spin_r":' not in res.text):205 print_error("Bağlantı hatası oluştu! (CookieErrorSpinR)")206 return207 if ('"__spin_b":' not in res.text):208 print_error("Bağlantı hatası oluştu! (CookieErrorSpinB)")209 return210 if ('"__spin_t":' not in res.text):211 print_error("Bağlantı hatası oluştu! (CookieErrorSpinT)")212 return213 if ('"server_revision":' not in res.text):214 print_error("Bağlantı hatası oluştu! (CookieErrorRev)")215 return216 if ('"hsi":' not in res.text):217 print_error("Bağlantı hatası oluştu! (CookieErrorHsi)")218 return219 try:220 lsd = res.text.split('["LSD",[],{"token":"')[1].split('"},')[0]221 spin_r = res.text.split('"__spin_r":')[1].split(',')[0]222 spin_b = res.text.split('"__spin_b":')[1].split(',')[0].replace('"',"")223 spin_t = res.text.split('"__spin_t":')[1].split(',')[0]224 hsi = res.text.split('"hsi":')[1].split(',')[0].replace('"',"")225 rev = res.text.split('"server_revision":')[1].split(',')[0].replace('"',"")226 datr = res.cookies.get_dict()["datr"]227 except:228 print_error("Bağlantı hatası oluştu! (CookieParsingError)")229 return230 report_cookies = {231 "datr": datr232 }233 report_form = {234 "jazoest": "2723",235 "lsd": lsd,236 "sneakyhidden": "",237 "Field419623844841592": video_url,238 "Field1476905342523314_iso2_country_code": "TR",239 "Field1476905342523314": "Türkiye",240 "support_form_id": "440963189380968",241 "support_form_hidden_fields": '{"423417021136459":false,"419623844841592":false,"754839691215928":false,"1476905342523314":false,"284770995012493":true,"237926093076239":false}',242 "support_form_fact_false_fields": "[]",243 "__user": "0",244 "__a": "1",245 "__dyn": "7xe6Fo4SQ1PyUhxOnFwn84a2i5U4e1Fx-ey8kxx0LxW0DUeUhw5cx60Vo1upE4W0OE2WxO0SobEa81Vrzo5-0jx0Fwww6DwtU6e",246 "__csr": "",247 "__req": "d",248 "__beoa": "0",249 "__pc": "PHASED:DEFAULT",250 "dpr": "1",251 "__rev": rev,252 "__s": "5gbxno:2obi73:56i3vc",253 "__hsi": hsi,254 "__comet_req": "0",255 "__spin_r": spin_r,256 "__spin_b": spin_b,257 "__spin_t": spin_t258 }259 try:260 res = ses.post(261 "https://help.instagram.com/ajax/help/contact/submit/page",262 data=report_form,263 headers=report_headers,264 cookies=report_cookies,265 timeout=10266 )267 except:268 print_error("Bağlantı hatası oluştu! (FormRequestsError)")269 return270 271 if (res.status_code != 200):272 print_error("Bağlantı hatası oluştu! (STATUS CODE:", res.status_code, ")")273 return274 ...

Full Screen

Full Screen

cli.py

Source:cli.py Github

copy

Full Screen

...17 formatter-internal errors as well as any problems encountered during18 parsing. Encountered problems are written to stderr.19 """20 if args.recursive and not args.inplace:21 print_error('error: recursive file processing requires --inplace')22 return 123 if not args.scripts:24 args.scripts = ['-']25 scripts = [] # Final list of Zeek scripts to format.26 for fname in args.scripts:27 if fname == '-':28 if args.inplace:29 print_error('warning: cannot use --inplace when reading from '30 'stdin, skipping it')31 else:32 scripts.append(fname)33 elif os.path.isdir(fname):34 if args.recursive: # implies --inplace35 for dirpath, _, filenames in os.walk(fname):36 filenames = [n for n in filenames if n.endswith('.zeek')]37 filenames = [os.path.join(dirpath, n) for n in filenames]38 scripts.extend(filenames)39 else:40 print_error('warning: "{}" is a directory but --recursive not '41 'set, skipping it'.format(fname))42 elif os.path.isfile(fname):43 scripts.append(fname)44 else:45 print_error('warning: skipping "{}"; not a supported file type')46 def do_write(source):47 with open(ofname, 'wb') if ofname else sys.stdout.buffer as ostream:48 ostream.write(source)49 if len(scripts) > 1 and not args.inplace:50 print_error('error: processing multiple files requires --inplace')51 return 152 errs = 053 for fname in scripts:54 script = Script(fname)55 ofname = fname if args.inplace else None56 try:57 if not script.parse():58 errs += 159 _, _, msg = script.get_error()60 if len(scripts) > 1:61 print_error('{}: {}'.format(fname, msg))62 else:63 print_error(msg)64 except Error as err:65 print_error('parsing error: ' + str(err))66 do_write(script.source)67 return 168 except Exception as err:69 print_error('internal error: ' + str(err))70 traceback.print_exc(file=sys.stderr)71 do_write(script.source)72 return 173 buf = io.BytesIO()74 try:75 script.format(buf, not args.no_linebreaks)76 except Exception as err:77 print_error('internal error: ' + str(err))78 traceback.print_exc(file=sys.stderr)79 do_write(script.source)80 return 181 # Write out the complete, reformatted source.82 do_write(buf.getvalue())83 if args.inplace:84 print('{} file{} processed, {} error{}'.format(85 len(scripts), '' if len(scripts) == 1 else 's',86 errs, '' if errs == 1 else 's'))87 return int(errs > 0)88def cmd_parse(args):89 """This function implements Zeek-script parsing for the commandline.90 It takes a single input file provided via the command line, parses it, and91 prints the parse tree to stdout according to the provided flags.92 Returns 0 when successful, 1 when a hard parse error came up that prevented93 building a parse tree, and 2 when the resulting parse tree has erroneous94 nodes.95 """96 script = Script(args.script or '-')97 try:98 script.parse()99 except ParserError as err:100 print_error('parsing error: ' + str(err))101 return 1102 except Error as err:103 print_error('error: ' + str(err))104 return 1105 script.write_tree(include_cst=args.concrete)106 if script.has_error():107 _, _, msg = script.get_error()108 print_error('parse tree has problems: %s' % msg)109 return 2110 return 0111def add_version_arg(parser):112 parser.add_argument(113 '--version', '-v', action='store_true', help='show version and exit')114def add_format_cmd(parser):115 """This adds a Zeek script formatting CLI interface to the given argparse116 parser. It registers the cmd_format() callback as the parser's run_cmd117 default."""118 parser.set_defaults(run_cmd=cmd_format)119 parser.add_argument(120 '--inplace', '-i', action='store_true',121 help='change provided files instead of writing to stdout')122 parser.add_argument(...

Full Screen

Full Screen

story_validator.py

Source:story_validator.py Github

copy

Full Screen

...16 print(colored(f'Usage: \tpython3 {argv[0]} <path to story_data directory>', colors.RED))17 exit(1)18def print_info(msg):19 print(msg)20def print_error(msg):21 print(colored(msg, colors.RED))22def exit_error(msg):23 print_error(msg)24 print_error('Exiting.')25 exit(1)26if __name__ == '__main__':27 if len(argv) != 2 or not os.path.isdir(argv[1]):28 exit_usage()29 result = results.PASS30 file_filter = lambda f: os.path.isfile(f'{argv[1]}/{f}') and f[-3:] == '.md'31 waf_filter = lambda f: f[0:4] == 'waf-'32 strip_md_mapper = lambda f: f[0:-3]33 md_files = list(map(strip_md_mapper, filter(file_filter, os.listdir(argv[1]))))34 if list(filter(waf_filter, md_files)):35 exit_error('ERR: You must delete waf-*.md files – write your own story! :)')36 print_info(f'Found {len(md_files)} .md files in {argv[1]}.')37 edges_dict = {}38 stories = {}39 for md_filename in md_files:40 with open(f'{argv[1]}/{md_filename}.md', 'r') as file:41 lines = file.readlines()42 i = 043 while i < len(lines) and lines[i][0:2] != '# ':44 if lines[i][0] == '#':45 print_error(f'WARN: A line in {md_filename}.md begins with a # that is not followed by a space. This is probably an error.')46 result = min(result, results.WARN)47 i += 148 if i == 0:49 exit_error(f'ERR: Empty file: {md_filename}')50 story_lines = filter(lambda l: len(l) > 0, map(lambda l: l.lstrip().rstrip(), lines[0:i]))51 story = '\n'.join(story_lines)52 edges = []53 while i < len(lines):54 dest = lines[i][2:].rstrip()55 j = i+156 while j < len(lines) and lines[j][0:2] != '# ':57 if lines[j][0] == '#':58 print_error(f'WARN: A line in {md_filename}.md begins with a # that is not followed by a space. This is probably an error.')59 result = min(result, results.WARN)60 j += 161 label_lines = filter(lambda l: len(l) > 0, map(lambda l: l.lstrip().rstrip(), lines[i+1:j]))62 label = '\n'.join(label_lines)63 edges.append((dest, label))64 i = j65 edges_dict[md_filename] = edges66 stories[md_filename] = story67 incoming_edges = defaultdict(list)68 has_end_node = False69 has_3_edge_node = False70 for md_filename, edges in edges_dict.items():71 for dest, _ in edges:72 incoming_edges[dest].append(md_filename)73 if dest not in edges_dict:74 exit_error(f'ERR: File {md_filename} has edge referring to non-existent file {dest}.md')75 if len(edges) == 0:76 has_end_node = True77 elif len(edges) >= 3:78 has_3_edge_node = True79 if len(edges) > 10:80 exit_error(f'ERR: File {md_filename} has more than 10 choices (outgoing edges)! Has: {len(edges)} choices')81 print('\nYour graph was parsed as follows:\n')82 for node, edges in edges_dict.items():83 print(colored(node, colors.BLUE))84 print(stories[node])85 for edge, story in edges:86 print(colored(f'\t==> {edge}', colors.BLUE) + f': {story}')87 print()88 if not has_end_node:89 print_error('ERR: At least one narrative must be the ending of the story (an ending vertex will have no outbound edges).')90 result = min(result, results.ERR)91 if not has_3_edge_node:92 print_error('ERR: At least one narrative must have at least 3 choices.')93 result = min(result, results.ERR)94 num_start_nodes = 095 start_nodes = []96 for node in edges_dict.keys():97 if len(incoming_edges[node]) == 0:98 num_start_nodes += 199 start_nodes.append(node)100 if num_start_nodes == 0:101 print_error('ERR: Exactly one narrative must be the beginning of the story (one vertex must have no incoming edges). No beginning node found.')102 result = min(result, results.ERR)103 elif num_start_nodes > 1:104 print_error(f'ERR: Exactly one narrative must be the beginning of the story (one vertex must have no incoming edges). {num_start_nodes} beginning nodes found.')105 print_error(f'This is the list of all starting nodes found: {start_nodes}')106 result = min(result, results.ERR)107 num_total_nodes = len(edges_dict)108 if num_total_nodes < 8:109 print_error(f'ERR: Your interactive story must have at least 8 narratives. Actual number of narratives: {num_total_nodes}')110 result = min(result, results.ERR)111 num_total_edges = sum(map(len, edges_dict.values()))112 if num_total_edges < 13:113 print_error(f'ERR: Your interactive story must have at least 13 choices. Actual number of choices: {num_total_edges}')114 result = min(result, results.ERR)115 if result == results.PASS:116 print_info(colored('Validation completed with no errors or warnings.', colors.GREEN))117 elif result == results.WARN:118 print_error('Validation completed with warnings.')119 elif result == results.ERR:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Molotov automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful