Skip to content

Instantly share code, notes, and snippets.

@73spica
Last active October 4, 2016 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 73spica/d5973048a86acadd24c0f78441009061 to your computer and use it in GitHub Desktop.
Save 73spica/d5973048a86acadd24c0f78441009061 to your computer and use it in GitHub Desktop.
from PIL import Image
# H4CK1T CTF 2016 Online
# Mozambique – 1magePr1son ($TEGO 150 pts )
def main():
img = Image.open("./planet.png")
rgb_img = img.convert("RGB")
print img
size = rgb_img.size
rgb_img2 = Image.new("RGB",size)
for x in xrange(size[0]):
for y in xrange(size[1]):
# get pixel
r,g,b = rgb_img.getpixel((x,y))
if x%24==0 and y%24==0:
if r-g >90 and b-g>90:
r = 255
g = 255
b = 255
else:
r = 0
g = 0
b = 0
else:
r = 0
g = 0
b = 0
rgb_img2.putpixel((x,y),(r,g,b))
print rgb_img2
rgb_img2.save("./ans.png")
img3 = Image.new("RGB",size)
for x in xrange(size[0]):
for y in xrange(size[1]):
# get pixel
r,g,b = rgb_img2.getpixel((x,y))
if r==255 and g ==255 and b==255:
r = 254
for i in xrange(-2,3):
for j in xrange(-2,3):
img3.putpixel((x+i,y+j),(r,g,b))
print img3
img3.save("./ans_modified.png")
if __name__ == '__main__':
main()
@73spica
Copy link
Author

73spica commented Oct 3, 2016

H4CK1T CTF 2016 Online
Mozambique – 1magePr1son ($TEGO 150 pts )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment