0

I've accidentally downloaded PNG images as ASCII files. The original files are already deleted so I have now only the downloaded files. Is it possible to fix PNG files corrupted by ASCII conversion?

cyn
  • 1
  • 1
  • 2
  • 1
    No. Since all three of `\r\n`, `\r` and `\n` are translated into `\n`, you cannot know what code it originally was. And that's for *all* occurrences, so there are (I'm guessing here) 3ⁿ possibilities for *n* occurrences. – Jongware Nov 03 '14 at 12:48
  • It's possible, but it would entail identifying every possible byte sequence that might have been replaced, generating every possible combination of those addresses, and doing the reverse replacement for each combination, then testing to see if the resultant file is usable and correct. In other words, for any decently sized file with a fair number of potential corruption sites, it's going to take a very long time and a lot of effort... It might be feasible on smaller files like icons and what-not, though... – twalberg Nov 03 '14 at 17:19

2 Answers2

1

It depends. What kind of convertion was done? ( \r\n -> \n ? or the reverse?). If the image is really small, there is some probability of successful recovery but blindly doing the reverse convertion. See eg fixgz. Otherwise you should try all the alternatives, which can be a lot. The fact that PNG is structured in fixed length chunk can help, but it would take some work.

leonbloy
  • 73,180
  • 20
  • 142
  • 190
  • You're right--being able to locate, and then use the checksum may help. This could be interesting after all. Perhaps @cyn can share one of the damaged files; least we can do is take a look at it. – Jongware Nov 03 '14 at 20:46
0

Generally there are too many permutations, for example if 3974 bytes have been replaced it'll take 2^3974 attempts to work out the image. It's much better to look for a similar image online and do a fuzzy comparison pctf.

Qgenerator
  • 323
  • 2
  • 8