Added the magic flag to regexes to say whether it is useful for magic to use

This commit is contained in:
n1073645 2019-12-04 14:12:27 +00:00
parent 4d9fb7ef58
commit 8df9d6fcf6
43 changed files with 142 additions and 32 deletions

View file

@ -87,13 +87,14 @@ class potentialOps {
for (const op in OperationConfig) { for (const op in OperationConfig) {
if (("inputRegexes" in OperationConfig[op]) && !!(OperationConfig[op].inputRegexes)) if (("inputRegexes" in OperationConfig[op]) && !!(OperationConfig[op].inputRegexes))
OperationConfig[op].inputRegexes.forEach(pattern => { OperationConfig[op].inputRegexes.forEach(pattern => {
opPatterns.push({ if(pattern.magic)
op: op, opPatterns.push({
match: pattern.match, op: op,
flags: pattern.flags, match: pattern.match,
args: pattern.args, flags: pattern.flags,
useful: pattern.useful || false args: pattern.args,
}); useful: pattern.useful || false
});
}); });
} }
@ -110,14 +111,15 @@ class potentialOps {
for (const op in OperationConfig) { for (const op in OperationConfig) {
if ((OperationConfig[op].outputRegexes) && !(OperationConfig[op].inputRegexes)) if ((OperationConfig[op].outputRegexes) && !(OperationConfig[op].inputRegexes))
OperationConfig[op].outputRegexes.forEach(pattern => { OperationConfig[op].outputRegexes.forEach(pattern => {
opPatterns.push({ if(pattern.magic)
op: op, opPatterns.push({
match: pattern.match, op: op,
flags: pattern.flags, match: pattern.match,
shouldMatch: pattern.shouldMatch, flags: pattern.flags,
args: pattern.args, shouldMatch: pattern.shouldMatch,
useful: pattern.useful || false args: pattern.args,
}); useful: pattern.useful || false
});
}); });
} }

View file

@ -38,31 +38,37 @@ class A1Z26CipherDecode extends Operation {
{ {
match: "^\\s*([12]?[0-9] )+[12]?[0-9]\\s*$", match: "^\\s*([12]?[0-9] )+[12]?[0-9]\\s*$",
flags: "", flags: "",
magic: true,
args: ["Space"] args: ["Space"]
}, },
{ {
match: "^\\s*([12]?[0-9],)+[12]?[0-9]\\s*$", match: "^\\s*([12]?[0-9],)+[12]?[0-9]\\s*$",
flags: "", flags: "",
magic: true,
args: ["Comma"] args: ["Comma"]
}, },
{ {
match: "^\\s*([12]?[0-9];)+[12]?[0-9]\\s*$", match: "^\\s*([12]?[0-9];)+[12]?[0-9]\\s*$",
flags: "", flags: "",
magic: true,
args: ["Semi-colon"] args: ["Semi-colon"]
}, },
{ {
match: "^\\s*([12]?[0-9]:)+[12]?[0-9]\\s*$", match: "^\\s*([12]?[0-9]:)+[12]?[0-9]\\s*$",
flags: "", flags: "",
magic: true,
args: ["Colon"] args: ["Colon"]
}, },
{ {
match: "^\\s*([12]?[0-9]\\n)+[12]?[0-9]\\s*$", match: "^\\s*([12]?[0-9]\\n)+[12]?[0-9]\\s*$",
flags: "", flags: "",
magic: true,
args: ["Line feed"] args: ["Line feed"]
}, },
{ {
match: "^\\s*([12]?[0-9]\\r\\n)+[12]?[0-9]\\s*$", match: "^\\s*([12]?[0-9]\\r\\n)+[12]?[0-9]\\s*$",
flags: "", flags: "",
magic: true,
args: ["CRLF"] args: ["CRLF"]
} }
]); ]);

View file

@ -49,41 +49,49 @@ class BaconCipherDecode extends Operation {
{ {
match: "^\\s*([01]{5}\\s?)+$", match: "^\\s*([01]{5}\\s?)+$",
flags: "", flags: "",
magic: true,
args: ["Standard (I=J and U=V)", "0/1", false] args: ["Standard (I=J and U=V)", "0/1", false]
}, },
{ {
match: "^\\s*([01]{5}\\s?)+$", match: "^\\s*([01]{5}\\s?)+$",
flags: "", flags: "",
magic: true,
args: ["Standard (I=J and U=V)", "0/1", true] args: ["Standard (I=J and U=V)", "0/1", true]
}, },
{ {
match: "^\\s*([AB]{5}\\s?)+$", match: "^\\s*([AB]{5}\\s?)+$",
flags: "", flags: "",
magic: true,
args: ["Standard (I=J and U=V)", "A/B", false] args: ["Standard (I=J and U=V)", "A/B", false]
}, },
{ {
match: "^\\s*([AB]{5}\\s?)+$", match: "^\\s*([AB]{5}\\s?)+$",
flags: "", flags: "",
magic: true,
args: ["Standard (I=J and U=V)", "A/B", true] args: ["Standard (I=J and U=V)", "A/B", true]
}, },
{ {
match: "^\\s*([01]{5}\\s?)+$", match: "^\\s*([01]{5}\\s?)+$",
flags: "", flags: "",
magic: true,
args: ["Complete", "0/1", false] args: ["Complete", "0/1", false]
}, },
{ {
match: "^\\s*([01]{5}\\s?)+$", match: "^\\s*([01]{5}\\s?)+$",
flags: "", flags: "",
magic: true,
args: ["Complete", "0/1", true] args: ["Complete", "0/1", true]
}, },
{ {
match: "^\\s*([AB]{5}\\s?)+$", match: "^\\s*([AB]{5}\\s?)+$",
flags: "", flags: "",
magic: true,
args: ["Complete", "A/B", false] args: ["Complete", "A/B", false]
}, },
{ {
match: "^\\s*([AB]{5}\\s?)+$", match: "^\\s*([AB]{5}\\s?)+$",
flags: "", flags: "",
magic: true,
args: ["Complete", "A/B", true] args: ["Complete", "A/B", true]
} }
]); ]);

View file

@ -36,9 +36,10 @@ class Bzip2Decompress extends Operation {
]; ];
this.checks = new magicObject([ this.checks = new magicObject([
{ {
"match": "^\\x42\\x5a\\x68", match: "^\\x42\\x5a\\x68",
"flags": "", flags: "",
"args": [] magic: true,
args: []
} }
]); ]);
} }

View file

@ -47,11 +47,13 @@ class CSVToJSON extends Operation {
{ {
match: "^\\s*([A-Z\\s]*,){5}", match: "^\\s*([A-Z\\s]*,){5}",
flags: "i", flags: "i",
magic: true,
args: [",", "\r\n", "Array of dictionaries"] args: [",", "\r\n", "Array of dictionaries"]
}, },
{ {
match: "^\\s*([A-Z\\s]*,){5}", match: "^\\s*([A-Z\\s]*,){5}",
flags: "i", flags: "i",
magic: true,
args: [",", "\r\n", "Array of arrays"] args: [",", "\r\n", "Array of arrays"]
} }
]); ]);

View file

@ -42,16 +42,19 @@ class ChangeIPFormat extends Operation {
{ {
match: "^\\s*([0-9]{1,3}\\.){3}[0-9]{1,3}$", match: "^\\s*([0-9]{1,3}\\.){3}[0-9]{1,3}$",
flags: "", flags: "",
magic: false,
args: ["Dotted Decimal", "Decimal"] args: ["Dotted Decimal", "Decimal"]
}, },
{ {
match: "^\\s*([0-9]{1,3}\\.){3}[0-9]{1,3}$", match: "^\\s*([0-9]{1,3}\\.){3}[0-9]{1,3}$",
flags: "", flags: "",
magic: false,
args: ["Dotted Decimal", "Octal"] args: ["Dotted Decimal", "Octal"]
}, },
{ {
match: "^\\s*([0-9]{1,3}\\.){3}[0-9]{1,3}$", match: "^\\s*([0-9]{1,3}\\.){3}[0-9]{1,3}$",
flags: "", flags: "",
magic: false,
args: ["Dotted Decimal", "Hex"] args: ["Dotted Decimal", "Hex"]
} }
]); ]);

View file

@ -31,6 +31,7 @@ class CitrixCTX1Decode extends Operation {
{ {
match: "([A-Z]{4}){10,}", match: "([A-Z]{4}){10,}",
flags: "", flags: "",
magic: true,
args: [] args: []
} }
]); ]);

View file

@ -29,6 +29,7 @@ class DechunkHTTPResponse extends Operation {
{ {
match: "^\\s*[0-9A-F]+\r\n", match: "^\\s*[0-9A-F]+\r\n",
flags: "i", flags: "i",
magic: true,
args: [] args: []
} }
]); ]);

View file

@ -35,6 +35,7 @@ class DecodeNetBIOSName extends Operation {
{ {
match: "^\\s*\\S{32}$", match: "^\\s*\\S{32}$",
flags: "", flags: "",
magic: true,
args: [65] args: [65]
} }
]); ]);

View file

