Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
Decode Base64 to Windows executable file in ActiveX JavaScript

I'm trying to, with WSH JavaScript, decode a base64 string containing an executable file, and write the EXE to a file. This is the function I have for decoding:

decodeBase64 = function(s) {
    var e={},i,b=0,c,x,l=0,a,r='',w=String.fromCharCode,L=s.length;
    var A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    for(i=0;i<64;i++){e[A.charAt(i)]=i;}
    for(x=0;x<L;x++){
        c=e[s.charAt(x)];b=(b<<6)+c;l+=6;
        while(l>=8){((a=(b>>>(l-=8))&0xff)||(x<(L-2)))&&(r+=w(a));}
    }
    return r;
};

It works for the decoding but when I try to write the decoded string to a file, I get an error saying "Invalid procedure call or argument". I suspect that's due to the encoding being wrong. Here's that code:

var FSO = new ActiveXObject("Scripting.FileSystemObject");
var f = FSO.CreateTextFile(Path, true, false);
f.Write(decodeBase64(data));
f.Close();

Now, I know you can make a ADODB.Stream with ISO-8859-1 encoding and read it out as Windows-1252 encoding, but I don't have that in the environment I'm in. Is it possible that there is another way to decode a Base64 string, containing an EXE in JavaScript, in the Windows ANSI encoding then save that to a file? Possibly a way to convert the encoding of the result of the decodeBase64 function to an encoding that I could write as a valid EXE?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda