DEV Community

Cover image for "IpSurv", an IP survey tool made in Python, has been released.
Deer hunt
Deer hunt

Posted on

"IpSurv", an IP survey tool made in Python, has been released.

"IpSurv" has been released. It's an IP survey tool developed by Python.

🥕Installation

IpSurv's installation is as following. You aren't trouble by complex settings or any dependency problems.

$ pip install ipsurv
or
$ pip3 install ipsurv
Enter fullscreen mode Exit fullscreen mode

☕️Let's try!

1. Surveying 192.168.1.10

Surveying '192.168.1.10', the following results are as follows.

$ ipsurv 192.168.1.10
192.168.1.10,OK,US,PRIVATE-ADDRESS-CBLK-RFC1918-IANA-RESERVED,192.168.0.0,192.168.255.255
Enter fullscreen mode Exit fullscreen mode

2. Customizing output format

It' available to customize output format flexibly.

$ ipsurv 8.8.8.8 --format=geo
8.8.8.8,37.4056;-122.0775

$ ipsurv 8.8.8.8 --format=detail
8.8.8.8,OK,US,GOGL,GOGL,AS15169 Google LLC,8.8.8.0/24,37.4056;-122.0775,1600 Amphitheatre Parkway Mountain View CA 94043 United States,dns.google

$ ipsurv 8.8.8.8 --format="{status}\t{geto}\t{country}\t{address}\t{hostname}"
8.8.8.8 NG      -       US      1600 Amphitheatre Parkway Mountain View CA 94043 United States  dns.google
Enter fullscreen mode Exit fullscreen mode

3. Surveying a domain with json option

If you use "json" option, You can see the results in vertical format.

$ ipsurv github.com --json=2 --add_ip
{
  "original": "github.com",
  "ip": "20.27.177.113",
  "status": "OK",
  "group": "",
  "country": "US",
  "name": "MSFT",
  "network_start": "20.0.0.0",
  "network_end": "20.31.255.255"
}
Enter fullscreen mode Exit fullscreen mode

If you'd like to retrieve more detail data, please use --format=heavy and --exhaustive option.

$ ipsurv dev.to --format=heavy --exhaustive --json=2 --add_ip
{
  "success": false,
  "status": "NG",
  "requests": [
    "RDAP",
    "DNSREVERSE",
    "IPINFO"
  ],
  "errors": [
    "[Errno 1] Unknown host"
  ],
  "sequence": 1,
  "original": "dev.to",
  "target": "151.101.130.217",
  "ip": "151.101.130.217",
  "ip_int": 2540012249,
  "port": null,
  "group_int": 0,
  "group": "",
  "group_found": false,
  "group_status": "-",
  "country": "US",
  "timezone": "America/Los_Angeles",
  "name": "SKYCA-3",
  "handle": "SKYCA-3",
  "org": "AS54113 Fastly, Inc.",
  "cidr": "151.101.0.0/16",
  "network_start": "151.101.0.0",
  "network_end": "151.101.255.255",
  "geo": "37.7621,-122.3971",
  "address": "PO Box 78266 San Francisco CA 94107 United States",
  "description": "",
  "hostname": "",
  "identifier": "151.101.130.217",
  "identifier_int": 2540012249,
  "rdap_time": 1687.8,
  "country_updated": true,
  "port43": "whois.arin.net",
  "dnsreverse_time": 19.4,
  "ipinfo_time": 258.9,
  "city": "San Francisco",
  "region": "California",
  "postal": "94107",
  "target.raw": "dev.to",
  "target.identifier": "151.101.130.217",
  "target.identifier_int": 2540012249,
  "target.ip": "151.101.130.217",
  "target.url": null,
  "target.fqdn": "dev.to",
  "target.port": null,
  "target.status": "EXIST"
}
Enter fullscreen mode Exit fullscreen mode

4. Surveying self IP information

The results are as follows.

$ ipsurv self
Self IP status by https://ipinfo.io

Ip: 144.*.*.*
Hostname: 
Organization: AS797 AT&T Services, Inc.
Country: US
City: San Jose
Region: California
Postal: 95103
Geo: 37.3394,-121.8950
Timezone: America/Los_Angeles
LocalIp: 10.0.2.15
LocalDns: ['8.8.8.8', '8.8.4.4']
Enter fullscreen mode Exit fullscreen mode

5. Measure server reply status

Check ICMP