@ -30,6 +30,7 @@ class DefangIPAddresses extends Operation {
{ {
match: "^\\s*(([0-9]{1,3}\\.){3}[0-9]{1,3}|([0-9a-f]{4}:){7}[0-9a-f]{4})\\s*$", match: "^\\s*(([0-9]{1,3}\\.){3}[0-9]{1,3}|([0-9a-f]{4}:){7}[0-9a-f]{4})\\s*$",
flags: "i", flags: "i",
magic: true,
args: [], args: [],
} }
], ],
@ -37,6 +38,7 @@ class DefangIPAddresses extends Operation {
{ {
match: "^\\s*(([0-9]{1,3}\\[\\.\\]){3}[0-9]{1,3}|([0-9a-f]{4}\\[\\:\\]){7}[0-9a-f]{4})\\s*$", match: "^\\s*(([0-9]{1,3}\\[\\.\\]){3}[0-9]{1,3}|([0-9a-f]{4}\\[\\:\\]){7}[0-9a-f]{4})\\s*$",
flags: "i", flags: "i",
magic: true,
shouldMatch: true, shouldMatch: true,
args: [] args: []
} }

View file

@ -52,41 +52,49 @@ class DefangURL extends Operation {
{ {
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
flags: "i", flags: "i",
magic: false,
args: [false, false, false, "Everything"], args: [false, false, false, "Everything"],
}, },
{ {
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
flags: "i", flags: "i",
magic: false,
args: [true, false, false, "Everything"], args: [true, false, false, "Everything"],
}, },
{ {
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
flags: "i", flags: "i",
magic: false,
args: [false, true, false, "Everything"], args: [false, true, false, "Everything"],
}, },
{ {
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
flags: "i", flags: "i",
magic: false,
args: [true, true, false, "Everything"], args: [true, true, false, "Everything"],
}, },
{ {
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
flags: "i", flags: "i",
magic: false,
args: [false, false, true, "Everything"], args: [false, false, true, "Everything"],
}, },
{ {
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
flags: "i", flags: "i",
magic: false,
args: [true, false, true, "Everything"], args: [true, false, true, "Everything"],
}, },
{ {
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
flags: "i", flags: "i",
magic: false,
args: [false, true, true, "Everything"], args: [false, true, true, "Everything"],
}, },
{ {
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
flags: "i", flags: "i",
magic: false,
args: [true, true, true, "Everything"], args: [true, true, true, "Everything"],
} }
], ],
@ -94,6 +102,7 @@ class DefangURL extends Operation {
{ {
match: "^\\s*(h(tt|xx)ps?|ftp)(://|\\[://\\])(-(\\.|\\[\\.\\]))?([^\\s/?\\.\\[\\]#-]+(\\.|\\[\\.\\])?)+(/\\S*)?\\s*$", match: "^\\s*(h(tt|xx)ps?|ftp)(://|\\[://\\])(-(\\.|\\[\\.\\]))?([^\\s/?\\.\\[\\]#-]+(\\.|\\[\\.\\])?)+(/\\S*)?\\s*$",
flags: "i", flags: "i",
magic: false,
shouldMatch: true, shouldMatch: true,
args: [true, true, true, "Everything"], args: [true, true, true, "Everything"],
} }

View file

@ -49,16 +49,19 @@ class EscapeUnicodeCharacters extends Operation {
{ {
match: "\\\\u(?:[\\da-f]{4,6})", match: "\\\\u(?:[\\da-f]{4,6})",
flags: "i", flags: "i",
magic: true,
args: ["\\u"] args: ["\\u"]
}, },
{ {
match: "%u(?:[\\da-f]{4,6})", match: "%u(?:[\\da-f]{4,6})",
flags: "i", flags: "i",
magic: true,
args: ["%u"] args: ["%u"]
}, },
{ {
match: "U\\+(?:[\\da-f]{4,6})", match: "U\\+(?:[\\da-f]{4,6})",
flags: "i", flags: "i",
magic: true,
args: ["U+"] args: ["U+"]
}, },
]); ]);

View file

@ -60,6 +60,7 @@ class FormatMACAddresses extends Operation {
{ {
match: "^\\s*([0-9a-f]{2}:){5}[0-9a-f]{2}$", match: "^\\s*([0-9a-f]{2}:){5}[0-9a-f]{2}$",
flags: "i", flags: "i",
magic: false,
args: ["Both", true, true, true, true, true] args: ["Both", true, true, true, true, true]
} }
]); ]);

View file

@ -54,6 +54,7 @@ class FromBCD extends Operation {
{ {
match: "^(?:\\d{4} ){3,}\\d{4}$", match: "^(?:\\d{4} ){3,}\\d{4}$",
flags: "", flags: "",
magic: true,
args: ["8 4 2 1", true, false, "Nibbles"] args: ["8 4 2 1", true, false, "Nibbles"]
} }
]); ]);

View file

@ -41,6 +41,7 @@ class FromBase32 extends Operation {
{ {
match: "^(?:[A-Z2-7]{8})+(?:[A-Z2-7]{2}={6}|[A-Z2-7]{4}={4}|[A-Z2-7]{5}={3}|[A-Z2-7]{7}={1})?$", match: "^(?:[A-Z2-7]{8})+(?:[A-Z2-7]{2}={6}|[A-Z2-7]{4}={4}|[A-Z2-7]{5}={3}|[A-Z2-7]{7}={1})?$",
flags: "", flags: "",
magic: true,
args: ["A-Z2-7=", false] args: ["A-Z2-7=", false]
}, },
]); ]);

View file

@ -43,11 +43,13 @@ class FromBase58 extends Operation {
{ {
match: "^[1-9A-HJ-NP-Za-km-z]{20,}$", match: "^[1-9A-HJ-NP-Za-km-z]{20,}$",
flags: "", flags: "",
magic: true,
args: ["123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz", false] args: ["123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz", false]
}, },
{ {
match: "^[1-9A-HJ-NP-Za-km-z]{20,}$", match: "^[1-9A-HJ-NP-Za-km-z]{20,}$",
flags: "", flags: "",
magic: true,
args: ["rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz", false] args: ["rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz", false]
}, },
]); ]);

View file

@ -41,66 +41,79 @@ class FromBase64 extends Operation {
{ {
match: "^\\s*(?:[A-Z\\d+/]{4})+(?:[A-Z\\d+/]{2}==|[A-Z\\d+/]{3}=)?\\s*$", match: "^\\s*(?:[A-Z\\d+/]{4})+(?:[A-Z\\d+/]{2}==|[A-Z\\d+/]{3}=)?\\s*$",
flags: "i", flags: "i",
magic: true,
args: ["A-Za-z0-9+/=", true] args: ["A-Za-z0-9+/=", true]
}, },
{ {
match: "^\\s*[A-Z\\d\\-_]{20,}\\s*$", match: "^\\s*[A-Z\\d\\-_]{20,}\\s*$",
flags: "i", flags: "i",
magic: true,
args: ["A-Za-z0-9-_", true] args: ["A-Za-z0-9-_", true]
}, },
{ {
match: "^\\s*(?:[A-Z\\d+\\-]{4}){5,}(?:[A-Z\\d+\\-]{2}==|[A-Z\\d+\\-]{3}=)?\\s*$", match: "^\\s*(?:[A-Z\\d+\\-]{4}){5,}(?:[A-Z\\d+\\-]{2}==|[A-Z\\d+\\-]{3}=)?\\s*$",
flags: "i", flags: "i",
magic: true,
args: ["A-Za-z0-9+\\-=", true] args: ["A-Za-z0-9+\\-=", true]
}, },
{ {
match: "^\\s*(?:[A-Z\\d./]{4}){5,}(?:[A-Z\\d./]{2}==|[A-Z\\d./]{3}=)?\\s*$", match: "^\\s*(?:[A-Z\\d./]{4}){5,}(?:[A-Z\\d./]{2}==|[A-Z\\d./]{3}=)?\\s*$",
flags: "i", flags: "i",
magic: true,
args: ["./0-9A-Za-z=", true] args: ["./0-9A-Za-z=", true]
}, },
{ {
match: "^\\s*[A-Z\\d_.]{20,}\\s*$", match: "^\\s*[A-Z\\d_.]{20,}\\s*$",
flags: "i", flags: "i",
magic: true,
args: ["A-Za-z0-9_.", true] args: ["A-Za-z0-9_.", true]
}, },
{ {
match: "^\\s*(?:[A-Z\\d._]{4}){5,}(?:[A-Z\\d._]{2}--|[A-Z\\d._]{3}-)?\\s*$", match: "^\\s*(?:[A-Z\\d._]{4}){5,}(?:[A-Z\\d._]{2}--|[A-Z\\d._]{3}-)?\\s*$",
flags: "i", flags: "i",
magic: true,
args: ["A-Za-z0-9._-", true] args: ["A-Za-z0-9._-", true]
}, },
{ {
match: "^\\s*(?:[A-Z\\d+/]{4}){5,}(?:[A-Z\\d+/]{2}==|[A-Z\\d+/]{3}=)?\\s*$", match: "^\\s*(?:[A-Z\\d+/]{4}){5,}(?:[A-Z\\d+/]{2}==|[A-Z\\d+/]{3}=)?\\s*$",
flags: "i", flags: "i",
magic: true,
args: ["0-9a-zA-Z+/=", true] args: ["0-9a-zA-Z+/=", true]
}, },
{ {
match: "^\\s*(?:[A-Z\\d+/]{4}){5,}(?:[A-Z\\d+/]{2}==|[A-Z\\d+/]{3}=)?\\s*$", match: "^\\s*(?:[A-Z\\d+/]{4}){5,}(?:[A-Z\\d+/]{2}==|[A-Z\\d+/]{3}=)?\\s*$",
flags: "i", flags: "i",
magic: true,
args: ["0-9A-Za-z+/=", true] args: ["0-9A-Za-z+/=", true]
}, },
{ {
match: "^[ !\"#$%&'()*+,\\-./\\d:;<=>?@A-Z[\\\\\\]^_]{20,}$", match: "^[ !\"#$%&'()*+,\\-./\\d:;<=>?@A-Z[\\\\\\]^_]{20,}$",
flags: "", flags: "",
magic: true,
args: [" -_", false] args: [" -_", false]
}, },
{ {
match: "^\\s*[A-Z\\d+\\-]{20,}\\s*$", match: "^\\s*[A-Z\\d+\\-]{20,}\\s*$",
flags: "i", flags: "i",
magic: true,
args: ["+\\-0-9A-Za-z", true] args: ["+\\-0-9A-Za-z", true]
}, },
{ {
match: "^\\s*[!\"#$%&'()*+,\\-0-689@A-NP-VX-Z[`a-fh-mp-r]{20,}\\s*$", match: "^\\s*[!\"#$%&'()*+,\\-0-689@A-NP-VX-Z[`a-fh-mp-r]{20,}\\s*$",
flags: "", flags: "",
magic: true,
args: ["!-,-0-689@A-NP-VX-Z[`a-fh-mp-r", true] args: ["!-,-0-689@A-NP-VX-Z[`a-fh-mp-r", true]
}, },
{ {
match: "^\\s*(?:[N-ZA-M\\d+/]{4}){5,}(?:[N-ZA-M\\d+/]{2}==|[N-ZA-M\\d+/]{3}=)?\\s*$", match: "^\\s*(?:[N-ZA-M\\d+/]{4}){5,}(?:[N-ZA-M\\d+/]{2}==|[N-ZA-M\\d+/]{3}=)?\\s*$",
flags: "i", flags: "i",
magic: true,
args: ["N-ZA-Mn-za-m0-9+/=", true] args: ["N-ZA-Mn-za-m0-9+/=", true]
}, },
{ {
match: "^\\s*[A-Z\\d./]{20,}\\s*$", match: "^\\s*[A-Z\\d./]{20,}\\s*$",
flags: "i", flags: "i",
magic: true,
args: ["./0-9A-Za-z", true] args: ["./0-9A-Za-z", true]
}, },
]); ]);

