Created
July 3, 2024 23:45
-
-
Save jimdiroffii/deba160b368b4b3dec0cc80376a714c3 to your computer and use it in GitHub Desktop.
Python Image Generator - Useful for generating text into images, testing template injection attacks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageDraw, ImageFont | |
def main(): | |
# Define image size (x,y) in pixels | |
img = Image.new('RGB', (2000,100)) | |
draw = ImageDraw.Draw(img) | |
# Choose an easily readable font for OCR | |
myFont = ImageFont.truetype('LiberationMono-Regular.ttf', 15) | |
# Text to insert into image | |
payload = "{{ 191 * 7 }}" | |
# (255,255,255) draws white text onto a default black background | |
draw.text((0,3), payload, fill=(255,255,255), font=myFont) | |
img.save('payload.png') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment