资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

http_banner获取v0.2-创新互联

#-*-coding=utf-8-*-
# __author__  = 'sanr'
# __email__   = '5754190@qq.com'
# __url__     = 'http://0x007.blog.51cto.com/'
# __version__ = '0.2'
import requests
import re
from threading import Thread,Lock
import time
import sys
import chardet
import netaddr
import struct
import socket

lock = Lock()

def ip2int(addr):
        return struct.unpack("!I", socket.inet_aton(addr))[0]
def int2ip(addr):
        return socket.inet_ntoa(struct.pack("!I", addr))
def int_dec(pagehtml):

        charset = None
        if pagehtml != '':
                # print 'use charset dect'
                enc = chardet.detect(pagehtml)
                # print 'enc= ', enc
                if enc['encoding'] and enc['confidence'] > 0.9:
                        charset = enc['encoding']

                if charset == None:
                        charset_re = re.compile("((^|;)\s*charset\s*=)([^\"']*)", re.M)
                        charset=charset_re.search(pagehtml[:1000]) 
                        charset=charset and charset.group(3) or None

                # test charset
                try:
                        if charset:
                                unicode('test',charset,errors='replace')
                except Exception,e:
                        print 'Exception',e
                        charset = None
        # print 'charset=', charset
        return charset


def http_banner(url):
        ip=url
        try:
                url=requests.get(url,timeout=2)        

                body = url.content
                
                charset = None
                if body != '':
                        charset = int_dec(body)

                if charset == None or charset == 'ascii':
                        charset = 'ISO-8859-1'

                if charset and charset != 'ascii' and charset != 'unicode':
                        try:
                                body = unicode(body,charset,errors='replace')
                        except Exception, e:
                                body = ''
                Struts=url.status_code
                Server=url.headers['server'][0:13]
                if Struts==200 or Struts==403 or Struts==401:
                        title=re.findall(r"(.*)<\/title>",body)
                        if len(title):
                                title = title[0].strip()
                        else:
                                title = ''
                        lock.acquire()
                        print ('%s\t%d\t%-10s\t%s'%(ip.lstrip('http://'),Struts,Server,title))
                        lock.release()
        except (requests.HTTPError,requests.RequestException,AttributeError,KeyError),e:
                pass



if __name__ == '__main__':
        if len(sys.argv) >= 2:
                ips = sys.argv[1]
        else:
                print 'usage: python http_banner.py 192.168.1./24 '
                print 'usage: python http_banner.py 192.168.1.1-192.168.1.254 '
                print 'usage: python http_banner.py 192.168.1./24 8080'
                print 'usage: python http_banner.py 192.168.1.1-192.168.1.254 8080'
                sys.exit()
        port = '80'
        if len(sys.argv) == 3:
                port = sys.argv[2]
                
        if '-' in ips:
                start, end = ips.split('-')
                startlong = ip2int(start)
                endlong = ip2int(end)
                ips = netaddr.IPRange(start,end)
                for ip in list(ips):
                        url='http://%s:%s'%(ip,port)
                        t = Thread(target=http_banner,args=(url,))
                        t.daemon=False
                        t.start()
        elif '/'        in ips:
                ips = netaddr.IPNetwork(ips)
                for ip in list(ips):
                        url='http://%s:%s'%(ip,port) 
                        t = Thread(target=http_banner,args=(url,))
                        t.daemon=False
                        t.start()</pre><p><strong>更新了端口自定义 默认端口为80</strong></p>创新互联于2013年创立,先为泰和等服务建站,泰和等地企业,进行企业商务咨询服务。为泰和企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。<p><strong><img src="/upload/otherpic16/131896.jpg" alt="http_banner获取v0.2"></strong></p><p><img src="/upload/otherpic16/131898.jpg" alt="http_banner获取v0.2"></p><p><img src="/upload/otherpic16/131902.jpg" alt="http_banner获取v0.2"></p><p align=center>另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、<a href="https://www.cdcxhl.com/gaofang/" target="_blank">高防服务器</a>、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。</p>            <br>
            当前名称:http_banner获取v0.2-创新互联            <br>
            网站路径:<a href="http://www.cdkjz.cn/article/cdgsdp.html">http://www.cdkjz.cn/article/cdgsdp.html</a>
        </div>
        <div class="g-return-wrapper clearfix">
            <a href="http://www.cdkjz.cn/" class="home">返回首页</a>
            <a href="http://www.cdkjz.cn/news/" class="column">了解更多建站资讯</a>
        </div>
    </div>
</div>
<div class="full-related-news">
    <h3 class="related-title">相关资讯</h3>
    <div class="related-news weblg">
        <ul class="clearfix">
            <li>
                    <a href="/article/dgpdosi.html">
                        <h2 class="title">超级粉丝团qq小程序 超级粉丝团怎么集结</h2>
                    </a>
                </li><li>
                    <a href="/article/dgpdoej.html">
                        <h2 class="title">html5保存拖拽 h5拖拽时样式修改</h2>
                    </a>
                </li><li>
                    <a href="/article/dgpohgp.html">
                        <h2 class="title">ios开发获取状态 applald获取</h2>
                    </a>
                </li><li>
                    <a href="/article/dgpdoed.html">
                        <h2 class="title">电脑搜狗截屏快捷键 电脑搜狗截屏快捷键是哪个</h2>
                    </a>
                </li><li>
                    <a href="/article/dgpdooe.html">
                        <h2 class="title">css样式对齐怎么设置的简单介绍</h2>
                    </a>
                </li><li>
                    <a href="/article/dgpohhj.html">
                        <h2 class="title">ios开发系统构架图 ios开发架构有哪几种</h2>
                    </a>
                </li><li>
                    <a href="/article/dgpdosp.html">
                        <h2 class="title">ios无障碍模式开发 无障碍模式怎么打开苹果</h2>
                    </a>
                </li><li>
                    <a href="/article/dgpohpp.html">
                        <h2 class="title">android计步器制作 手机计步器制作</h2>
                    </a>
                </li>        </ul>
    </div>
