The image in this tweet is needed to solve this challenge: https://twitter.com/leonjza/status/1678419863436443648
Last active
July 10, 2023 15:05
-
-
Save leonjza/cb9034e7b4ca81d064621dcc54705cf1 to your computer and use it in GitHub Desktop.
SenseCon '23 Announcement Challenge
This file contains 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
<? | |
class Message { | |
private $message = "This was the announcement challenge for SenseCon '23, our annual internal @sensepost hackathon. Have fun solving it!"; | |
function echo_it() { | |
echo $this->message . PHP_EOL; | |
} | |
function write($message, $source, $target) { | |
$binary = ''; | |
for ($i = 0; $i < mb_strlen($message); ++$i) { | |
$character = ord($message[$i]); | |
$binary .= str_pad(decbin($character), 8, '0', STR_PAD_LEFT); | |
} | |
$binary .= '00000011'; | |
$img = imagecreatefrompng($source); | |
$pos = 0; | |
for ($y = 0; $y < imagesy($img); $y++) { | |
for ($x = 0; $x < imagesx($img); $x++) { | |
if (!isset($binary[$pos])) break 2; | |
$colors = imagecolorsforindex($img, imagecolorat($img, $x, $y)); | |
$blue = str_pad(decbin($colors['blue']), 8, '0', STR_PAD_LEFT); | |
$blue[strlen($blue) - 1] = $binary[$pos] == '1' ? '0' : '1'; | |
$newBlue = bindec($blue); | |
$newColor = imagecolorallocatealpha( | |
$img, $colors['red'], $colors['green'], $newBlue, $colors['alpha']); | |
imagesetpixel($img, $x, $y, $newColor); | |
$pos++; | |
} | |
} | |
imagepng($img, $target, 9); | |
imagedestroy($img); | |
} | |
} | |
$t = new Message; | |
$t->echo_it(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment