mirror of
https://github.com/horsicq/Detect-It-Easy.git
synced 2026-06-24 01:54:08 +00:00
128 lines
No EOL
3.2 KiB
Text
128 lines
No EOL
3.2 KiB
Text
/**
|
|
* The type of the signature. For example <code>compiler</code> or <code>packer</code>.
|
|
*/
|
|
var sType;
|
|
/**
|
|
* The name of the signature.
|
|
*/
|
|
var sName;
|
|
/**
|
|
* The version of the signature.
|
|
*/
|
|
var sVersion;
|
|
/**
|
|
* Options used by the signature.
|
|
*/
|
|
var sOptions;
|
|
/**
|
|
* The flag to indicate the signature was found.
|
|
*/
|
|
var bDetected;
|
|
|
|
/**
|
|
* Initialize a signature.
|
|
* @param {String} [sType="unknown"] - The signature type.
|
|
* @param {String} [sName="unknown"] - The signature name.
|
|
* @param {String} [sVersion=""] - The signature version.
|
|
* @param {String} [sOptions=""] - The signature options.
|
|
*/
|
|
function init() {
|
|
sType = arguments[0] ? arguments[0] : "unknown";
|
|
sName = arguments[1] ? arguments[1] : "unknown";
|
|
sVersion = arguments[2] ? arguments[2] : "";
|
|
sOptions = arguments[3] ? arguments[3] : "";
|
|
bDetected = 0;
|
|
}
|
|
|
|
/**
|
|
* Append one or more strings.
|
|
* @param {...String} sString - String(s) to append.
|
|
* @returns {String} The new string.
|
|
* @global
|
|
* @example
|
|
* sOptions=sOptions.append("debug",string1);
|
|
*/
|
|
String.prototype.append = function() {
|
|
var s = this.valueOf();
|
|
var sep = ",";
|
|
if (arguments.length) {
|
|
if (s) s += sep;
|
|
s += arguments[0];
|
|
for (var i = 1; i < arguments.length; i++) {
|
|
s += sep + arguments[i];
|
|
}
|
|
}
|
|
return s;
|
|
}
|
|
|
|
/**
|
|
* Append a string with a custom separator.
|
|
* @param {String} sString - String to append.
|
|
* @param {String} [sSep=","] - Separator string.
|
|
* @returns {String} The new string.
|
|
* @global
|
|
* @example
|
|
* sOptions=sOptions.appendS("debug","::");
|
|
*/
|
|
String.prototype.appendS = function() {
|
|
var s = this.valueOf();
|
|
var sep = arguments[1] ? arguments[1] : ",";
|
|
if (arguments.length) {
|
|
if (s) s += sep;
|
|
s += arguments[0];
|
|
}
|
|
return s
|
|
}
|
|
|
|
String.prototype.addIfNone = function() {
|
|
var s = this.valueOf();
|
|
if (arguments.length)
|
|
if (s.indexOf(arguments[0]) < 0) s += arguments[0]
|
|
return s;
|
|
}
|
|
|
|
/**
|
|
* Pad the start of a line with spaces or the character given.
|
|
* This reimplements missing functionality of the more modern ECMAScript.
|
|
* @param {String or Number} The width desired.
|
|
* @param {Number} [nPad=" "] The padding string. Loops.
|
|
* @returns {String} The new string.
|
|
* @global
|
|
* @example
|
|
* var a = 12; ...; if("aba12" === a.padStart(5,"ab")) ...
|
|
*/
|
|
String.prototype.padStart = function() {
|
|
var s = this.valueOf();
|
|
if (!s.length || !arguments.length || s.length <= arguments[0].length) return s;
|
|
var c = 0,
|
|
p = ' ';
|
|
if (arguments.length > 1) p = arguments[1].toString();
|
|
var pp = "";
|
|
for (var i = 0; i < Math.max(0, arguments[0] - s.length); i++) {
|
|
pp += p[c];
|
|
c++;
|
|
if (c === p.length) c = 0
|
|
}
|
|
return pp + s
|
|
}
|
|
|
|
Number.prototype.padStart = function() {
|
|
var s = this.valueOf().toString();
|
|
if (!arguments.length || s.length >= arguments[0]) return s;
|
|
var c = 0,
|
|
p = ' ';
|
|
if (arguments.length > 1) p = arguments[1].toString();
|
|
var pp = "";
|
|
for (var i = 0; i < Math.max(0, arguments[0] - s.length); i++) {
|
|
pp += p[c];
|
|
c++;
|
|
if (c === p.length) c = 0
|
|
}
|
|
return pp + s
|
|
}
|
|
|
|
function debug(messageText) {
|
|
_setResult("debug", messageText, "", "");
|
|
}
|
|
|
|
includeScript("language"); |