Extracting text from images
In the previous recipe, we saw how to hide text in the RGBA
values of an image. This recipe will let us extract that data out.
How to do it…
We saw in the previous recipe that we split up a characters byte into 8 bits and spread them over the LSBs of two pixels. Here's that diagram again as a refresher:
The following is the script that will do the extraction:
from PIL import Image from itertools import izip def get_pixel_pairs(iterable): a = iter(iterable) return izip(a, a) def get_LSB(value): if value & 1 == 0: return '0' else: return '1' def extract_message(carrier): c_image = Image.open(carrier) pixel_list = list(c_image.getdata()) ...
Get Python: Penetration Testing for Developers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.