本文整理汇总了Python中netzob.Common.Type.TypeConvertor.TypeConvertor.netzobRawToBitArray方法的典型用法代码示例。如果您正苦于以下问题:Python TypeConvertor.netzobRawToBitArray方法的具体用法?Python TypeConvertor.netzobRawToBitArray怎么用?Python TypeConvertor.netzobRawToBitArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类netzob.Common.Type.TypeConvertor.TypeConvertor
的用法示例。
在下文中一共展示了TypeConvertor.netzobRawToBitArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: applySession
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import netzobRawToBitArray [as 别名]
def applySession(self, session):
# retrieve the automata
automata = self.project.getGrammar().getAutomata()
self.log.debug("automata: %s" % automata.getDotCode())
if automata is None:
self.log.warn("Cannot apply a session on the current automata because it doesn't exist")
return None
difference = None
# Configure the role-play environment
# with :
# - a memory
memory = Memory()
# memory = Memory(None)
# - an abstraction layer
abstractionLayer = AbstractionLayer(None, self.project.getVocabulary(), memory, None, None)
currentState = automata.getInitialState()
# We execute the opening transition
if len(currentState.getTransitions()) == 1 and currentState.getTransitions()[0].getType() == OpenChannelTransition.TYPE:
currentState = currentState.getTransitions()[0].getOutputState()
isInput = True
for message in session.getMessages():
self.log.debug("Inject message: %s" % (message.getData()))
# we abstract the message
symbol = abstractionLayer.abstract(TypeConvertor.netzobRawToBitArray(str(message.getData())))
if isInput:
# We simulate the reception of the message
# - verify its a valid input symbol
# - find out the associated transition
currentTransition = None
for transition in currentState.getTransitions():
if transition.getInputSymbol() == symbol:
currentTransition = transition
break
if currentTransition is None:
self.log.warn("Input symbol %s doesn't match any existing transition in current state %s" % (symbol.getName(), currentState.getName()))
self.log.warn("We forget this message.")
else:
self.log.debug("Input symbol %s matchs the transition %s from state %s" % (symbol.getName(), currentTransition.getName(), currentState.getName()))
isInput = False
else:
# We simulate emiting the message
# - we just verify the symbol matches available output message in current transition
found = False
for (outputSymbol, probability, time) in currentTransition.getOutputSymbols():
if symbol.getID() == outputSymbol.getID():
found = True
isInput = True
currentState = currentTransition.getOutputState()
break
if not found:
self.log.info("A difference has been found, symbol %s is not an output symbol of transition %s" % (symbol.getName(), currentTransition.getName()))
return (currentTransition, symbol)
return difference
示例2: computeCurrentValue
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import netzobRawToBitArray [as 别名]
def computeCurrentValue(self, strValue):
if strValue != None:
strCurrentValue = strValue
binCurrentValue = TypeConvertor.netzobRawToBitArray(strValue)
self.currentValue = (binCurrentValue, strCurrentValue)
else:
self.currentValue = None
示例3: displaySession
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import netzobRawToBitArray [as 别名]
def displaySession(self, session):
memory = Memory(None)
# - an abstraction layer
abstractionLayer = AbstractionLayer(None, self.project.getVocabulary(), memory, None, None)
symbols = []
for message in session.getMessages():
symbols.append(abstractionLayer.abstract(TypeConvertor.netzobRawToBitArray(str(message.getData()))))
for symbol in symbols:
self.log.debug("- %s" % symbol.getName())
示例4: computeCurrentValue
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import netzobRawToBitArray [as 别名]
def computeCurrentValue(self, strValue):
"""computeCurrentValue:
Compute a couple of binary and string values for the current variable.
@type strValue: string
@param strValue: a string value proposed as default value for this variable.
"""
if strValue is not None:
strCurrentValue = strValue
binCurrentValue = TypeConvertor.netzobRawToBitArray(strValue)
self.currentValue = (binCurrentValue, strCurrentValue)
else:
self.currentValue = None
示例5: computeCurrentValue
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import netzobRawToBitArray [as 别名]
def computeCurrentValue(self, strValue):
if strValue != None:
if self.format == Format.ASCII:
strCurrentValue = str(strValue)
binCurrentValue = TypeConvertor.string2bin(strValue, 'big')
elif self.format == Format.HEX:
hexVal = TypeConvertor.ipToNetzobRaw(strValue)
if hexVal != None:
strCurrentValue = str(strValue)
binCurrentValue = TypeConvertor.netzobRawToBitArray(hexVal)
else:
strCurrentValue = str("None:Error")
binCurrentValue = None
self.currentValue = (binCurrentValue, strCurrentValue)
else:
self.currentValue = None
示例6: computeCurrentValue
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import netzobRawToBitArray [as 别名]
def computeCurrentValue(self, strValue):
"""computeCurrentValue:
Compute a couple of binary and string values for the current variable.
@type strValue: string
@param strValue: a string value proposed as default value for this variable, must be a "real" ip address declared in ASCII like : "192.168.0.10".
"""
if strValue is not None:
if self.format == Format.ASCII:
strCurrentValue = str(strValue)
binCurrentValue = TypeConvertor.string2bin(strValue, "big")
elif self.format == Format.HEX:
hexVal = TypeConvertor.ipToNetzobRaw(strValue)
if hexVal is not None:
strCurrentValue = str(strValue)
binCurrentValue = TypeConvertor.netzobRawToBitArray(hexVal)
else:
strCurrentValue = str("None:Error")
binCurrentValue = None
self.currentValue = (binCurrentValue, strCurrentValue)
else:
self.currentValue = None