Base64 Decoding in BRU javascript

Javascript renaming examples. Javascript renaming is supported in version 3 or newer.

Base64 Decoding in BRU javascript

Postby Cybercanvas » Fri Nov 25, 2022 5:58 pm

Hi all. This is my first time posting here so please forgive me if I misstep.

I have unfortunately been the victim of a ransomware attack that renamed my files (not folders) using a base64 encoding. I did a hex comparison with some backup files and am confident that the file content has not been changed, only the name. So I just need to do a recursive file rename that does a base64 decode.

I am not fluent in javascript and could use any help I can get.

Rob
Cybercanvas
 
Posts: 6
Joined: Fri Nov 25, 2022 5:24 pm

Re: Base64 Decoding

Postby Admin » Sat Nov 26, 2022 1:54 am

Hi, sorry to hear about the attack!

Do you have examples of file renames wanted before -> after ?

thanks
Admin
Site Admin
 
Posts: 2354
Joined: Tue Mar 08, 2005 8:39 pm

Re: Base64 Decoding

Postby Cybercanvas » Sat Nov 26, 2022 6:54 am

Sure. You can check some out yourself at this url:https://codebeautify.org/base64-decode

For example, one of my files has been renamed to: cm9iLXByb2ZpbGUtMi5qcGc=

After Base64 decoding this becomes: rob-profile-2.jpg

But there are 10s of thousands of files that this has been done to.
Cybercanvas
 
Posts: 6
Joined: Fri Nov 25, 2022 5:24 pm

Re: Base64 Decoding

Postby Admin » Sun Nov 27, 2022 10:27 am

Try this javascript :

Code: Select all
var Base64 = {_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9+/=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/rn/g,"n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r)}else if(r>127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n<e.length){r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r);n++}else if(r>191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}}

// Decode the String
newName = Base64.decode(name);


Copy and paste in BRU javascript editor.
Admin
Site Admin
 
Posts: 2354
Joined: Tue Mar 08, 2005 8:39 pm

Re: Base64 Decoding in BRU javascript

Postby Cybercanvas » Sun Nov 27, 2022 3:16 pm

Thank you so much. It's been a week! I was diagnosed with cancer two years ago so now I am working from home and my laptop / files are my source of income. Then my wife was diagnosed with cancer the same day I got hit with the ransomware attack. I really appreciate your efforts.
Cybercanvas
 
Posts: 6
Joined: Fri Nov 25, 2022 5:24 pm

Re: Base64 Decoding in BRU javascript

Postby Cybercanvas » Sun Nov 27, 2022 3:19 pm

Crap! I just discovered that I can't apply your solution without paying $115.00 anyway. LOL

OK. So when I bite the bullet on that is there also a way to make it do the rename recursively AND leave folder names alone?

Rob
Cybercanvas
 
Posts: 6
Joined: Fri Nov 25, 2022 5:24 pm

Re: Base64 Decoding in BRU javascript

Postby Cybercanvas » Sun Nov 27, 2022 3:36 pm

I found the subfolder & folder filter options... now on to the commercial License
Cybercanvas
 
Posts: 6
Joined: Fri Nov 25, 2022 5:24 pm

Re: Base64 Decoding in BRU javascript

Postby Admin » Mon Nov 28, 2022 4:00 am

Hi, I am sorry to hear about this very difficult time :( please write to support via e-mail re the commercial license. thank you very much
Admin
Site Admin
 
Posts: 2354
Joined: Tue Mar 08, 2005 8:39 pm


Return to Javascript Renaming