有关IPV6

作者: 青花瓷的平方 | 来源:发表于2016-05-18 10:51 被阅读426次

    苹果在6月1日要求上线app必须支持ipv6,具体链接
    Supporting IPv6 DNS64/NAT64 Networks
    具体中文版本见:
    针对苹果iOS最新审核要求为应用兼容IPv6

    写了一个脚本检测是否使用ipv4的非法方法:
    检查第三方库的脚本,使用方法: python ipv6_api_scan.py TO_BE_CHECKED_DIR >> result.log

    具体脚本代码:

    # -- coding: utf-8 -*-
    
    import zipfile
    import os
    import re
    import fnmatch
    import itertools
    import subprocess
    import sys
    import csv
    
    
    #代码所在路径 需要设置
    codepath = None
    
    #App 所在位置
    apppath = None
    
    def isMachOFormat(path):
        if not os.path.exists(path):
            return False;
    
        f = open(path,'rb');
        if f:
            data=f.read();
            fsize=f.tell();
            f.close();
            if fsize > 8 :
                ma=data[0].encode('hex')
                mb=data[1].encode('hex')
                mc=data[2].encode('hex')
                md=data[3].encode('hex')          
                prefix=ma+mb+mc+md;
                if prefix == "cafebabe":
                    return True;
        return False;
    
    
    def scanFiles(path):
        if not os.path.exists(path):
            print "文件路径:"+path+"不存在!"
            return -1;
        print "开始check文件(夹):"+path
        for parent, dirnames, filenames in os.walk(path):
              for filename in filenames:                        #输出文件信
                # print "filename is:" + filename
                fullPath=os.path.join(parent,filename);
                isMachO = isMachOFormat(fullPath)
                if isMachO and not os.path.islink(fullPath):
                    nmCheck(fullPath, filename)
    
       
    
    def nmCheck(path,filename):
        func_list=["inet_addr","inet_aton","inet_lnaof","inet_makeaddr","inet_netof","inet_network","inet_ntoa","inet_ntoa_r","bindresvport","getipv4sourcefilter","setipv4sourcefilter","SCNetworkReachabilityCreateWithAddress"];
        str_log_name= path + ".log";
        if os.path.exists(str_log_name):
            os.system("rm -rf " + str_log_name)
    
        cmd_touch="touch " + str_log_name;
        
        items = set();
    
        os.system(cmd_touch);
        for func_name in func_list:
            cmd_nm="nm " + path + " | grep " + func_name + " >> "+ path + ".log";
            os.system(cmd_nm);
    
        f=open(str_log_name);
        if f:
            str_func=f.read()
            str_func=str_func.replace("                 U _", "");
            item_list=str_func.split("\n")
            for item in item_list:
                if len(item) > 0:
                    items.add(item)
            f.close()
    
        if len(items) > 0:
            print "检查Library:" + filename#输出文件路径信息
            print "发现IPV6非法函数:";
            for item in items:
                print item;
            print "\r\n"
        # else:
        #     print filename+"是IPV6兼容的!\r\n"
    
        if os.path.exists(str_log_name):
            os.system("rm " + str_log_name)
    
    if __name__ == '__main__':
        if len(sys.argv) == 1:
            print "usage: python ipv6_api_scan.py to_be_checked_dir"
            print "usage: python ipv6_api_scan.py to_be_checked_dir >> out.log"
        else:
            scanFiles(sys.argv[1])
    

    相关文章

      网友评论

        本文标题:有关IPV6

        本文链接:https://www.haomeiwen.com/subject/kgcwrttx.html