mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Handling of /24 ranges
This commit is contained in:
parent
752ce789c2
commit
a616e46b50
1 changed files with 39 additions and 15 deletions
|
@ -19,7 +19,7 @@ class IPv6TransitionAddresses extends Operation {
|
||||||
|
|
||||||
this.name = "IPv6 Transition Addresses";
|
this.name = "IPv6 Transition Addresses";
|
||||||
this.module = "Default";
|
this.module = "Default";
|
||||||
this.description = "Converts IPv4 addresses to their IPv6 Transition addresses. IPv6 Transition addresses can also be converted back into their original IPv4 address. MAC addresses can also be converted into the EUI-64 format, this can them be appended to your IPv6 /64 range to obtain a full /128 address.<br><br>Transition technologies enable translation between IPv4 and IPv6 addresses or tunneling to allow traffic to pass through the incompatible network, allowing the two standards to coexist.<br><br>Remove headers to easily copy out results.";
|
this.description = "Converts IPv4 addresses to their IPv6 Transition addresses. IPv6 Transition addresses can also be converted back into their original IPv4 address. MAC addresses can also be converted into the EUI-64 format, this can them be appended to your IPv6 /64 range to obtain a full /128 address.<br><br>Transition technologies enable translation between IPv4 and IPv6 addresses or tunneling to allow traffic to pass through the incompatible network, allowing the two standards to coexist.<br><br>Only /24 ranges and currently handled. Remove headers to easily copy out results.";
|
||||||
this.infoURL = "https://wikipedia.org/wiki/IPv6_transition_mechanism";
|
this.infoURL = "https://wikipedia.org/wiki/IPv6_transition_mechanism";
|
||||||
this.inputType = "string";
|
this.inputType = "string";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
|
@ -62,7 +62,7 @@ class IPv6TransitionAddresses extends Operation {
|
||||||
/**
|
/**
|
||||||
* Function converts IPv4 to IPv6 Transtion address
|
* Function converts IPv4 to IPv6 Transtion address
|
||||||
*/
|
*/
|
||||||
function ipTransition(input) {
|
function ipTransition(input, range) {
|
||||||
let output = "";
|
let output = "";
|
||||||
const HEXIP = input.split(".");
|
const HEXIP = input.split(".");
|
||||||
|
|
||||||
|
@ -72,7 +72,12 @@ class IPv6TransitionAddresses extends Operation {
|
||||||
if (!args[1]) {
|
if (!args[1]) {
|
||||||
output += "6to4: ";
|
output += "6to4: ";
|
||||||
}
|
}
|
||||||
output += "2002:" + hexify(HEXIP[0]) + hexify(HEXIP[1]) + ":" + hexify(HEXIP[2]) + hexify(HEXIP[3]) + "::/48\n";
|
output += "2002:" + hexify(HEXIP[0]) + hexify(HEXIP[1]) + ":" + hexify(HEXIP[2]);
|
||||||
|
if (range) {
|
||||||
|
output += "00::/40\n";
|
||||||
|
} else {
|
||||||
|
output += hexify(HEXIP[3]) + "::/48\n";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapped
|
* Mapped
|
||||||
|
@ -80,7 +85,12 @@ class IPv6TransitionAddresses extends Operation {
|
||||||
if (!args[1]) {
|
if (!args[1]) {
|
||||||
output += "IPv4 Mapped: ";
|
output += "IPv4 Mapped: ";
|
||||||
}
|
}
|
||||||
output += "::ffff:" + hexify(HEXIP[0]) + hexify(HEXIP[1]) + ":" + hexify(HEXIP[2]) + hexify(HEXIP[3]) + "\n";
|
output += "::ffff:" + hexify(HEXIP[0]) + hexify(HEXIP[1]) + ":" + hexify(HEXIP[2]);
|
||||||
|
if (range) {
|
||||||
|
output += "00/120\n";
|
||||||
|
} else {
|
||||||
|
output += hexify(HEXIP[3]) + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translated
|
* Translated
|
||||||
|
@ -88,7 +98,12 @@ class IPv6TransitionAddresses extends Operation {
|
||||||
if (!args[1]) {
|
if (!args[1]) {
|
||||||
output += "IPv4 Translated: ";
|
output += "IPv4 Translated: ";
|
||||||
}
|
}
|
||||||
output += "::ffff:0:" + hexify(HEXIP[0]) + hexify(HEXIP[1]) + ":" + hexify(HEXIP[2]) + hexify(HEXIP[3]) + "\n";
|
output += "::ffff:0:" + hexify(HEXIP[0]) + hexify(HEXIP[1]) + ":" + hexify(HEXIP[2]);
|
||||||
|
if (range) {
|
||||||
|
output += "00/120\n";
|
||||||
|
} else {
|
||||||
|
output += hexify(HEXIP[3]) + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nat64
|
* Nat64
|
||||||
|
@ -96,8 +111,12 @@ class IPv6TransitionAddresses extends Operation {
|
||||||
if (!args[1]) {
|
if (!args[1]) {
|
||||||
output += "Nat 64: ";
|
output += "Nat 64: ";
|
||||||
}
|
}
|
||||||
output += "64:ff9b::" + hexify(HEXIP[0]) + hexify(HEXIP[1]) + ":" + hexify(HEXIP[2]) + hexify(HEXIP[3]) + "\n";
|
output += "64:ff9b::" + hexify(HEXIP[0]) + hexify(HEXIP[1]) + ":" + hexify(HEXIP[2]);
|
||||||
|
if (range) {
|
||||||
|
output += "00/120\n";
|
||||||
|
} else {
|
||||||
|
output += hexify(HEXIP[3]) + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -165,8 +184,12 @@ class IPv6TransitionAddresses extends Operation {
|
||||||
// Remove blank rows
|
// Remove blank rows
|
||||||
inputs = inputs.filter(Boolean);
|
inputs = inputs.filter(Boolean);
|
||||||
for (let input = 0; input < inputs.length; input++) {
|
for (let input = 0; input < inputs.length; input++) {
|
||||||
|
// if ignore ranges is checked and input is a range, skip
|
||||||
|
if ((args[0] && !inputs[input].includes("\/")) || (!args[0])) {
|
||||||
if (/^[0-9]{1,3}(?:\.[0-9]{1,3}){3}$/.test(inputs[input])) {
|
if (/^[0-9]{1,3}(?:\.[0-9]{1,3}){3}$/.test(inputs[input])) {
|
||||||
output += ipTransition(inputs[input]);
|
output += ipTransition(inputs[input], false);
|
||||||
|
} else if (/\/24$/.test(inputs[input])) {
|
||||||
|
output += ipTransition(inputs[input], true);
|
||||||
} else if (/^([0-9A-F]{2}:){5}[0-9A-F]{2}$/.test(inputs[input].toUpperCase())) {
|
} else if (/^([0-9A-F]{2}:){5}[0-9A-F]{2}$/.test(inputs[input].toUpperCase())) {
|
||||||
output += macTransition(input.toLowerCase());
|
output += macTransition(input.toLowerCase());
|
||||||
} else if (/^((?:[0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:(?:(?::[0-9a-fA-F]{1,4}){1,6})|:(?:(?::[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(?::[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(?:ffff(?::0{1,4}){0,1}:){0,1}(?:(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])|(?:[0-9a-fA-F]{1,4}:){1,4}:(?:(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/.test(inputs[input])) {
|
} else if (/^((?:[0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}|(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}|(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}|(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:(?:(?::[0-9a-fA-F]{1,4}){1,6})|:(?:(?::[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(?::[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(?:ffff(?::0{1,4}){0,1}:){0,1}(?:(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])|(?:[0-9a-fA-F]{1,4}:){1,4}:(?:(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/.test(inputs[input])) {
|
||||||
|
@ -175,6 +198,7 @@ class IPv6TransitionAddresses extends Operation {
|
||||||
output = "Enter compressed or expanded IPv6 address, IPv4 address or MAC Address.";
|
output = "Enter compressed or expanded IPv6 address, IPv4 address or MAC Address.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue