Why the name?
I'm not creative when it comes to names.
Inspiration
Python is my favorite language. In my free time, I dig around through the default cpython interpreter source and every now and then make my own edits to it for fun. This is one of those edits.
What it does
You can store valid python code in an image without actually changing the image, and now run the image as if it were the python code.
Example:
$ python -p myimage.png hello_world.py # Just prints hello world
# myimage.png can now be run as a python script
$ python myimage.png
Hello world
# Additionally, the image has no visible changes to it and looks the same as it did before
How I built it
Using an image editing library in C, I embed individual bits of the original source code into pixels in the original image. These bits are then extracted from the image when executing it. (Essentially stenanography.) This was implemented in C since the default python interpreter is written in C. The default interpreter was also edited enough to support accepting images as concealing data in those images.
Algorithm Used
The actual algorithm used for concealing data within the images is pretty simple, but can also be changed easily to support other, more complex algorithms. The default one is hiding every two bits in the two least significant bits of the R value in each sequential pixel. For this, the number of bits can be increased or decreased at the cost of altering the image more or not having enough room to store the original code.
Challenges I ran into
- C (not C++) has a very limited number of image processing libraries (at least that I know of). As of now, only pngs are supported.
- The image that will have the code stored in it must be large enough to actually store the code.
- Supporting all the features of python while still being able to run an image
Accomplishments that I'm proud of
- Edited the cpython interpreter, the tool that is in charge of evaluating one of the most popular languages in the world.
- Did this all by myself
- Glad that I know my C as well as my python
What I learned
- The source code for cpython is very bulky
- There are a limited number of image processing programs in C
What's next for PiThon
- The only thing that I have tested for and have not had time to solve yet was being able to use frameworks that exist within a virtual environment in the picture. I am able to import functions/classes from other files given that the image is in the same directory as them or they are also located on the PYTHONPATH.
- Implement other algorithms for concealing images
Log in or sign up for Devpost to join the conversation.