JPG图片中默认存在敏感数据,例如位置,相机类型等,可以使用Python脚本提取出来,加以利用,自己手动拍摄一张照片,然后就能解析出这些敏感数据了,对于渗透测试信息搜索有一定帮助,但有些相机默认会抹除这些参数。
提取图片EXIF参数: 通过提取指定图片的EXIF参数结合GPS数据定位到当时拍摄图片的物理位置.
import os,sys,json import exifread import urllib.request
def getlocation(lat,lon): url = "http://api.map.baidu.com/reverse_geocoding/v3/?ak=GPqF0q0uFT4zOmVKmPU7 \ gu3SmB9z3jFV&output=json&coordtype=wgs84ll&location="+lat+","+lon req = urllib.request.urlopen(url) res = req.read().decode("utf-8") string = json.loads(res) jsonResult = string.get("result") formatted_address = jsonResult.get("formatted_address") print("目标所在城市: {}".format(formatted_address))
if __name__ == "__main__": if len(sys.argv) < 2: print("[-] 请传递一个图片地址") else: ImageName = str(sys.argv[1]) with open(ImageName,'rb') as f: tags = exifread.process_file(f) print("设备品牌: {}".format(tags['Image Make'])) print("具体型号: {}".format(tags['Image Model'])) print('照片尺寸: {} x {}'.format(tags['EXIF ExifImageWidth'], tags['EXIF ExifImageLength'])) print("创建日期: {}".format(tags['Image DateTime'])) print("拍摄时间: {}".format(tags["EXIF DateTimeOriginal"].printable)) print("GPS处理方法: {}".format(tags['GPS GPSProcessingMethod'])) print("GPSTimeStamp: {}".format(tags['GPS GPSTimeStamp'])) print("拍摄软件版本: {}".format(tags['Image Software'])) LatRef=tags["GPS GPSLatitudeRef"].printable Lat=tags["GPS GPSLatitude"].printable[1:-1].replace(" ","").replace("/",",").split(",") Lat=float(Lat[0])+float(Lat[1])/60+float(Lat[2])/float(Lat[3])/3600 if LatRef != "N": Lat=Lat*(-1) LonRef=tags["GPS GPSLongitudeRef"].printable Lon=tags["GPS GPSLongitude"].printable[1:-1].replace(" ","").replace("/",",").split(",") Lon=float(Lon[0])+float(Lon[1])/60+float(Lon[2])/float(Lon[3])/3600 if LonRef!="E": Lon=Lon*(-1) f.close() print("目标所在经纬度: {},{}".format(Lat,Lon)) getlocation(str(Lat),str(Lon))
|
将图片转为字符图片: 通过pillow图片处理库,对图片进行扫描,然后用特殊字符替换图片的每一个位,生成的字符图片.
from PIL import Image import argparse
def get_char(r,g,b,alpha = 256): ascii_char = list("~!@#$%^&*()_+ ") if alpha == 0: return " " length = len(ascii_char) gray = int(0.2126 * r + 0.7152 * g + 0.0722 * b) unit = (256.0 + 1)/length return ascii_char[int(gray/unit)]
if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--file",dest="file",help="指定一个图片文件") parser.add_argument("--width",dest="width",type=int,default=50,help="指定图片宽度") parser.add_argument("--height",dest="height",type=int,default=25,help="指定图片高度") args = parser.parse_args() if args.file != None: img = Image.open(args.file) img = img.resize((args.width,args.height), Image.NEAREST) txt = "" for row in range(args.height): for cow in range(args.width): txt += get_char(*img.getpixel((cow,row))) txt += "\n" print(txt) else: parser.print_help()
|