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

21 lines
575 B
Python
Raw Normal View History

2024-10-24 23:09:21 +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 {}