Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated dnscommon for NS, PTR, MX records and enhancement for 'AAAA' and 'TXT' records #166

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

pranavnyu
Copy link

patch for issue #167 , added code for NS and PTR type of queries separately.
_parse_answer_address was limited to converting answer into address but NS should provide naming servers for NS type of queries and domain name for PTR types.
After this code we have following results for NS and PTR types:

  • reverse query
--------------------------------------------------------------------------------
Standard out :
..............................Produced..............................
('173.252.120.6', {'domain': 'edge-star-shv-12-frc3.facebook.com'})

matches with - dig -x '173.252.120.6' (for facebook IP)

;; QUESTION SECTION:
;6.120.252.173.in-addr.arpa.    IN  PTR

;; ANSWER SECTION:
6.120.252.173.in-addr.arpa. 3600 IN PTR edge-star-shv-12-frc3.facebook.com.
  • naming servers
--------------------------------------------------------------------------------
Standard out :
..............................Produced..............................
('google.com', ['ns3.google.com', 'ns2.google.com', 'ns4.google.com', 'ns1.google.com'])

matches with - -dig google.com NS (for google's NS)

; QUESTION SECTION:
;google.com.            IN  NS

;; ANSWER SECTION:
google.com.     14400   IN  NS  ns1.google.com.
google.com.     14400   IN  NS  ns2.google.com.
google.com.     14400   IN  NS  ns3.google.com.
google.com.     14400   IN  NS  ns4.google.com.

  • MX records
Standard out :
..............................Produced..............................
('google.com', ['alt3.aspmx.l.google.com', 'aspmx.l.google.com', 'alt1.aspmx.l.google.com', 'alt2.aspmx.l.google.com', 'alt4.aspmx.l.google.com'])

matches with - dig google.com MX

;; QUESTION SECTION:
;google.com.            IN  MX

;; ANSWER SECTION:
google.com.     553 IN  MX  40 alt3.aspmx.l.google.com.
google.com.     553 IN  MX  30 alt2.aspmx.l.google.com.
google.com.     553 IN  MX  50 alt4.aspmx.l.google.com.
google.com.     553 IN  MX  20 alt1.aspmx.l.google.com.
google.com.     553 IN  MX  10 aspmx.l.google.com.
  • Support for 'TXT' records:
Standard out :
..............................Produced..............................
('google.com', ['Kv=spf1 include:_spf.google.com ip4:216.73.93.70/31 ip4:216.73.93.72/31 ~all'])

matches with - dig @8.8.8.8 google.com TXT

; QUESTION SECTION:
;google.com.            IN  TXT

;; ANSWER SECTION:
google.com.     3599    IN  TXT "v=spf1 include:_spf.google.com ip4:216.73.93.70/31 ip4:216.73.93.72/31 ~all"

  • Support for 'AAAA' records:
Standard out :
..............................Produced..............................
('facebook.com', ['2a03:2880:2130:cf05:face:b00c:0000:0001'])

matches with - dig facebook.com AAAA

; QUESTION SECTION:
;facebook.com.          IN  AAAA

;; ANSWER SECTION:
facebook.com.       20  IN  AAAA    2a03:2880:2130:cf05:face:b00c::1

@pranavnyu pranavnyu changed the title updated dnscommon for NS and PTR updated dnscommon for NS, PTR, MX records and enhancement for 'AAAA' records May 12, 2015
@pranavnyu pranavnyu self-assigned this May 12, 2015
@pranavnyu pranavnyu changed the title updated dnscommon for NS, PTR, MX records and enhancement for 'AAAA' records updated dnscommon for NS, PTR, MX records and enhancement for 'AAAA' and 'TXT' records May 12, 2015
@pranavnyu
Copy link
Author

updated dnsquery.r2py and librepy.r2py for DNS measurements.

if answer_type in simple_answers:
read_index, resource_data['address'] = _parse_answer_address(read_index, dns_query_data)
elif answer_type == 'NS':
read_index, resource_data['nameserver'] = _parse_address(read_index,dns_query_data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please combine all the answer types that are treated the same way under a single elif branch.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not combine all because when you query for MX or reverse or AAAA etc then you have additional section containing extra data. We don't need that but if we don't separate then packet dictionary will contain mixed details. So by separating, packet dictionary will contain all information with their respective query types.
for eg.

;; QUESTION SECTION:
;google.com.            IN  MX

;; ANSWER SECTION:
google.com.     600 IN  MX  20 alt1.aspmx.l.google.com.
google.com.     600 IN  MX  30 alt2.aspmx.l.google.com.
google.com.     600 IN  MX  40 alt3.aspmx.l.google.com.
google.com.     600 IN  MX  10 aspmx.l.google.com.
google.com.     600 IN  MX  50 alt4.aspmx.l.google.com.

;; ADDITIONAL SECTION:
alt1.aspmx.l.google.com. 156    IN  A   64.233.186.27

or

;google.com.            IN  NS

;; ANSWER SECTION:
google.com.     14400   IN  NS  ns4.google.com.
google.com.     14400   IN  NS  ns1.google.com.
google.com.     14400   IN  NS  ns2.google.com.
google.com.     14400   IN  NS  ns3.google.com.

;; ADDITIONAL SECTION:
ns1.google.com.     13328   IN  A   216.239.32.10
ns2.google.com.     13956   IN  A   216.239.34.10
ns3.google.com.     2225    IN  A   216.239.36.10
ns4.google.com.     2315    IN  A   216.239.38.10

@aaaaalbert
Copy link
Contributor

  1. See detailed comments to your commit.
  2. Check your use of operators versus the coding style guidelines. (E.g., Don't do this i+=1, but that: i += 1.)
  3. Why are dnsquery and librepy included in a PR that supposedly fixes dnscommon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants