# Light SaBer solve ### There are only two pictures in the file. ![flag](https://hackmd.io/_uploads/SJBk0mu4T.png) ![image](https://hackmd.io/_uploads/BJrZA7O46.png) --- ### Use HxD to open the help.png image and modify its height. ![image](https://hackmd.io/_uploads/HJdhCQuEa.png) >## Get the picture below, which says ASCII CODE. >![image](https://hackmd.io/_uploads/r16fJEd4T.png) --- ### Use stegsolve to open and check the image. ![image](https://hackmd.io/_uploads/SkHENEOEa.png) ![image](https://hackmd.io/_uploads/SJnHE4_N6.png) --- >## You can find that Blue Plane 0 seems to have a missing qrcode. >![image](https://hackmd.io/_uploads/Sk7D4VOEp.png) --- ### Save the image, splice the Qrcode and scan it to get a URL. ![image](https://hackmd.io/_uploads/rk3XUVuEp.png) > ## https://webtes.onrender.com/ --- ### Go to the website and you will see an interface where you can upload files and enter messages. ![image](https://hackmd.io/_uploads/r10I8NOVp.png) ### Try to upload the image and use stegsolve to check the returned image. ![IMG_1183](https://hackmd.io/_uploads/HJ8r5NO46.png) ![image](https://hackmd.io/_uploads/r1DN5E_Na.png) > ## Get the picture below >![encoded_IMG_1183](https://hackmd.io/_uploads/HkiI5NOEp.png) ### Found that some pixels were changed ![image](https://hackmd.io/_uploads/Hyth9Eu46.png) ![image](https://hackmd.io/_uploads/ByeCqNdEa.png) ![image](https://hackmd.io/_uploads/S1LJiNOVp.png) ### It is speculated that LSB steganography using ascii code is used to send three different color images for checking. >## etect B channel >![image](https://hackmd.io/_uploads/HJwroNuEa.png) >## etect R channel >![image](https://hackmd.io/_uploads/ry6PiNdE6.png) >## etect G channel >![image](https://hackmd.io/_uploads/HJKYsEuET.png) > ## Presumably using the G 'green' channel --- ### Write a script to check the modified pixel coordinate position of the image and record it ``` from PIL import Image import numpy as np image_path_1 = r"C:\Users\Maxsu\OneDrive\桌面\image1.png" image_path_2 = r"C:\Users\Maxsu\OneDrive\桌面\image2.png" def compare_images_and_print(image_path_1, image_path_2): # Load the images image1 = Image.open(image_path_1) image2 = Image.open(image_path_2) # Convert images to numpy arrays array1 = np.array(image1) array2 = np.array(image2) # Check if both images have the same size if array1.shape != array2.shape: raise ValueError("Images do not have the same size") # Find the pixels that are different diff = array1 != array2 diff_coords = np.where(diff) if np.any(diff): # If there are any differences # Extract the modified pixel values from both images modified_pixels_image1 = array1[diff_coords] modified_pixels_image2 = array2[diff_coords] # Prepare the data to be printed differences = list(zip(zip(*diff_coords), modified_pixels_image1, modified_pixels_image2)) # Define a custom sorting function based on y, then x values def custom_sort(item): coords, orig_pixel, mod_pixel = item return (coords[1], coords[0]) # Sort by y first, then x # Sort the differences list using the custom sorting function differences.sort(key=custom_sort) # Print the differences for coords, orig_pixel, mod_pixel in differences: print(f"Coordinates: {coords}, Original: {orig_pixel}, Modified: {mod_pixel}") else: # If the images are the same print("圖片相同") # Run the comparison and catch any exceptions try: compare_images_and_print(image_path_1, image_path_2) except ValueError as e: print(e) ``` --- #### Presumed to be ascii code conversion, use ÿ character to test the website #### Enter messages of different lengths and you will find that up to 24 pixels will be modified. ![image](https://hackmd.io/_uploads/Hkaohka4p.png) ![image](https://hackmd.io/_uploads/Hk_KMx6VT.png) --- ![image](https://hackmd.io/_uploads/SygTn1aVp.png) ![image](https://hackmd.io/_uploads/r1cozeTV6.png) --- ![image](https://hackmd.io/_uploads/S1Y96JpVp.png) ![image](https://hackmd.io/_uploads/HkgTMlaVa.png) --- ![image](https://hackmd.io/_uploads/Hyu0hJT4p.png) ![image](https://hackmd.io/_uploads/Hy1CflT46.png) --- >## Can detect up to three steganographic characters and record their coordinate sequence >first character(57, 57), (58, 8), (63, 54), (94, 46), (96, 160),(135, 88), (138, 110), (157, 169) >second character(4, 184), (6, 59),(25, 0), (63, 178), (84, 90), (144, 177), (145, 123),(149, 91) >third character (40, 56), (55, 153), (101, 157), (108, 9), (131, 55), (134, 115), (186, 153), (194, 36) ### According to the rules obtained from the records, it is found that ascii code is used ### Use record coordinates to write a script to decrypt flag.png --- ``` from PIL import Image def lsb_decrypt_print_ascii_and_message(image_path, coordinates): try: # Load the image for decoding image = Image.open(image_path) pixels = image.load() # Retrieve the binary bits from the image's LSB of the green channel binary_bits = '' for coord in coordinates: x, y = coord pixel = list(pixels[x, y]) # Extract the LSB of the green channel binary_bits += str(pixel[1] & 1) # Chunk the binary string into bytes of 8 bits binary_chunks = [binary_bits[i:i+8] for i in range(0, len(binary_bits), 8)] # Convert binary bytes to ASCII codes ascii_codes = [int(binary, 2) for binary in binary_chunks] # Convert binary bytes to ASCII characters message = ''.join([chr(code) for code in ascii_codes]) # Print out the ASCII codes and the message print("ASCII Codes:", ascii_codes) print("Decoded Message:", message) return ascii_codes, message except Exception as e: print(f"Error decoding image: {e}") return None, None # Coordinates provided in the original script coordinates = [ (57, 57), (58, 8), (63, 54), (94, 46), (96, 160), (135, 88), (138, 110), (157, 169), (4, 184), (6, 59), (25, 0), (63, 178), (84, 90), (144, 177), (145, 123), (149, 91), (40, 56), (55, 153), (101, 157), (108, 9), (131, 55), (134, 115), (186, 153), (194, 36) ] # Placeholder for the actual path to the image # Make sure to replace this with the actual path where the image is stored on your computer image_path = r"C:\Users\Maxsu\OneDrive\桌面\encoded_falg1 (2).PNG" # Decrypt the message and print both ASCII codes and the decoded message ascii_codes, message = lsb_decrypt_print_ascii_and_message(image_path, coordinates) ``` ### get flag ![image](https://hackmd.io/_uploads/ByJePlaET.png) MCDX{orz}