Quantcast
Channel: Reboot.pro
Viewing all articles
Browse latest Browse all 6812

[RELEASE] catedit.g4b - script to write hex values

$
0
0

Here is small .script (just below 1024 bytes) that allows to "hexedit" files or device sectors from command line.

Not particularly (please read as completely unlike ) foolproof :w00t:, but less half-@§§ed than usual, actually working and potentially very dangerous :ph34r:.

Kids, play with this on something of which you have a copy or backup (bytes, once written, tend to stay written ;)).

!BAT
setlocal
if %1.==. goto :help
set ddwrite=%~dpnx0
set target=%1
shift
set offset=%1
if not exist offset goto :help
set /a offset=%offset% > nul
set /a counter=0 > nul

:p_loop
shift
if %1.==. goto :show
set /a skip=%offset%+%counter% > nul
cat --hex --skip=%skip% --length=1 %target% | set tbyte=
cat --hex --skip=%skip% --locate=\x%tbyte:~10,2% --number=1 --replace=\x%1 %target%
set /a counter=%counter%+1 > nul
goto :p_loop

:show
cat --hex --skip=%offset% --length=%counter% %target%
goto :EOF

:help
echo catedit.g4b - small script to write hex values (bytes) to file or device
echo - by jaclaz - completely FREE under Careware License
echo Usage:
echo catedit.g4b <target> <offset> [space separated hex values]
echo
echo Examples:
echo catedit.g4b (fd0)0+1 510 55 AA
echo will write the "Magic Bytes" 55AA on the first sector of first floppy device
echo
echo catedit.g4b (hd0,0)/boot.ini 54 3D 31 30
echo will write "=10" at offset 54 in the file (hd0,0)/BOOT.INI
goto :EOF

:cheers:

Wonko

Attached Files


Viewing all articles
Browse latest Browse all 6812

Trending Articles