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

Addition of 'RefangURL' that does the opposite of defanging a URL #1591

Closed
wants to merge 2 commits into from
Closed
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
62 changes: 62 additions & 0 deletions src/core/operations/RefangURL.jsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* @author Matt Kelly @breakersall
* @copyright 2023
* @license Apache-2.0
*/

import Operation from "../Operation.mjs";

/**
* RefangURL operation
*/
class RefangURL extends Operation {

/**
* RefangURL constructor
*/
constructor() {
super();

this.name = "Refang URL";
this.module = "Default";
this.description = "Takes a defanged Universal Resource Locator (URL) and 'Refangs' it, making the URL valid again.<br><br>This can be used to revert a URL that has been defanged once again allowing you to potentially click on a malicious link.<br><br>Use carefully and only with trusted links.<br><br>This is probably irresposible.";
this.infoURL = "https://isc.sans.edu/forums/diary/Defang+all+the+things/22744/";
this.inputType = "string";
this.outputType = "string";
this.args = [
{
name: "Unescape dots",
type: "boolean",
value: true
},
{
name: "Unescape http",
type: "boolean",
value: true
},
{
name: "Unescape ://",
type: "boolean",
value: true
}
];
}

/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
const [dots, http, slashes] = args;

if (dots) input = input.replace(/\[\.\]/g, ".");
if (http) input = input.replace(/hxxp/gi, "http");
if (slashes) input = input.replace(/\[:\/\/\]/g, "://");

return input;
}

}

export default RefangURL;
Loading