mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 23:06:16 -04:00
ESM: Ported Punycode, HTTP and PRNG operations
This commit is contained in:
parent
0d1e5311dc
commit
c29ea53405
6 changed files with 427 additions and 0 deletions
55
src/core/operations/ParseUserAgent.mjs
Normal file
55
src/core/operations/ParseUserAgent.mjs
Normal file
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2016
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
import UAParser from "ua-parser-js";
|
||||
|
||||
/**
|
||||
* Parse User Agent operation
|
||||
*/
|
||||
class ParseUserAgent extends Operation {
|
||||
|
||||
/**
|
||||
* ParseUserAgent constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Parse User Agent";
|
||||
this.module = "UserAgent";
|
||||
this.description = "Attempts to identify and categorise information contained in a user-agent string.";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const ua = UAParser(input);
|
||||
return `Browser
|
||||
Name: ${ua.browser.name || "unknown"}
|
||||
Version: ${ua.browser.version || "unknown"}
|
||||
Device
|
||||
Model: ${ua.device.model || "unknown"}
|
||||
Type: ${ua.device.type || "unknown"}
|
||||
Vendor: ${ua.device.vendor || "unknown"}
|
||||
Engine
|
||||
Name: ${ua.engine.name || "unknown"}
|
||||
Version: ${ua.engine.version || "unknown"}
|
||||
OS
|
||||
Name: ${ua.os.name || "unknown"}
|
||||
Version: ${ua.os.version || "unknown"}
|
||||
CPU
|
||||
Architecture: ${ua.cpu.architecture || "unknown"}`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default ParseUserAgent;
|
Loading…
Add table
Add a link
Reference in a new issue