Socket
Socket
Sign inDemoInstall

subquest

Package Overview
Dependencies
70
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.3.0

__tests__/bing.js

122

index.js

@@ -6,17 +6,16 @@ var dns = require('native-dns');

var path = require('path');
var debug = require('debug');
var events = require('events');
var path = require('path')
var os = require("os");
// Get the DNS servers addresses
var resolvers = fs.readFileSync(__dirname+'/resolvers.txt').toString().trim().split(os.EOL);
var validResolvers = [];
var resolvers = fs.readFileSync(__dirname+'/resolvers.txt').toString().trim().split('\n');
// Check whether a dns server is valid.
exports.isValidDnsServer = function(dnsServer, cb){
var question = dns.Question({
name: 'www.google.com',
type: 'A',
});
var req = dns.Request({
question: question,
question: dns.Question({
name: 'www.google.com',
type: 'A',
}),
server: { address: dnsServer, port: 53, type: 'udp' },

@@ -33,34 +32,43 @@ timeout: 4000

req.on('message', function (err, answer) {
if(answer.header.rcode == 0)
if(answer.header.rcode == 0) {
cb(true);
else
} else{
cb(false);
}
});
// Send the DNS verification request
req.send();
return;
return;
}
/**
* Get the best resolver in the following order,
* 1. User supplied.
* 2. From our list.
* This is used while specifying Custom DNS Server.
* @param {string} dnsServer The DNS server address as string
* @param {function} result_cb The callback to run once has done
* @return {[type]} [description]
*/
exports.getResolver = function(dnsServer, callback){
// Init results array
var dnsServers = [];
/* Get the best resolver in the following order,
1. User supplied.
2. From our list.
This is used while specifying Custom DNS Server.
*/
exports.getResolver = function(dnsServer, result_cb){
var dnsServers = [];
// Handle the first arg as callback if no server is specified.
if(typeof dnsServer !== 'function')
if(typeof dnsServer !== 'function') {
dnsServers.push(dnsServer);
else
result_cb = dnsServer;
} else{
callback = dnsServer;
}
// Concat the DNS servers arrays
dnsServers = dnsServers.concat(resolvers);
// For each server validate it and run the callback
async.eachSeries(dnsServers, function(server, cb){
exports.isValidDnsServer(server, function(result){
if(result === true){
result_cb(server);
callback(server);
} else {

@@ -74,4 +82,8 @@ cb();

/**
* Get the dictionary files names
* @return {array} Array of file names
*/
exports.getDictionaryNames = function(){
return fs.readdirSync(__dirname+'/dictionary');
return fs.readdirSync(path.join(__dirname, 'dictionary'));
}

@@ -81,7 +93,13 @@

exports.getSubDomains = function(opts){
let defaults = {
dictionary: 'top_50',
dnsServer: '8.8.8.8'
};
var EE = new events.EventEmitter();
opts = Object.assign({}, defaults, opts);
if(!opts.host) EE.emit('error', 'HOST_ERROR');
opts.dictionary = opts.dictionary || 'top_100';
opts.dnsServer = opts.dnsServer || '8.8.8.8';
// Optionally run a bing search
if(opts.bingSearch === true){

@@ -93,10 +111,14 @@ var bingSearch = require('./lib/bingSearch.js');

exports.getResolver(opts.dnsServer, function(dnsServer){
EE.emit('dnsServer', dnsServer);
var dictionary = fs.readFileSync(__dirname+'/dictionary/'+ opts.dictionary+'.txt').toString().trim().split('\n');
var dictionary = fs.readFileSync(path.join(__dirname, `dictionary/${opts.dictionary}.txt`)).toString().trim().split(os.EOL);
var subdomains = [];
var total = dictionary.length;
dictionary.forEach(function(subdomain){
dictionary.forEach(function(subdomain) {
probeDNS(subdomain, opts.host, dnsServer)
.once('found', function(result){
EE.emit('subdomain', result);
.once('found', function(result) {
subdomains.push(result);

@@ -110,21 +132,21 @@ })

})
})
})
return EE;
return EE;
}
// Send DNS requests
// Send DNS requests
function probeDNS(subdomain, tld, dnsServer){
var EE = new events.EventEmitter();
var Sdomain = subdomain + '.' + tld;
var question = dns.Question({
name: Sdomain,
type: 'A',
});
var start = Date.now();
var domain = `${subdomain}.${tld}`;
var req = dns.Request({
question: question,
question: dns.Question({
name: domain,
type: 'A',
}),
server: {address: dnsServer, port: 53, type: 'udp'},

@@ -134,17 +156,15 @@ timeout: 5000

req.on('timeout', function () {
//console.log('Timeout in making request');
});
// rcode = 0 , NoError
// rcode = 3 , NXDomain
req.on('message', function (err, answer) {
if(answer.header.rcode == 0)
EE.emit('found', Sdomain);
if(answer.header.rcode == 0){
EE.emit('found', domain);
}
});
// Emit the end event
req.on('end', function () {
var delta = (Date.now()) - start;
EE.emit('end');
//console.log('Finished processing request: ' + delta.toString() + 'ms');
EE.emit('end');
});

@@ -154,3 +174,3 @@

return EE;
return EE;
}

@@ -15,5 +15,5 @@ // Search bing.com using the 'domain:' dork and retrieve possible sub-domains.

exports.find = function(domainName){
var EE = new events.EventEmitter();
// get a unique list of all hrefs which ends with the '.domain.com' form.

@@ -37,3 +37,3 @@ request('http://www.bing.com/search?count=50&q=domain:'+ domainName, function(err, res, body){

return EE;
return EE;
}
{
"name": "subquest",
"version": "1.2.0",
"version": "1.3.0",
"description": "Fast, Elegant subdomain scanner using nodejs",

@@ -11,9 +11,8 @@ "main": "index.js",

"dependencies": {
"async": "^0.9.0",
"commander": "^2.3.0",
"debug": "^2.0.0",
"native-dns": "^0.6.1",
"request": "^2.47.0",
"cheerio": "^0.17.0",
"lodash": "^2.4.1"
"async": "^2.5.0",
"commander": "^2.11.0",
"native-dns": "^0.7.0",
"request": "^2.83.0",
"cheerio": "^1.0.0-rc.2",
"lodash": "^4.17.4"
},

@@ -24,4 +23,4 @@ "bin": {

"scripts": {
"prepublish": "npm prune",
"test": "mocha ./tests/*.js"
"prepublish": "nsp check",
"test": "jest --coverage"
},

@@ -52,5 +51,5 @@ "engines": {

"devDependencies": {
"mocha": "^1.21.4",
"should": "^4.0.4"
"jest": "^21.2.1",
"nsp": "^2.8.1"
}
}
}
# subquest
### Fast, Elegant subdomain scanner using nodejs
![logo](https://raw.github.com/skepticfx/subquest/master/etc/logo.png)
## Status
[![Build Status](https://travis-ci.org/skepticfx/subquest.svg?branch=master)](https://travis-ci.org/skepticfx/subquest)
> Fast, Elegant subdomain scanner using nodejs
![logo](logo.png)
## Installation
If you want to use it as cli tool, you must install it globally first:
`sudo npm install -g subquest`

@@ -32,22 +31,25 @@

## Using it in your modules
If you want to use it as a node module you can install and add it to your project dependencies:
`npm install subquest`
```
npm install subquest
```
Than you can __require__ it in your script and use various methods:
```js
var subquest = require('subquest');
console.log('Scanning the sub domains of ea.com with 4 requests at a time.');
subquest
.getSubDomains({
host: 'ea.com', // required
rateLimit:'4',
dnsServer:'4.2.2.2',
dictionary: 'top_200'
host: 'google.com', // required
rateLimit:'4', // four requests at time
dnsServer:'4.2.2.2', // custom DNS server
dictionary: 'top_200' // dictionary file to use
})
.on('end', function(arr){
console.log(arr); // array of subdomains.
.on('end', function(res){
console.log(res); // array of subdomains.
})
```
This scans ea.com for the list of all subdomains using the top_200 dictionary.
This scans google.com for the list of all subdomains using the top_200 dictionary.

@@ -54,0 +56,0 @@ ## Want to add a new entry to Subquest's dictionary?

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc