Last active
July 10, 2023 15:05
-
-
Save leonjza/cb9034e7b4ca81d064621dcc54705cf1 to your computer and use it in GitHub Desktop.
Revisions
-
leonjza revised this gist
Jul 10, 2023 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ # SenseCon '23 Announcement Challenge The image in this tweet is needed to solve this challenge: https://twitter.com/leonjza/status/1678419863436443648 -
leonjza created this gist
Jul 10, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ <? 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();