NikolaiT / zardaxt

Passive TCP/IP Fingerprinting Tool. Run this on your server and find out what Operating Systems your clients are *really* using.
Other
292 stars 33 forks source link

Passive TCP/IP Fingerprinting 🚀

Zardaxt.py is a passive TCP/IP fingerprinting tool. Run Zardaxt.py on your server to find out what operating systems your clients are really using. This tool considers the header fields and options from the very first incoming SYN packet of the TCP 3-Way Handshake.

Test your TCP/IP Fingerprint with curl:

curl 'https://tcpip.incolumitas.com/classify?by_ip=1'
curl 'https://tcpip.incolumitas.com/classify?by_ip=1&detail=1'

Why the rewrite?

What can I do with this tool?

This tool may be used to correlate an incoming TCP/IP connection with a operating system class. For example, It can be used to detect proxies, if the proxy operating system (mostly Linux) differs from the operating system taken from the User-Agent.

If the key os_mismatch is true, then the TCP/IP inferred OS is different from the User-Agent OS.

On the other hand, most VPN protocols cannot be revealed by TCP/IP fingerprint mismatches. This is because VPN protocols work on the network layer, and VPN servers do not establish a dedicated TCP/IP connection that could have the TCP/IP characteristics of the VPN server.

Demo

Installation & Usage

First clone the repo:

# clone repo
git clone https://github.com/NikolaiT/zardaxt
# move into directory
cd zardaxt

I am using pew to create Python virtual environments. If you don't have pew installed yet, install it as follows:

pip3 install pew

Note: For newer Python 3 versions (Such as Python 3.10), you will have to install pcapy-ng (See: https://pypi.org/project/pcapy-ng/) instead of pcapy.

# create a virtual environment with pew
pew new zardaxt
# work on virtual environment `zardaxt`
pew workon zardaxt
# install packages now with pip inside the environment `zardaxt`
pip install dpkt pcapy-ng requests

By default, zardaxt.py looks for a configuration file named zardaxt.json that should reside in the same directory as zardaxt.py. But you can provide your own path to your own config file as first argument to zardaxt.py.

python zardaxt.py ./zardaxt.json

Or run zardaxt.py in the background on your server

nohup pew in zardaxt python zardaxt.py 

Serving over https via nginx

If you want to serve zardaxt.py over nginx, your configuration has to look something like this. HTTPS is provided by Let’s Encrypt (certbot).

server {
  listen 443 ssl default_server;
  listen [::]:443 ssl default_server;

  server_name tcpip.incolumitas.com;

  location / {
    proxy_pass http://localhost:8249;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Host $host;
    proxy_set_header  X-Real-IP $remote_addr;
    proxy_cache_bypass $http_upgrade;
  }

  ssl_certificate /etc/letsencrypt/live/abs.incolumitas.com/fullchain.pem; # managed by Certbot
  ssl_certificate_key /etc/letsencrypt/live/abs.incolumitas.com/privkey.pem; # managed by Certbot
}

API Support

When you run zardaxt.py, the program automatically launches a simple web API that you can query. A http server is bound to 0.0.0.0:8249. You can query it on http://0.0.0.0:8249/classify.

If you want to query the TCP/IP fingerprint only for the client IP address, use

curl "http://0.0.0.0:8249/classify"

And if you want to have all details in the API output, append &detail=1 to the URL:

curl "http://0.0.0.0:8249/classify?detail=1"

If you want to query all fingerprints in the API database, you have to specify the API key:

curl "http://0.0.0.0:8249/classify?key=abcd1234"

If you want to query/lookup a specific IP address (Example: 103.14.251.215), you will have to specify the IP address and the API key:

curl "http://0.0.0.0:8249/classify?key=abcd1234&ip=103.14.251.215"

What header fields are used for TCP/IP fingerprinting?

Several fields such as TCP Options or TCP Window Size or IP Fragment Flag depend heavily on the OS type and version. Detecting operating systems by analyzing the first incoming SYN packet is surely no exact science, but it's better than nothing.

Entropy from the IP header

Entropy from the TCP header

Sources

  1. Mostly Wikipedia TCP/IP fingerprinting article
  2. A lot of inspiration from satori.py
  3. Another TCP/IP fingerprinting tool