浏览代码

Merge branch 'add_url_defang' of https://github.com/arnydo/CyberChef into arnydo-add_url_defang

n1474335 6 年之前
父节点
当前提交
253346a201
共有 2 个文件被更改,包括 45 次插入1 次删除
  1. 2 1
      src/core/config/Categories.json
  2. 43 0
      src/core/operations/DefangURL.mjs

+ 2 - 1
src/core/config/Categories.json

@@ -208,7 +208,8 @@
             "Escape string",
             "Unescape string",
             "Pseudo-Random Number Generator",
-            "Sleep"
+            "Sleep",
+            "Defang URL"
         ]
     },
     {

+ 43 - 0
src/core/operations/DefangURL.mjs

@@ -0,0 +1,43 @@
+/**
+ * @author arnydo [arnydo@protonmail.com]
+ * @copyright Crown Copyright 2016
+ * @license Apache-2.0
+ */
+
+import Operation from "../Operation";
+
+/**
+ * DefangURL operation
+ */
+class DefangURL extends Operation {
+
+    /**
+     * DefangURL constructor
+     */
+    constructor() {
+        super();
+
+        this.name = "Defang URL";
+        this.module = "URL";
+        this.description = "Takes a Universal Resource Locator (URL) and 'Defangs' it; meaning, the URL becomes invalid and neutralizes the risk of accidentally clicking on a malicious link.<br><br>This is often used when dealing with malicious links or IOCs.<br><br>Works well when combined with the 'Extract URLs' operation.";
+        this.infoURL = "";
+        this.inputType = "string";
+        this.outputType = "string";
+        this.args = [];
+    }
+
+    /**
+     * @param {string} input
+     * @param {Object[]} args
+     * @returns {string}
+     */
+    run(input, args) {
+        let defang = input.replace(/http/gi, "hxxp");
+        defang = defang.replace(/\./g, "[.]");
+        defang = defang.replace(/:\/\//g, "[://]");
+        return defang;
+    }
+
+}
+
+export default DefangURL;