
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.5">Jekyll</generator><link href="https://vorabrijesh.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://vorabrijesh.github.io/" rel="alternate" type="text/html" /><updated>2026-02-28T18:17:58-08:00</updated><id>https://vorabrijesh.github.io/feed.xml</id><title type="html">Brijesh Vora</title><subtitle>personal description</subtitle><author><name>Brijesh Vora</name></author><entry><title type="html">Getting started with Shodan API</title><link href="https://vorabrijesh.github.io/posts/2022/09/06/shodan-api-getting-started/" rel="alternate" type="text/html" title="Getting started with Shodan API" /><published>2022-09-06T00:00:00-07:00</published><updated>2022-09-06T00:00:00-07:00</updated><id>https://vorabrijesh.github.io/posts/2022/09/06/shodan-api-getting-started</id><content type="html" xml:base="https://vorabrijesh.github.io/posts/2022/09/06/shodan-api-getting-started/"><![CDATA[<p><img src="/images/shodan-header.webp" alt="Shodan Search Engine Header" /></p>

<p>Welcome to Shodan. Shodan is the Search Engine for the Internet of Everything. Learning and using Shodan can be quite scary at first but as you get used to it, you will discover that it has a lot to offer.</p>

<p>From scanning vulnerabilities of an IP, to finding the geographical location, VPN, ASN, country information, etc., all can be requested using the API call. In this post, I’ll show you how you can use the Shodan API to find relevant information about an IP address. We are using the Shodan API at Ennetix, Inc to find out open ports, vulnerabilities, and other info.</p>

<p>After making an account with Shodan, grab the API key unique to your account and paste it in the code below (<code class="language-plaintext highlighter-rouge">shodan.py</code>). This script queries Shodan using your API key and dumps the results into a JSON file.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">shodan</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="n">api</span> <span class="o">=</span> <span class="n">shodan</span><span class="p">.</span><span class="n">Shodan</span><span class="p">(</span><span class="n">your_api_key</span><span class="p">)</span>  <span class="c1"># private api key
</span><span class="k">def</span> <span class="nf">shodan_fun</span><span class="p">(</span><span class="n">IP</span><span class="p">):</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">ipinfo</span> <span class="o">=</span> <span class="n">api</span><span class="p">.</span><span class="n">host</span><span class="p">(</span><span class="n">IP</span><span class="p">)</span>
    <span class="k">except</span> <span class="n">shodan</span><span class="p">.</span><span class="n">APIError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>  <span class="c1"># this line is resolved
</span>        <span class="n">ipinfo</span> <span class="o">=</span> <span class="p">{}</span>
    <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s">"shodan_results.json"</span><span class="p">,</span> <span class="s">'w'</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
        <span class="n">json</span><span class="p">.</span><span class="n">dump</span><span class="p">(</span><span class="n">ipinfo</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">ipinfo</span>
<span class="n">shodan_fun</span><span class="p">(</span><span class="n">sys</span><span class="p">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
</code></pre></div></div>

<p>Now you can run the below command to get the info of an IP. Instead of <code class="language-plaintext highlighter-rouge">IP</code>, type the IP address you want to query (e.g., 8.8.8.8):</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>python3 shodan.py IP
</code></pre></div></div>

<h2 id="example-output">Example Output</h2>

<p>Here are examples of the JSON output you might get from the Shodan API:</p>

<p>Let’s analyse the output:</p>

<p><img src="/images/shodan-1.webp" alt="Example Shodan Output" />
<img src="/images/shodan-2.webp" alt="Another Example Shodan Output" /></p>

<p>From the above JSON output, one can see the tags, country_code, hostnames, domains, location, port, and even product info — OpenSSH in this case.</p>

<p><img src="/images/shodan-3.webp" alt="Example Vulnerabilities List" /></p>

<p>The <code class="language-plaintext highlighter-rouge">vulns</code> field shows the vulnerabilities from that IP address. So, the attacker might have leveraged this information to access this server and launch an attack on a different machine using this machine. Shodan also shows open ports for that IP. This information can be leveraged in many ways, one of them being to launch a DDoS attack.</p>

<p>Shodan can show the top 10 or top 100 vulnerabilities across the internet, and if that vulnerability is present in your organization IP then it should be resolved quickly before any attack happens.</p>

<p>Shodan can do much more than the data shown here. This is just the tip of the iceberg. It can show Shodan Trends — historical trends, Shodan Monitor — monitor the network for incoming and outgoing requests. It has a database of blacklisted IP addresses which you can download locally with Enterprise access.</p>

<p>For more information and tutorials, visit <a href="https://www.shodan.io/">https://www.shodan.io/</a>.</p>

<hr />

<p><em>This blog post was originally published on <a href="https://medium.com/@brijesh.vora12/getting-started-with-shodan-api-35196da3c774">Medium</a>.</em></p>

<p>PS:
Brijesh Vora is a grad student at University of California, Davis and was a software engineering intern at Ennetix, a leading provider of AI-powered analytics solutions for deterministic digital operations. This blog post was developed as a part of Ennetix, Inc.</p>]]></content><author><name>Brijesh Vora</name></author><category term="network-security" /><category term="shodan" /><category term="api" /><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Zeek 101: Getting Started with Network Security Monitoring</title><link href="https://vorabrijesh.github.io/posts/2022/07/21/zeek-101/" rel="alternate" type="text/html" title="Zeek 101: Getting Started with Network Security Monitoring" /><published>2022-07-21T00:00:00-07:00</published><updated>2022-07-21T00:00:00-07:00</updated><id>https://vorabrijesh.github.io/posts/2022/07/21/zeek-101</id><content type="html" xml:base="https://vorabrijesh.github.io/posts/2022/07/21/zeek-101/"><![CDATA[<p>Welcome to the world of Zeek! This guide is for folks who want to learn about Zeek or implement it into their system. I’ll walk you through installation, basic setup, and running your first Zeek script.</p>

<h2 id="installing-zeek-from-source-in-ubuntu">Installing Zeek from Source in Ubuntu</h2>

<p>For other Linux variants, check the <a href="https://docs.zeek.org/en/master/install.html">official documentation</a>.</p>

<p>First, install the dependencies:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>apt-get <span class="nb">install </span>cmake make gcc g++ flex bison libpcap-dev libssl-dev python3 python3-dev swig zlib1g-dev
</code></pre></div></div>

<p>Clone the Repository:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone <span class="nt">--recursive</span> https://github.com/zeek/zeek
</code></pre></div></div>

<p>Build from Source:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./configure
make
make <span class="nb">install</span>
</code></pre></div></div>

<p>By default, the installation is in <code class="language-plaintext highlighter-rouge">/usr/local/zeek/</code> which requires root privileges during <code class="language-plaintext highlighter-rouge">make install</code>. You can use the <code class="language-plaintext highlighter-rouge">--prefix</code> option to install in other directories. For example, to install in the <code class="language-plaintext highlighter-rouge">.local</code> folder in your home directory:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./configure <span class="nt">--prefix</span><span class="o">=</span>/home/yourusername/.local
</code></pre></div></div>

<p>The configuration and installation process might take a while. If you can run <code class="language-plaintext highlighter-rouge">zeek --help</code>, then you’ve installed it successfully.</p>

<h2 id="installing-via-pre-built-binary-source-packages">Installing via Pre-built Binary Source Packages</h2>

<p>You can download packages from the <a href="https://software.opensuse.org/download.html?project=security%3Azeek&amp;package=zeek">official repository</a> according to your OS. For Ubuntu 22.04:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">echo</span> <span class="s1">'deb http://download.opensuse.org/repositories/security:/zeek/xUbuntu_22.04/ /'</span> | <span class="nb">sudo tee</span> /etc/apt/sources.list.d/security:zeek.list
curl <span class="nt">-fsSL</span> https://download.opensuse.org/repositories/security:zeek/xUbuntu_22.04/Release.key | gpg <span class="nt">--dearmor</span> | <span class="nb">sudo tee</span> /etc/apt/trusted.gpg.d/security_zeek.gpg <span class="o">&gt;</span> /dev/null
<span class="nb">sudo </span>apt update
<span class="nb">sudo </span>apt <span class="nb">install </span>zeek
</code></pre></div></div>

<h2 id="configuring-the-runtime-environment">Configuring the Runtime Environment</h2>

<p>Export the installation path:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">export </span><span class="nv">PATH</span><span class="o">=</span>/usr/local/zeek/bin:<span class="nv">$PATH</span>
</code></pre></div></div>

<h2 id="running-your-first-script">Running Your First Script</h2>

<p>Create your first Zeek script with this simple “Hello World” example:</p>

<pre><code class="language-zeek">event zeek_init() {
    print "Hello, World!";
}

event zeek_done() {
    print "Goodbye, World!";
}
</code></pre>

<p>Save this as <code class="language-plaintext highlighter-rouge">hello.zeek</code> and run it:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>zeek hello.zeek
</code></pre></div></div>

<h2 id="capturing-and-analyzing-network-traffic">Capturing and Analyzing Network Traffic</h2>

<p>Let’s capture some packets and analyze them with Zeek. First, capture some traffic:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>tcpdump <span class="nt">-s</span> 0 <span class="nt">-w</span> get.trace
</code></pre></div></div>

<p>Run this for about 5 minutes, then press Ctrl+C to stop.</p>

<p>Now create a script to record log files (save as <code class="language-plaintext highlighter-rouge">main.zeek</code>):</p>

<pre><code class="language-zeek">event zeek_init() {
    Log::create_stream(Conn::LOG, [$columns=Conn::Info, $path="Conn"]);
    local filter: Log::Filter = [$name="conn", $path="conn"];
    Log::add_filter(Conn::LOG, filter);
    Log::remove_filter(Conn::LOG, "default");
}
</code></pre>

<p>Analyze the captured traffic:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>zeek <span class="nt">-C</span> <span class="nt">-r</span> get.trace main.zeek
</code></pre></div></div>

<p>This will generate several log files including <code class="language-plaintext highlighter-rouge">conn.log</code>, <code class="language-plaintext highlighter-rouge">dns.log</code>, <code class="language-plaintext highlighter-rouge">reporter.log</code>, <code class="language-plaintext highlighter-rouge">ssl.log</code>, and <code class="language-plaintext highlighter-rouge">weird.log</code>. These logs can be inspected for suspicious activity and further analysis.</p>

<h2 id="next-steps">Next Steps</h2>

<p>To learn more about the Zeek scripting language, check out the <a href="https://try.zeek.org/">official tutorial</a>.</p>

<p>Happy Zeeking!</p>

<hr />
<p><em>This post was originally published on <a href="https://medium.com/@brijesh.vora12/zeek-101-473306869a81">Medium</a> and has been adapted for this blog.</em></p>]]></content><author><name>Brijesh Vora</name></author><category term="zeek" /><category term="network security monitoring" /><category term="forensics" /><summary type="html"><![CDATA[Welcome to the world of Zeek! This guide is for folks who want to learn about Zeek or implement it into their system. I’ll walk you through installation, basic setup, and running your first Zeek script.]]></summary></entry></feed>