Scripting
Here you find useful scripts for Synalyze It! Pro. Install them by clicking on the links provided the Pro version is installed already.
If you created own scripts that may be of use for others you're welcome to share them - just send an email to me with the .script file!
Scripts working on Grammars
Scripts working on Files
Scripts working on selected bytes
BASE64_Decode.script decodes selected
Scripts for Custom Data Types
DOSDateTime.script decodes and encodes a
HexStringLength.script decodes and encodes a
PythonTimestamp.script decodes and encodes a
EvenPascal.script parses a
FILETIME.script decodes and encodes a
Scripts for Script Elements
Scripted elements allow to extend grammars beyond what’s possible with standard means.
This small Python script exposes the current parsing position so that you can reference it in another element, typically an offset element as additional value:
results = currentMapper.getCurrentResults()currentPos = currentMapper.getCurrentOffset()posValue = NumberValue()posValue.setUnsigned(currentPos)currentElement = currentMapper.getCurrentElement()results.addElement(currentElement, 0, 0, posValue)
An extended version of the previous script inserts a binary element when the current parsing position is not a multiple of 4 (padding to 4 bytes alignment:
currentPos = currentMapper.getCurrentOffset()paddingBytes = 4 - (currentPos % 4)if paddingBytes < 4:posValue = NumberValue()posValue.setUnsigned(currentPos)currentGrammar = currentMapper.getCurrentGrammar()paddingStructure = currentGrammar.getStructureByName("Padding")paddingElement = paddingStructure.getElementByName("PaddingElement")currentMapper.mapElementWithSize(paddingElement, paddingBytes)
The following Python script parses a string at the current position that uses the previously parsed number as length if it doesn’t exceed the remaining space:
# get collection with results so farresults = currentMapper.getCurrentResults()# get latest added resultlastResult = results.getLastResult()# access the parsed valuevalue = lastResult.getValue()# get the numberstringLength = value.getUnsignedNumber()currentPos = currentMapper.getCurrentOffset()remainingBytes = currentMapper.getCurrentRemainingSize()actualSize = min(stringLength, remainingBytes)byteView = currentMapper.getCurrentByteView()string = byteView.readString(currentPos, actualSize, "ISO-8859-1")stringValue = Value()stringValue.setString(string)currentElement = currentMapper.getCurrentElement()results.addElement(currentElement, actualSize, 0, stringValue)
Examples for scripting usage in Grammars
Kelvin created a small grammar that shows how to represent an