Skip to content

Instantly share code, notes, and snippets.

@zedd3v
Last active May 30, 2024 17:00
Show Gist options
  • Save zedd3v/1585403f43265cdca88a3afa47bd45c8 to your computer and use it in GitHub Desktop.
Save zedd3v/1585403f43265cdca88a3afa47bd45c8 to your computer and use it in GitHub Desktop.
PerimeterX Payload decode & encode functions
export interface EncodeOptions {
shift?: boolean;
shiftAmount?: number;
base64?: boolean;
}
export interface DecodeOptions extends EncodeOptions {}
export const decodePayload = (payload: string, options: DecodeOptions = {}): string => {
let { shift, base64, shiftAmount } = options;
base64 ??= true;
shift ??= true;
shiftAmount ??= 50;
const string = base64 ? Buffer.from(payload, 'base64').toString() : payload;
let d = '';
for (let i = 0; i < string.length; i++) {
d += shift ? String.fromCharCode(string.charCodeAt(i) ^ shiftAmount) : string[i];
}
return d;
};
export const encodePayload = (payload: string, options: EncodeOptions = {}): string => {
let { shift, base64, shiftAmount } = options;
base64 ??= true;
shift ??= true;
shiftAmount ??= 50;
let e = '';
for (let i = 0; i < payload.length; i++) {
e += shift ? String.fromCharCode(payload.charCodeAt(i) ^ shiftAmount) : payload[i];
}
return base64 ? Buffer.from(e).toString('base64') : e;
};
@kadnan
Copy link

kadnan commented Jan 13, 2022

@zedd3v
I tried your code, it partially decoded the final output. Is there anyway to contact you via email?

@zedd3v
Copy link
Author

zedd3v commented Apr 8, 2022

@kadnan

It was updated to a new encryption; will not be released yet
If you need a quick decoding tool, use my website https://antibot.io/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment