Page 1 of 1

Is there a way to obfuscate parts of a batch file?

Posted: 09 Apr 2021 12:52
by rasil
Hello,

I have a batch file that I need to obfuscate. Instead of just obfuscating all of it I just want to obfuscate parts of it. is that possible? The example file is called test.bat
test.bat

Code: Select all

@echo off
echo this part isint hidden.
pause
goto axtb
:axtb
cls 
echo this part is hidden.
pause
exit
And this is the obfuscator that I use.
obfu.bat

Code: Select all

set filename="sd"
set source="engine"
if exist temp.~b644 goto n
if not exist %filename%.bat exit
"%source%.cmd" "%filename%.bat"
:n
del %filename%.bat
::ping localhost -n 2 >nul
ren t.bat %filename%.bat
"%source%.cmd" "%filename%.bat"
engine.cmd

Code: Select all

if "%~1"=="" exit /b
if /i "%~x1" neq ".bat" if /i "%~x1" neq ".cmd" exit /b
for /f %%i in ("certutil.exe") do if not exist "%%~$path:i" (
  echo CertUtil.exe not found.
  pause
  exit /b
)
>"temp.~b64" echo(//4mY2xzDQo=
certutil.exe -f -decode "temp.~b64" "t.bat"
del "temp.~b64"
::ping localhost -n 1 >nul
copy "t.bat" /b + "%~1" /b
echo .>temp.~b644
::ping localhost -n 1 >nul
start obfu.bat
exit
Both of these files need to be together to work. Using this obfuscator or something else, is this possible? in test.bat i want the second part obfuscated while the first part untouched.

Thanks Rasil

Re: Is there a way to obfuscate parts of a batch file?

Posted: 09 Apr 2021 13:59
by ShadowThief
Dbenham used ROT13 to obfuscate a significant chunk of his port of Colossal Cave Adventure: viewtopic.php?f=3&t=4876

Re: Is there a way to obfuscate parts of a batch file?

Posted: 09 Apr 2021 15:44
by rasil
ShadowThief wrote:
09 Apr 2021 13:59
Dbenham used ROT13 to obfuscate a significant chunk of his port of Colossal Cave Adventure: viewtopic.php?f=3&t=4876
Hi,

ROT13.. hmmm I don't know how to use that to obfuscate a batch file.. I am pretty new to this so I feel like an idiot :oops:

Re: Is there a way to obfuscate parts of a batch file?

Posted: 09 Apr 2021 16:36
by dbenham
Also check out - viewtopic.php?f=3&t=7990. Lots of good techniques there for obfuscating code. Nothing to obfuscate select portions, but that could certainly be developed.

I feel like this topic has been explored fairly extensively, and I'm not too interested in revisiting the topic.


Dave Benham