Strings in a File

Filed under Uncategorized

Working in metadata removal from Office documents, one thing I do almost constantly is dig through files with a hex editor looking for any text that’s readable.

I’d been contemplated writing a string filter utility for some time when I happened to see an offhand mention of something like that from SysInternals.

Now, if you’ve ever played with anything from the guys at Sysinternals (now a part of Microsoft), you know their stuff is gold, so I had to check it out.

The utility is called Strings. It does exactly that, pulls strings (both ANSI and UNICODE) from any file you throw at it and spits em out STDOUT. Pipe it to a file and it’s MONEY, BABY!

Even better, put STRINGS.EXE and this little BAT file somewhere on your path, then setup a shortcut to the BAT file in your SEND TO folder, and you can Right click-Send To on any file and immediately have all the strings loaded up into whatever Text Editor is currently associated with TXT files. And that, as an old boss of mine would say, is “bells, whistles, hell, it’s the whole damn midway!” 

ECHO OFF
REM Run the strings.exe program to extract all strings from a given file
REM Then load the file into an editor
REM 
REM Create a Shortcut to this BAT file in your SENDTO folder to make it even
REM better! Then, you can right click, select SEND TO and immediately get a full
REM list of strings embedded within the file loaded into your editor.


REM Extract the strings to a temp file
strings -q %1 >"%temp%\%~n1-Raw.txt"


REM Sort strings to make it a bit easier to find things
REM This may or may not be something you want to do consistently
REM Either do the sort or the copy
REM sort "%temp%\%~n1-raw.txt" /o "%temp%\%~n1.txt"
copy "%temp%\%~n1-Raw.txt" "%temp%\%~n1.txt"
del "%temp%\%~n1-Raw.txt"


REM -----------
REM Use this to load the file into whatever editor is associated with a TXT file
REM -----------
start "Strings" /I /B "%temp%\%~n1.txt"

REM OR

REM -----------
REM Use this to load the file into a specific named editor
REM -----------
REM o:\dev\protools\textpad\textpad "%temp%\%~n1.txt"

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*