Skip to content

Instantly share code, notes, and snippets.

@myalcin81
Forked from omarkurt/nss.js
Last active December 2, 2020 06:58
Show Gist options
  • Save myalcin81/27b280713e7c20afc595734e8a32d4e9 to your computer and use it in GitHub Desktop.
Save myalcin81/27b280713e7c20afc595734e8a32d4e9 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name NC
// @namespace http://sahvemat.com
// @version 0.9
// @description try to take over the world!
// @author You
// @updateURL https://gist.githubusercontent.com/myalcin81/27b280713e7c20afc595734e8a32d4e9/raw/nss.js
// @match https://www.netsparkercloud.com/*
// @match https://*.netsparker.cloud/*
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==
/*$(document).on('keydown', function ( e ) {
// You may replace `c` with whatever key you want
if ((e.metaKey || e.ctrlKey) && ( String.fromCharCode(e.which).toLowerCase() === 'z') ) { */
$(document).ready(function () {
String.prototype.replaceAll = function (search, replacement) {
var target = this;
return target.replace(new RegExp(search, 'g'), replacement);
};
function convertMS(ms) {
var d,
h,
m,
s;
s = Math.floor(ms / 1000);
m = Math.floor(s / 60);
s = s % 60;
h = Math.floor(m / 60);
m = m % 60;
d = Math.floor(h / 24);
h = h % 24;
var pad = function (n) {
return n < 10 ? '0' + n : n;
};
var result = d + 'd ' + pad(h) + 'h ' + pad(m) + "m";
return result;
};
function GetUrlRewriteRules() {
var arr = [];
$(".urlrewrite-placeholderPattern").each(function () {
arr.push(this.value)
})
//console.dir(arr);
console.log("please copy following expression and paste your NE ");
var out = "var serializedStr='" + JSON.stringify(arr) + "';";
out += "var arr = JSON.parse( serializedStr );";
out += 'for(i=0;i<arr.length;i++){if($(".urlrewrite-placeholderPattern")[i]==undefined){$(".grid-create-row").click();}}';
out += '(function doIt(i) {setTimeout(function() {var obj=$(".urlrewrite-placeholderPattern");var ix=(obj.length-i);obj[ix].value=arr[ix];if (--i){doIt(i);}}, 100)})(arr.length);';
console.log(out);
}
function convertToDate(str) {
// replace '/' with '-'
str = str.replace(/\//ig, '-');
/**
* extracting the year, month, day, hours and minutes.
* the month, day and hours can be 1 or 2 digits(the leading zero is optional).
* i.e: '4/3/2022 2:18 AM' is the same as '04/03/2022 02:18 AM' => Notice the absence of the leading zero.
**/
var y = /\-([\d]{4})/.exec(str)[1],
m = /\-([\d]{2}|[\d])/.exec(str)[1],
d = /([\d]{2}|[\d])\-/.exec(str)[1],
H = /\s([\d]{2}|[\d]):/.exec(str)[1],
i = /:([\d]{2})/.exec(str)[1],
AMorPM = /(AM|PM)/.exec(str)[1];
// return a Date instance.
return new Date(y + '-' + m + '-' + d + ' ' + H + ':' + i + ' ' + AMorPM)
}
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
};
function fallbackCopyTextToClipboard(text) {
var textArea = document.createElement("textarea");
textArea.value = text;
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Fallback: Copying text command was ' + msg);
} catch (err) {
console.error('Fallback: Oops, unable to copy', err);
}
document.body.removeChild(textArea);
}
function copyTextToClipboard(text) {
if (!navigator.clipboard) {
fallbackCopyTextToClipboard(text);
return;
}
navigator.clipboard.writeText(text).then(function () {
console.log('Async: Copying to clipboard was successful!');
}, function (err) {
console.error('Async: Could not copy text: ', err);
});
}
var getVuln = function (vulnerabilityId) {
var navUrl = "";
if (location.href.indexOf("vulnerabilityId") > 0) {
navUrl = location.href.split("vulnerabilityId")[0] + "vulnerabilityId=" + vulnerabilityId;
} else {
navUrl = location.href + "?vulnerabilityId=" + vulnerabilityId;
}
console.log(navUrl);
location.href = navUrl;
};
//scan listesi icin js
if (location.href.indexOf("Scans/Index") > 0) {
$("table#scans_index_recent-scans-table thead tr th:nth-child(6)").before("<th>Duration</th>");
$("table#scans_index_recent-scans-table tbody tr td:nth-child(6)").before('<td class="duration">Duration</td>');
$.each($("table#scans_index_recent-scans-table tbody tr"), function (rowIndex, r) {
// console.log($(r).find(".duration"));
var start = "",
end = "";
try {
start = $(r).find(".duration").next().text();
} catch (err) {}
try {
end = $(r).find(".duration").next().next().text();
} catch (err) {}
var startReady = 0;
var endReady = 0;
if (start.toLowerCase().indexOf("am") > 0 || start.toLowerCase().indexOf("pm") > 0) {
// console.log(start);
start = convertToDate(start);
startReady = 1;
}
if (end.toLowerCase().indexOf("am") > 0 || end.toLowerCase().indexOf("pm") > 0) {
// console.log(end);
end = convertToDate(end);
endReady = 1;
}
//console.log(start);console.log(end);
if (startReady == 1 && endReady == 1) {
var diff = end.getTime() - start.getTime();
// console.log("diff"+diff);
var text = convertMS(diff).trim();
if (
text == "0d 0h 04m" || text == "0d 00h 03m" || text == "0d 00h 02m" || text == "0d 00h 01m" || text == "0d 00h 00m") {
text = "<h3>" + text + "</h3>";
}
$(r).find(".duration").html(text);
} else if (startReady == 1 && endReady == 0) {
$(r).find(".duration").html("-");
} else {
$(r).find(".duration").html(end + "." + start);
}
});
}
//scan profile sayfasi icin js
if (location.href.indexOf("scans/new") > 0) {
var urlRewriteCopy = '<input type="button" id="urlRewriteCopy" value="urlRewriteCopy!">';
urlRewriteCopy.addEventListener('click', function (event) {
copyTextToClipboard($("#urlRewriteCopy").GetUrlRewriteRules());
});
}
//report detay sayfasi icin js
if (location.href.indexOf("scans/report") > 0) {
var curVulnId = "";
curVulnId = getUrlParameter("vulnerabilityId");
var vulnIndex = -1;
if (curVulnId == undefined)
vulnIndex = -1;
else if (curVulnId == "")
vulnIndex = -1;
else
vulnIndex = model["Vulnerabilities"].findIndex(function (x) {
return x.VulnerabilityId == curVulnId
});
$("body").append('<style>.vulnbutton{position:fixed;bottom:50px;right:50px;}.vulnbutton button{font-size:25px;}</style>');
$("body").append('<div class="vulnbutton"><button class="upBtn ">Back Vuln</button><button class="downBtn ">Next Vuln</button>');
$(".upBtn").click(function () {
var goIndex = 0;
if (vulnIndex < model["Vulnerabilities"].length - 1)
goIndex = vulnIndex + 1;
if (vulnIndex == model["Vulnerabilities"].length - 1)
goIndex = 0;
if (vulnIndex == -1)
goIndex = 0;
console.log(goIndex);
getVuln(model["Vulnerabilities"][goIndex].VulnerabilityId);
});
$(".downBtn").click(function () {
var goIndex = 0;
if (vulnIndex > 0)
goIndex = vulnIndex - 1;
if (vulnIndex == 0)
goIndex = model["Vulnerabilities"].length - 1;
if (vulnIndex == -1)
goIndex = 0;
console.log(goIndex);
getVuln(model["Vulnerabilities"][goIndex].VulnerabilityId);
});
var site = $("body").find("#scan-detail-summary > div > div > div > div:nth-child(1) > div:nth-child(1) > div.col-md-7 > table > tbody > tr:contains('Target URL') > td > a").eq(0).text().trim();
var scandate = $("body").find("#scan-detail-summary > div > div > div > div:nth-child(1) > div:nth-child(1) > div.col-md-7 > table > tbody > tr:contains('Initiated') > td").text().trim();
var duration = $("body").find("#scan-detail-summary > div > div > div > div:nth-child(1) > div:nth-child(1) > div.col-md-7 > table > tbody > tr:contains('Duration') > td").eq(0).text().trim();
var policy = $("body").find("#scan-detail-summary > div > div > div > div:nth-child(1) > div:nth-child(1) > div.col-md-7 > table > tbody > tr:contains('Scan Policy') > td > a").text().trim();
var ReportUrl = location.href;
var ScanAuth = $("body").find("#scan-detail-summary > div > div > div > div:nth-child(1) > div:nth-child(1) > div.col-md-7 > table > tbody > tr:contains('Authentication') > th").text().trim();
var IsHeuristic = $("body").find("#scan-detail-summary > div > div > div > div:nth-child(1) > div:nth-child(2) > div > table > tbody > tr:contains('URL Rewrite Mode') > td > a").text().trim();
console.log("Site", $.trim(site));
site = site.replaceAll(",", " ");
policy = policy.replaceAll(",", "_");
if (ReportUrl.indexOf("/?") > 0)
ReportUrl = ReportUrl.split("/?")[0];
/* console.log("Site",$.trim(site));
console.log("Scan Date ",$.trim(scandate));
console.log("Duration ",$.trim(duration));
console.log("Policy",$.trim(policy));
console.log("ScansURL",$.trim(ReportUrl));
console.log("Custom URL?",$.trim(IsHeuristic)); */
if (ScanAuth == "") {
ScanAuth = "None";
} else {
ScanAuth = $.trim($("Body").find("#scan-detail-summary > div > div > div > div:nth-child(1) > div:nth-child(1) > div.col-md-7 > table > tbody > tr:contains('Authentication') > td > a").text());
if (ScanAuth.trim() == "Form Authentication") {
ScanAuth = "Form Auth";
} else if (ScanAuth.trim() == "Header Authentication") {
ScanAuth = "Header Auth";
} else {
ScanAuth = "ALEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEERT";
}
}
console.log("Auth", ScanAuth);
var misc = ScanAuth + " - " + $.trim(IsHeuristic) + " - " + $.trim(policy);
var complete = "" + $.trim(site) + "," + $.trim(scandate) + "," + $.trim(duration) + "," + $.trim(ReportUrl) + " ,-," + misc + "";
console.log(complete);
var copyHTML = '<input type="button" id="copyBuddy" value="Data Extract!">';
$(".content").prepend(copyHTML + '<br/><span id="copyHTML">' + complete + "</span>");
copyBuddy.addEventListener('click', function (event) {
copyTextToClipboard($("#copyHTML").text());
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment