CYBV-473-WK-10-SEEK

.py
School
University Of Arizona**We aren't endorsed by this school
Course
CYBV 473
Subject
Communications
Date
Dec 19, 2024
Pages
2
Uploaded by CaptainFang11596
'''WK-10 Extraction of Covert Messages'''import sysimport osfrom collections import OrderedDict''' 3rd Party Library '''from PIL import Image'''Image Orientation||y (rows) ||| -----------------------------x (columns)'''# Pixel tuple indexRED = 0GREEN = 1BLUE = 2codeBook = OrderedDict()codeBook[0] = '0-Dead Drop @'codeBook[1] = '1-Corner of Lexington Ave and E 48th Street'codeBook[2] = '2-Corner of Madison Ave and E 34th Street'codeBook[3] = '3-Drop Package in Potted Plant outside Wells Fargo'codeBook[4] = '4-Drop Package in Gold Gargage Can'codeBook[5] = '5-12 PM Sharp'codeBook[6] = '6-7 AM Sharp'codeBook[7] = '7-Abort if you see a Red Rose'def clear():for i in range(0, 2):print() class EXTRACT_CONTENT:''' COVERT Image Creation Class '''def __init__(self, baseImage, covertImage):try:self.baseImg = Image.open(baseImage)self.covertImg = Image.open(covertImage)self.height = self.baseImg.heightself.width = self.baseImg.widthself.basePIX = self.baseImg.load()self.covertPIX = self.covertImg.load()except Exception as err:sys.exit(str(err))
Background image
self.usedPixelList = []def ExtractAlteredPixels(self):self.recoveredMessage = []for row in range(0, self.height):for col in range(0, self.width):basePix = self.basePIX[col, row]covertPix = self.covertPIX[col, row]if basePix != covertPix:redPix = covertPix[0]grnPix = covertPix[1]bluPix = covertPix[2] redLSB = redPix & 0b00000001grnLSB = grnPix & 0b00000001bluLSB = bluPix & 0b00000001codeIndex = redLSB*4 + grnLSB*2 + bluLSB*1self.recoveredMessage.append(codeBook[codeIndex])def PrintResults(self):print("\n=============== Recovered Messages =================\n")indentLevel = 1for eachCodebookEntry in self.recoveredMessage:print(" "*(indentLevel*2), "Step:", indentLevel, "->", eachCodebookEntry[2:])indentLevel+=1if __name__ == '__main__':# Create PixelSearch Objectprint("\nExtracting Covert Message Ver .50\n")covertFile = input("\nSelect Covert File: ")if not os.path.isfile(covertFile):sys.exit("\nInvalid Covert File\n")covertObj = EXTRACT_CONTENT('monalisa.bmp', covertFile)covertObj.ExtractAlteredPixels()covertObj.recoveredMessage.sort()covertObj.PrintResults()
Background image