Skip to content

Commit

Permalink
🚧 feat(whois): Adding whois
Browse files Browse the repository at this point in the history
  • Loading branch information
MedericPixium committed May 17, 2020
1 parent c6649f9 commit af88233
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 13 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"axios": "^0.19.2",
"chalk": "^3.0.0",
"crimson-progressbar": "^1.3.0",
"tslib": "^1"
"tslib": "^1",
"whois-json": "^2.0.4"
},
"devDependencies": {
"@oclif/dev-cli": "^1",
Expand Down Expand Up @@ -56,7 +57,7 @@
"scripts": {
"postpack": "rm -f oclif.manifest.json",
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\" --full-trace",
"version": "oclif-dev readme && git add README.md"
},
"types": "lib/index.d.ts"
Expand Down
2 changes: 0 additions & 2 deletions src/commands/hello.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Command, flags} from '@oclif/command'

export default class Hello extends Command {
static description = 'describe the command here'

Expand All @@ -21,7 +20,6 @@ hello world from ./src/hello.ts!

async run() {
const {args, flags} = this.parse(Hello)

const name = flags.name || 'world'
this.log(`hello ${name} from ./src/commands/hello.ts`)
if (args.file && flags.force) {
Expand Down
22 changes: 14 additions & 8 deletions src/commands/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {intenseScan} from '../tools/scanTools';
import IntenseScan from '../classes/intenseScan';
import * as https from 'https';
import {formatDate} from '../tools/dateFormatter';
import * as whois from 'whois-json';
//-----------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------
// TODO: get path disclosures for basic get
Expand All @@ -24,11 +25,13 @@ export default class Scan extends Command {
]
static flags = {
help: flags.help({ char: 'h' }),
target: flags.string({ char: 't', description: 'target to scan', required: true }),
method: flags.enum({char: 'm', description: 'requet methods can be: GET, POST, BOTH', required: false, options: ["GET", "POST", "BOTH"], default: "POST" }),
shortlist: flags.boolean({ char: 's', description: 'use the shortlist for endpoints', required: true, default: true, allowNo: true}),
output: flags.string({char: 'o', description: 'specify the ouput directory'}),
parameters: flags.boolean({ char: 'p', description: 'use extra parameters on endpoints', required: true, default: true, allowNo: true}),
report: flags.enum({ char: 'r', description: 'type of report to generate', required: true, default: "MD", options: ["MD", "HTML"]}),
shortlist: flags.boolean({ char: 's', description: 'use the shortlist for endpoints', required: true, default: true, allowNo: true}),
target: flags.string({ char: 't', description: 'target to scan', required: true }),
whois: flags.boolean({char: 'w', description: 'perform who is request on the target', required: true, default: true, allowNo: true})
}

async run() {
Expand Down Expand Up @@ -59,17 +62,18 @@ export default class Scan extends Command {
console.log(`Error code: ${error.code}`);
}
}
const reswhois = await whois('mederic.me');
console.log(reswhois);
// If base url can be contacted start basic analysis
// Init report
if (init) {
finalReport.loadFromResponse(init);
if (this.validateStatus(init.status) == true) {
console.log(` - Successfully connected to target`)
console.log(` - Gathering basic header information`)
const result = new Report(init)
console.log(` - Target Powered by: ${chalk.cyan(result.poweredBy)}`)
console.log(` - Target Last Modified at: ${chalk.cyan(result.lastModified)}`)
if (result.cors == "*") {
console.log(` - Target Powered by: ${chalk.cyan(finalReport.poweredBy)}`)
console.log(` - Target Last Modified at: ${chalk.cyan(finalReport.lastModified)}`)
if (finalReport.cors == "*") {
console.log(` - Target ${chalk.cyan('Not CORS protected')}`)
} else {
console.log(` - Target ${chalk.cyan('Is CORS protected')}`)
Expand All @@ -79,7 +83,7 @@ export default class Scan extends Command {
console.log(init.status)
}
} else {
console.log("plop")
console.log(` - Couldn't connect to base target`)
}
// Init an intense scan
let intenseResult: IntenseScan | void = await intenseScan(flags.target, flags.shortlist, flags.parameters, flags.method);
Expand All @@ -94,8 +98,10 @@ export default class Scan extends Command {
finalReport.endDate = endDate;
finalReport.elapsedSeconds = (endDate.getTime() - startDate.getTime()) / 1000;
// Export reports
// command line report
intenseResult.exportSummary();
finalReport.exportSummary(reportType)
// file report
finalReport.exportSummary(reportType, flags.output)
console.log(` - ${chalk.green(formatDate(endDate, "dddd dd MMMM yyyy hh:mm"))}`)
console.log(` - Time Elapsed: ${chalk.green(finalReport.elapsedSeconds)} seconds`)
}
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"outDir": "lib",
"rootDir": "src",
"strict": true,
"target": "es2017"
"target": "es2017",
"composite": true
},
"include": [
"src/**/*"
Expand Down
Loading

0 comments on commit af88233

Please sign in to comment.