mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-07 06:57:12 -04:00
Update ExtractIPAddresses.mjs to include Defanged IPv4 Addresses
This commit is contained in:
parent
1bc88728f0
commit
4fd8865e0c
1 changed files with 12 additions and 1 deletions
|
@ -40,6 +40,12 @@ class ExtractIPAddresses extends Operation {
|
|||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
,
|
||||
{
|
||||
name: "Defanged IPv4 Addresses",
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "Display total",
|
||||
type: "boolean",
|
||||
|
@ -64,8 +70,9 @@ class ExtractIPAddresses extends Operation {
|
|||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const [includeIpv4, includeIpv6, removeLocal, displayTotal, sort, unique] = args,
|
||||
const [includeIpv4, includeIpv6, removeLocal, includeDefangedIpv4, displayTotal, sort, unique] = args,
|
||||
ipv4 = "(?:(?:\\d|[01]?\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d|\\d)(?:\\/\\d{1,2})?",
|
||||
ipv4_defanged = "(?:(?:\\d|[01]?\\d\\d|2[0-4]\\d|25[0-5])\\[\\.\\]){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d|\\d)(?:\\/\\d{1,2})?",
|
||||
ipv6 = "((?=.*::)(?!.*::.+::)(::)?([\\dA-F]{1,4}:(:|\\b)|){5}|([\\dA-F]{1,4}:){6})((([\\dA-F]{1,4}((?!\\3)::|:\\b|(?![\\dA-F])))|(?!\\2\\3)){2}|(((2[0-4]|1\\d|[1-9])?\\d|25[0-5])\\.?\\b){4})";
|
||||
let ips = "";
|
||||
|
||||
|
@ -73,6 +80,10 @@ class ExtractIPAddresses extends Operation {
|
|||
ips = ipv4 + "|" + ipv6;
|
||||
} else if (includeIpv4) {
|
||||
ips = ipv4;
|
||||
} else if (includeIpv4 && includeDefangedIpv4){
|
||||
ips = ipv4 + "|" + ipv4_defanged
|
||||
} else if (includeIpv4 && includeDefangedIpv4 && includeIpv6){
|
||||
ips = ipv4 + "|" + ipv4_defanged + "|" + ipv6
|
||||
} else if (includeIpv6) {
|
||||
ips = ipv6;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue