Skip to content

Instantly share code, notes, and snippets.

@jimdiroffii
Created July 3, 2024 23:45
Show Gist options
  • Save jimdiroffii/deba160b368b4b3dec0cc80376a714c3 to your computer and use it in GitHub Desktop.
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
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