I'm trying to display ping information in a html page that is presented in JSON format. I have some what achived it but i can't figure out how to print it out in an ordered way.
JS Script
function scanner() {
var evilscan = require("evilscan");
var options = {
target: "10.0.0.161",
port: "21-23",
status: "TROU", // Timeout, Refused, Open, Unreachable
banner: true
};
var scanner = new evilscan(options);
scanner.on("result", function(data) {
// fired when item is matching options
console.log(data);
document.getElementById("pingStatus").innerHTML = JSON.stringify(
data,
undefined,
2
);
});
scanner.on("error", function(err) {
throw new Error(data.toString());
});
scanner.on("done", function() {
// finished !
});
scanner.run();
}
I have taken some inspiration from W3 Schools https://www.w3schools.com/js/tryit.asp?filename=tryjson_parse
Added following to HTML:
<p id="pingStatus" type="text"></p>
But are presented with a JSON string that looks like:
{ "ip": "10.0.0.161", "port": 21, "banner": "", "status": "closed (timeout)" }
What is the best/common way to handle and display strings like this on a HTML page so its displayed like:
Example
- ip: 10.0.0.161
- Port: 21
ect..