Created
May 5, 2022 04:46
-
-
Save vinhjaxt/6ec09af67241134e524372e5abc4e6bf to your computer and use it in GitHub Desktop.
Add acunetix targets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ENV = { | |
dashboard: 'https://xxxx/', | |
api_key: 'xxxx' | |
} | |
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0 | |
const dns = require('dns') | |
const fs = require('fs') | |
const ifetch = require('ifetch-node') | |
const fetch = ifetch.defaults({ | |
url: ENV.dashboard, | |
headers: { | |
Accept: 'application/json', | |
'X-Auth': ENV.api_key | |
}, | |
json: true, | |
}) | |
const groupIdMap = Object.create(null) | |
function getGroups() { | |
return fetch('/api/v1/target_groups', { | |
method: 'GET', | |
}).then(r => { | |
for (const g of r.groups) { | |
console.log('Found group:', g.name) | |
groupIdMap[g.name] = g.group_id | |
} | |
}) | |
} | |
function createGroup(name) { | |
return fetch('/api/v1/target_groups', { | |
method: 'POST', | |
json: { | |
"name": name, | |
"description": name, | |
} | |
}).then(r => { | |
if (!r.group_id) throw new Error(JSON.stringify(r)) | |
groupIdMap[name] = r.group_id | |
console.log('Created group:', name, r.group_id) | |
}) | |
} | |
function createTargets(targets, groupId) { | |
if (!Array.isArray(targets)) targets = [targets] | |
return fetch('/api/v1/targets/add', { | |
method: 'POST', | |
json: { | |
"targets": targets.map(url => { | |
return { | |
"address": url, | |
"description": url, | |
"type": "default", | |
"criticality": 0 // business Criticality (Critical [30], High [20], Normal [10], Low [0]) | |
} | |
}), | |
"groups": [ | |
groupId | |
] | |
} | |
}).then(r => { | |
if (!r.targets) throw new Error(JSON.stringify(r)) | |
}) | |
} | |
function dnsResolve(name, type) { | |
return new Promise((resolve, reject) => { | |
dns.resolve(name, type, (e, r) => { | |
if (e) return reject(e) | |
resolve(r) | |
}) | |
}) | |
} | |
function httpLive(url) { | |
return ifetch(url, { | |
timeout: 7000 | |
}).then(() => url).catch(e => { }) | |
} | |
async function checkLive(name) { | |
const prms = [] | |
prms.push(httpLive('https://' + name)) | |
prms.push(httpLive('http://' + name)) | |
for (const prm of prms) { | |
const t = await prm | |
if (t) return t | |
} | |
return false | |
} | |
!(async () => { | |
try { | |
await getGroups() | |
const files = fs.readdirSync(__dirname + '/targets') | |
for (const f of files) { | |
const targets = fs.readFileSync(__dirname + '/targets/' + f).toString().split('\n') | |
let currentGroup | |
for (let t of targets) { | |
t = t.trim() | |
if (!t || t.startsWith('#')) continue | |
if (t[0] === ':') { | |
currentGroup = t.substr(1) | |
if (!groupIdMap[currentGroup]) | |
await createGroup(currentGroup) | |
continue | |
} | |
let url = await checkLive(t) | |
if (!url) continue | |
console.log(url) | |
await createTargets(url, groupIdMap[currentGroup]) | |
} | |
} | |
} catch (e) { | |
console.error(e) | |
} | |
})().then(() => console.log('Done')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://securitytrails.com/list/apex_domain/mic.gov.vn | |
# get-gov.vn.js | |
:Danh sách subdomains mic.gov.vn (05/05/2022) | |
mic.gov.vn | |
egov.mic.gov.vn | |
ncov.mic.gov.vn | |
news.mic.gov.vn | |
ict.mic.gov.vn | |
e-services.mic.gov.vn | |
dichvucong3.mic.gov.vn | |
vaithieu.mic.gov.vn | |
mailbox.mic.gov.vn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment