pysap.SAPDiag module

class pysap.SAPDiag.SAPDiag(_pkt='', post_transform=None, _internal=0, _underlayer=None, **fields)[source]

Bases: pysap.utils.fields.PacketNoPadded

SAP Diag packet

This packet holds the Diag Header and serve as a container for SAPDiagItem items. It handles compression/decompression, adding the appropriate Compression Header when necessary.

aliastypes = [<class 'pysap.SAPDiag.SAPDiag'>, <class 'pysap.utils.fields.PacketNoPadded'>, <class 'scapy.packet.Packet'>]
do_compress(s)[source]

Compress a string using SAP compression C++ extension.

Parameters:s (C{string}) – string to compress
Returns:string compression header plus the compressed string
Return type:C{string}
Raises:pysapcompress.Error – when a compression error is raised
do_decompress(s, length)[source]

Decompress a string using SAP compression C++ extension.

Parameters:
  • s (C{string}) – compression header plus compressed string
  • length (int) – reported compressed length
Returns:

decompressed string

Return type:

C{string}

Raises:

pysapcompress.Error – when a decompression error is raised

fields_desc = [<Field (SAPDiag).mode>, <Field (SAPDiag).com_flag_TERM_GRA>, <Field (SAPDiag).com_flag_TERM_NNM>, <Field (SAPDiag).com_flag_TERM_CAS>, <Field (SAPDiag).com_flag_TERM_INI>, <Field (SAPDiag).com_flag_TERM_EOP>, <Field (SAPDiag).com_flag_TERM_NOP>, <Field (SAPDiag).com_flag_TERM_EOC>, <Field (SAPDiag).com_flag_TERM_EOS>, <Field (SAPDiag).mode_stat>, <Field (SAPDiag).err_no>, <Field (SAPDiag).msg_type>, <Field (SAPDiag).msg_info>, <Field (SAPDiag).msg_rc>, <Field (SAPDiag).compress>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <Field (SAPDiag).message>]
get_item(item_type=None, item_id=None, item_sid=None)[source]

Get an item from the packet’s message. Returns None if the message is not found, or a list if the item is found multiple times.

Parameters:
  • item_type (int or C{string} or list) – item type byte or string value
  • item_id (int or C{string} or list) – item ID byte or string value
  • item_sid (int or C{string} or list) – item SID byte or string value
Returns:

list of items found on the packet or None

Return type:

list of SAPDiagItem

post_build(p, pay)[source]

Compress the payload. If the compression flag is set, compress both the message field and the payload.

pre_dissect(s)[source]

Prepares the packet for dissection. If the compression flag is set, decompress the payload.

class pysap.SAPDiag.SAPDiagDP(_pkt='', post_transform=None, _internal=0, _underlayer=None, **fields)[source]

Bases: scapy.packet.Packet

SAP Diag DP Header packet

This packet is used for initialization of Diag connections. Usually there’s no need to change any value more that the terminal.

aliastypes = [<class 'pysap.SAPDiag.SAPDiagDP'>, <class 'scapy.packet.Packet'>]
fields_desc = [<Field (SAPDiagDP).request_id>, <Field (SAPDiagDP).retcode>, <Field (SAPDiagDP).sender_id>, <Field (SAPDiagDP).action_type>, <Field (SAPDiagDP).req_info>, <Field (SAPDiagDP).tid>, <Field (SAPDiagDP).uid>, <Field (SAPDiagDP).mode>, <Field (SAPDiagDP).wp_id>, <Field (SAPDiagDP).wp_ca_blk>, <Field (SAPDiagDP).appc_ca_blk>, <Field (SAPDiagDP).length>, <Field (SAPDiagDP).new_stat>, <Field (SAPDiagDP).unused1>, <Field (SAPDiagDP).rq_id>, <Field (SAPDiagDP).unused2>, <Field (SAPDiagDP).terminal>, <Field (SAPDiagDP).unused3>, <Field (SAPDiagDP).unused4>, <Field (SAPDiagDP).unused5>, <Field (SAPDiagDP).unused6>, <Field (SAPDiagDP).unused7>, <Field (SAPDiagDP).unused8>, <Field (SAPDiagDP).unused9>, <Field (SAPDiagDP).unused10>]
class pysap.SAPDiag.SAPDiagError(_pkt='', post_transform=None, _internal=0, _underlayer=None, **fields)[source]

Bases: pysap.utils.fields.PacketNoPadded

SAP Diag Error packet

This packet holds Diag error packets.

aliastypes = [<class 'pysap.SAPDiag.SAPDiagError'>, <class 'pysap.utils.fields.PacketNoPadded'>, <class 'scapy.packet.Packet'>]
fields_desc = [<Field (SAPDiagError).msg>, <Field (SAPDiagError).padd>]
class pysap.SAPDiag.SAPDiagItem(_pkt='', post_transform=None, _internal=0, _underlayer=None, **fields)[source]

Bases: pysap.utils.fields.PacketNoPadded

SAP Diag Item packet

This packet holds the different types of Diag items. The value field is interpreted according to the Type/ID/SID specified for the item.

aliastypes = [<class 'pysap.SAPDiag.SAPDiagItem'>, <class 'pysap.utils.fields.PacketNoPadded'>, <class 'scapy.packet.Packet'>]
fields_desc = [<Field (SAPDiagItem).item_type>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <scapy.fields.ConditionalField object>, <Field (SAPDiagItem).item_value>]
class pysap.SAPDiag.SAPDiagItems(_pkt='', post_transform=None, _internal=0, _underlayer=None, **fields)[source]

Bases: scapy.packet.Packet

SAP Diag Items container

Container for SAPDiagItem packets.

aliastypes = [<class 'pysap.SAPDiag.SAPDiagItems'>, <class 'scapy.packet.Packet'>]
fields_desc = [<Field (SAPDiagItems).message>]
pysap.SAPDiag.bind_diagitem(item_class, item_type, item_id=None, item_sid=None)[source]

Registers a Diag item class associated to a given type, ID and SID.

Parameters:
  • item_class (SAPDiagItem class) – item class to associate
  • item_type (int or string) – item type to associate
  • item_id (int) – item ID to associate
  • item_sid (int) – item SID to associate
pysap.SAPDiag.diag_appl_ids = {1: 'SCRIPT', 2: 'GRAPH', 3: 'IXOS', 4: 'ST_USER', 5: 'DYNN', 6: 'ST_R3INFO', 7: 'POPU', 8: 'RFC_TR', 9: 'DYNT', 10: 'CONTAINER', 11: 'MNUENTRY', 12: 'VARINFO', 14: 'CONTROL', 15: 'UI_EVENT', 18: 'ACC_LIST', 19: 'RCUI', 20: 'GUI_PACKET'}

Diag APPL/APPL4 IDs

pysap.SAPDiag.diag_appl_sids = {1: {1: 'SCRIPT_OTF', 2: 'SCRIPT_SCREEN', 3: 'SCRIPT_POSTSCRIPT', 4: 'SCRIPT_ITF'}, 2: {3: 'GRAPH RELEASE 3', 5: 'GRAPH RELEASE 5'}, 3: {1: 'ABLAGE', 2: 'ANZEIGE', 3: 'IXOS_COMMAND'}, 4: {1: 'V1', 2: 'CONNECT', 3: 'SELECTEDRECT', 4: 'FONTMETRIC', 5: 'TABLEMETRIC', 6: 'GUITIME', 7: 'GUITIMEZONE', 8: 'TURNTIME', 9: 'GUIVERSION', 11: 'SUPPORTDATA', 12: 'RFC_CONNECT', 13: 'WSIZE', 14: 'V2', 15: 'TURNTIME2', 16: 'RFC_PARENT_UUID', 17: 'RFC_NEW_UUID', 18: 'RFC_UUIDS', 19: 'RFC_UUIDS2', 20: 'XML_LOGIN', 21: 'XML_TRANSACTION', 22: 'SCROLLBAR_WIDTH', 23: 'TOOLBAR_HEIGHT', 24: 'PASSPORT_DATA', 25: 'GUI_STATE', 26: 'DECIMALPOINT', 27: 'LANGUAGE', 28: 'USERNAME', 29: 'GUIPATCHLEVEL', 30: 'WSIZE_PIXEL', 31: 'GUI_OS_VERSION', 32: 'BROWSER_VERSION', 33: 'OFFICE_VERSION', 34: 'JDK_VERSION', 35: 'GUIXT_VERSION', 36: 'DISPLAY_SIZE', 37: 'GUI_TYPE', 38: 'DIALOG_STEP_NUMBER'}, 5: {1: 'CHL', 3: 'XMLPROP DYNPRO'}, 6: {1: 'MODENUMBER', 2: 'DBNAME', 3: 'CPUNAME', 4: 'RFC_TRIGGER', 5: 'GUI_LABEL', 6: 'DIAGVERSION', 7: 'TCODE', 8: 'RFC_WAITING', 9: 'RFC_REFRESH', 10: 'IMODENUMBER', 11: 'MESSAGE', 12: 'CLIENT', 13: 'DYNPRONAME', 14: 'DYNPRONUMBER', 15: 'CUANAME', 16: 'CUASTATUS', 17: 'SUPPORTDATA', 18: 'RFC_CONNECT_OK', 19: 'GUI_FKEY', 20: 'GUI_FKEYT', 21: 'STOP_TRANS', 22: 'RFC_DIAG_BLOCK_SIZE', 23: 'USER_CHECKED', 24: 'FLAGS', 25: 'USERID', 26: 'ROLLCOUNT', 27: 'GUI_XT_VAR', 28: 'IMODEUUID', 29: 'IMODEUUID_INVALIDATE', 30: 'IMODEUUIDS', 31: 'IMODEUUIDS2', 32: 'CODEPAGE', 33: 'CONTEXTID', 34: 'AUTOLOGOUT_TIME', 35: 'CODEPAGE_DIAG_GUI', 36: 'CODEPAGE_APP_SERVER', 37: 'GUI_THEME', 38: 'GUI_USER_SCRIPTING', 39: 'CODEPAGE_APP_SERVER_1', 40: 'TICKET4GUI', 41: 'KERNEL_VERSION', 42: 'STD_TOOLBAR_ITEMS'}, 7: {2: 'DEST'}, 8: {0: 'RFC_TR_REQ', 1: 'RFC_TR_RET', 2: 'RFC_TR_ERR', 3: 'RFC_TR_RQT', 4: 'RFC_TR_MOR', 5: 'RFC_TR_MOB', 6: 'RFC_TR_RNB', 7: 'RFC_TR_RNT', 8: 'RFC_TR_DIS', 9: 'RFC_TR_CALL', 10: 'RFC_TR_CALL_END', 11: 'RFC_TR_RES'}, 9: {1: 'DYNT_FOCUS', 2: 'DYNT_ATOM', 3: 'DYNT_EVENT_UNUSED', 4: 'TABLE_ROW_REFERENCE', 5: 'TABLE_ROW_DAT_INPUT_DUMMY', 6: 'TABLE_INPUT_HEADER', 7: 'TABLE_OUTPUT_HEADER', 8: 'TABLE_ROW_DATA_INPUT', 9: 'TABLE_ROW_DATA_OUTPUT', 10: 'DYNT_NOFOCUS', 11: 'DYNT_FOCUS_1', 12: 'TABLE_ROW_REFERENCE_1', 13: 'TABLE_FIELD_NAMES', 14: 'TABLE_HEADER', 15: 'DYNT_TABSTRIP_HEADER', 16: 'DYNT_TABSTRIP_BUTTONS', 17: 'TABLE_ROW_REFERENCE_2', 18: 'DYNT_CONTROL_FOCUS', 21: 'DYNT_TC_COLUMN_TITLE_XMLP', 22: 'DYNT_TC_ROW_SELECTOR_NAME', 23: 'DYNT_FOCUS_FRAME'}, 10: {1: 'RESET', 2: 'DEFAULT', 3: 'SUBSCREEN', 4: 'LOOP', 5: 'TABLE', 6: 'NAME', 8: 'TABSTRIP', 9: 'TABSTRIP_PAGE', 10: 'CONTROL', 12: 'XMLPROP', 13: 'SPLITTER', 14: 'SPLITTER_CELL'}, 11: {1: 'MENU_ACT', 2: 'MENU_MNU', 3: 'MENU_PFK', 4: 'MENU_KYB'}, 12: {1: 'MESTYPE', 2: 'SCROLL_INFOS', 3: 'MESTYPE2', 4: 'OKCODE', 5: 'CONTAINER', 6: 'SCROLL_INFOS2', 7: 'AREASIZE', 8: 'AREA_PIXELSIZE', 9: 'SESSION_TITLE', 10: 'SESSION_ICON', 11: 'LIST_CELL_TEXT', 12: 'CONTAINER_LOOP', 13: 'LIST_FOCUS', 14: 'MAINAREA_PIXELSIZE', 15: 'SERVICE_REQUEST'}, 14: {1: 'CONTROL_PROPERTIES'}, 15: {1: 'UI_EVENT_SOURCE'}, 18: {1: 'ACC_LIST_INFO4FIELD', 2: 'ACC_LIST_CONTAINER'}, 19: {1: 'RCUI_STREAM', 2: 'RCUI_SYSTEM_ERROR', 3: 'RCUI_SPAGPA', 4: 'RCUI_MEMORYID', 5: 'RCUI_TXOPTION', 6: 'RCUI_VALUE', 7: 'RCUI_COMMAND', 8: 'RCUI_BDCMSG', 9: 'RCUI_CONNECT_DATA'}, 20: {1: 'GUI_PACKET_STATE', 2: 'GUI_PACKET_DATA'}}

