Convert hex dump of file to binary (program) file on Windows?

8

3

I have a hex file that I am attempting to convert to binary. I have performed this on Linux before using the command:

xxd -r -p mykey.hex > mykey.bin

But I cannot figure out how to do this same command on Windows. I have downloaded a few hex editor tools but not really sure how to use them to convert hex into a binary representation.

Is there a way to do this in Windows, or are there any similar tools out there that would allow me to do this?

Kevin

Posted 2012-11-01T17:16:59.163

Reputation: 261

From @fadelix: you can check this articles: http://indogeeks.com/how-to-convert-any-files-to-hex-with-script/

– fixer1234 – 2015-09-21T03:49:40.637

@fixer1234, OP wanted hex-to-binary - not the other way round. Also, the scripts you linked to appear to only produce a hex dump of the binary file. That's OK if it's all you need, but a true hex file is usually in Motorola or Intel hex format, with framing and checksums added.

– rossmcm – 2015-11-17T22:57:21.143

So the ge.tt link broke in my answer and I just fixed it. Why did you just change your accepted answer, to an answer that points to unxutils that many including you yourself even saw doesn't contain xxd? Even the author of that answer apologised for his link not having xxd. That is extremely irresponsible. Accepting answers you know are wrong while also not commenting when an issue occurs with an answer, is very irresponsible, I have downvoted you accordingly. If others had known you'd do that they would not have upvoted you. – barlop – 2018-11-06T09:14:53.580

I have attempted the similar once. I succeeded by turning the source into a javascript-escaped string with a regex and unescaping. – None – 2012-11-01T17:22:55.787

Answers

1

There is a native port of xxd to Win32.

See unxutils here for downloads.

Another source of Win32 ports of common GNU and/or *nix utilities is GnuWin32.

Greg Jandl

Posted 2012-11-01T17:16:59.163

Reputation: 144

OK @barlop, I'm really confused. I just downloaded [UnxUtlis.zip] (http://www.weihenstephan.de/~syring/win32/UnxUtils.zip) and I can't find xxd in there, or anything else that looks like it might be a hex-to-binary converter. (FWIW I can't get link markup to work either. Not my day).

– rossmcm – 2015-11-17T22:30:04.490

@rossmcm I think I was just interpreting synetech and taking what he said as correct..when I commented about it being in unxutils. I've just deleted that comment of mine 'cos it's misleading. Maybe Synetech didn't check either(beyond the webpage that listed). But indeed, I don't see xxd in unxutils either, or in any unxutils that i'd extracted in the past either. – barlop – 2015-11-18T00:03:27.180

@Synetech ross and I don't see it in unxutils (or unxupdates), it's not there. – barlop – 2015-11-18T00:06:56.793

I have downloaded this package but I do not see the xxd.exe anywhere in the package.. – None – 2012-11-01T17:40:08.507

My apologies. I swear that's where I fetched it from long ago. – None – 2012-11-01T17:44:18.100

@Kevin, which one did you get and not find it in? It’s not in GnuWin32, it’s in the first paged that Greg linked to, in the table towards the middle of the page (just use your browser’s search function and type xxd). Also, typing xxd into the search-field of the GnuWin32 page brings up the reversable hexdump that it includes.

– Synetech – 2013-08-30T17:07:19.957

17

VIM 7.x contains xxd for Windows

https://ftp.nluug.nl/pub/vim/pc/gvim73_46_s.zip

C:\Program Files (x86)\Vim\vim74>.\xxd -v
xxd V1.10 27oct98 by Juergen Weigert (Win32)

C:\Program Files (x86)\Vim\vim74>dir xxd.exe
10/08/2013  12:33 PM            70,144 xxd.exe

C:\Program Files (x86)\Vim\vim74>file xxd.exe
xxd.exe; PE32 executable for MS Windows (console) Intel 80386 32-bit

Cygwin has one also

C:\cygwin\bin>.\xxd.exe -v
xxd V1.10 27oct98 by Juergen Weigert

C:\cygwin\bin>dir xxd.exe
18/09/2015  05:44 AM            18,963 xxd.exe

C:\cygwin\bin>file xxd.exe
xxd.exe: PE32+ executable (console) x86-64, for MS Windows

barlop

Posted 2012-11-01T17:16:59.163

Reputation: 18 677

note- my old cygwin xxd.exe was "26/08/2014 12:00 AM 17,437 xxd.exe" I doubt even that the diff file size is relevant though. I didn't run the file.exe command on it though I'm sure it was 64 bit 'cos the -v output was the same. Odd that the file size was different, not that it matters. I just updated the answer to have the file.exe command run on it, just to show whether 32 bit or 64 bit though that's shown with the version info anyway with -v. The 32bit one says 32bit with the -v and the 64bit doesn't say 32bit which is meant to imply that it's 64bit since the 32bit xxd -v says 32bit. – barlop – 2015-11-12T12:57:13.667

Chrome blocks xxd.exe from http://ge.tt/5jfutZq/v/0 as malware.

– rossmcm – 2015-11-17T23:00:42.600

@rossmcm chrome is being ridiculous.. you can go to the downloads section in chrome and click "recover malicious file" http://i.imgur.com/6vBebqL.png Or, get it from cygwin or vim.

– barlop – 2015-11-18T00:01:20.407

OK, xxd.exe was only flagged by 1 out of 40 at VirusTotal so I'm happy. Note that it doesn't seem to convert hex files to binary however. I was looking for something that took Intel or Motorola hex files and converted them to a binary image. This hex2bin at SourceForge did the trick.

– rossmcm – 2015-11-18T06:06:21.310

@rossmcm the question has a use case of xxd converting hex to binary xxd -r -p mykey.hex > mykey.bin – barlop – 2016-12-24T20:21:56.147

@barlop if rossmcm meant hex to 101010101101 kind of binary then no. To executable kind of binary, yes. – barlop – 2018-11-06T09:51:11.570

xxd is also https://archive.org/details/hexviewer_Xxd_x86

– barlop – 2018-11-06T09:51:30.250

2

use powershell format-hex command:

PS C:\path\path\Documents\blah> format-hex Util3.class


           Path: C:\blah\blah\Documents\blah\Util3.class

           00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00000000   CA FE BA BE 00 00 00 34 00 1F 0A 00 07 00 10 09  Êþº¾...4........
etc...

mcgyver5

Posted 2012-11-01T17:16:59.163

Reputation: 1 031

This question is about converting a hex dump into a binary, not vice versa! – Monkey Supersonic – 2018-12-03T09:46:11.717

According to the doc, that is supposed to be supported. But it seems like this tool only returns a pretty formatted string that looks like your typical hex editor. You can't do anything with the 3 columns returned (ignoring metadata). Interested if someone sees it differently and has an example converting from hex back to binary. – TamusJRoyce – 2019-04-20T20:54:47.367

1

WinHex is the best for you to kick off stupid DOS command.

  1. Open Hex file
  2. Edit>>Converter File
  3. In the dialog box, Select Intel Hex to Binary
  4. Hit OK button.
  5. Round up file Size? Click No.
  6. SAVE File as Bin.

Wucharinton Meephanlom

Posted 2012-11-01T17:16:59.163

Reputation: 11

1How / where can this software be obtained? – Scott – 2017-10-29T04:14:07.533

It works perfectly! Here is the link to the free download page: https://www.x-ways.net/winhex/index-m.html

– slaadvak – 2019-11-28T21:48:24.163

0

If you are nuts, you could try processing the characters via input and then outputting the values 8 bits at a time using a programming language

Joe Plante

Posted 2012-11-01T17:16:59.163

Reputation: 111

This is a very old post, but it is really a comment rather than an answer. – fixer1234 – 2016-11-15T19:26:10.400

0

Use this hex to bin converted: (works in browser, no software install necessary)

http://matrixstorm.com/avr/hextobin/ihexconverter.html

vouvoume

Posted 2012-11-01T17:16:59.163

Reputation: 1

-2

You can use the free Mcumall GQ4X programmer software without the programmer. Select the device and load the hex file. Save as a bin file and that is it.

Arnold van Os

Posted 2012-11-01T17:16:59.163

Reputation: 1

2How / where can this software be obtained? – Scott – 2016-11-13T18:52:53.967

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review

– Ramhound – 2016-11-13T19:53:45.487

@Ramhound: Aside from my comment, how does this “not answer the question”? It provides steps to achieve the requested result, and it looks like it could plausibly work. – Scott – 2016-11-13T20:11:53.290

Ofcourse it works, First try it before given any comment pls. – Arnold van Os – 2016-11-13T21:56:47.400

My Dutch is much bettter than my English. – Arnold van Os – 2016-11-13T21:58:05.207

Pls see my GQ4X comment on this page. – Arnold van Os – 2016-11-15T13:00:50.817