Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add url defang #394

Merged
merged 2 commits into from
Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/config/Categories.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@
"Escape string",
"Unescape string",
"Pseudo-Random Number Generator",
"Sleep"
"Sleep",
"Defang URL"
]
},
{
Expand Down
43 changes: 43 additions & 0 deletions src/core/operations/DefangURL.mjs
Original file line number Diff line number Diff line change
@@ -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;