python打造社工脚本

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

转载于:https://www.cnblogs.com/haq5201314/p/8590367.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值