This function takes one ip and ask for the dns PTR record information or reverse DNS hostname, and latter adds it to the main dictionary
(ip)
| 956 | |
| 957 | |
| 958 | def check_PTR_record(ip): |
| 959 | """ |
| 960 | This function takes one ip and ask for the dns PTR record information or reverse DNS hostname, and latter adds it to the main dictionary |
| 961 | """ |
| 962 | global debug |
| 963 | global domain_data |
| 964 | |
| 965 | try: |
| 966 | if debug: |
| 967 | logging.debug('\t\t> Checking {0} ip reverse DNS hostname'.format(ip)) |
| 968 | """ |
| 969 | temp_ip = ip.split('.') |
| 970 | temp_ip.reverse() |
| 971 | reverse_ip="" |
| 972 | for i in temp_ip: |
| 973 | reverse_ip = reverse_ip + i +'.' |
| 974 | reverse_ip = reverse_ip + 'in-addr.arpa' |
| 975 | """ |
| 976 | reverse_name = dns.reversename.from_address(ip).to_text()[:-1] |
| 977 | return reverse_name |
| 978 | |
| 979 | except Exception as inst: |
| 980 | print(type(inst)) # the exception instance |
| 981 | print(inst.args) # arguments stored in .args |
| 982 | print(inst) # __str__ allows args to printed directly |
| 983 | x, y = inst # __getitem__ allows args to be unpacked directly |
| 984 | print('x =', x) |
| 985 | print('y =', y) |
| 986 | return "" |
| 987 | |
| 988 | |
| 989 |
no test coverage detected