diff --git a/rizzfield/README.md b/rizzfield/README.md new file mode 100644 index 0000000..9b82f1c --- /dev/null +++ b/rizzfield/README.md @@ -0,0 +1,13 @@ +# Rizzfield + +## Text + +What's 9 + 10? + +## Files + +rizzfield.gif + +## How to Deploy + +N/A diff --git a/rizzfield/SOLUTION.md b/rizzfield/SOLUTION.md new file mode 100644 index 0000000..98e0789 --- /dev/null +++ b/rizzfield/SOLUTION.md @@ -0,0 +1,15 @@ +## Difficulty + +Medium++ + +## Category + +Steg + +## How To Solve + +I changed the color of the 21th frame. What you can do, is randomize the entire palette of the 21th frame and the text should become visible. + +## Flag + +IGCTF{H3sGoTsTh3RiZz} diff --git a/rizzfield/frame_destroyer.py b/rizzfield/frame_destroyer.py new file mode 100644 index 0000000..c20203b --- /dev/null +++ b/rizzfield/frame_destroyer.py @@ -0,0 +1,42 @@ +from PIL import Image +import numpy as np + +# Load the GIF +gif_path = "./garfield-garfield-meme-ezgif.com-added-text.gif" +gif = Image.open(gif_path) + +# Define the color you want to replace (original text color) and the new color +original_text_color = (55, 126, 34) # Replace with the actual color of the text in RGB +new_text_color = (255, 254, 253) # Desired replacement color, e.g., black + +# Function to find the indices of the top 5 closest colors in the palette +def find_closest_palette_color_indices(palette, target_color, num_colors=25): + palette = np.array(palette).reshape(-1, 3) + target_color = np.array(target_color) + distances = np.sqrt(((palette - target_color) ** 2).sum(axis=1)) + # Get the indices of the closest colors + return distances.argsort()[:num_colors] + +# Extract frames and modify frame 21 +frames = [] +for i in range(gif.n_frames): + gif.seek(i) + new_frame = gif.convert("P", palette=Image.ADAPTIVE) # Convert to palette mode + + if i == 20: + # Get the palette and find the closest color indices for the original text color + palette = new_frame.getpalette() + closest_color_indices = find_closest_palette_color_indices(palette, original_text_color, num_colors=255) + + # Modify the palette at each of the closest color indices to the new color + for idx in closest_color_indices: + palette[idx*3:idx*3+3] = list(new_text_color) + new_frame.putpalette(palette) + + # Append the modified (or unmodified) frame + frames.append(new_frame) + +# Save the modified GIF +output_path = "./modified_gif.gif" +frames[0].save(output_path, save_all=True, append_images=frames[1:], loop=0, duration=gif.info['duration']) +print(f"Modified GIF saved as {output_path}") diff --git a/rizzfield/randomize_palette.py b/rizzfield/randomize_palette.py new file mode 100644 index 0000000..c215fa8 --- /dev/null +++ b/rizzfield/randomize_palette.py @@ -0,0 +1,37 @@ +from PIL import Image +import random + +# Load the GIF +gif_path = "./garfield-garfield-meme-ezgif.com-added-text.gif" +gif = Image.open(gif_path) + +# Function to randomize the palette +def randomize_palette(palette): + # Convert palette (a flat list) to a list of (R, G, B) tuples + colors = [(palette[i], palette[i + 1], palette[i + 2]) for i in range(0, len(palette), 3)] + # Shuffle the colors + random.shuffle(colors) + # Flatten the list back to the original format + randomized_palette = [val for color in colors for val in color] + return randomized_palette + +# Extract frames and modify frame 21 +frames = [] +for i in range(gif.n_frames): + gif.seek(i) + new_frame = gif.convert("P", palette=Image.ADAPTIVE) # Convert to palette mode + + if i == 20: + # Get the palette of the frame and randomize it + palette = new_frame.getpalette() + randomized_palette = randomize_palette(palette) + # Apply the randomized palette to the frame + new_frame.putpalette(randomized_palette) + + # Append the modified (or unmodified) frame + frames.append(new_frame) + +# Save the modified GIF +output_path = "./randomized_palette_gif.gif" +frames[0].save(output_path, save_all=True, append_images=frames[1:], loop=0, duration=gif.info['duration']) +print(f"Modified GIF with randomized palette saved as {output_path}") diff --git a/rizzfield/rizzfield.gif b/rizzfield/rizzfield.gif new file mode 100644 index 0000000..af62a2d Binary files /dev/null and b/rizzfield/rizzfield.gif differ diff --git a/rizzfield/solution.gif b/rizzfield/solution.gif new file mode 100644 index 0000000..6f9f84b Binary files /dev/null and b/rizzfield/solution.gif differ