Skip to content

trevor-viljoen/parse_resolv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parse resolv.conf into json or yaml

Create lexer.rb

rex test_resolv.rex -o lexer.rb

Parse file

ruby resolv_parse.rb

YAML output from sample resolv.conf file

---
nameservers:
- 192.168.1.254
- 192.168.1.253
domain: local.tld
search:
- a.local.tld
- b.local.tld
- local.tld
options:
- rotate
- timeout:1
- attempts:2

JSON output from sample resolv.conf file

{
  "nameservers": ["192.168.1.254","192.168.1.253"],
  "domain": "local.tld",
  "search": ["a.local.tld","b.local.tld","local.tld"],
  "options": ["rotate","timeout:1","attempts:2"]
}

Ruby hash output from sample resolv.conf file

{
  :nameservers => ["192.168.1.254", "192.168.1.253"],
  :domain => "local.tld",
  :search => ["a.local.tld", "b.local.tld", "local.tld"],
  :options => ["rotate", "timeout:1", "attempts:2"]
}

About

Ruby code to parse resolv.conf into a json object

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published