mirror of
https://github.com/gchq/CyberChef.git
synced 2026-02-28 04:24:31 +01:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
782e0f3475 | ||
|
|
6be7ac89d4 | ||
|
|
ad2424cfdd | ||
|
|
ed84614389 | ||
|
|
67bd2605c0 | ||
|
|
83c145c2ac | ||
|
|
53bf52c989 |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cyberchef",
|
||||
"version": "8.0.2",
|
||||
"version": "8.1.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cyberchef",
|
||||
"version": "8.0.2",
|
||||
"version": "8.1.0",
|
||||
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
|
||||
"author": "n1474335 <n1474335@gmail.com>",
|
||||
"homepage": "https://gchq.github.io/CyberChef",
|
||||
|
||||
@@ -137,6 +137,7 @@
|
||||
"ops": [
|
||||
"HTTP request",
|
||||
"Strip HTTP headers",
|
||||
"Dechunk HTTP response",
|
||||
"Parse User Agent",
|
||||
"Parse IP range",
|
||||
"Parse IPv6 address",
|
||||
|
||||
50
src/core/operations/DechunkHTTPResponse.mjs
Normal file
50
src/core/operations/DechunkHTTPResponse.mjs
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @author sevzero [sevzero@protonmail.com]
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
|
||||
/**
|
||||
* Dechunk HTTP response operation
|
||||
*/
|
||||
class DechunkHTTPResponse extends Operation {
|
||||
|
||||
/**
|
||||
* DechunkHTTPResponse constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Dechunk HTTP response";
|
||||
this.module = "Default";
|
||||
this.description = "Parses an HTTP response transferred using Transfer-Encoding: Chunked";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const chunks = [];
|
||||
let chunkSizeEnd = input.indexOf("\n") + 1;
|
||||
const lineEndings = input.charAt(chunkSizeEnd - 2) === "\r" ? "\r\n" : "\n";
|
||||
const lineEndingsLength = lineEndings.length;
|
||||
let chunkSize = parseInt(input.slice(0, chunkSizeEnd), 16);
|
||||
while (!isNaN(chunkSize)) {
|
||||
chunks.push(input.slice(chunkSizeEnd, chunkSize + chunkSizeEnd));
|
||||
input = input.slice(chunkSizeEnd + chunkSize + lineEndingsLength);
|
||||
chunkSizeEnd = input.indexOf(lineEndings) + lineEndingsLength;
|
||||
chunkSize = parseInt(input.slice(0, chunkSizeEnd), 16);
|
||||
}
|
||||
return chunks.join("") + input;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default DechunkHTTPResponse;
|
||||
Reference in New Issue
Block a user