2023-06-21 07:33:51 +00:00
|
|
|
// virustotal.js
|
|
|
|
// Namhyeon Go <abuse@catswords.net>
|
|
|
|
|
|
|
|
var FILE = require("lib/file");
|
|
|
|
var HTTP = require("lib/http");
|
|
|
|
var Chrome = require("lib/chrome");
|
|
|
|
var RAND = require("lib/rand");
|
|
|
|
|
|
|
|
function getHashes() {
|
2023-06-21 07:41:32 +00:00
|
|
|
var rows = [];
|
2023-06-21 07:33:51 +00:00
|
|
|
|
2023-10-30 04:56:43 +00:00
|
|
|
var lines = splitLn(FILE.readFile("data\\hashes.txt", FILE.CdoCharset.CdoUTF_8));
|
2023-06-21 07:41:32 +00:00
|
|
|
for (var i = 0; i < lines.length; i++) {
|
|
|
|
var row = lines[i].split(',');
|
|
|
|
if (row.length == 2) rows.push(row);
|
|
|
|
if (row.length == 1) rows.push(['', row[0]]);
|
2023-06-21 07:33:51 +00:00
|
|
|
}
|
|
|
|
|
2023-06-21 07:41:32 +00:00
|
|
|
return rows;
|
2023-06-21 07:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function main(args) {
|
|
|
|
var hashes = getHashes();
|
|
|
|
var lines = [];
|
|
|
|
var wbInstance = Chrome.startWithDebugging("https://virustotal.com", null, "virustotal", 9222);
|
|
|
|
|
2024-12-18 10:07:17 +00:00
|
|
|
// Wait
|
2023-06-21 07:33:51 +00:00
|
|
|
sleep(5000);
|
|
|
|
|
2024-12-18 10:07:17 +00:00
|
|
|
// finding browser tap
|
2023-06-21 07:33:51 +00:00
|
|
|
pages = wbInstance.getPagesByTitle("VirusTotal");
|
|
|
|
if (pages.length > 0) {
|
|
|
|
page = pages[0];
|
|
|
|
wbInstance.setPageId(page.id);
|
|
|
|
wbInstance.autoAdjustByWindow(1920, 1080, 1050, 1200, 800, 950);
|
|
|
|
}
|
|
|
|
|
|
|
|
var callback1 = function(row) {
|
|
|
|
var hash = row[1];
|
|
|
|
|
2024-12-18 10:07:17 +00:00
|
|
|
console.log("Attempt exploring:", hash);
|
2023-06-21 07:33:51 +00:00
|
|
|
|
|
|
|
wbInstance.navigate("https://www.virustotal.com/gui/file/" + hash);
|
|
|
|
sleep(RAND.getInt(4000, 5000));
|
|
|
|
|
2024-12-18 10:07:17 +00:00
|
|
|
// Indicates whether data was found
|
2023-06-21 07:33:51 +00:00
|
|
|
var msgNotFound = wbInstance.getEvaluatedValue(
|
|
|
|
"__getDocument().querySelector('vt-ui-shell').shadowRoot.querySelector('#mainContent').querySelector('slot').assignedNodes()[2]" +
|
|
|
|
wbInstance.getShadowRootSelector([
|
|
|
|
"search-view",
|
|
|
|
"vt-ui-special-states"
|
|
|
|
]) +
|
|
|
|
".shadowRoot.querySelector('.title slot').assignedNodes()[0].innerText"
|
|
|
|
);
|
|
|
|
if (msgNotFound == "No matches found") {
|
2024-12-18 10:07:17 +00:00
|
|
|
console.log("No matches found"): " + hash);
|
2023-06-21 07:33:51 +00:00
|
|
|
lines.push([hash, '', '0', '0', '0', ''].join(','));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-12-18 10:07:17 +00:00
|
|
|
// Check how many times it was examined to detect and diagnose viruses
|
2023-06-21 07:33:51 +00:00
|
|
|
var positives = wbInstance.getEvaluatedValue(
|
|
|
|
"__getDocument().querySelector('vt-ui-shell').shadowRoot.querySelector('#mainContent').querySelector('slot').assignedNodes()[2]" +
|
|
|
|
wbInstance.getShadowRootSelector([
|
|
|
|
"file-view",
|
|
|
|
"vt-ui-main-generic-report",
|
|
|
|
"vt-ui-detections-widget"
|
|
|
|
]) +
|
|
|
|
".shadowRoot.querySelector('div > div > div.positives').innerText"
|
|
|
|
);
|
|
|
|
|
2024-12-18 10:07:17 +00:00
|
|
|
// known filename
|
2023-06-21 07:33:51 +00:00
|
|
|
var filename = wbInstance.getEvaluatedValue(
|
|
|
|
"__getDocument().querySelector('vt-ui-shell').shadowRoot.querySelector('#mainContent').querySelector('slot').assignedNodes()[2]" +
|
|
|
|
wbInstance.getShadowRootSelector([
|
|
|
|
"file-view",
|
|
|
|
"vt-ui-file-card"
|
|
|
|
]) +
|
2023-06-21 07:52:03 +00:00
|
|
|
".shadowRoot.querySelector('div > div.card-body > div > div.hstack.gap-4 > div.vstack.gap-2.align-self-center.text-truncate > div.file-name.text-truncate > a').innerText"
|
2023-06-21 07:33:51 +00:00
|
|
|
);
|
|
|
|
|
2024-12-18 10:07:17 +00:00
|
|
|
// Check the latest date of the examination to detect and diagnose a virus
|
2023-06-21 07:33:51 +00:00
|
|
|
var last = wbInstance.getEvaluatedValue(
|
|
|
|
"__getDocument().querySelector('vt-ui-shell').shadowRoot.querySelector('#mainContent').querySelector('slot').assignedNodes()[2]" +
|
|
|
|
wbInstance.getShadowRootSelector([
|
|
|
|
"file-view",
|
|
|
|
"vt-ui-file-card"
|
|
|
|
]) +
|
2023-06-21 07:52:03 +00:00
|
|
|
".shadowRoot.querySelector('div > div.card-body > div > div.hstack.gap-4 > div:nth-child(5) > vt-ui-time-ago').getAttribute('data-tooltip-text')"
|
2023-06-21 07:33:51 +00:00
|
|
|
);
|
|
|
|
|
2024-12-18 10:07:17 +00:00
|
|
|
// Check whether a Korean vaccine programme has examined to detect and diagnose virus
|
2023-06-21 07:33:51 +00:00
|
|
|
var score_undetected = wbInstance.getEvaluatedValue(
|
|
|
|
'Object.values(' +
|
|
|
|
"__getDocument().querySelector('vt-ui-shell').shadowRoot.querySelector('#mainContent').querySelector('slot').assignedNodes()[2].querySelector('file-view').shadowRoot.querySelector('vt-ui-main-generic-report').querySelector('.tab-slot')" +
|
|
|
|
wbInstance.getShadowRootSelector([
|
|
|
|
"vt-ui-detections-list",
|
|
|
|
"vt-ui-expandable"
|
|
|
|
]) +
|
|
|
|
".querySelectorAll('.detection')).reduce(function(a, x) { if(/AhnLab|ALYac|ViRobot/.test(x.innerText) && x.innerText.indexOf('Undetected') > -1) a = a + 1; return a; }, 0)"
|
|
|
|
);
|
|
|
|
|
2024-12-18 10:07:17 +00:00
|
|
|
console.log("hash:", hash);
|
|
|
|
console.log("known filename:", filename);
|
|
|
|
console.log("examined the whole to detect and diagnose viruses :", positives);
|
|
|
|
console.log("date of the latest activity:", last);
|
|
|
|
console.log("Hasn ' t examined with a Korean vaccine programme to detect and diagnose viruses:", score_undetected + "건");
|
2023-06-21 07:33:51 +00:00
|
|
|
|
2024-12-18 10:07:17 +00:00
|
|
|
// create lines for writing
|
2023-06-21 07:33:51 +00:00
|
|
|
lines.push([hash, filename, '1', positives, score_undetected, last].join(','));
|
|
|
|
};
|
|
|
|
|
|
|
|
hashes.forEach(callback1);
|
|
|
|
|
2023-10-30 04:56:43 +00:00
|
|
|
FILE.appendFile("data\\vt_matches_2.txt", lines.join("\r\n"), FILE.CdoCharset.CdoUTF_8);
|
2023-06-21 07:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.main = main;
|