Batch file / Enscri...
 
Notifications
Clear all

Batch file / Enscript - HEX to ASCII on multiple .txt files

9 Posts
5 Users
0 Likes
2,163 Views
(@research1)
Posts: 165
Estimable Member
Topic starter
 

Hi,

I'm looking for a batch file or en-script which will convert all hex in a .txt into ascii. I've found one batch script online but it skips large portions of hex. Does anyone have one on hand?

Commercial or open source, all appreciated. Encase / ftk / winhex isnt much use, as it reads the hex as asci (as it should). Unless I'm missing a useful function in winhex (trial) to convert??

 
Posted : 25/01/2013 2:44 am
Passmark
(@passmark)
Posts: 376
Reputable Member
 

Maybe I am missing the point, but just opening the file in a text editor, Like Notepad, UltraEdit or many others will display a binary file as text. Of course many hex values are outside of the ASCII range, so there is no sensible way to display them. So you'll either get a lot of garbage characters, or a lot values skipped, depending on the tool and font in use.

I think your whole idea of *conversion* to ASCII doesn't make sense. ASCII is a just mapping of values in a file to symbols to characters.

The question would make sense, if it was a conversion from UTF-16 to ASCII. Or a conversion from EBCDIC to ASCII. Or maybe you mean something like converting ASCII HTML hex encoded character references to plain unencoded ASCII?
0x48 0x45 0x4c 0x4c 0x4f = HELLO

 
Posted : 25/01/2013 3:12 am
(@research1)
Posts: 165
Estimable Member
Topic starter
 

Hi Passmark,

"ASCII HTML hex encoded character references to plain unencoded ASCII?" - Highly likely. The data was generated by a web-server.

"So you'll either get a lot of garbage characters, or a lot values skipped, depending on the tool and font in use." - Plenty of garbage characters.

I can decode the hex in web based converters, but I need something that can batch recursive on multiple .txt files.

 
Posted : 25/01/2013 3:31 am
Passmark
(@passmark)
Posts: 376
Reputable Member
 

Can you give an example of what the source file looks like (or a link to an example file)

 
Posted : 25/01/2013 5:25 am
TuckerHST
(@tuckerhst)
Posts: 175
Estimable Member
 

Research1, do I understand that you have a text file that contains the following

48656c6c6f20776f726c6421
And you want to convert that into some one byte character set, e.g., ASCII. That's an interesting question.

Passmark, thanks for participating. And, umm, aren't you a famous rockstar? )

 
Posted : 25/01/2013 7:24 am
Passmark
(@passmark)
Posts: 376
Reputable Member
 

Try this freeware,
http//www.gdargaud.net/Hack/BinToAscii.html
(Disclaimer, I have never used it, but the screen shot looks like it might do what we are guessing you want done).

…aren't you a famous rockstar?

Only in my dreams…..

 
Posted : 25/01/2013 9:20 am
Chris_Ed
(@chris_ed)
Posts: 314
Reputable Member
 

Can you give an example of what the source file looks like (or a link to an example file)

I second this! In the meantime, here's a quick and dirty python 2.x solution assuming your file content is something like this

48656C6C6F20576F726C64


import binascii
hex_content = open("c\\some\\path\\here\\file.txt").read()
ascii_string = binascii.a2b_hex(hex_content)
print ascii_string
hex_file.close()

I had a quick look at doing it in EnScript, but to be honest I find EnScript to be an exercise in frustration with this sort of simple file content processing.

 
Posted : 25/01/2013 1:30 pm
(@research1)
Posts: 165
Estimable Member
Topic starter
 

Thanks all for your assistance.

To close this off, in the end I used vb hooked into exel with a macro and converted inside. All the comments assisted greatly though.

I would still like a decent batch script to do this for research, if anyone knows of one.

 
Posted : 25/01/2013 8:58 pm
EricZimmerman
(@ericzimmerman)
Posts: 222
Estimable Member
 

i just did something similar in .net to process Ares data in the registry for osTriage. while not a batch file, its a very simple loop to do what you want to do and "decode" the files.

do you have what you need at this point?

 
Posted : 28/01/2013 1:36 am
Share: