#!/usr/bin/env python3 """Dorking pipeline: search_zombies() reaches each engine branch without raising. We monkey-patch _engine_fetch (HTTP-fetched engines) and the DDGS class (duck) to return synthetic markup, then call search_zombies() with engine= and verify it parses at least one href without exceptions. This validates the regex / decoder paths for all 7 engines without touching the network. """ import sys, os, types sys.path.insert(0, os.path.abspath('test')) from core.main import UFONet err = [] ENGINES_HTTP = { "bing": 'Example', "brave": 'Example', "mojeek": 'Example', "yahoo": 'Example', "startpage": 'Example', "ecosia": 'Example', } DUCK_RESULTS = [ {"href": "https://example.com/proxy.php?url=foo", "title": "ex", "body": "x"}, {"href": "https://example.org/proxy.php?url=bar", "title": "ex2", "body": "x"}, ] class _FakeDDGS: def text(self, q, **kw): return iter(DUCK_RESULTS) def make_ufo(): ufo = UFONet() ufo.create_options(['--sd', 'botnet/dorks.txt']) ufo.options.verbose = False ufo.options.num_results = 5 ufo.user_agent = "Mozilla/5.0 test" ufo.referer = "https://example.com" ufo.agents = [ufo.user_agent] ufo.options.proxy = None ufo.options.forceyes = True return ufo for engine, body in ENGINES_HTTP.items(): try: ufo = make_ufo() ufo.options.engine = engine ufo._engine_fetch = lambda url, headers, timeout=10, _body=body: _body result = ufo.search_zombies('proxy.php?url=', []) print("[OK] " + engine + " -> parsed (returned object: " + str(type(result).__name__) + ")") except Exception as e: err.append(engine + ": " + type(e).__name__ + ": " + str(e)[:200]) try: ufo = make_ufo() ufo.options.engine = "duck" import sys as _s _fake_mod = types.ModuleType("ddgs") _fake_mod.DDGS = _FakeDDGS _s.modules["ddgs"] = _fake_mod _fake_dds = types.ModuleType("duckduckgo_search") _fake_dds.DDGS = _FakeDDGS _s.modules["duckduckgo_search"] = _fake_dds result = ufo.search_zombies('proxy.php?url=', []) print("[OK] duck -> parsed (" + str(type(result).__name__) + ")") except Exception as e: err.append("duck: " + type(e).__name__ + ": " + str(e)[:200]) for e in err: print("FAIL:", e) print() print(str(7 - len(err)) + "/7 engine code paths OK") sys.exit(0 if not err else 1)