0x00前言:
大家都知道图片是有Exif信息的。里面包含着
你的GPS信息。还有拍摄时间等等的敏感信息。
0x01准备:
exifread
requests
0x02思路:
读取图片的Exif信息。
如果有GPS信息就将其扔到脚本的ip定位功能
0x03代码:
import optparse from PIL import Image import requests import exifread def main(): usage="-x [选择图片]" "-i [ip]" parser=optparse.OptionParser(usage) parser.add_option('-x',dest='Exif',help='提取图片的Exif') parser.add_option('-i',dest='host',help='ip解析成经纬度') (options,args)=parser.parse_args() if options.Exif: exif=options.Exif EXIF(exif) elif options.host: host=options.host HOST(host) else: parser.print_help() exit() def EXIF(exif): f = open(exif, 'rb') tags = exifread.process_file(f) for tag in tags.keys(): if tag not in ('JPEGThumbnail', 'TIFFThumbnail', 'Filename', 'EXIF MakerNote'): print(tag, tags[tag]) def HOST(host): headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36'} url = "http://api.map.baidu.com/location/ip?ip={}&ak=你的AK".format(host) r = requests.get(url, headers=headers) json = r.json() print('[+]地址', json['address']) print('[+]省', json['content']['address_detail']['province']) print('[+]市', json['content']['address_detail']['city']) print('[+]纬度', json['content']['point']['y']) print('[+]经度', json['content']['point']['x']) if __name__ == '__main__': main()
0x04结果:
百度IP定位免费API:http://lbsyun.baidu.com/index.php?title=webapi