Swiss File Knife
a command line
free external tools,
- download the free Swiss File Knife Base from Sourceforge. - open the Windows CMD command line, Mac OS X Terminal or Linux shell. - OS X : type mv sfk-mac-i686.exe sfk and chmod +x sfk then ./sfk - Linux: type mv sfk-linux.exe sfk and chmod +x sfk then ./sfk OS X and Linux syntax may differ, check the help within the tool.
sfk ... +hextobin outfile convert lines of text containing hexdump to binary. chain-only command hextobin can be used only after another command, typically filter, which reads and prepares the input data. options -fuzzy ignore >< and # characters -verbose tell conversion statistics supported input formats since SFK 1.6.9: - if >...< is found then only hex data inside that is used. - if # is found then only hex data before that is used. - else any hex characters are used, and with option -fuzzy any >< or # characters are ignored. - whitespace at line start is ignored. 1. sfk hexdump full bracket delimited format: :file test.dat >6578616D 706C6520 77697468 206E6F6E< example with non 00000000 >20616C6E 756D0D0A 63686172 61637465< alnum..characte 00000010 >73202D2B 28295C2F 2E0D0A< s -+()\/... 00000020 2. sfk postdump minimal format, for forums and wiki: :file test.dat 65 78 61 6D 70 6C 65 20 77 69 74 68 20 6E 6F 6E # example.with.non 0000 20 61 6C 6E 75 6D 0D 0A 63 68 61 72 61 63 74 65 # .alnum..characte 0010 73 20 2D 2B 28 29 5C 2F 2E 0D 0A # s.......... 0020 3. any text with hex data inbetween that does not contain the >< or # characters (else -fuzzy must be used): --== 6578616D 706C6520 77697468 ==-- // 0x65, 0x78, 0x61, 0x6D :: input line length limitation: text lines in the input file should not be longer than 4000 characters or sfk filter will split them, causing hextobin to produce errors like "wrong hex format". web reference http://stahlworks.com/sfk-hextobin examples sfk filter dump.txt +hextobin out.dat convert file dump.txt and write to out.dat sfk fromclip +hextobin %TEMP%\tmp1.dat +hexdump takes a hex sequence like 22737769 73732066 from clipboard, printing its text via a temporary file and hexdump. example: write a list of bytes into a binary file let's say we want to write the binary data 0x01 0x02 0x03 0x04 0x05 into a binary file "target.exe" at offset 0x9876, then this can be achieved by these steps: sfk echo "01 02 03 04 05" +hextobin tmp1.dat writes the byte sequence into a temporary file. sfk partcopy tmp1.dat 0 5 target.exe 0x9876 -yes copies these bytes from tmp1.dat into target.exe, which must exist, at the offset 0x9876 (39030 decimal). finally, you may sfk hexdump target.exe -offlen 0x9870 20 to check the result by dumping the bytes around that area: :file target.exe >28C80000 10C20102 03040500 00000000< (............... 00009870 >00000000 06C90000 44C20000 00000000< ........D....... 00009880 see also: sfk hexdump - creating hexdumps from binary data. sfk partcopy - copy parts of a binary file.
sfk is a free open-source tool, running instantly without installation efforts. no DLL's,
no registry changes - just get sfk.exe from the zip package and use it (binaries for
windows, linux and mac are included).
read more about all sfk functions here.