mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2025-01-31 05:33:41 +00:00
commit
7e1d8ee5b6
45
DOH-Dig/README.md
Normal file
45
DOH-Dig/README.md
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
# doh-dig
|
||||||
|
|
||||||
|
A python dig script that returns json dns record lookup using cloud flares DNS servers.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
```
|
||||||
|
Usage:
|
||||||
|
doh-dig type <type> <record>
|
||||||
|
doh-dig ptr <ip>
|
||||||
|
doh-dig (-h | --help)
|
||||||
|
doh-dig --version
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### requirements
|
||||||
|
* [docopt]: https://github.com/docopt/docopt
|
||||||
|
* [requests]: https://pypi.org/project/requests/
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
#### lookup and A record for google.com
|
||||||
|
./doh-dig type a google.com |python -m json.tool
|
||||||
|
```
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "google.com.",
|
||||||
|
"type": 1,
|
||||||
|
"TTL": 235,
|
||||||
|
"data": "172.217.19.174"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
#### lookup reverse record for an IP
|
||||||
|
./doh-dig ptr 1.1.1.1 |python -m json.tool
|
||||||
|
```
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "1.1.1.1.in-addr.arpa.",
|
||||||
|
"type": 12,
|
||||||
|
"TTL": 1345,
|
||||||
|
"data": "one.one.one.one."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
52
DOH-Dig/doh-dig
Executable file
52
DOH-Dig/doh-dig
Executable file
|
@ -0,0 +1,52 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# Author: @awsumco
|
||||||
|
|
||||||
|
"""DNS OF HTTPS - DIG
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
doh-dig type <type> <record>
|
||||||
|
doh-dig ptr <ip>
|
||||||
|
doh-dig (-h | --help)
|
||||||
|
doh-dig --version
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h --help Show this screen.
|
||||||
|
--version Show version.
|
||||||
|
|
||||||
|
"""
|
||||||
|
from docopt import docopt
|
||||||
|
from pprint import pprint as pp
|
||||||
|
from sys import exit
|
||||||
|
import ipaddress, json
|
||||||
|
|
||||||
|
def CloudFlareLookup(type,record):
|
||||||
|
import requests
|
||||||
|
headers = {'accept': 'application/dns-json'}
|
||||||
|
url = "https://1.1.1.1/dns-query?name=%s&type=%s" % (record,type)
|
||||||
|
r = requests.get(url, headers=headers)
|
||||||
|
j_data = json.loads(r.text)
|
||||||
|
try:
|
||||||
|
return(j_data['Answer'])
|
||||||
|
except:
|
||||||
|
return(j_data['Question'])
|
||||||
|
|
||||||
|
|
||||||
|
valid_types = ['A','MX','PTR','SRV','TXT','NS']
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
arguments = docopt(__doc__, version='doh-dig 0.1')
|
||||||
|
if arguments['type']:
|
||||||
|
t = arguments['<type>'].upper()
|
||||||
|
r = arguments['<record>'].lower()
|
||||||
|
if t not in valid_types:
|
||||||
|
exit('invalid type')
|
||||||
|
x = CloudFlareLookup(t,r)
|
||||||
|
print(json.dumps(x))
|
||||||
|
elif arguments['ptr']:
|
||||||
|
ip = arguments['<ip>']
|
||||||
|
arpa = ipaddress.ip_address(ip).reverse_pointer
|
||||||
|
x = CloudFlareLookup('PTR',arpa)
|
||||||
|
print(json.dumps(x))
|
||||||
|
else:
|
||||||
|
print(arguments)
|
||||||
|
|
2
DOH-Dig/requirements.txt
Normal file
2
DOH-Dig/requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
docopt
|
||||||
|
requests
|
|
@ -26,6 +26,7 @@ So far, the following projects have been integrated to this repo:
|
||||||
| [Crypt socket](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Crypt_Socket)|[Willian GL](https://github.com/williangl) |
|
| [Crypt socket](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Crypt_Socket)|[Willian GL](https://github.com/williangl) |
|
||||||
|[Current City Weather](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Current_City_Weather) |[Jesse Bridge](https://github.com/jessebridge) |
|
|[Current City Weather](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Current_City_Weather) |[Jesse Bridge](https://github.com/jessebridge) |
|
||||||
|[Directory organizer](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Directory-organizer) | [Athul P](https://github.com/athulpn) |
|
|[Directory organizer](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Directory-organizer) | [Athul P](https://github.com/athulpn) |
|
||||||
|
|[DOH DIG](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/DOH-Dig/) | [Ryan](https://github.com/awsumco) |
|
||||||
|[Excel Files Merger](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Excel_Files_Merger) | [Andrei N](https://github.com/Andrei-Niculae)|
|
|[Excel Files Merger](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Excel_Files_Merger) | [Andrei N](https://github.com/Andrei-Niculae)|
|
||||||
|[Excel to List](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Excel_to_ListofList) | [Nitish Srivastava](https://github.com/nitish-iiitd)|
|
|[Excel to List](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Excel_to_ListofList) | [Nitish Srivastava](https://github.com/nitish-iiitd)|
|
||||||
|[Extended_ip_address_info](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/extended_ip_address_info) | [hafpaf](https://github.com/hafpaf)|
|
|[Extended_ip_address_info](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/extended_ip_address_info) | [hafpaf](https://github.com/hafpaf)|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user