Script To Resolve DNS

From Observer GigaFlow Support | VIAVI Solutions Inc.
Jump to: navigation, search
var utils = Java.type('ros.CROSUtils');
var InetAddress = Java.type('java.net.InetAddress');
var PrintWriter = Java.type('java.io.PrintWriter');
var writer = new PrintWriter("./dns"+utils.now()+".txt", "UTF-8");
var subnets=[
 {start:"172.21.40.10",end:"172.21.40.20"},
 {start:"172.21.40.100",end:"172.21.40.110"}
]
for (var s in subnets){
	testSubnet(subnets[s]);
}
writer.close();
function testSubnet(subnet){

for (var t=utils.inet_atoi(subnet.start);t<utils.inet_atoi(subnet.end);t++){

       var inet=InetAddress.getByName(utils.inet_itoa(t));
       log.warn(utils.inet_itoa(t)+"\t"+inet.getHostName());
       writer.println(utils.inet_itoa(t)+"\t"+inet.getHostName());

}

}