-Some additional packages are also required for full functionality: +Some packages are required for full functionality: * **Debian 10 / Ubuntu 20.04 (or newer):** @@ -304,28 +312,61 @@ Some additional packages are also required for full functionality: dnf -y install curl whois bind-utils mtr jq nmap nmap-ncat ipcalc aha grepcidr ``` -* **Manjaro/Arch Linux:** *(thanks [Worty](https://github.com/worty))* +* **openSUSE Leap 15.5 (or newer), openSUSE Tumbleweed** ``` - yay -S asn-git + zypper in -y curl whois bind-utils mtr jq nmap ncat ipcalc aha grepcidr ``` -* **Alpine Linux 3.18 (or newer)** *(thanks [Francesco Colista](https://github.com/fcolista))* +* **FreeBSD**: ``` - apk add -X https://dl-cdn.alpinelinux.org/alpine/v3.19/community asn + env ASSUME_ALWAYS_YES=YES pkg install bash coreutils curl whois mtr jq ipcalc grepcidr nmap aha ``` -* **openSUSE Leap 15.5 (or newer), openSUSE Tumbleweed** +* **Windows**: + + * **using [WSL2](https://docs.microsoft.com/en-us/windows/wsl/about) (recommended):** + Install Windows Subsystem for Linux (v2) by following Microsoft's [guide](https://docs.microsoft.com/en-us/windows/wsl/install-win10#manual-installation-steps). On step 6, choose one of the Linux distributions listed above (Ubuntu 20.04 LTS is recommended). + Once your WSL2 system is up and running, open a Linux terminal and follow the prerequisite installation instructions above for your distribution of choice. + + > *Note for Windows users: Check [this](https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/) page for details on how to activate **systemd** if you plan to install the [asn service](#installing-the-asn-server-as-a-system-service).* + + * **using [Cygwin](https://cygwin.com/index.html):** + Most of the prerequisite packages listed above for *Debian 10 / Ubuntu 20.04 (or newer)* are obtainable directly with Cygwin's own Setup wizard (or through scripts like *apt-cyg*). You will still have to manually compile (or find a suitable third-party precompiled binary) the *mtr*, *grepcidr* and *aha* tools. Instructions on how to do so can be found directly on the respective projects homepages. +
+ +Afterwards, to install the **asn** script from your shell to **/usr/bin**: + +`curl "https://raw.githubusercontent.com/nitefood/asn/master/asn" > /usr/bin/asn && chmod 0755 /usr/bin/asn` + +
+ +* **Debian Sid / Ubuntu 24.04 (or newer):** *(thanks [Marcos Rodrigues de Carvalo](https://github.com/odaydebian))* ``` - zypper in -y curl whois bind-utils mtr jq nmap ncat ipcalc aha grepcidr + sudo apt update && sudo apt install asn ``` +* **Manjaro / Arch Linux:** *(thanks [Worty](https://github.com/worty))* -* **FreeBSD**: + ``` + yay -S asn-git + ``` + +* **Alpine Linux 3.18 (or newer)** *(thanks [Francesco Colista](https://github.com/fcolista))* ``` - env ASSUME_ALWAYS_YES=YES pkg install bash coreutils curl whois mtr jq ipcalc grepcidr nmap aha + apk add -X https://dl-cdn.alpinelinux.org/alpine/v3.19/community asn ``` * **NixOS** *(thanks [devhell](https://github.com/devhell))* @@ -338,32 +379,15 @@ Some additional packages are also required for full functionality: brew install asn ``` - *Notes for MacOS users:* - - * *If `mtr` still can't be found after running the command above, [this](https://docs.brew.sh/FAQ#my-mac-apps-dont-find-usrlocalbin-utilities) may help to fix it.* - * *Homebrew has a [policy](https://github.com/Homebrew/homebrew-core/issues/35085#issuecomment-447184214) not to install any binary with the **setuid** bit, and mtr (or actually, the mtr-packet helper binary that comes with it) requires to elevate to root to perform traces (good explanations for this can be found [here](https://github.com/traviscross/mtr/issues/204#issuecomment-723961118) and [here](https://github.com/traviscross/mtr/blob/master/SECURITY)). If mtr (and therefore `asn`) traces are not working on your system, you should either run `asn` as root using **sudo**, or set the proper SUID permission bit on the mtr (or better, on the mtr-packet) binary.* - -* **Windows**: - - * **using [WSL2](https://docs.microsoft.com/en-us/windows/wsl/about) (recommended):** - Install Windows Subsystem for Linux (v2) by following Microsoft's [guide](https://docs.microsoft.com/en-us/windows/wsl/install-win10#manual-installation-steps). On step 6, choose one of the Linux distributions listed above (Ubuntu 20.04 LTS is recommended). - Once your WSL2 system is up and running, open a Linux terminal and follow the prerequisite installation instructions above for your distribution of choice. - *Note for WSL2 users:* - * ~~*systemd is not currently available in WSL2, so you won't be able to run the **asn server** in daemon mode as described below (if you want server mode you'll have to launch it manually using `asn -l`). An alternative could be to run it as a background process (optionally also using `nohup`), or using Windows' own task scheduler to start it at boot.*~~ **UPDATE: systemd is now supported on WSL2. Check [this](https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/) page for details on how to activate it.** - * **using [Cygwin](https://cygwin.com/index.html):** - Most of the prerequisite packages listed above for *Debian 10 / Ubuntu 20.04 (or newer)* are obtainable directly with Cygwin's own Setup wizard (or through scripts like *apt-cyg*). You will still have to manually compile (or find a suitable third-party precompiled binary) the *mtr*, *grepcidr* and *aha* tools. Instructions on how to do so can be found directly on the respective projects homepages. - -### Script download and installation + >*Note for MacOS users:* + > + > *Homebrew has a [policy](https://github.com/Homebrew/homebrew-core/issues/35085#issuecomment-447184214) not to install any binary with the **setuid** bit, and mtr (or actually, the mtr-packet helper binary that comes with it) requires to elevate to root to perform traces (good explanations for this can be found [here](https://github.com/traviscross/mtr/issues/204#issuecomment-723961118) and [here](https://github.com/traviscross/mtr/blob/master/SECURITY)). If mtr (and therefore `asn`) traces are not working on your system, you should either run `asn` as root using **sudo**, or set the proper SUID permission bit on the mtr (or better, on the mtr-packet) binary.* -Afterwards, to install the **asn** script from your shell to **/usr/bin**: - -`curl "https://raw.githubusercontent.com/nitefood/asn/master/asn" > /usr/bin/asn && chmod 0755 /usr/bin/asn` - -You can then use the script by running `asn`. +
+ +##### Command: + +`asn -J 8.8.8.8` + +##### Output: -```jsonp -root@KRUSTY:~# asn -J 8.8.8.8 +```json { "target": "8.8.8.8", "target_type": "ipv4", @@ -920,89 +949,97 @@ root@KRUSTY:~# asn -J 8.8.8.8 ] } ``` +
-*Example 2 - ASN lookup:* +##### Command: -```jsonp -root@KRUSTY:~# asn -J 5505 +`asn -J 5505` + +##### Output: + +```json { "target": "5505", "target_type": "asn", "result": "ok", "reason": "success", - "version": "0.72.1", - "request_time": "2022-03-28T21:59:51", - "request_duration": 4, + "version": "0.76.0", + "request_time": "2024-02-22T00:11:41", + "request_duration": 10, "result_count": 1, "results": [ { "asn": "5505", "asname": "VADAVO, ES", - "org": "VDV-VLC-RED05 VDV-VLC-RED05 - CLIENTES DATACENTER", + "asrank": 3779, + "org": "VDV-VLC-RED06 VDV-VLC-RED06 - CLIENTES TELECOM", "holder": "VADAVO SOLUCIONES SL", "abuse_contacts": [ "abuse@vadavo.com" ], "registration_date": "2016-12-13T08:28:07", "ixp_presence": [ - "NIXVAL-ix: Peering LAN1", "DE-CIX Madrid: DE-CIX Madrid Peering LAN", - "ESPANIX Madrid Lower LAN", - "IXPlay Global Peers" + "ESPANIX Madrid Lower LAN" ], "prefix_count_v4": 8, "prefix_count_v6": 1, - "bgp_peer_count": 32, + "bgp_peer_count": 36, "bgp_peers": { "upstream": [ "1299", "6939", - "3262", - "34549", - "13030", - "25369", - "33891", - "35280", + "59432", + "174", "25091", + "33891", + "8218", "41327", - "1239", - "34927", - "60501", + "48348", + "35280", + "35625", "4455", - "24482", - "13786", - "8218", + "13030", + "202766", + "3303", + "6057", + "137409", "15830" ], "downstream": [ - "200509", "48952", - "207495", "208248", - "205093", - "202054", - "205086" + "205086", + "202054" ], "uncertain": [ - "61573", - "51185", - "271253", - "264479", - "34854", + "47787", + "39384", + "37721", + "36236", "25160", - "37721" + "24482", + "51185", + "49544", + "41047", + "29680", + "29049", + "212483", + "14840", + "34927" ] }, "announced_prefixes": { "v4": [ - "185.123.206.0/24", - "185.210.227.0/24", - "185.123.205.0/24", "185.123.204.0/24", "185.123.207.0/24", - "185.210.226.0/24", "188.130.247.0/24", - "185.210.225.0/24" + "185.210.226.0/24", + "185.210.227.0/24", + "185.123.205.0/24", + "185.210.225.0/24", + "185.123.206.0/24" ], "v6": [ "2a03:9320::/32" @@ -1021,7 +1058,14 @@ root@KRUSTY:~# asn -J 5505 ] }, "inetnums_announced_by_other_as": { - "v4": [], + "v4": [ + { + "prefix": "188.130.254.0/24", + "origin_asn": "", + "origin_org": "", + "is_announced": false + } + ], "v6": [] } } @@ -1029,52 +1073,88 @@ root@KRUSTY:~# asn -J 5505 } ``` -*Example 3 - enumerating abuse contacts for every IP to which a hostname resolves:* +
-```shell -root@KRUSTY:~# asn -j www.google.com | jq '[.results[].abuse_contacts[]] | unique[]' +##### Command: + +`asn -j www.google.com | jq '[.results[].abuse_contacts[]] | unique[]'` + +##### Output: + +``` "network-abuse@google.com" "ripe-contact@google.com" ``` -*Example 4 - enumerating known vulnerabilities for a target:* +
-```shell -root@KRUSTY:~# asn -j 45.67.34.100 | jq '.results[].fingerprinting.vulns[]' +##### Command: + +`asn -j 45.67.34.100 | jq '.results[].fingerprinting.vulns[]'` + +##### Output: +``` "CVE-2017-15906" "CVE-2018-15919" ``` -*Example 5 - upstream/transit AS lookup for a given IP:* +
-```shell -root@KRUSTY:~#: asn -Ju 72.17.119.201 +##### Command: + +`asn -Ju 72.17.119.201` + +##### Output: + +```json { "target": "72.17.119.201", "target_type": "ipv4", "result": "ok", "reason": "success", - "version": "0.74", - "request_time": "2023-05-11T23:46:12", - "request_duration": 1, + "version": "0.76.0", + "request_time": "2024-02-22T00:15:25", + "request_duration": 3, "result_count": 1, "results": [ { + "prefix": "72.17.0.0/17", "origin_as": "33363", "origin_as_name": "BHN-33363, US", + "origin_as_rank": 435, + "upstreams_count": 1, "upstreams": [ { "asn": "7843", "asname": "TWC-7843-BB, US", - "probability": 100 + "probability": 100, + "is_tier1": false } ], - "multiple_transits": false + "multiple_upstreams": false } ] } ``` +
+ +##### Command: + +`asn -j AS5505 | jq -r '.results[].inetnums_announced_by_other_as.v4[] | select(.is_announced==false) | .prefix'` + +##### Output: + +``` +188.130.254.0/24 +``` + +