-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
78 lines (71 loc) · 2.13 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import yargs from 'yargs/yargs'
import { hideBin } from 'yargs/helpers'
import { getRecursiveSubdomains, getSubdomains } from './aggregation'
import { log } from './utils/logger'
import { getPerformanceTimeDelta } from './utils/getPerformanceTimeDelta'
interface Args {
domain: string
outputPath: string
domainFile: string
concurrency: number
}
async function main() {
let argv = yargs(hideBin(process.argv))
.option('domain', {
alias: 'd',
describe: 'The domain to enumerate subdomains for',
type: 'string',
})
.option('outputPath', {
alias: 'o',
describe: 'The output file with the found subdomains',
type: 'string',
demandOption: true,
})
.option('domainFile', {
alias: 'f',
decsribe:
'A file with domains separated by line breaks (for recursive enumeration)',
type: 'string',
})
.option('concurrency', {
alias: 'c',
describe: 'Number of concurrent coroutines',
type: 'number',
default: 4,
})
.parseSync() as Args
let results: string[] = []
const { outputPath } = argv
if (Object.prototype.hasOwnProperty.call(argv, 'domain') && argv.domain) {
const { domain } = argv
const timeAtStart = performance.now()
log(`Enumerating subdomains for [${domain}]`)
results = await getSubdomains(domain)
const timeAtEnd = performance.now()
log(
`Subdomain enumeration completed - ${getPerformanceTimeDelta(
timeAtEnd,
timeAtStart
)}`
)
} else if (
Object.prototype.hasOwnProperty.call(argv, 'domainFile') &&
argv.domainFile
) {
const { domainFile, concurrency } = argv
const domains = (await Bun.file(domainFile).text()).split('\n')
const timeAtStart = performance.now()
log(`Enumerating recursive subdomains for input file [${domainFile}]`)
results = await getRecursiveSubdomains(domains, concurrency)
const timeAtEnd = performance.now()
log(
`Recursive subdomain enumeration completed - ${getPerformanceTimeDelta(
timeAtEnd,
timeAtStart
)}`
)
}
await Bun.write(outputPath, results.join('\n'))
}
main()