In previous articles, we explained how to access the OVH/GoDaddy APIs. This time, we will program a script that combines both APIs to locate a specific domain. It will also generate a cache file to speed up the search and the possibility of consulting the WHOIS/DNS information of the domain in case it is not found in any panel.
We install the necessary libraries:
We program the script, which will connect to the OVH/GoDaddy APIs and dump all the domains, generate a cache file, and search in it. In future executions, if the existence of the cache file is detected, it will be searched directly in it.
If the domain is not found, the cache is regenerated, and if it still cannot be found, the WHOIS/DNS information will be consulted.
#!/usr/bin/env python3
import ovh
import os
import time
from cymruwhois import Client as cymruwhoisClient
import socket
import re
from godaddypy import Client, Account
import dns.resolver
# pip install ovh cymruwhois godaddypy dnspython
tmpFile = '/tmp/domainInfo.log'
configFileOvh = 'configs/lista_ids_ovh.list'
configFileGoDaddy = 'configs/lista_ids_godaddy.list'
os.system('clear')
print('')
print('##################################################################')
print('| OVH-GoDaddy Domain/Whois searcher system v0.7b - coded by Kr0m |')
print('| Cache data file path: %s |' % tmpFile)
print('##################################################################')
print('')
def searchDomain(domain):
print('-- Searching domain: %s' % domain)
with open(tmpFile) as f:
lines = f.readlines()
for line in lines:
dataId = line.split()[0]
dataISP = line.split()[1]
dataDomain = line.split()[2]
if domain == dataDomain:
info = dataId + ' ' + dataISP
return info
return 'NULL'
def refreshData():
f = open(tmpFile, 'w')
print('')
print('>> Retriving domain information from OVH....')
for line in open(configFileOvh,'r').readlines():
#print('Line: %s' % line)
ovhId = line.split(':')[0]
ovhKey = line.split(':')[1]
ovhSecret = line.split(':')[2]
ovhConsumer = line.split(':')[3]
ovhRealId = line.split(':')[4].rstrip("\n")
APPLICATION_KEY = ovhKey
APPLICATION_SECRET = ovhSecret
CONSUMER_KEY = ovhConsumer
client = ovh.Client(
endpoint = 'ovh-eu',
application_key = APPLICATION_KEY,
application_secret = APPLICATION_SECRET,
consumer_key = CONSUMER_KEY,
)
print('-- Retrieving domains info from id: %s' % ovhId)
domains=client.get('/domain')
if domains:
for domain in domains:
data = ovhRealId + ' OVH ' + domain + '\n'
f.write(data)
else:
print('-- No Domains found for ID: %s' % ovhId)
print('')
print('>> Retriving domain information from GoDaddy....')
for line in open(configFileGoDaddy,'r').readlines():
daddyName = line.split(':')[0]
daddyKey = line.split(':')[1]
daddySecret = line.split(':')[2]
daddyId = line.split(':')[3].rstrip("\n")
#print('daddyName: %s ' % daddyName)
#print('daddyKey: %s ' % daddyKey)
#print('daddySecret: %s ' % daddySecret)
#print('daddyId: %s ' % daddyId)
print('-- Retrieving domains info from id: %s' % daddyName)
my_acct = Account(api_key=daddyKey, api_secret=daddySecret)
delegate_acct = Account(api_key=daddyKey, api_secret=daddySecret, delegate=daddyId)
client = Client(my_acct)
delegate_client = Client(delegate_acct)
domains = client.get_domains()
if domains:
for domain in domains:
#print('-- Domain: %s' % domain)
data = daddyId + ' GoDaddy ' + domain + '\n'
f.write(data)
else:
print('-- No Domains found for ID: %s' % daddyName)
f.close()
while True:
if not os.path.isfile(tmpFile):
print('-- Previous data file not found, refreshing data.')
refreshData()
print('-- Done')
print('')
domain = input("Wich domain would you like to search > ")
id = searchDomain(domain)
if id == 'NULL':
print('-- Domain not found in previous data, refreshing data.')
refreshData()
print('-- Done.')
print('-- Retrying previous search.')
id = searchDomain(domain)
if id == 'NULL':
print('')
print('++ Domain NOT found.')
print('>> Quering WHOIS/DNS info.')
ip = socket.gethostbyname(domain)
print('Ip: %s' % ip)
c = cymruwhoisClient()
domainWhois = c.lookup(ip)
print('Owner: %s' % domainWhois.owner)
nameservers = dns.resolver.query(domain,'NS')
for nameserver in nameservers:
print('NS: %s' % nameserver)
else:
print('++ Domain found ID: %s' % id)
print('')
We assign the necessary permissions:
We generate the files with the access credentials to the
OVH
and
GoDaddy
APIs.
vi configs/lista_ids_ovh.list
DESCRIPTIVE_NAME:OVH_KEY:OVH_SECRET:OVH_CONSUMERKEY:OVH_ID
DESCRIPTIVE_NAME:DADDY_KEY:DADDY_SECRET:DADDY_ID
We run the script:
##################################################################
| OVH-GoDaddy Domain/Whois searcher system v0.7b - coded by Kr0m |
| Cache data file path: /tmp/domainInfo.log |
##################################################################
Wich domain would you like to search > asd.com
++ Domain NOT found.
>> Quering WHOIS/DNS info.
Ip: 198.46.84.198
Owner: INMOTI-1, US
NS: ns3.sungardns.com.
NS: ns1.sungardns.com.
NS: ns2.sungardns.com.