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://abwzjs.com/article/cdgsdp.html">http://abwzjs.com/article/cdgsdp.html</a>
            </div>
        </div>
        <div class="contentr fr">
            <h3>其他资讯</h3>
            <ul>
                <li>
                        <a href="/article/dohocee.html">智能聊天概念股爆雷 chiplet 概念股</a>
                    </li><li>
                        <a href="/article/dohocsg.html">如何确保服务器上的安全 如何保证服务器安全</a>
                    </li><li>
                        <a href="/article/dohoceh.html">java中年份的代码 java年龄</a>
                    </li><li>
                        <a href="/article/dohocsi.html">帝国cms做网站 帝国cms做商城</a>
                    </li><li>
                        <a href="/article/dohocic.html">关于智能聊天接入微信勾公众号的信息</a>
                    </li>            </ul>
        </div>
    </div>
</div>
<!--底部-->
<footer>
    <div class="foot">
        <div class="container">
            <h1>大橙子建站您身边的网站建设服务商</h1>
            <div class="foot1">
                <ul>
                    <li>
                        <dl><i class="iconfont"></i><b>地址ADDRESS</b></dl>
                        <p>四川-阿坝青羊区太升南路288号<br>
                            锦天国际A座10楼
                        </p>
                    </li>
                    <li>
                        <dl><i class="iconfont"></i><b>电话/TEL</b></dl>
                        <p><a href="tel:02886922220" target="_blank">028 86922220</a> (工作日)<br>
                            <a href="tel:18980820575" target="_blank">1898082 0575</a> ( 7x24 )
                        </p>
                    </li>
                    <li>
                        <dl><i class="iconfont"></i><b>QQ咨询</b></dl>
                        <p> 244261566 (售前)<br>
                            631063699 (售后)
                        </p>
                    </li>
                    <li>
                        <dl><i class="iconfont"></i><b>邮箱/E: mail</b></dl>
                        <p> service@cdcxhl.com (业务)<br>
                            hr@cdcxhl.com (求职)
                        </p>
                    </li>
                </ul>
            </div>
            <div class="link">
                友情链接:
                <a href="http://www.dmvi.cn/" title="成都广告制作" target="_blank">成都广告制作</a>   <a href="https://www.cdxwcx.com/wangzhan/app.html" title="app开发公司" target="_blank">app开发公司</a>   <a href="http://www.scjierui.cn/" title="四川网站建设" target="_blank">四川网站建设</a>   <a href="https://www.cdcxhl.cn/
" title="免备案虚拟主机空间" target="_blank">免备案虚拟主机空间</a>   <a href="http://chengdu.cdcxhl.cn/seo/
" title="成都网站推广" target="_blank">成都网站推广</a>   <a href="https://www.scvps.cn/" title="申请域名" target="_blank">申请域名</a>   <a href="https://www.cdcxhl.cn/
" title="免备案空间腾讯云" target="_blank">免备案空间腾讯云</a>   <a href="https://www.xwcx.net/zuyong.html" title="成都租用服务器" target="_blank">成都租用服务器</a>   <a href="http://www.cdxwcx.cn/tuoguan/xiyun.html" title="成都移动托管" target="_blank">成都移动托管</a>   <a href="https://www.cdcxhl.cn/
" title="php主机" target="_blank">php主机</a>               </div>
        </div>
    </div>
    <div class="copy container">
        Copyright © 2017-2022 All Rights Reserved. 青羊区大橙子信息咨询工作室 版权所有  <a href="http://www.beian.miit.gov.cn/" target="_blank" rel="nofollow">蜀ICP备2022028542号-9</a>
        [原创设计,独立版权。未经许可.不得拷贝或镜像]<br>
        <a href="http://www.kswsj.cn/" target="_blank">网站营销推广</a> | <a href="https://www.cdcxhl.com/pinpai.html" target="_blank">品牌网站设计</a> | <a href="http://www.cdweb.net/" target="_blank">自适应网站建设</a> | <a href="http://cdkjz.cn/wangzhan/pinpai/" target="_blank">品牌网站建设</a> | <a href="http://chengdu.cdxwcx.cn/" target="_blank">成都网站制作</a> | <a href="https://www.cdcxhl.com/cloud/" target="_blank">云服务器</a> | <a href="https://www.cdcxhl.com/weihu/abazhou.html" target="_blank">阿坝网站维护</a> | (阿坝网站建设QQ : 631063699 )</div>
</footer>
<!--在线咨询-->
<div class="fot">
    <ul>
        <li>
            <a href="mqqwpa://im/chat?chat_type=wpa&uin=532337155&version=1&src_type=web&web_src=oicqzone.com" target="_blank">
                <img src="/Public/Home/img/fot1.png" alt="建站咨询">
                <p>在线咨询</p>
            </a>
        </li>
        <li>
            <a href="tel:18980820575" target="_blank">
                <img src="/Public/Home/img/fot2.png" alt="建站电话">
                <p>拨打电话</p>
            </a>
        </li>
    </ul>
</div>
</body>
</html>
<script>
    $(".con 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>