add: exported function name customization

This commit is contained in:
D00Movenok
2023-09-14 01:25:08 +03:00
parent 6b6ae87a57
commit 273bf18e1b
4 changed files with 18 additions and 12 deletions
+9 -6
View File
@@ -1,5 +1,7 @@
# HTMLSmuggler ✉️
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
HTMLSmuggler - JS payload generator for IDS bypass and payload delivery via HTML smuggling.
## Description
@@ -33,11 +35,12 @@ The main goal of HTMLSmuggler tool is creating an independent javascript library
```text
Options:
-p, --payload <string> Path to payload file you want to smuggle
-n, --name <string> Name of file, that would be downloaded
-c, --compress Enable payload compression (gzip)
-t, --type <string> Contet-Type of downlonaded file (default: "application/octet-stream")
-h, --help Display help for command
-p, --payload <string> Path to payload file you want to smuggle
-n, --name <string> Name of file, that would be downloaded
-t, --type <string> Contet-Type of downlonaded file (default: "application/octet-stream")
-f, --function <string> Name of exported function (default: "download")
-c, --compress Enable payload compression (gzip)
-h, --help display help for command
```
## Usage
@@ -51,7 +54,7 @@ The main goal of HTMLSmuggler tool is creating an independent javascript library
yarn build -p /path/to/payload -n file.exe -t "application/octet-stream" -c
```
3. Get your payload from `dist/payload.esm.js` or `dist/payload.umd.js`. After that, it may be inserted into your page and called with `download()` function.
3. Get your payload from `dist/payload.esm.js` or `dist/payload.umd.js`. After that, it may be inserted into your page and called with `download()` (or custom specified with `-f` flag) function.
> `payload.esm.js` is used in `import { download } from 'payload.esm';` imports (ECMAScript standart).
>
+4 -2
View File
@@ -20,6 +20,7 @@ program
"Contet-Type of downlonaded file",
"application/octet-stream"
)
.option("-f, --function <string>", "Name of exported function", "download")
.option("-c, --compress", "Enable payload compression (gzip)");
program.parse();
@@ -42,8 +43,9 @@ fs.readFile(program.opts().payload, { encoding: "utf8" }, (err, data) => {
const compiler = webpack(
webpackConfig({
type: program.opts().type,
name: program.opts().name,
filetype: program.opts().type,
filename: program.opts().name,
funcname: program.opts().function,
compress: program.opts().compress,
})
);
+1 -1
View File
@@ -3,7 +3,7 @@ import { decompressSync, strToU8 } from "fflate";
import payload from "./assets/payload.bin";
import { download as down } from "./utils";
export function download() {
export function dontRemoveFunctionName() {
let data = strToU8(payload, true);
data = COMPRESS ? decompressSync(data) : data;
down(data, "dont_remove_filename_var", "dont_remove_content_type_var");
+4 -3
View File
@@ -3,7 +3,7 @@ const webpack = require("webpack");
const WebpackObfuscator = require("webpack-obfuscator");
const obfuscatorOptions = require("./obfuscator");
module.exports = ({ name, type, compress }) => {
module.exports = ({ filename, filetype, funcname, compress }) => {
const commonConfig = {
mode: "production",
performance: {
@@ -20,8 +20,9 @@ module.exports = ({ name, type, compress }) => {
loader: "string-replace-loader",
options: {
multiple: [
{ search: "dont_remove_filename_var", replace: name },
{ search: "dont_remove_content_type_var", replace: type },
{ search: "dont_remove_filename_var", replace: filename },
{ search: "dont_remove_content_type_var", replace: filetype },
{ search: "dontRemoveFunctionName", replace: funcname },
],
},
},