<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: gevar</title>
    <description>The latest articles on DEV Community by gevar (@gevarru).</description>
    <link>https://dev.to/gevarru</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4236423%2F14eeb5ad-2519-4bb9-87a6-6a5556692771.png</url>
      <title>DEV Community: gevar</title>
      <link>https://dev.to/gevarru</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gevarru"/>
    <language>en</language>
    <item>
      <title>I built a non-destructive attack surface scanner in Python — here's what real targets taught me</title>
      <dc:creator>gevar</dc:creator>
      <pubDate>Tue, 10 Nov 2026 06:50:23 +0000</pubDate>
      <link>https://dev.to/gevarru/i-built-a-non-destructive-attack-surface-scanner-in-python-heres-what-real-targets-taught-me-4l5l</link>
      <guid>https://dev.to/gevarru/i-built-a-non-destructive-attack-surface-scanner-in-python-heres-what-real-targets-taught-me-4l5l</guid>
      <description>&lt;h1&gt;
  
  
  I built a non-destructive attack surface scanner in Python — here's what real targets taught me
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;AttackSurfaceX (ASX)&lt;/strong&gt; is an open-source, CLI-first attack surface scanner with one hard design rule: &lt;em&gt;it must never be able to hurt the target&lt;/em&gt;. No exploits, no fuzzing payloads, no write operations — detection only, behind a strict scope gate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pipx install git+https://github.com/gevarru/AttackSurfaceX.git
asx scan -t https://example.com -p safe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/docs%2Fasx_demo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/docs%2Fasx_demo.gif" alt="demo" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why "non-destructive" is the whole point
&lt;/h2&gt;

&lt;p&gt;Most recon tools assume you trust yourself. ASX assumes you'll run it against production systems at 2 AM. That drove three architectural decisions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Scope enforcement before anything else.&lt;/strong&gt; Nothing is scanned unless it's declared in &lt;code&gt;scope.yaml&lt;/code&gt;. Wide scans require an explicit flag. The scanner refuses to even resolve a host outside the declared scope.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. A plugin safety gate.&lt;/strong&gt; Plugins are third-party Python, so the loader statically inspects imports — a plugin that touches &lt;code&gt;os&lt;/code&gt;, &lt;code&gt;subprocess&lt;/code&gt;, or raw &lt;code&gt;socket&lt;/code&gt; is refused before it ever runs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. GET/HEAD only.&lt;/strong&gt; The HTTP layer physically cannot send state-changing requests. Rate-limited, self-identifying User-Agent, fixed timeouts.&lt;/p&gt;

&lt;p&gt;Modules: asyncio TCP port scan with banner grabbing, a TLS audit (cert chain, deprecated protocol detection — read-only handshakes), web checks (security headers, cookie flags, CORS, version disclosure, exposed sensitive paths, inert reflected-XSS canaries), a YAML rules engine, and reporters for &lt;strong&gt;JSON / Markdown / interactive HTML / SARIF&lt;/strong&gt; (GitHub Code Scanning). MIT licensed, Python 3.11+.&lt;/p&gt;

&lt;h2&gt;
  
  
  What real targets actually taught me
&lt;/h2&gt;

&lt;p&gt;I want this part to be honest, because most "I built a scanner" posts only show the happy path. Here's what happened when ASX met real, hardened perimeters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson 1: Geo-blocking is indistinguishable from TLS failure — and your scanner will lie about it.&lt;/strong&gt;&lt;br&gt;
The first real run was against a major fintech. Every port "closed", TLS handshake "failed", HTTP "unreachable". It looked like a finding (CWE-326, medium). In reality, the target silently drops connections from certain countries at the CDN edge. The packets never arrived. The scanner wasn't measuring the target's security — it was measuring my network position.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fix in progress:&lt;/em&gt; a dedicated &lt;code&gt;target-unreachable/filtered&lt;/code&gt; finding type, triggered when TCP fails across the entire port set and TLS never completes. If your scanner can't tell "firewalled" from "broken crypto", it will file false reports — and in a bug bounty context, false reports are reputation damage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson 2: Modern SPAs return HTTP 200 for everything.&lt;/strong&gt;&lt;br&gt;
Exposed-path scanning (&lt;code&gt;/.git/HEAD&lt;/code&gt;, &lt;code&gt;/.env&lt;/code&gt;, &lt;code&gt;/swagger.json&lt;/code&gt;) hits a wall: single-page apps serve the index HTML with a 200 for &lt;em&gt;any&lt;/em&gt; path. Naive checking produced dozens of "exposed .git" hits that were all the same 12 KB of HTML. The discriminator is &lt;strong&gt;content variance&lt;/strong&gt; — real endpoints differ in size and type from the catch-all shell. The same host that shows 200 for &lt;code&gt;/backup.zip&lt;/code&gt; will 401 or 404 for the real thing once you follow the variance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lesson 3: Failed handshakes leak sockets — the edge that filters you also exhausts you.&lt;/strong&gt;&lt;br&gt;
Same geo-block scenario, second bug — and this one was in &lt;em&gt;my&lt;/em&gt; code, not theirs. The TLS probe used to look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;socket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create_connection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ssock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;wrap_socket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;server_hostname&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When &lt;code&gt;wrap_socket&lt;/code&gt; fails mid-handshake — precisely what a silently-filtering edge does — the exception path returned early and the raw socket was never closed. One leaked fd per failed probe: harmless in a five-target scan, a slow exhaustion in a wide recon run. The fix is ownership discipline: clear the raw reference once the TLS socket takes over, and close it in &lt;code&gt;finally&lt;/code&gt; if it never did. (Found by reading the code paths the geo-block run exercised; fixed in commit &lt;code&gt;d8ccc5f&lt;/code&gt;.)&lt;/p&gt;

&lt;h2&gt;
  
  
  The verdict after the first recon runs
&lt;/h2&gt;

&lt;p&gt;Against top-tier perimeters (large fintech, food delivery platform), ASX found &lt;strong&gt;zero reportable vulnerabilities from the outside&lt;/strong&gt;. That is the correct result — mature programs are externally clean. The scanner's value isn't finding magic bugs in port 443; it's mapping the surface cheaply and &lt;em&gt;safely&lt;/em&gt; so human effort can go where bugs actually live: authenticated application logic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Roadmap
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;CSRF &amp;amp; form-analysis module&lt;/li&gt;
&lt;li&gt;Session/authenticated scanning helpers&lt;/li&gt;
&lt;li&gt;SBOM / supply-chain scanning (OSV integration)&lt;/li&gt;
&lt;li&gt;Resume support for long scans&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;target-unreachable&lt;/code&gt; classification (Lesson 1)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/gevarru/AttackSurfaceX.git
&lt;span class="nb"&gt;cd&lt;/span&gt; AttackSurfaceX
pip install -e .
python -m asx.cli scan -t https://your-own-domain.com -p safe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only scan what you own or are authorized to test. ASX detects indicators — it never exploits them.&lt;/p&gt;

&lt;p&gt;⭐ &lt;a href="https://github.com/gevarru/AttackSurfaceX" rel="noopener noreferrer"&gt;github.com/gevarru/AttackSurfaceX&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
