Skip to content

Instantly share code, notes, and snippets.

@kshji
Forked from woltage/getdomains.sh
Last active December 21, 2020 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kshji/a5d3dc9929d2a1264c5be16b9752e5f1 to your computer and use it in GitHub Desktop.
Save kshji/a5d3dc9929d2a1264c5be16b9752e5f1 to your computer and use it in GitHub Desktop.
Skripti jolla saa Y-tunnuksella kaikki firman omistamat .fi -verkkotunnukset
## Y-Tunnukseen perustuva domainejen haku (.fi)
## Esimerkki: getdomains 1093944-1 # MTV Oy
# Laita tämä .bashrc tai .zshrc
# Käyttöesimerkkejä:
# Looppaa Y-tunnuksetn kaikki domainit läpi ja tee kysely
# for i in $(getdomains 1093944-1); do echo $i && host -t cname www.$i; done
function getdomains() {
curl 'https://odata.domain.fi/OpenDomainData.svc/Domains()?$orderby=GrantDate%20desc&$top=500&$filter=OrganizationId%20eq%20%27'$1'%27' -s| grep -oP "<d:Name>\K([a-å]+)<"|sed 's/</.fi/g'
}
# Hae domainiin perustuen: domain_getdomains
function domain_getdomains() {
CODE=`whois $1|grep -oP "register number(.*): \K(.*)"`
getdomains $CODE
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment