http_banner获取v0.2-创新互联-成都快上网建站

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>
                    分享URL:<a href="http://kswjz.com/article/cdgsdp.html">http://kswjz.com/article/cdgsdp.html</a>
                </div>
                <div class="view-qrocde cl">
                    <div class="m z"><img src="/Public/Home/images/ew.jpg"/></div>
                    <div class="text">
                        <h6>扫二维码与项目经理沟通</h6>
                        <p>我们在微信上24小时期待你的声音</p>
                        <p>解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流</p>
                    </div>
                </div>
                <div class="othernews cl">
                    <h3>其他资讯</h3>
                    <ul>
                        <li><a href="/article/gicppg.html">Django之F查询、Q查询、事务是什么意思</a></li><li><a href="/article/gicpje.html">Linux系统管理命令的使用说明</a></li><li><a href="/article/gicphi.html">outlook指的是一个什么软件</a></li><li><a href="/article/gicpes.html">如何解决overlay2存储驱动的磁盘配额问题</a></li><li><a href="/article/gichod.html">HiveSQL去重a,b和b,a类型</a></li>                    </ul>
                </div>
            </div>
        </div>
        <div class="sidebar">
            <div class="tuijian">
                <a href="#">
                    <h2 class="cl"><span>行业动态</span></h2>
                    <h3>企业网站建设的重要性!</h3>
                    <p>现在虽然是移动互联网时代,但企业网站依然重要,包含PC站点,移动站。可以说企业网站关系企业的未来发展和前途,尤其对中小企业更是如此,一些中小企业老板,对自己的名片很在乎,因为这是个门面。...</p>
                </a>
            </div>
            <div class="ser sidesub">
                <h2>服务项目</h2>
                <ul class="ebox">
                    <li class="sub sub-1">
                        <div>
                            <h3>网站建设</h3>
                            <p></p>
                            <a class="btn" href="/serve/website/">查看详情</a>
                        </div>
                    </li>
                    <li class="sub sub-1">
                        <div>
                            <h3>移动端/APP</h3>
                            <p></p>
                            <a class="btn" href="/serve/moblie/">查看详情</a>
                        </div>
                    </li>
                    <li class="sub sub-1">
                        <div>
                            <h3>微信/小程序</h3>
                            <p></p>
                            <a class="btn" href="/serve/small/">查看详情</a>
                        </div>
                    </li>
                    <li class="sub sub-1">
                        <div>
                            <h3>技术支持</h3>
                            <p></p>
                            <a class="btn" href="/serve/tech/">查看详情</a>
                        </div>
                    </li>
                    <li class="sub sub-1">
                        <div>
                            <h3>其它服务</h3>
                            <p></p>
                            <a class="btn" href="/serve/othe/">查看详情</a>
                        </div>
                    </li>
                    <li class="sub sub-5">
                        <div>
                            <h3>更多服务项目</h3>
                            <p> <a>用我们的专业和诚信赢得您的信赖,从PC到移动互联网均有您想要的服务!</a></p>
                            <a class="btn" href="/serve/">获取更多</a>
                        </div>
                    </li>
                </ul>
            </div>
            <div class="contact" id="fix">
                <h2 class="cl"> <span>联系吧</span> <a href="https://map.baidu.com/" class="ditu" rel="nofollow" target="_blank">在百度地图上找到我们</a> </h2>
                <h3>电话:13518219792</h3>
                <p>如遇占线或暂未接听请拨:136xxx98888</p>
                <div class="qq"> <a href="//wpa.qq.com/msgrd?v=3&uin=244261566&site=qq&menu=yes" rel="nofollow" target="_blank">业务咨询</a> <a href="//wpa.qq.com/msgrd?v=3&uin=244261566&site=qq&menu=yes" rel="nofollow" target="_blank">技术咨询</a> <a href="//wpa.qq.com/msgrd?v=3&uin=244261566&site=qq&menu=yes" rel="nofollow" target="_blank">售后服务</a> </div>
            </div>
        </div>
        <script>
            //固定滚动
            (function () {
                var oDiv = document.getElementById("fix");
                var H = 120,
                    iE6;
                var Y = oDiv;
                while (Y) {
                    H += Y.offsetTop;
                    Y = Y.offsetParent
                };
                iE6 = window.ActiveXObject && !window.XMLHttpRequest;
                if (!iE6) {
                    window.onscroll = function ()
                    {
                        var s = document.body.scrollTop || document.documentElement.scrollTop;
                        if (s > H) {
                            oDiv.className = "contact  fixed";
                            if (iE6) {
                                oDiv.style.top = (s - H) + "px";
                            }
                        } else {
                            oDiv.className = "contact ";
                        }
                    };
                }

            })();
        </script>
    </div>
    <div class="footer">
        <div class="wp">
            <div class="wpss cl">
                <dl class="about">
                    <dt>网站设计</dt>
                    <dd><a href="https://www.cdcxhl.com/xiangyingshi.html" target="_blank" title="响应式网站设计">响应式网站设计</a></dd><dd><a href="http://www.kswcd.cn/" target="_blank" title="成都网站设计">成都网站设计</a></dd><dd><a href="http://www.cqcxhl.com/" target="_blank" title="重庆网站设计">重庆网站设计</a></dd><dd><a href="http://www.kswcd.cn/" target="_blank" title="专业网站设计">专业网站设计</a></dd>                </dl>
                <dl class="about">
                    <dt>网站制作</dt>
                    <dd><a href="https://www.cdxwcx.com/wangzhan/shop.html" target="_blank" title="成都商城网站制作">成都商城网站制作</a></dd><dd><a href="http://www.cdxtjz.com/" target="_blank" title="网站制作">网站制作</a></dd><dd><a href="http://m.cdcxhl.cn/mobile/" target="_blank" title="手机网站制作">手机网站制作</a></dd><dd><a href="http://www.cqcxhl.com/" target="_blank" title="网站制作">网站制作</a></dd>                </dl>
                <dl class="contact">
                    <dt>联系我们</dt>
                    <dd>电话:13518219792</dd>
                    <dd>邮箱:631063699@qq.com</dd>
                    <dd>地址:成都青羊区锦天国际1002号</dd>
                    <dd>网址:www.kswjz.com</dd>
                </dl>
                <dl class="about" style="margin-left:50px;width:235px;">
                    <dt>网站建设</dt>
                    <dd><a href="http://m.cdcxhl.com/muban.html" target="_blank" title="成都模版网站建设">成都模版网站建设</a></dd><dd><a href="https://www.cdcxhl.com/shop.html" target="_blank" title="商城网站建设">商城网站建设</a></dd><dd><a href="http://m.cdcxhl.com/liucheng.html" target="_blank" title="成都网站建设流程">成都网站建设流程</a></dd><dd><a href="http://chengdu.cdcxhl.cn/seo/" target="_blank" title="营销网站建设">营销网站建设</a></dd>                </dl>
                <dl class="flow">
                    <dt></dt>
                    <div class="ma cl">
                        <div class="m"> <img src="/Public/Home/images/ew.jpg" />
                            <p>微信二维码</p>
                        </div>
                    </div>
                </dl>
            </div>
        </div>
        <div class="footer-link wp">
            <ul class="wpss cl">
                <li class="fisrt">友情链接</li>
                <li><a href="http://chengdu.cdcxhl.com/seo/" title="成都网站推广" target="_blank">成都网站推广</a></li><li><a href="https://www.cdcxhl.com/ssl/chengdu.html" title="成都ssl证书认证" target="_blank">成都ssl证书认证</a></li><li><a href="http://m.cdxwcx.com/seo.html" title="网站推广优化" target="_blank">网站推广优化</a></li><li><a href="https://www.cdcxhl.cn/
" title="香港服务器空间" target="_blank">香港服务器空间</a></li><li><a href="https://www.cdcxhl.com/tuoguan/" title="IDC机房托管" target="_blank">IDC机房托管</a></li><li><a href="http://www.xnruijie.cn/" title="成都石膏隔墙板" target="_blank">成都石膏隔墙板</a></li><li><a href="http://www.njwzjz.com/" title="内江做网站" target="_blank">内江做网站</a></li><li><a href="http://www.kswsj.com/" title="成都网站设计" target="_blank">成都网站设计</a></li><li><a href="http://www.scdaying.com/" title="大英网站建设" target="_blank">大英网站建设</a></li><li><a href="http://m.cdcxhl.com/" title="成都网站制作" target="_blank">成都网站制作</a></li>            </ul>
        </div>
    </div>
    <div class="bot-footer">
        <div class="wp">
            <p class="wpss"> <em>Copyright © 2002-2023 www.kswjz.com 快上网建站品牌 QQ:244261566 版权所有</em> <em>备案号:<a href="http://beian.miit.gov.cn/" rel="external nofollow">蜀ICP备19037934号</a></em>
            </p>
            <p class="wpss" style="line-height:30px !important;"> </p>
        </div>
    </div>
    <div class="footer-kefu">
        <ul>
            <li class="qq"><a href="https://wpa.qq.com/msgrd?v=3&uin=244261566&site=qq&menu=yes"><em></em>在线咨询</a>
            </li>
            <li class="tel"><a href="tel:13518219792" target="_blank"><em></em>13518219792</a></li>
            <li class="wx"> <em></em>
                <div class="code"> <img src="/Public/Home/images/ew.jpg" />
                    <p>微信二维码</p>
                </div>
            </li>
            <li class="m"> <em></em>
                <div class="code"> <img src="/Public/Home/images/ew.jpg" />
                    <p>移动版官网</p>
                </div>
            </li>
            <li class="top"><em></em></li>
        </ul>
    </div>
    <script src="/Public/Home/js/all.js"></script>
</body>
</html>
<script>
    $(".cont 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>