• Web爬虫--fofa-资产信息搜集


    免责声明:本文仅做技术交流与学习...

    目录

    fofa.py

    fofa搜索参数分析

    fofa_api.py


    fofa.py

    1. import requests
    2. from bs4 import BeautifulSoup
    3. # 登录fofa之后,把自己的cookie弄过来.
    4. header={
    5. 'cookie':''
    6. }
    7. # 参数为搜索的语法.
    8. url='https://fofa.info/result?qbase64=dGl0bGU9IuS4iua1t%2BS6pOmAmuWkp%2BWtpiIgJiYgY291bnRyeT0iQ04i'
    9. s=requests.get(url,headers=header).text
    10. # print(s)
    11. soup = BeautifulSoup(s, 'lxml')
    12. # 获取要搜索的总页数.
    13. edu1=soup.find_all('p',attrs={'class': 'hsxa-nav-font-size'})
    14. for edu in edu1:
    15. edu_name = edu.span.get_text()
    16. i=int(edu_name)/10
    17. yeshu=int(i)+1
    18. # print(yeshu)
    19. # 依次对每页的数据进行爬取:
    20. for ye in range(1,yeshu+1):
    21. url = 'https://fofa.info/result?qbase64=dGl0bGU9IuS4iua1t%2BS6pOmAmuWkp%2BWtpiIgJiYgY291bnRyeT0iQ04i&page='+str(ye)+'&page_size=10'
    22. print(url)
    23. s = requests.get(url,headers=header).text
    24. edu1=soup.find_all('span',attrs={'class': 'hsxa-host'})
    25. # 提取所有域名(网址):
    26. for edu in edu1:
    27. edu_name = edu.a.get_text().strip()
    28. print(edu_name)

    fofa搜索参数分析

    --------------> 

     


    fofa_api.py

    通过fofa的api接口直接调用.

    1. import requests
    2. import base64
    3. # email=your_email&key=your_key&qbase64=dGl0bGU9ImJpbmci
    4. def get_fofa_data(email, apikey):
    5. for edu_name in open('edu_name.txt', encoding='utf-8'):
    6. e = edu_name.strip()
    7. # 搜索语法
    8. search = '"%s" && country="CN" && title=="Error 404--Not Found"' % e
    9. # 先编码在解.......
    10. b = base64.b64encode(search.encode('utf-8'))
    11. b = b.decode('utf-8')
    12. url = 'https://fofa.info/api/v1/search/all?email=%s&key=%s&qbase64=%s' % (email, apikey, b)
    13. s = requests.get(url).json()
    14. print('查询->' + edu_name)
    15. print(url)
    16. # 拿取详细数据:
    17. if s['size'] != 0:
    18. print(edu_name + '有数据啦!')
    19. for ip in s['results']:
    20. print(ip[0])
    21. else:
    22. print('没有数据')
    23. if __name__ == '__main__':
    24. email = ''
    25. apikey = ''
    26. get_fofa_data(email, apikey)


  • 相关阅读:
    mysql之数据表高级操作
    GJB 5000B二级-II实施基础
    HTML 之 块级元素、行内元素和行内块元素之间的嵌套规则
    网络知识点之-HTTP协议
    常见问题小结
    CANopen Object 1000h: Device type 多设备信息
    浅析Relaxed Ordering对PCIe系统稳定性的影响
    一文理解所有需求分析中的基本术语
    【JDBC】----封装工具类和ORM
    【数据结构与算法】图的基本概念
  • 原文地址:https://blog.csdn.net/2303_80857229/article/details/139724299