$ cat list.txt|ipsurv --icmp=1
$ ipsurv 8.8.8.8 --icmp=1 --format="{ip},{icmp},{icmp_time}"
8.8.8.8,8.8.8.8,ICMP_OK,45.6
Enter fullscreen mode Exit fullscreen mode

Check TCP port

$ cat list.txt|ipsurv --tcp=1
$ cat list.txt|ipsurv --tcp=80 --format=country
$ ipsurv www.craigslist.org --tcp=1 --format="{ip},{tcp},{tcp_time}"
www.craigslist.org,208.82.238.225,TCP_OK,144.2
Enter fullscreen mode Exit fullscreen mode

Check UDP port

$ cat list.txt|ipsurv --udp=1 --format="{ip},{udp},{udp_time}"
Enter fullscreen mode Exit fullscreen mode

Check HTTP response

$ cat list.txt|ipsurv --http=1
$ cat list.txt|ipsurv --http=2 --format=country --add_ip
$ ipsurv reddit.com --http=2 --format="{ip},{http},{http_time},{http_h2}"
reddit.com,151.101.1.140,HTTP_OK,1161.0,HTTP2
Enter fullscreen mode Exit fullscreen mode

🍩Miscellaneous

Public IP or Private IP

Check public IP or private IP.

$ ipsurv 192.168.1.100 --format="{ip_type}"
192.168.1.100,PRIVATE
Enter fullscreen mode Exit fullscreen mode
$ ipsurv 8.8.8.8 --format="{ip_type}"
8.8.8.8,PUBLIC
Enter fullscreen mode Exit fullscreen mode

IP address <--> IP int

Convert IP address to IP int and IP int to IP address.

$ ipsurv 192.168.1.100 --format="{ip_int}"
192.168.1.100,3232235876

$ ipsurv 16777217 --format="{ip}" --identify_int
16777217,1.0.0.1
Enter fullscreen mode Exit fullscreen mode

IP is in IP/subnet ranges?

Checking whether IP is in IP/subnet ranges by using --range option and in_range format.

$ ipsurv 192.168.1.10 1.0.0.1 --format="{in_range}" --range="1.0.0.1/24;192.168.1.8/24"
192.168.1.10,RANGE_OK
1.0.0.1,RANGE_OK

$ ipsurv 10.0.0.1 --format="{in_range}" --range="1.0.0.1/24;192.168.1.8/24"
10.0.0.1,RANGE_NG
Enter fullscreen mode Exit fullscreen mode

🥝Inspecting Apache log

Of course, IpSurv can also inspect log files containing IPs, such as Apache logs.

$ cat /var/log/httpd/access_log|ipsurv --add_ip --no_original
$ cat /var/log/httpd/access_log|ipsurv --format=country --add_ip --no_original
$ cat /var/log/httpd/access_log|ipsurv --format=geo --add_ip --no_original
Enter fullscreen mode Exit fullscreen mode

🌽Debugging

IpSurv has verbose mode, It can output internal data for debugging.
Specifying --verbose=3, Debug data been made output.

$ ipsurv 8.8.8.8 --verbose=3
Enable verbose mode. Current:3 [Level - 1:TRACE_ERROR, 2:INFO, 3:DEBUG]
2024-11-28 01:36:05,043 - INFO - ENV(IPSURV_ARGS):
{}
2024-11-28 01:36:05,043 - INFO - ENV(IPSURV_CONF):
{}
2024-11-28 01:36:05,044 - INFO - ARGUMENTS:
{ 'add_ip': False,
  'all_collect': False,
  'alt_delimiter': ';',
  'autodetect': False,
  'begin': -1,
  'collect': 'rdap;dnstxt;dnsreverse;ipinfo',
  'delimiter': None,
  'disable_env': False,
  'enclose': None,
  'end': -1,
  'exhaustive': False,
  'format': 'default',
  'group': None,
  'headers': 0,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2024-11-28 01:36:05,044 - INFO - Fixed delimiter:,
2024-11-28 01:36:05,044 - INFO - Fixed format:{original},{status},{group},{country},{name},{network_start},{network_end}
2024-11-28 01:36:05,044 - INFO - Fixed timeout:{'dns': 8.0, 'http': 8.0, 'reactivity': 8.0}
2024-11-28 01:36:05,044 - INFO - Fixed enclose:
2024-11-28 01:36:05,044 - INFO - Fixed collectors:['rdap', 'dnstxt', 'dnsreverse', 'ipinfo']
2024-11-28 01:36:05,045 - INFO - MODE:SURVEY_IPS
2024-11-28 01:36:05,046 - INFO - IP:8.8.8.8
2024-11-28 01:36:05,046 - INFO - FQDN:None
2024-11-28 01:36:05,046 - INFO - PORT:None
2024-11-28 01:36:05,046 - DEBUG - TARGET_RAW:8.8.8.8
2024-11-28 01:36:05,046 - INFO - TARGET_IDENTIFIER:8.8.8.8
2024-11-28 01:36:05,046 - INFO - TARGET_DATA:
{ 'fqdn': None,
  'identifier': '8.8.8.8',
  'identifier_int': 134744072,
  'ip': '8.8.8.8',
  'port': None,
  'raw': '8.8.8.8',
  'status': 'EXIST',
  'url': None}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2024-11-28 01:36:05,648 - INFO - RDAP:OK
2024-11-28 01:36:05,648 - INFO - RDAP_TIME(ms):596.2
2024-11-28 01:36:05,648 - DEBUG - UNNECESSARY:DNSTXT
2024-11-28 01:36:05,648 - DEBUG - UNNECESSARY:DNSREVERSE
2024-11-28 01:36:05,648 - DEBUG - UNNECESSARY:IPINFO
2024-11-28 01:36:05,649 - INFO - COLLECTED_DATA:
{ 'address': '1600 Amphitheatre Parkway Mountain View CA 94043 United States',
  'cidr': '8.8.8.0/24',
  'country': 'US',
  'country_updated': True,
  'description': '',
  'errors': [],
  'group': '',
  'group_found': False,
  'group_int': 0,
  'group_status': '-',
  'handle': 'GOGL',
  'identifier': '8.8.8.8',
  'identifier_int': 134744072,
  'ip': '8.8.8.8',
  'ip_int': 134744072,
  'name': 'GOGL',
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  'target.ip': '8.8.8.8',
  'target.port': None,
  'target.raw': '8.8.8.8',
  'target.status': 'EXIST',
  'target.url': None}
2024-11-28 01:36:05,649 - DEBUG - REQUESTS:
['RDAP']
8.8.8.8,OK,US,GOGL,8.8.8.0,8.8.8.255
Enter fullscreen mode Exit fullscreen mode

🥗There are many options

IpSurv have any other many options.

In detail, You can read command options in documentation site.

Documentation site top
https://deer-hunt.github.io/ipsurv/

About Command arguments
https://deer-hunt.github.io/ipsurv/pages/command_arguments.html


GitHub logo deer-hunt / ipsurv

"IpSurv" is a Python program for surveying IP addresses, host information, and more.

IpSurv

ipsurv is a command-line program for surveying IP addresses, host information, and more. Also ipsurv is extensible program by Python.

CI - Test CI - Test GitHub Actions build status (Lint) Coverage PyPI - Status License - MIT Newest PyPI version Number of PyPI downloads GitHub code size in bytes Supported Versions

 

ipsurv visual image

Installation

$ pip install ipsurv
or
$ pip3 install ipsurv
Enter fullscreen mode Exit fullscreen mode

Requirements

  • python and pip command
  • Python 3.0 or later version.

If you'd like to use in Python 2.7, you can refactor to Python 2.7 code easily. See "development_debug.md".

Usage

Specify Target using Argument

$ ipsurv 192.168.1.10
$ ipsurv 192.168.1.10 192.168.1.11
$ ipsurv test-example-sample-ipsurv.com --add_ip
$ ipsurv x.x.x.x --format=geo
Enter fullscreen mode Exit fullscreen mode

Specify Target using PIPE

$ cat ips.txt|ipsurv
$ cat apache.log|ipsurv --add_ip
Enter fullscreen mode Exit fullscreen mode

Example result

8.8.8.8:53,8.8.8.0,US,ICMP_OK,TCP_OK,UDP_OK
Enter fullscreen mode Exit fullscreen mode

Survey-mode

ipsurv have two Survey-mode. Those are "Survey IPs" and "Survey Self".


















Survey-mode Description
Survey IPs Primary mode. Surveying IP or Host or URL.
Survey Self Surveying self IP.

Survey Self e.g.

$ ipsurv self
Ip: 144.160.*.*
Hostname
Organization: AS797 AT&T Services, Inc.
Country: US
City: San Jose
Enter fullscreen mode Exit fullscreen mode

Top comments (0)