Diag APPL/APPL4 SIDs

pysap.SAPDiag.diag_compress_values = {0: 'Compression switched off', 1: 'Compression switched on', 2: 'Data encrypted', 3: 'Data encrypted wrap'}

Compression Flag values

pysap.SAPDiag.diag_guess_diagdp_header(self, payload)[source]

Guess if the payload is a SAPDiag or SAPDiagDP, base on the mode field. Use this function as guess_payload_class for the SAPNI packet if need to dissect SAPDiag packets.

pysap.SAPDiag.diag_item_appl_classes = {}

Dictionary for registering Diag APPL/APPL4 item classes

pysap.SAPDiag.diag_item_classes = {}

Dictionary for registering Diag item classes

pysap.SAPDiag.diag_item_get_class(pkt, item_type, item_id, item_sid)[source]

Obtains the Diag item class according to the type, ID and SID of the packet. If the Type/ID/SID is not registered, returns None.

Parameters:
  • pkt (SAPDiagItem) – the item to look at
  • item_type (int) – function that returns the item type
  • item_id (int) – function that returns the item ID
  • item_sid (int) – functions that returns the item SID
Returns:

the associated SAPDiagItem class if registered or None

pysap.SAPDiag.diag_item_get_length(item)[source]

Returns the item length according to the item_type

Parameters:item (SAPDiagItem) – item to look at
Returns:the item length
Return type:int
pysap.SAPDiag.diag_item_is_appl_appl4(item)[source]

Returns if an item is APPL or APPL4

Parameters:item (SAPDiagItem) – item to look a
Returns:whether the item is a APPL or APPL4 item
Return type:bool
pysap.SAPDiag.diag_item_is_long(item)[source]

Returns if the item has a long length field

Parameters:item (SAPDiagItem) – item to look at
Returns:if the item has a long length field (4 bytes)
Return type:bool
pysap.SAPDiag.diag_item_is_short(item)[source]

Returns if the item has a short length field

Parameters:item (SAPDiagItem) – item to look at
Returns:if the item has a short length field (2 bytes)
Return type:bool
pysap.SAPDiag.diag_item_types = {1: 'SES', 2: 'ICO', 3: 'TIT', 7: 'DiagMessage', 8: 'OKC', 9: 'CHL', 10: 'SFE', 11: 'SBA', 12: 'EOM', 16: 'APPL', 17: 'DIAG_XMLBLOB', 18: 'APPL4', 19: 'SLC', 21: 'SBA2'}

Diag Item Types