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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
rasil
Posts: 31
Joined: 23 Apr 2020 13:05

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

#1 Post by rasil » 09 Apr 2021 12:52

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

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

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

#2 Post by ShadowThief » 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

rasil
Posts: 31
Joined: 23 Apr 2020 13:05

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

#3 Post by rasil » 09 Apr 2021 15:44

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:

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

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

#4 Post by dbenham » 09 Apr 2021 16:36

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

Post Reply