View file

@ -38,36 +38,43 @@ class FromBinary extends Operation {
{ {
match: "^(?:[01]{8})+$", match: "^(?:[01]{8})+$",
flags: "", flags: "",
magic: true,
args: ["None"] args: ["None"]
}, },
{ {
match: "^(?:[01]{8})(?: [01]{8})*$", match: "^(?:[01]{8})(?: [01]{8})*$",
flags: "", flags: "",
magic: true,
args: ["Space"] args: ["Space"]
}, },
{ {
match: "^(?:[01]{8})(?:,[01]{8})*$", match: "^(?:[01]{8})(?:,[01]{8})*$",
flags: "", flags: "",
magic: true,
args: ["Comma"] args: ["Comma"]
}, },
{ {
match: "^(?:[01]{8})(?:;[01]{8})*$", match: "^(?:[01]{8})(?:;[01]{8})*$",
flags: "", flags: "",
magic: true,
args: ["Semi-colon"] args: ["Semi-colon"]
}, },
{ {
match: "^(?:[01]{8})(?::[01]{8})*$", match: "^(?:[01]{8})(?::[01]{8})*$",
flags: "", flags: "",
magic: true,
args: ["Colon"] args: ["Colon"]
}, },
{ {
match: "^(?:[01]{8})(?:\\n[01]{8})*$", match: "^(?:[01]{8})(?:\\n[01]{8})*$",
flags: "", flags: "",
magic: true,
args: ["Line feed"] args: ["Line feed"]
}, },
{ {
match: "^(?:[01]{8})(?:\\r\\n[01]{8})*$", match: "^(?:[01]{8})(?:\\r\\n[01]{8})*$",
flags: "", flags: "",
magic: true,
args: ["CRLF"] args: ["CRLF"]
}, },
]); ]);

View file

