03 - find-domain-by-asn

Exemple récupérer le nombre de domaines connus par host.io pour certains ASN associé au gouvernement du canada


La première commande vise à identifier le nombre de domaine connus par ASN.

curl https://host.io/api/domains/asn/ASXXXX?limit=0&token=TA_CLÉ_API

Tu dois remplacer les XXXX par le numéro d'AS que tu veux et TA_CLÉ_API par ta propre clé valide host.io

Exemple en batch :

schaos@stack:/stuff/elastic-data/demo$ more commande-host.io_gouv.canada.txt
curl https://host.io/api/domains/asn/AS2665?limit=0&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl https://host.io/api/domains/asn/AS27293?limit=0&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl https://host.io/api/domains/asn/AS25689?limit=0&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl https://host.io/api/domains/asn/AS395262?limit=0&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl https://host.io/api/domains/asn/AS3766?limit=0&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl https://host.io/api/domains/asn/AS20010?limit=0&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl https://host.io/api/domains/asn/AS19737?limit=0&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl https://host.io/api/domains/asn/AS2653?limit=0&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl https://host.io/api/domains/asn/AS2675?limit=0&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl https://host.io/api/domains/asn/AS806?limit=0&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl https://host.io/api/domains/asn/AS2682?limit=0&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl https://host.io/api/domains/asn/AS820?limit=0&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl https://host.io/api/domains/asn/AS818?limit=0&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl https://host.io/api/domains/asn/AS837?limit=0&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl https://host.io/api/domains/asn/AS74?limit=0&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
schaos@stack:/stuff/elastic-data/demo$

schaos@stack:/stuff/elastic-data/demo$ cat commande-host.io_gouv.canada.txt | while read LINE; do $LINE; echo " "; sleep 2;done
{
  "asn": "AS2665",
  "total": 2373,
  "domains": []
}
{
  "error": "No details on 'asn' found for AS27293"
}
{
  "asn": "AS25689",
  "total": 41,
  "domains": []
}
{
  "error": "No details on 'asn' found for AS395262"
}
{
  "asn": "AS3766",
  "total": 57,
  "domains": []
}
{
  "asn": "AS20010",
  "total": 4,
  "domains": []
}
{
  "asn": "AS19737",
  "total": 6,
  "domains": []
}
{
  "asn": "AS2653",
  "total": 1194,
  "domains": []
}
{
  "asn": "AS2675",
  "total": 2136,
  "domains": []
}
{
  "asn": "AS806",
  "total": 118,
  "domains": []
}
{
  "error": "No details on 'asn' found for AS2682"
}
{
  "asn": "AS820",
  "total": 303,
  "domains": []
}
{
  "asn": "AS818",
  "total": 8,
  "domains": []
}
{
  "error": "No details on 'asn' found for AS837"
}
{
  "asn": "AS74",
  "total": 1,
  "domains": []
}
schaos@stack:/stuff/elastic-data/demo$


Mon forfait API pour host.io est limité à 50 réponses maximum par requête. Donc pour récupérer tous les domaines de AS2665 (total domaines = 2 373) je dois faire 48 requêtes. Exemple de requête pour la première page de 50 résultats :

schaos@stack:/stuff/elastic-data/demo$ curl "https://host.io/api/domains/asn/AS2665?limit=50&page=1&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA"
{
  "asn": "AS2665",
  "page": 1,
  "total": 2373,
  "domains": [
    "infolait.gc.ca",
    "affairesindiennesducanada.ca",
    "ainc-inac.org",
    "securitepubliquecanada.gc.ca",
    "surreyrcmp.ca",
    ...
    censuré
    ...
    ...
    "nationaltreeseedcentre.ca",
    "peeic.gc.ca",
    "www.crcd.gc.ca"
  ]
}
schaos@stack:/stuff/elastic-data/demo$

Pour les 50 résultats suivants, il faut mettre page=2 au lieu de page=1 . . . et ainsi de suite.

curl “https://host.io/api/domains/asn/AS2665?limit=50&page=2&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA"

En batch :

schaos@stack:/stuff/elastic-data/demo$ more commande-host.io_gouv.canada_AS2665.txt
curl -sS -o host.io_AS2665_page1.json https://host.io/api/domains/asn/AS2665?limit=50&page=1&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page2.json https://host.io/api/domains/asn/AS2665?limit=50&page=2&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page3.json https://host.io/api/domains/asn/AS2665?limit=50&page=3&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page4.json https://host.io/api/domains/asn/AS2665?limit=50&page=4&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page5.json https://host.io/api/domains/asn/AS2665?limit=50&page=5&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page6.json https://host.io/api/domains/asn/AS2665?limit=50&page=6&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page7.json https://host.io/api/domains/asn/AS2665?limit=50&page=7&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page8.json https://host.io/api/domains/asn/AS2665?limit=50&page=8&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page9.json https://host.io/api/domains/asn/AS2665?limit=50&page=9&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page10.json https://host.io/api/domains/asn/AS2665?limit=50&page=10&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page11.json https://host.io/api/domains/asn/AS2665?limit=50&page=11&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page12.json https://host.io/api/domains/asn/AS2665?limit=50&page=12&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page13.json https://host.io/api/domains/asn/AS2665?limit=50&page=13&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page14.json https://host.io/api/domains/asn/AS2665?limit=50&page=14&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page15.json https://host.io/api/domains/asn/AS2665?limit=50&page=15&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page16.json https://host.io/api/domains/asn/AS2665?limit=50&page=16&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page17.json https://host.io/api/domains/asn/AS2665?limit=50&page=17&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page18.json https://host.io/api/domains/asn/AS2665?limit=50&page=18&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page19.json https://host.io/api/domains/asn/AS2665?limit=50&page=19&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page20.json https://host.io/api/domains/asn/AS2665?limit=50&page=20&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page21.json https://host.io/api/domains/asn/AS2665?limit=50&page=21&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page22.json https://host.io/api/domains/asn/AS2665?limit=50&page=22&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page23.json https://host.io/api/domains/asn/AS2665?limit=50&page=23&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page24.json https://host.io/api/domains/asn/AS2665?limit=50&page=24&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page25.json https://host.io/api/domains/asn/AS2665?limit=50&page=25&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page26.json https://host.io/api/domains/asn/AS2665?limit=50&page=26&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page27.json https://host.io/api/domains/asn/AS2665?limit=50&page=27&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page28.json https://host.io/api/domains/asn/AS2665?limit=50&page=28&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page29.json https://host.io/api/domains/asn/AS2665?limit=50&page=29&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page30.json https://host.io/api/domains/asn/AS2665?limit=50&page=30&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page31.json https://host.io/api/domains/asn/AS2665?limit=50&page=31&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page32.json https://host.io/api/domains/asn/AS2665?limit=50&page=32&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page33.json https://host.io/api/domains/asn/AS2665?limit=50&page=33&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page34.json https://host.io/api/domains/asn/AS2665?limit=50&page=34&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page35.json https://host.io/api/domains/asn/AS2665?limit=50&page=35&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page36.json https://host.io/api/domains/asn/AS2665?limit=50&page=36&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page37.json https://host.io/api/domains/asn/AS2665?limit=50&page=37&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page38.json https://host.io/api/domains/asn/AS2665?limit=50&page=38&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page39.json https://host.io/api/domains/asn/AS2665?limit=50&page=39&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page40.json https://host.io/api/domains/asn/AS2665?limit=50&page=40&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page41.json https://host.io/api/domains/asn/AS2665?limit=50&page=41&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page42.json https://host.io/api/domains/asn/AS2665?limit=50&page=42&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page43.json https://host.io/api/domains/asn/AS2665?limit=50&page=43&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page44.json https://host.io/api/domains/asn/AS2665?limit=50&page=44&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page45.json https://host.io/api/domains/asn/AS2665?limit=50&page=45&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page46.json https://host.io/api/domains/asn/AS2665?limit=50&page=46&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page47.json https://host.io/api/domains/asn/AS2665?limit=50&page=47&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page48.json https://host.io/api/domains/asn/AS2665?limit=50&page=48&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
curl -sS -o host.io_AS2665_page49.json https://host.io/api/domains/asn/AS2665?limit=50&page=49&token=aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1vSGc1U0pZUkhBMA
schaos@stack:/stuff/elastic-data/demo$


schaos@stack:/stuff/elastic-data/demo$ cat commande-host.io_gouv.canada_AS2665.txt | while read LINE; do $LINE; sleep 2;done
schaos@stack:/stuff/elastic-data/demo$

pour afficher seulement les noms de domaines à partir des fichiers json :

jq '.domains' host.io_AS2665_page*.json