zoukankan      html  css  js  c++  java
  • Bing资产查询脚本

        在实际渗透过程中,对目标信息收集越完整,成功率往往越高。但是在对出口段探测的时候,很多主机所属资产不容易准确识别。这里我们用Bing查询IP来作为辅助参考往往会有意想不到的效果。

    测试如图:

    代码:

    #-*- coding: utf-8 -*-
    import sys
    import requests
    import re
    
    
    from requests.packages.urllib3.exceptions import InsecureRequestWarning
    requests.packages.urllib3.disable_warnings()
      
    def scan(ip = ''):
        print ('[*]:{}'.format(ip)) 
        try:
            global res
            res = requests.get('http://www.bing.com/search?q=ip:{}&count=50'.format(ip),timeout=10)
        except Exception as e:
            print (str(e))
        regex = re.compile(r'<li class="b_algo"><h2><a href="(.*?)"')
        matchs = []
        try:
            matchs = regex.findall(res.content.decode())
        except UnicodeDecodeError:
            matchs = regex.findall(res.content)
        for val in matchs:
            print (val)
           
    def getips(host = ''):
        ips = []
        ip_pre = ""
        for pre in host.split('.')[0:3]:
            ip_pre = ip_pre + pre +'.'
        for i in range(1,255):
            ips.append(ip_pre + str(i))
        return ips
    
    def usage():
        print ("[*] python bing.py 192.168.1.1 
    ")
        sys.exit(1)
    
    def main(host = ''):
        ips = list()
        ips = getips(host)
        for ip in ips:
            scan(ip)
        return
        
    if __name__ == "__main__":
        if len(sys.argv) != 2:
            usage()
        host = sys.argv[1]
        try:
            main(host)
        except KeyboardInterrupt as e:
            sys.exit(-1)
        
  • 相关阅读:
    C++ map的基本操作和用法
    堆排序汇总
    gdb调试多进程和多线程命令
    Linux内存分配机制
    svn 修改文件的可执行权限
    proc/sys/net/ipv4/下各项的意义
    linux read()和write
    ps命令参数
    /etc/passwd- 和/etc/shadow-文件
    openssh源码分析笔记
  • 原文地址:https://www.cnblogs.com/persuit/p/6665357.html
Copyright © 2011-2022 走看看