@ -41,31 +41,37 @@ class FromDecimal extends Operation {
{ {
match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?: (?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?: (?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$",
flags: "", flags: "",
magic: true,
args: ["Space", false] args: ["Space", false]
}, },
{ {
match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:,(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:,(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$",
flags: "", flags: "",
magic: true,
args: ["Comma", false] args: ["Comma", false]
}, },
{ {
match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:;(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:;(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$",
flags: "", flags: "",
magic: true,
args: ["Semi-colon", false] args: ["Semi-colon", false]
}, },
{ {
match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?::(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?::(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$",
flags: "", flags: "",
magic: true,
args: ["Colon", false] args: ["Colon", false]
}, },
{ {
match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$",
flags: "", flags: "",
magic: true,
args: ["Line feed", false] args: ["Line feed", false]
}, },
{ {
match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\r\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\r\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$",
flags: "", flags: "",
magic: true,
args: ["CRLF", false] args: ["CRLF", false]
}, },
]); ]);

View file

@ -30,6 +30,7 @@ class FromHTMLEntity extends Operation {
{ {
match: "&(?:#\\d{2,3}|#x[\\da-f]{2}|[a-z]{2,6});", match: "&(?:#\\d{2,3}|#x[\\da-f]{2}|[a-z]{2,6});",
flags: "i", flags: "i",
magic: true,
args: [] args: []
}, },
]); ]);

View file

@ -37,46 +37,55 @@ class FromHex extends Operation {
{ {
match: "^(?:[\\dA-F]{2})+$", match: "^(?:[\\dA-F]{2})+$",
flags: "i", flags: "i",
magic: true,
args: ["None"] args: ["None"]
}, },
{ {
match: "^[\\dA-F]{2}(?: [\\dA-F]{2})*$", match: "^[\\dA-F]{2}(?: [\\dA-F]{2})*$",
flags: "i", flags: "i",
magic: true,
args: ["Space"] args: ["Space"]
}, },
{ {
match: "^[\\dA-F]{2}(?:,[\\dA-F]{2})*$", match: "^[\\dA-F]{2}(?:,[\\dA-F]{2})*$",
flags: "i", flags: "i",
magic: true,
args: ["Comma"] args: ["Comma"]
}, },
{ {
match: "^[\\dA-F]{2}(?:;[\\dA-F]{2})*$", match: "^[\\dA-F]{2}(?:;[\\dA-F]{2})*$",
flags: "i", flags: "i",
magic: true,
args: ["Semi-colon"] args: ["Semi-colon"]
}, },
{ {
match: "^[\\dA-F]{2}(?::[\\dA-F]{2})*$", match: "^[\\dA-F]{2}(?::[\\dA-F]{2})*$",
flags: "i", flags: "i",
magic: true,
args: ["Colon"] args: ["Colon"]
}, },
{ {
match: "^[\\dA-F]{2}(?:\\n[\\dA-F]{2})*$", match: "^[\\dA-F]{2}(?:\\n[\\dA-F]{2})*$",
flags: "i", flags: "i",
magic: true,
args: ["Line feed"] args: ["Line feed"]
}, },
{ {
match: "^[\\dA-F]{2}(?:\\r\\n[\\dA-F]{2})*$", match: "^[\\dA-F]{2}(?:\\r\\n[\\dA-F]{2})*$",
flags: "i", flags: "i",
magic: true,
args: ["CRLF"] args: ["CRLF"]
}, },
{ {
match: "^[\\dA-F]{2}(?:0x[\\dA-F]{2})*$", match: "^[\\dA-F]{2}(?:0x[\\dA-F]{2})*$",
flags: "i", flags: "i",
magic: true,
args: ["0x"] args: ["0x"]
}, },
{ {
match: "^[\\dA-F]{2}(?:\\\\x[\\dA-F]{2})*$", match: "^[\\dA-F]{2}(?:\\\\x[\\dA-F]{2})*$",
flags: "i", flags: "i",
magic: true,
args: ["\\x"] args: ["\\x"]
} }
]); ]);

View file

@ -31,6 +31,7 @@ class FromHexContent extends Operation {
{ {
match: "^\\s*.*?\\|([0-9a-f]{2})+\\|.*$", match: "^\\s*.*?\\|([0-9a-f]{2})+\\|.*$",
flags: "i", flags: "i",
magic: true,
args: [] args: []
} }
]); ]);

View file

@ -32,6 +32,7 @@ class FromHexdump extends Operation {
{ {
match: "^(?:(?:[\\dA-F]{4,16}h?:?)?[ \\t]*((?:[\\dA-F]{2} ){1,8}(?:[ \\t]|[\\dA-F]{2}-)(?:[\\dA-F]{2} ){1,8}|(?:[\\dA-F]{4} )*[\\dA-F]{4}|(?:[\\dA-F]{2} )*[\\dA-F]{2})[^\\n]*\\n?){2,}$", match: "^(?:(?:[\\dA-F]{4,16}h?:?)?[ \\t]*((?:[\\dA-F]{2} ){1,8}(?:[ \\t]|[\\dA-F]{2}-)(?:[\\dA-F]{2} ){1,8}|(?:[\\dA-F]{4} )*[\\dA-F]{4}|(?:[\\dA-F]{2} )*[\\dA-F]{2})[^\\n]*\\n?){2,}$",
flags: "i", flags: "i",
magic: true,
args: [] args: []
}, },
]); ]);

View file

@ -42,6 +42,7 @@ class FromMorseCode extends Operation {
{ {
match: "(?:^[-. \\n]{5,}$|^[_. \\n]{5,}$|^(?:dash|dot| |\\n){5,}$)", match: "(?:^[-. \\n]{5,}$|^[_. \\n]{5,}$|^(?:dash|dot| |\\n){5,}$)",
flags: "i", flags: "i",
magic: true,
args: ["Space", "Line feed"] args: ["Space", "Line feed"]
}, },
]); ]);

View file

