Last active
January 25, 2021 19:53
-
-
Save Yuhtin/94b5b621c90e0b2b1bbe3cf9b9cbae81 to your computer and use it in GitHub Desktop.
Resolve DNS
This file contains 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 dns = require('dns'); | |
const axios = require('axios'); | |
const api = axios.create({ baseURL: 'http://ip-api.com' }); | |
const dnsIp = 'netflix.com', | |
resetColor = '[0m', | |
bold = '[28m', | |
backgroundColor = '[7m', | |
pinkColor = '[35m', | |
cyanColor = '[96m', | |
prefix = resetColor + '[' + cyanColor + '+' + resetColor + '] ' + cyanColor + bold + backgroundColor; | |
dns.lookup(dnsIp, (error, address, arguments) => { | |
if (error) throw error; | |
console.log(pinkColor + | |
'██████╗ ███╗ ██╗███████╗ ██████╗ ███████╗███████╗ ██████╗ ██╗ ██╗ ██╗███████╗██████╗ \n' + | |
'██╔══██╗████╗ ██║██╔════╝ ██╔══██╗██╔════╝██╔════╝██╔═══██╗██║ ██║ ██║██╔════╝██╔══██╗ \n' + | |
'██║ ██║██╔██╗ ██║███████╗ ██████╔╝█████╗ ███████╗██║ ██║██║ ██║ ██║█████╗ ██████╔╝ \n' + | |
'██║ ██║██║╚██╗██║╚════██║ ██╔══██╗██╔══╝ ╚════██║██║ ██║██║ ╚██╗ ██╔╝██╔══╝ ██╔══██╗ \n' + | |
'██████╔╝██║ ╚████║███████║ ██║ ██║███████╗███████║╚██████╔╝███████╗╚████╔╝ ███████╗██║ ██║ \n' + | |
'╚═════╝ ╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═════╝ ╚══════╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝') | |
console.log(cyanColor + '\n' | |
+ ' Coded by Yuhtin \n' | |
+ ' Version 1.0-SNAPSHOT \n\n' | |
+ resetColor); | |
console.log('[' + cyanColor + '>' + resetColor + ']' + cyanColor + ' Hostname -> ' + resetColor + dnsIp + '\n'); | |
dnsResolve(address); | |
}); | |
async function dnsResolve(address) { | |
var map = new Array(); | |
var response = await api.get(`/json/${address}`); | |
var data = response.data; | |
map["country"] = data.country, | |
map["countryCode"] = data.countryCode, | |
map["region"] = data.region, | |
map["regionName"] = data.regionName, | |
map["city"] = data.city, | |
map["zip"] = data.zip, | |
map["latitude"] = data.latitude, | |
map["longitude"] = data.longitude, | |
map["timezone"] = data.timezone, | |
map["ipReverse"] = undefined, | |
dns.reverse(address, (error, hostname) => { | |
if (error) return; | |
hostname.forEach(host => { map["ipReverse"] = host; }); | |
}); | |
await new Promise(resolve => setTimeout(resolve, 2000)); | |
for (var key in map) { | |
const value = map[key]; | |
if (value == undefined) continue; | |
console.log(prefix + key + ':' + resetColor + ' ' + resetColor + value) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment