image_type headers['content-type'split("/")[ image http_payload[http_payload index("\ \ \ \ ")+ :if we detect compression decompress the image tryif "content-encodingin headers keys()if headers['content-encoding'="gzip"image zlib decompress(image +zlib max_wbitselif headers['content-encoding'="deflate"image zlib decompress(imageexceptpass exceptreturn none,none return image,image_type these supporting functions help us to take closer look at the http data that we retrieved from our pcap file the get_http_headers function takes the raw http traffic and splits out the headers using regular expression the extract_image function takes the http headers and determines whether we received an image in the http response if we detect that the content-type header does indeed contain the image mime typewe split out the type of imageand if there is compression applied to the image in transitwe attempt to decompress it before returning the image type and the raw image buffer now let' drop in our facial detection code to determine if there is human face in any of the images that we retrieved add the following code to pic_carver pydef face_detect(path,file_name)img cv imread(pathcascade cv cascadeclassifier("haarcascade_frontalface_alt xml"rects cascade detectmultiscale(img cv cv cv_haar_ scale_image( , )if len(rects= return false rects[: :+rects[:: highlight the faces in the image for , , , in rectscv rectangle(img,( , ),( , ),( , , ), cv imwrite("% /% -% (faces_directory,pcap_file,file_name),imgreturn true this code was generously shared by chris fidao at slight modifications by yours truly using the opencv python bindingswe can read in the image and then apply classifier that is trained in advance for detecting faces in front-facing orientation there are classifiers for profile (sidewaysface detectionhandsfruitand whole host of other objects that you can try out for yourself after the detection has been runit will return rectangle coordinates that correspond to where the face was detected in the image we then draw an actual green rectangle over that area and write out the resulting image now let' take this all for spin inside your kali vm