@ -37,31 +37,37 @@ class FromOctal extends Operation {
{ {
match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?: (?:[0-7]{1,2}|[123][0-7]{2}))*$", match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?: (?:[0-7]{1,2}|[123][0-7]{2}))*$",
flags: "", flags: "",
magic: true,
args: ["Space"] args: ["Space"]
}, },
{ {
match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:,(?:[0-7]{1,2}|[123][0-7]{2}))*$", match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:,(?:[0-7]{1,2}|[123][0-7]{2}))*$",
flags: "", flags: "",
magic: true,
args: ["Comma"] args: ["Comma"]
}, },
{ {
match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:;(?:[0-7]{1,2}|[123][0-7]{2}))*$", match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:;(?:[0-7]{1,2}|[123][0-7]{2}))*$",
flags: "", flags: "",
magic: true,
args: ["Semi-colon"] args: ["Semi-colon"]
}, },
{ {
match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?::(?:[0-7]{1,2}|[123][0-7]{2}))*$", match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?::(?:[0-7]{1,2}|[123][0-7]{2}))*$",
flags: "", flags: "",
magic: true,
args: ["Colon"] args: ["Colon"]
}, },
{ {
match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:\\n(?:[0-7]{1,2}|[123][0-7]{2}))*$", match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:\\n(?:[0-7]{1,2}|[123][0-7]{2}))*$",
flags: "", flags: "",
magic: true,
args: ["Line feed"] args: ["Line feed"]
}, },
{ {
match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:\\r\\n(?:[0-7]{1,2}|[123][0-7]{2}))*$", match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:\\r\\n(?:[0-7]{1,2}|[123][0-7]{2}))*$",
flags: "", flags: "",
magic: true,
args: ["CRLF"] args: ["CRLF"]
}, },
]); ]);

View file

@ -33,6 +33,7 @@ class FromQuotedPrintable extends Operation {
{ {
match: "^[\\x21-\\x3d\\x3f-\\x7e \\t]{0,76}(?:=[\\da-f]{2}|=\\r?\\n)(?:[\\x21-\\x3d\\x3f-\\x7e \\t]|=[\\da-f]{2}|=\\r?\\n)*$", match: "^[\\x21-\\x3d\\x3f-\\x7e \\t]{0,76}(?:=[\\da-f]{2}|=\\r?\\n)(?:[\\x21-\\x3d\\x3f-\\x7e \\t]|=[\\da-f]{2}|=\\r?\\n)*$",
flags: "i", flags: "i",
magic: true,
args: [] args: []
}, },
]); ]);

View file

@ -38,21 +38,25 @@ class FromUNIXTimestamp extends Operation {
{ {
match: "^1?\\d{9}$", match: "^1?\\d{9}$",
flags: "", flags: "",
magic: true,
args: ["Seconds (s)"] args: ["Seconds (s)"]
}, },
{ {
match: "^1?\\d{12}$", match: "^1?\\d{12}$",
flags: "", flags: "",
magic: true,
args: ["Milliseconds (ms)"] args: ["Milliseconds (ms)"]
}, },
{ {
match: "^1?\\d{15}$", match: "^1?\\d{15}$",
flags: "", flags: "",
magic: true,
args: ["Microseconds (μs)"] args: ["Microseconds (μs)"]
}, },
{ {
match: "^1?\\d{18}$", match: "^1?\\d{18}$",
flags: "", flags: "",
magic: true,
args: ["Nanoseconds (ns)"] args: ["Nanoseconds (ns)"]
}, },
]); ]);

View file

@ -32,6 +32,7 @@ class Gunzip extends Operation {
{ {
match: "^\\x1f\\x8b\\x08", match: "^\\x1f\\x8b\\x08",
flags: "", flags: "",
magic: true,
args: [] args: []
}, },
]); ]);

View file

@ -30,6 +30,7 @@ class ObjectIdentifierToHex extends Operation {
{ {
match: "^\\s*([0-9]{1,3}\\.?)+\\s*$", match: "^\\s*([0-9]{1,3}\\.?)+\\s*$",
flags: "", flags: "",
magic: true,
args: [] args: []
} }
]); ]);

View file

@ -33,6 +33,7 @@ class ParseIPv6Address extends Operation {
{ {
match: "^\\s*([a-f\\d]{4}:?)+\\s*$", match: "^\\s*([a-f\\d]{4}:?)+\\s*$",
flags: "i", flags: "i",
magic: false,
args: [] args: []
} }
]); ]);

View file

@ -36,10 +36,11 @@ class ParseQRCode extends Operation {
]; ];
this.checks = new magicObject([ this.checks = new magicObject([
{ {
"match": "^(?:\\xff\\xd8\\xff|\\x89\\x50\\x4e\\x47|\\x47\\x49\\x46|.{8}\\x57\\x45\\x42\\x50|\\x42\\x4d)", match: "^(?:\\xff\\xd8\\xff|\\x89\\x50\\x4e\\x47|\\x47\\x49\\x46|.{8}\\x57\\x45\\x42\\x50|\\x42\\x4d)",
"flags": "", flags: "",
"args": [false], args: [false],
"useful": true magic: true,
useful: true
} }
]); ]);
} }

View file

