code-dumps/lambda/dns-query/lambda_function.py

21 lines
575 B
Python
Raw Normal View History

2023-03-29 13:58:52 +08:00
import dns.resolver
import dns.query
def lambda_handler(event, context):
res = dns.resolver.Resolver()
res.timeout = 5
res.lifetime = 30
res.nameservers = ['10.135.6.95','10.135.6.96']
results = res.query('_ldap._tcp.hkg.yourdomain.com', 'SRV', tcp=True)
print('_ldap._tcp.hkg.yourdomain.com:')
for line in results:
print(line.to_text())
results = res.query('_kerberos._tcp.hkg.yourdomain.com', 'SRV', tcp=True)
print('_kerberos._tcp.hkg.yourdomain.com:')
for line in results:
print(line.to_text())
return {}