ASCII Me Anything

~# cat Question

I got this weird output from this program, can you help me figure out the input?

FILES: output.txt, source.js

Reversing the operation

Output.txt

ECSM{j³v³scµtx_m¹_sxr¸eng³

Source.js

var _0xb3e0 = [
  "",
  "join",
  "charCodeAt",
  "fromCharCode",
  "map",
  "from",
  "Encrypted string: ",
  "log",
];
function yes(_0x6c57x2) {
  const _0x6c57x3 = Array[_0xb3e0[5]](_0x6c57x2)
    [_0xb3e0[4]]((_0x6c57x4) => {
      return String[_0xb3e0[3]](_0x6c57x4[_0xb3e0[2]](0) ^ 0x42);
    })
    [_0xb3e0[1]](_0xb3e0[0]);
  const _0x6c57x5 = Array[_0xb3e0[5]](_0x6c57x3)
    [_0xb3e0[4]]((_0x6c57x4) => {
      return String[_0xb3e0[3]](_0x6c57x4[_0xb3e0[2]](0) + 0x42);
    })
    [_0xb3e0[1]](_0xb3e0[0]);
  return _0x6c57x5;
}
const possibly = yes(flag);

The provided JS code defines a function (yes) that takes a string _0x6c57x2 as input and performs XOR and addition operations on its characters to transform it into a new string _0x6c57x5. Then, it logs the result to the console with a prefix. To solve this challenge, we can inverse the operation that is getting applied to retrieve the flag.

# Original text
output_text = "ECSM{j³v³scµtx_m¹_sxr¸eng³"

def reverse_yes(input):
  # Subtract 0x42 from each character
  reverse = ''.join([chr(ord(char) - 0x42) for char in input])
        
  # XOR each character with 0x42
  original_input = ''.join([chr(ord(char) ^ 0x42) for char in reverse])
        
  return original_input
        
# Reverse the transformation to get the original input
original_input = reverse_yes(output_text)
        
print(original_input)

Flag: ACSI{j3v3sc1pt_i5_str4ang3}

Last updated