当前位置: 首页>>代码示例>>Python>>正文


Python KNN.ibk方法代码示例

本文整理汇总了Python中KNN.ibk方法的典型用法代码示例。如果您正苦于以下问题:Python KNN.ibk方法的具体用法?Python KNN.ibk怎么用?Python KNN.ibk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KNN的用法示例。


在下文中一共展示了KNN.ibk方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import KNN [as 别名]
# 或者: from KNN import ibk [as 别名]
def main(argv):
    """ Start of the program """
    
    if len(argv)==0:      ## check of the arguments
        print("\n Improper command format")
        usage()
        sys.exit()
        
    filename=''  
    flow = False
    dump = False
    try:
        opts,args=getopt.getopt(argv,"hf:d",["ifile=", "dump"])   
    except getopt.GetoptError:
        print("\n Improper command format")
        usage()
        sys.exit()
        
    ## to read the arguments
    for opt,arg in opts:
        if opt=="-h":
            usage()
            sys.exit()
        elif opt in ("-f","--ifile"):
            filename=arg
            flow = True
        elif opt in ("d","--dump"):
            dump=True
        else:
             print("\n Improper command format")
             usage()
             sys.exit()
    if flow :
        #print(filename)
        if os.path.isfile(filename):
            #print("File name  : ",filename)
            openfile = open(filename,'rb')
            readfile = openfile.read()
            print("Entropy of file is ", H(readfile))
       
            pe=pefile.PE(filename)
            sizeofHeader = pe.OPTIONAL_HEADER.SizeOfHeaders
            unknownEntropy = []
            unknownPackedEntropy = []
            for section in pe.sections:
                init=section.VirtualAddress
                last=section.VirtualAddress+section.Misc_VirtualSize
                sectionData= readfile[init:last]
                unknownEntropy.append(HsetReduction(sectionData))

                hex_bytes = binascii.hexlify(sectionData)
                cleartext = hex_bytes.decode("utf-8")
                cipherText= encrypFile(cleartext)
                unknownPackedEntropy.append(HsetReduction(cipherText))
            TotalunknownEntropy= 0
            TotalunknownPackedEntropy = 0 
            for i in range (len(unknownEntropy)):
                TotalunknownEntropy = TotalunknownEntropy+ unknownEntropy[i]
                TotalunknownPackedEntropy = TotalunknownPackedEntropy+ unknownPackedEntropy[i]
            firstEntropy = TotalunknownEntropy/len(unknownEntropy)
            secondEntropy =TotalunknownPackedEntropy/len(unknownPackedEntropy)
            #print("First Entropy = ",firstEntropy)
            #print("Entropy after packing = ",secondEntropy)
            TestingList = [firstEntropy,secondEntropy,(secondEntropy-firstEntropy)]
            predictedResult = KNN.ibk(TestingList)
            print(filename," is ",predictedResult)
            #KNN.ibktest()
            if dump:
                print(dump_info(filename))
        
        else:
            print("File doesn't exit or path is improper")
    else:
        print("\n Improper command format")
        usage()
开发者ID:Kamlapati,项目名称:skEntropy,代码行数:77,代码来源:skEntropy.py


注:本文中的KNN.ibk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。