本文整理汇总了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()