</div>
<div class="full-icontact-cover m-ft-contact">
    <div class="weblg">
        <div class="clearfix content">
            <div class="motto">
                多年建站经验
            </div>
            <div class="info">
                <h3>多一份参考,总有益处</h3>
                <h2> 联系快上网,免费获得专属《策划方案》及报价</h2>
                <div class="msg">
                    <p>咨询相关问题或预约面谈,可以通过以下方式与我们联系</p>
                    <h4> 大客户专线   成都:<a
                            href="tel:+13518219792" rel="nofollow">13518219792</a>
                          座机:<a href="tel:02886922220" rel="nofollow">028-86922220</a>
                    </h4>
                </div>
            </div>
        </div>
        <div class="btns clearfix">
            <a href="https://wpa.qq.com/msgrd?v=3&uin=631063699&site=qq&menu=yes" target="_blank" rel="nofollow"
               class="oline">在线咨询</a>
            <a href="javascript:;" class="edit" rel="nofollow">提交需求</a>
        </div>
    </div>
</div>
<div class="footer-content">
    <div class="weblg clearfix">
        <div class="friend-links">
            <h6 class="clearfix">
                <span class="tilte">友情链接</span>
                <a class="exchagne" href="http://wpa.qq.com/msgrd?v=3&uin=631063699&site=qq&menu=yes">交换友情链接</a>
            </h6>
            <div class="link-list clearfix">
                <div class="link-slider">
                    <a href="http://www.myzitong.com/" title="梓潼网站制作公司" target="_blank">梓潼网站制作公司</a><a href="http://www.cdxwcx.cn/tuoguan/deyang.html" title="德阳电信服务器托管" target="_blank">德阳电信服务器托管</a><a href="http://m.cdxwcx.com/guanghua.html" title="成都电信服务器托管" target="_blank">成都电信服务器托管</a><a href="http://www.cdhuace.com/faguangzi/wbfgz.html" title="无边发光字厂家" target="_blank">无边发光字厂家</a><a href="http://www.tpbzx.cn/" title="tpbzx.cn" target="_blank">tpbzx.cn</a><a href="https://www.cdcxhl.com/idc/wenjiang.html" title="温江服务器托管" target="_blank">温江服务器托管</a><a href="http://seo.cdkjz.cn/wangzhan/" title="网站推广公司" target="_blank">网站推广公司</a><a href="http://www.cdhuace.com/zhuangxiu.html" title="成都店面装修公司" target="_blank">成都店面装修公司</a><a href="https://www.cdcxhl.com/idc/yaan.html" title="雅安托管服务器" target="_blank">雅安托管服务器</a><a href="http://www.cdkjz.cn/wangzhan/" title="网站seo优化" target="_blank">网站seo优化</a>                </div>
            </div>
        </div>
    </div>
    <div class="full-foot-bottom">
        <div class="weblg clearfix">
            <p>成都网站建设公司地址:成都市青羊区太升南路288号锦天国际A座10层 建设咨询<a href="tel:028-86922220">028-86922220</a></p>
            <p>
                成都快上网科技有限公司-四川网站建设设计公司 | <a href="http://www.miitbeian.gov.cn/" target="_blank" rel="nofollow">蜀ICP备19037934号</a> Copyright 2020,ALL Rights Reserved cdkjz.cn | <a href="http://www.cdkjz.cn/" target="_blank">成都网站建设</a> | © Copyright 2020版权所有.</p>
            <p>专家团队为您提供<a href="http://www.cdkjz.cn/" target="_blank">成都网站建设</a>,<a href="http://www.cdkjz.cn/" target="_blank">成都网站设计</a>,成都品牌网站设计,成都营销型网站制作等服务,成都建网站就找快上网! | 成都网站建设哪家好? | <a href="###">网站建设地图</a></p>
        </div>
    </div>

</div>
<script type="text/javascript" src="../js/idangerous.swiper.min.js"></script>
<script type="text/javascript" src="../js/wow.min.js"></script>
<script type="text/javascript" src="../js/jquery.mousewheel.min.js"></script>
<script type="text/javascript" src="../js/jquery.placeholder.min.js"></script>
<script type="text/javascript" src="../js/layout.js"></script>
</body>
</html>
<script>
    $(".singlepage img").each(function(){
        var src = $(this).attr("src");    //获取图片地址
        var str=new RegExp("http");
        var result=str.test(src);
        if(result==false){
            var url = "https://www.cdcxhl.com"+src;    //绝对路径
            $(this).attr("src",url);
        }
    });
    window.onload=function(){
        document.oncontextmenu=function(){
            return false;
        }
    }
</script>