@ -43,6 +43,7 @@ class ParseSSHHostKey extends Operation {
{ {
match: "^\\s*([A-F\\d]{2}[,;:]){15,}[A-F\\d]{2}\\s*$", match: "^\\s*([A-F\\d]{2}[,;:]){15,}[A-F\\d]{2}\\s*$",
flags: "i", flags: "i",
magic: true,
args: ["Hex"] args: ["Hex"]
} }
]); ]);

View file

@ -30,6 +30,7 @@ class ParseUNIXFilePermissions extends Operation {
{ {
match: "^\\s*d[rxw-]{9}\\s*$", match: "^\\s*d[rxw-]{9}\\s*$",
flags: "", flags: "",
magic: true,
args: [] args: []
} }
]); ]);

View file

@ -30,6 +30,7 @@ class ParseUserAgent extends Operation {
{ {
match: "^(User-Agent:|Mozilla\\/)[^\\n\\r]+\\s*$", match: "^(User-Agent:|Mozilla\\/)[^\\n\\r]+\\s*$",
flags: "i", flags: "i",
magic: true,
args: [] args: []
} }
]); ]);

View file

@ -38,9 +38,10 @@ class ParseX509Certificate extends Operation {
]; ];
this.checks = new magicObject([ this.checks = new magicObject([
{ {
"match": "^-+BEGIN CERTIFICATE-+\\r?\\n[\\da-z+/\\n\\r]+-+END CERTIFICATE-+\\r?\\n?$", match: "^-+BEGIN CERTIFICATE-+\\r?\\n[\\da-z+/\\n\\r]+-+END CERTIFICATE-+\\r?\\n?$",
"flags": "i", flags: "i",
"args": [ magic: true,
args: [
"PEM" "PEM"
] ]
} }

View file

@ -28,6 +28,7 @@ class RemoveLineNumbers extends Operation {
{ {
match: "^\\s*([0-9]+ .*?(\\n))+[0-9] .+$", match: "^\\s*([0-9]+ .*?(\\n))+[0-9] .+$",
flags: "", flags: "",
magic: true,
args: [] args: []
} }
]); ]);

View file

@ -38,10 +38,11 @@ class RenderImage extends Operation {
]; ];
this.checks = new magicObject([ this.checks = new magicObject([
{ {
"match": "^(?:\\xff\\xd8\\xff|\\x89\\x50\\x4e\\x47|\\x47\\x49\\x46|.{8}\\x57\\x45\\x42\\x50|\\x42\\x4d)", match: "^(?:\\xff\\xd8\\xff|\\x89\\x50\\x4e\\x47|\\x47\\x49\\x46|.{8}\\x57\\x45\\x42\\x50|\\x42\\x4d)",
"flags": "", flags: "",
"args": ["Raw"], magic: true,
"useful": true args: ["Raw"],
useful: true
} }
]); ]);
} }

View file

@ -41,6 +41,7 @@ class StripHTMLTags extends Operation {
{ {
match: "^<html>(\\S|\\s)*</html>$", match: "^<html>(\\S|\\s)*</html>$",
flags: "i", flags: "i",
magic: true,
args: [true, true] args: [true, true]
} }
]); ]);

View file

@ -29,6 +29,7 @@ class StripHTTPHeaders extends Operation {
{ {
match: "^\\s*HTTP(.|\\s)+?(\\r?\\n){2}", match: "^\\s*HTTP(.|\\s)+?(\\r?\\n){2}",
flags: "", flags: "",
magic: true,
args: [] args: []
} }
]); ]);

View file

@ -29,6 +29,7 @@ class URLDecode extends Operation {
{ {
match: ".*(?:%[\\da-f]{2}.*){4}", match: ".*(?:%[\\da-f]{2}.*){4}",
flags: "i", flags: "i",
magic: true,
args: [], args: [],
} }
]); ]);

View file

@ -30,9 +30,10 @@ class Untar extends Operation {
this.args = []; this.args = [];
this.checks = new magicObject([ this.checks = new magicObject([
{ {
"match": "^.{257}\\x75\\x73\\x74\\x61\\x72", match: "^.{257}\\x75\\x73\\x74\\x61\\x72",
"flags": "", flags: "",
"args": [] magic: true,
args: []
} }
]); ]);
} }

View file

@ -45,6 +45,7 @@ class Unzip extends Operation {
{ {
match: "^\\x50\\x4b(?:\\x03|\\x05|\\x07)(?:\\x04|\\x06|\\x08)", match: "^\\x50\\x4b(?:\\x03|\\x05|\\x07)(?:\\x04|\\x06|\\x08)",
flags: "", flags: "",
magic: true,
args: ["", false] args: ["", false]
}, },
]); ]);

View file

@ -64,6 +64,7 @@ class ZlibInflate extends Operation {
{ {
match: "^\\x78(\\x01|\\x9c|\\xda|\\x5e)", match: "^\\x78(\\x01|\\x9c|\\xda|\\x5e)",
flags: "", flags: "",
magic: true,
args: [0, 0, "Adaptive", false, false] args: [0, 0, "Adaptive", false, false]
}, },
]); ]);