(view source code of obscure.bat as plain text)
@ECHO OFF
:: Check command line arguments and Windows version
IF "%~1"=="" GOTO Syntax
IF "%~1"=="/?" GOTO Syntax
IF "%~2"=="/?" GOTO Syntax
IF NOT "%~3"=="" GOTO Syntax
IF NOT "%~2"=="" IF /I NOT "%~1"=="-DEBUG" IF /I NOT "%~2"=="-DEBUG" GOTO Syntax
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
SETLOCAL
:: Initialize local variables
SET Dir=
SET Host=
SET IPHex=
SET IPDec=
SET Prot=
SET URL=
:: Parse command line arguments
ECHO. %* | FIND /I " -DEBUG " >NUL
IF ERRORLEVEL 1 (SET DEBUG=0) ELSE (SET DEBUG=1)
IF %DEBUG%==0 (
SET URL=%~1
) ELSE (
IF /I [%1]==[-DEBUG] SET URL=%~2
IF /I [%2]==[-DEBUG] SET URL=%~1
)
IF NOT DEFINED URL GOTO Syntax
ECHO "%URL%" | FINDSTR /R /I /C:"tps*://" >NUL
IF NOT ERRORLEVEL 1 (
FOR /F "tokens=1* delims=:" %%A IN ("%URL%") DO (
SET Prot=%%A
SET URL=%%B
)
)
IF DEFINED Prot (
SET Prot=%Prot%://
SET URL=%URL:~2%
)
FOR /F "tokens=1* delims=/" %%A IN ("%URL%") DO (
SET Host=%%A
SET Dir=%%B
)
IF DEFINED Dir (
SET Dir=/%Dir%
) ELSE (
ECHO."%URL%" | FIND "/" >NUL
IF NOT ERRORLEVEL 1 SET Dir=/%Dir%
)
:: Check if specified host name is available
FOR /F "tokens=2 delims=[]" %%A IN ('PING %Host% -4 -n 1 2^>NUL') DO SET IPDec=%%A
IF NOT DEFINED IPDec (
ECHO Host name invalid or host not available
GOTO:EOF
)
:: Call subroutine to convert IP address to decimal number
FOR /F "tokens=1-4 delims=." %%A IN ("%IPDec%") DO CALL :Hex2Dec %%A %%B %%C %%D
:: Display intermediate results if -DEBUG switch was used
IF "%DEBUG%"=="1" (
ECHO.
SET URL
SET Prot
SET Host
SET IPDec
SET IPHex
SET Dir
ECHO.
)
:: Display the result
ECHO.
ECHO Obscured URL examples:
ECHO.
ECHO %Prot%%IPHex%%Dir%
ECHO %Prot%fake.host@%IPHex%%Dir%
:: Done
ENDLOCAL
GOTO:EOF
:Dec2Hex
SETLOCAL ENABLEDELAYEDEXPANSION
SET DecDigits=%1
IF "%DecDigits:~0,1%"=="0" SET DecDigits=%DecDigits:~1%
IF "%DecDigits:~0,1%"=="0" SET DecDigits=%DecDigits:~1%
SET /A MSD = %DecDigits% / 16
SET /A LSD = %DecDigits% - 16 * %MSD%
SET Convert=0123456789ABCDEF
SET MSD=!Convert:~%MSD%,1!
SET LSD=!Convert:~%LSD%,1!
ENDLOCAL && SET HexDigits=%MSD%%LSD%
GOTO:EOF
:Hex2Dec
CALL :Dec2Hex %1
SET IPHex=0x%HexDigits%
CALL :Dec2Hex %2
SET IPHex=%IPHex%%HexDigits%
CALL :Dec2Hex %3
SET IPHex=%IPHex%%HexDigits%
CALL :Dec2Hex %4
SET IPHex=%IPHex%%HexDigits%
GOTO:EOF
:Syntax
ECHO Obscure.bat, Version 1.01 for Windows NT4 and later
ECHO Obscure the specified URL by converting the host name to a hexadecimal
ECHO IP address and by adding a fake hostname as a login name.
ECHO.
ECHO Usage: OBSCURE.BAT url [ -DEBUG ]
ECHO Where: "url" can be any valid URL, host name or IP address
ECHO -DEBUG displays intermediate results
ECHO.
ECHO Explanation: Let's take the fictional http://somehost.com/sources/ and
ECHO let's assume somehost.com's IP address is 11.12.13.14.
ECHO The hexadecimal representation of the IP address is: 0x0B0C0D0E.
ECHO Try pinging 0x0B0C0D0E, it will show 11.12.13.14 as the address being pinged.
ECHO So the URL could also be written as http://0x0B0C0D0E/sources/.
ECHO Any URL may be preceded with a user ID followed by an @.
ECHO So we can further obscure the URL by adding a fake host name:
ECHO http://fake.host@0x0B0C0D0E/ still points to http://somehost.com/
ECHO.
ECHO Note: Browser security settings may block use of hexadecimal addresses,
ECHO especially if preceded by a login that is not required by the site
ECHO.
ECHO Written by Rob van der Woude
ECHO https://www.robvanderwoude.com
IF "%OS%"=="Windows_NT" EXIT /B 1
page last modified: 2024-04-16; loaded in 0.0074 seconds