Skip to content

Fix Bing fallback in -g returning no links - #6150

Merged
stamparm merged 1 commit into
sqlmapproject:masterfrom
raju4199:fix-bing-search
Oct 21, 2026
Merged

stamparm merged 1 commit into
sqlmapproject:masterfrom
raju4199:fix-bing-search

Conversation

@raju4199

Copy link
Copy Markdown
Contributor

Related to #6009.

While looking into #6009 I tried each engine in lib/utils/search.py on its own. DuckDuckGo works, Google only serves the JS page now, and Bing returns a normal results page but sqlmap pulls 0 links out of it.

The Bing markup has changed in two ways:

  1. The anchor is now <h2 ...><a target="_blank" href="...">, so the old <h2><a href="..." h= pattern doesn't match anymore.
  2. The href isn't the result URL. It's a https://www.bing.com/ck/a?...&u=a1<base64url> redirect, and the real link is the base64url part after a1.

BING_REGEX now allows extra attributes and captures either the u payload of a ck/a link or a plain href. The payload goes through the existing decodeBase64(), which already handles the URL-safe alphabet and the missing padding. Plain hrefs work the same as before (with &amp; unescaped), in case some clients still get the old markup.

Testing:

  • saved live Bing results page: 0 -> 10 links
  • old-style markup still parses
  • python sqlmap.py --smoke-test passes

This doesn't fully fix #6009, since Google can't be scraped without JS, but it gives -g a working fallback again when DuckDuckGo starts throwing its anomaly page (which happened to me after a few requests while testing).

One side note: DDG's html endpoint seems to return 10 results per page now (its next-page form posts s=10), while we use (gpage - 1) * 30 for the offset. I couldn't verify that properly because DDG blocked me mid-testing, so I've left it out of this PR.

While looking into sqlmapproject#6009 I noticed the Bing fallback in -g never
returns anything, even when Bing itself serves a normal results page.

Two things changed on Bing's side. The result anchor now carries
target="_blank" before href, so '<h2><a href="..." h=' no longer
matches at all. And the href is no longer the target URL but a
tracking redirect (https://www.bing.com/ck/a?...&u=a1<base64url>),
where the real link sits base64url-encoded after the "a1" prefix
in the u parameter.

The regex now allows extra attributes on both tags and captures
either the u payload of a ck/a redirect or a plain href. The payload
is decoded with decodeBase64(), which already deals with the
URL-safe alphabet and the missing padding. Plain hrefs still work
the same as before (with &amp; unescaped), in case Bing serves the
old markup to some clients.

Checked against a saved live results page (0 -> 10 links) and the
old markup, and --smoke-test passes. Google still can't be scraped
since it only serves a JS page now, so this doesn't fully close
sqlmapproject#6009, but Bing is usable again as a fallback when DuckDuckGo blocks
the IP.
@stamparm
stamparm merged commit 5e2a6ae into sqlmapproject:master Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-g returns no results

2 participants