Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
25d150de07 | ||
|
90ed10c129 | ||
|
3bf715998d | ||
|
6e7a0c57c8 | ||
|
22f5297582 | ||
|
79154b093d | ||
|
9ad274a0bb |
6
CHANGELOG
Normal file
6
CHANGELOG
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
v1.3.6 - A suitable replacement for most of my uses for big
|
||||||
|
* Can capture dns packets in binary and JSON
|
||||||
|
* Parses common record types including:
|
||||||
|
* A,AAAA,CAA,CNAME,MX,NS,PTR,SOA,SRV,TXT
|
||||||
|
* Arbitrary TYPExxx support
|
||||||
|
* Known Bug: should error when label in rdata is not null terminated
|
41
LICENSE
Normal file
41
LICENSE
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
Copyright 2017 AJ ONeal
|
||||||
|
|
||||||
|
This is open source software; you can redistribute it and/or modify it under the
|
||||||
|
terms of either:
|
||||||
|
|
||||||
|
a) the "MIT License"
|
||||||
|
b) the "Apache-2.0 License"
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
Apache-2.0 License Summary
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
13
README.md
13
README.md
@ -3,8 +3,9 @@ dig.js
|
|||||||
|
|
||||||
| [dns-suite](https://git.coolaj86.com/coolaj86/dns-suite)
|
| [dns-suite](https://git.coolaj86.com/coolaj86/dns-suite)
|
||||||
| **dig.js**
|
| **dig.js**
|
||||||
|
| [mdig.js](https://git.coolaj86.com/coolaj86/mdig.js)
|
||||||
| [digd.js](https://git.coolaj86.com/coolaj86/digd.js)
|
| [digd.js](https://git.coolaj86.com/coolaj86/digd.js)
|
||||||
| Sponsored by [Daplie](https://daplie.com).
|
| Sponsored by [ppl](https://ppl.family)[.](https://dapliefounder.com)
|
||||||
|
|
||||||
Create and capture DNS and mDNS query and response packets to disk as binary and/or JSON.
|
Create and capture DNS and mDNS query and response packets to disk as binary and/or JSON.
|
||||||
Options are similar to the Unix `dig` command. Supports dns0x20 security checking.
|
Options are similar to the Unix `dig` command. Supports dns0x20 security checking.
|
||||||
@ -27,7 +28,7 @@ npm install -g 'git+https://git.coolaj86.com/coolaj86/dig.js.git#v1.0.0'
|
|||||||
### without git
|
### without git
|
||||||
|
|
||||||
Don't have git? Well, you can also bow down to the gods of the centralized, monopolized, concentrated, *dictator*net
|
Don't have git? Well, you can also bow down to the gods of the centralized, monopolized, concentrated, *dictator*net
|
||||||
(as we like to call it here at Daplie Labs), if that's how you roll:
|
(as we like to call it here at ppl Labs), if that's how you roll:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -g dig.js
|
npm install -g dig.js
|
||||||
@ -43,7 +44,7 @@ dig.js [TYPE] <domainname>
|
|||||||
**Example**:
|
**Example**:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
dig.js daplie.com
|
dig.js coolaj86.com
|
||||||
```
|
```
|
||||||
|
|
||||||
### mDNS Browser Example
|
### mDNS Browser Example
|
||||||
@ -63,9 +64,9 @@ dig.js -p 5353 @224.0.0.251 PTR _services._dns-sd._udp.local +time=3
|
|||||||
### Moar Examples
|
### Moar Examples
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
dig.js A daplie.com
|
dig.js A coolaj86.com
|
||||||
|
|
||||||
dig.js @8.8.8.8 A daplie.com
|
dig.js @8.8.8.8 A coolaj86.com
|
||||||
```
|
```
|
||||||
|
|
||||||
Options
|
Options
|
||||||
@ -79,7 +80,7 @@ Options
|
|||||||
-t <type> (superfluous) A, CNAME, MX, etc. Also supports -t type<decimal> for "unsupported" types. default ANY (mdns default: PTR)
|
-t <type> (superfluous) A, CNAME, MX, etc. Also supports -t type<decimal> for "unsupported" types. default ANY (mdns default: PTR)
|
||||||
-c <class> default IN
|
-c <class> default IN
|
||||||
-p <port> default 53 (mdns default: 5353) (listener is random for DNS and 5353 for mDNS)
|
-p <port> default 53 (mdns default: 5353) (listener is random for DNS and 5353 for mDNS)
|
||||||
-q <query> (superfluous) required (ex: daplie.com)
|
-q <query> (superfluous) required (ex: coolaj86.com)
|
||||||
--nameserver <ns> alias of @<nameserver>
|
--nameserver <ns> alias of @<nameserver>
|
||||||
--timeout <ms> alias of +time=<seconds>, but in milliseconds
|
--timeout <ms> alias of +time=<seconds>, but in milliseconds
|
||||||
|
|
||||||
|
56
bin/dig.js
56
bin/dig.js
@ -22,7 +22,7 @@ cli.parse({
|
|||||||
, 'nameserver': [ false, 'the nameserver to use for DNS resolution (defaults to ' + defaultNameservers.join(',') + ')', 'string' ]
|
, 'nameserver': [ false, 'the nameserver to use for DNS resolution (defaults to ' + defaultNameservers.join(',') + ')', 'string' ]
|
||||||
//, 'serve': [ 's', 'path to json file with array of responses to issue for given queries', 'string' ]
|
//, 'serve': [ 's', 'path to json file with array of responses to issue for given queries', 'string' ]
|
||||||
, 'type': [ 't', 'type (defaults to ANY for dns and PTR for mdns)', 'string' ]
|
, 'type': [ 't', 'type (defaults to ANY for dns and PTR for mdns)', 'string' ]
|
||||||
, 'query': [ 'q', 'a superfluous explicit option to set the query as a command line flag' ]
|
, 'query': [ 'q', 'a superfluous explicit option to set the query as a command line flag', 'string' ]
|
||||||
, 'norecase': [ false, 'Disable dns0x20 security checking (mixed casing). See https://dyn.com/blog/use-of-bit-0x20-in-dns-labels/' ]
|
, 'norecase': [ false, 'Disable dns0x20 security checking (mixed casing). See https://dyn.com/blog/use-of-bit-0x20-in-dns-labels/' ]
|
||||||
, 'recase': [ false, "Print the dns0x20 casing as-is rather than converting it back to lowercase. This is the default when explicitly using mixed case." ]
|
, 'recase': [ false, "Print the dns0x20 casing as-is rather than converting it back to lowercase. This is the default when explicitly using mixed case." ]
|
||||||
});
|
});
|
||||||
@ -30,14 +30,16 @@ cli.parse({
|
|||||||
var common = require('../common.js');
|
var common = require('../common.js');
|
||||||
|
|
||||||
cli.main(function (args, cli) {
|
cli.main(function (args, cli) {
|
||||||
|
cli.implicitType = cli.type;
|
||||||
|
cli.implicitQuery = cli.query;
|
||||||
args.forEach(function (arg) {
|
args.forEach(function (arg) {
|
||||||
if (typeRe.test(arg) || -1 !== common.types.concat([ 'ANY' ]).indexOf(arg.toUpperCase())) {
|
if (typeRe.test(arg) || -1 !== common.types.concat([ 'ANY' ]).indexOf(arg.toUpperCase())) {
|
||||||
if (cli.type) {
|
if (cli.implicitType) {
|
||||||
console.error("'type' was specified more than once");
|
console.error("'type' was specified more than once");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cli.type = cli.t = arg.toUpperCase();
|
cli.implicitType = cli.t = arg.toUpperCase();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,15 +83,41 @@ cli.main(function (args, cli) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cli.query) {
|
if ('string' === typeof cli.implicitQuery) {
|
||||||
console.error("'query' was specified more than once or unrecognized flag: " + cli.query + ", " + arg);
|
console.error("'query' was specified more than once or unrecognized flag: " + cli.implicitQuery + ", " + arg);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cli.query = cli.q = arg;
|
cli.implicitQuery = cli.q = arg;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// it can happen that a TLD is created with the name of a common type
|
||||||
|
if (!cli.type && cli.implicitType && !cli.implicitQuery) {
|
||||||
|
cli.implicitQuery = cli.implicitType;
|
||||||
|
cli.implicitType = null;
|
||||||
|
}
|
||||||
|
if ('string' === typeof cli.implicitQuery) {
|
||||||
|
cli.query = cli.implicitQuery;
|
||||||
|
}
|
||||||
|
if (cli.implicitType) {
|
||||||
|
cli.type = cli.implicitType;
|
||||||
|
}
|
||||||
|
if ('string' !== typeof cli.query) {
|
||||||
|
console.error('');
|
||||||
|
console.error('Usage:');
|
||||||
|
console.error('dig.js [@server] [TYPE] [domain]');
|
||||||
|
console.error('');
|
||||||
|
console.error('Example:');
|
||||||
|
console.error('dig.js daplie.com');
|
||||||
|
console.error('');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
if (cli.query !== cli.query.toLowerCase()) {
|
||||||
|
cli.norecase = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (cli.mdns) {
|
if (cli.mdns) {
|
||||||
if (!cli.type) {
|
if (!cli.type) {
|
||||||
cli.type = cli.t = 'PTR';
|
cli.type = cli.t = 'PTR';
|
||||||
@ -100,7 +128,7 @@ cli.main(function (args, cli) {
|
|||||||
if (!cli.nameserver) {
|
if (!cli.nameserver) {
|
||||||
cli.nameserver = '224.0.0.251';
|
cli.nameserver = '224.0.0.251';
|
||||||
}
|
}
|
||||||
if (!cli.query) {
|
if ('string' !== typeof cli.query) {
|
||||||
cli.query = '_services._dns-sd._udp.local';
|
cli.query = '_services._dns-sd._udp.local';
|
||||||
}
|
}
|
||||||
if (!cli.timeout) {
|
if (!cli.timeout) {
|
||||||
@ -112,10 +140,6 @@ cli.main(function (args, cli) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cli.query !== cli.query.toLowerCase()) {
|
|
||||||
cli.norecase = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cli.norecase) {
|
if (!cli.norecase) {
|
||||||
cli.casedQuery = cli.query.split('').map(function (ch) {
|
cli.casedQuery = cli.query.split('').map(function (ch) {
|
||||||
// dns0x20 takes advantage of the fact that the binary operation for toUpperCase is
|
// dns0x20 takes advantage of the fact that the binary operation for toUpperCase is
|
||||||
@ -138,16 +162,6 @@ cli.main(function (args, cli) {
|
|||||||
if (!cli.class) {
|
if (!cli.class) {
|
||||||
cli.class = cli.c = 'IN';
|
cli.class = cli.c = 'IN';
|
||||||
}
|
}
|
||||||
if (!cli.query) {
|
|
||||||
console.error('');
|
|
||||||
console.error('Usage:');
|
|
||||||
console.error('dig.js [@server] [TYPE] [domain]');
|
|
||||||
console.error('');
|
|
||||||
console.error('Example:');
|
|
||||||
console.error('dig.js daplie.com');
|
|
||||||
console.error('');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
var query = {
|
var query = {
|
||||||
header: {
|
header: {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dig.js",
|
"name": "dig.js",
|
||||||
"version": "1.3.6",
|
"version": "1.3.9",
|
||||||
"description": "Create and capture DNS and mDNS query and response packets to disk as binary and/or JSON. Options are similar to the Unix `dig` command.",
|
"description": "Create and capture DNS and mDNS query and response packets to disk as binary and/or JSON. Options are similar to the Unix `dig` command.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"homepage": "https://git.coolaj86.com/coolaj86/dig.js",
|
"homepage": "https://git.coolaj86.com/coolaj86/dig.js",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user