#NEWLINE# def create_system_object( search_string , content_string , condition ) : #NEWLINE# #INDENT# from cybox.objects.address_object import Address #NEWLINE# from cybox.objects.system_object import System , OS , BIOSInfo , NetworkInterface , NetworkInterfaceList , DHCPServerList , IPInfo , IPInfoList #NEWLINE# winsys_keys = ( 'SystemInfoItem/productID' , 'SystemInfoItem/regOrg' , 'SystemInfoItem/regOwner' , 'SystemInfoItem/domain' ) #NEWLINE# sys_attrmap = { #NEWLINE# #INDENT# 'SystemInfoItem/processor' : 'processor' , #NEWLINE# 'SystemInfoItem/timezoneDST' : 'timezone_dst' , #NEWLINE# 'SystemInfoItem/timezoneStandard' : 'timezone_standard' , #NEWLINE# 'SystemInfoItem/totalphysical' : 'total_physical' , #NEWLINE# 'SystemInfoItem/uptime' : 'uptime' , #NEWLINE# 'SystemInfoItem/user' : 'username' , #NEWLINE# 'SystemInfoItem/availphysical' : 'available_physical_memory' , #NEWLINE# 'SystemInfoItem/date' : 'date' , #NEWLINE# 'SystemInfoItem/hostname' : 'hostname' , #NEWLINE# #UNINDENT# } #NEWLINE# os_attrmap = { #NEWLINE# #INDENT# 'SystemInfoItem/buildNumber' : 'build_number' , #NEWLINE# 'SystemInfoItem/installDate' : 'install_date' , #NEWLINE# 'SystemInfoItem/OS' : 'platform' , #NEWLINE# 'SystemInfoItem/patchLevel' : 'patch_level' , #NEWLINE# #UNINDENT# } #NEWLINE# bios_attrmap = { #NEWLINE# #INDENT# 'SystemInfoItem/biosInfo/biosDate' : 'bios_date' , #NEWLINE# 'SystemInfoItem/biosInfo/biosVersion' : 'bios_version' , #NEWLINE# #UNINDENT# } #NEWLINE# iface_attrmap = { #NEWLINE# #INDENT# 'SystemInfoItem/MAC' : 'mac' , #NEWLINE# 'SystemInfoItem/networkArray/networkInfo/MAC' : 'mac' , #NEWLINE# 'SystemInfoItem/networkArray/networkInfo/adapter' : 'adapter' , #NEWLINE# 'SystemInfoItem/networkArray/networkInfo/description' : 'description' , #NEWLINE# 'SystemInfoItem/networkArray/networkInfo/dhcpLeaseExpires' : 'dhcp_lease_expires' , #NEWLINE# 'SystemInfoItem/networkArray/networkInfo/dhcpLeaseObtained' : 'dhcp_lease_obtained' , #NEWLINE# #UNINDENT# } #NEWLINE# os_ = OS ( ) #NEWLINE# system = System ( ) #NEWLINE# bios = BIOSInfo ( ) #NEWLINE# ipinfo = IPInfo ( ) #NEWLINE# iface = NetworkInterface ( ) #NEWLINE# if ( search_string in sys_attrmap ) : #NEWLINE# #INDENT# set_field ( system , sys_attrmap [ search_string ] , content_string , condition ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( search_string in os_attrmap ) : #NEWLINE# #INDENT# set_field ( os_ , os_attrmap [ search_string ] , content_string , condition ) #NEWLINE# system . os = os_ #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( search_string in iface_attrmap ) : #NEWLINE# #INDENT# set_field ( bios , bios_attrmap [ search_string ] , content_string , condition ) #NEWLINE# system . bios_info = bios #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( search_string in iface_attrmap ) : #NEWLINE# #INDENT# set_field ( iface , iface_attrmap [ search_string ] , content_string , condition ) #NEWLINE# system . network_interface_list = NetworkInterfaceList ( iface ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( search_string in winsys_keys ) : #NEWLINE# #INDENT# return create_win_system_obj ( search_string , content_string , condition ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( search_string == 'SystemInfoItem/networkArray/networkInfo/dhcpServerArray/dhcpServer' ) : #NEWLINE# #INDENT# addr = Address ( xml . sanitize ( content_string ) , category = Address . CAT_IPV4 ) #NEWLINE# iface . dhcp_server_list = DHCPServerList ( addr ) #NEWLINE# system . network_interface_list = NetworkInterfaceList ( iface ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( search_string == 'SystemInfoItem/networkArray/networkInfo/ipArray/ipInfo/ipAddress' ) : #NEWLINE# #INDENT# addr = Address ( xml . sanitize ( content_string ) , category = Address . CAT_IPV4 ) #NEWLINE# ipinfo . ip_address = addr #NEWLINE# iface . ip_list = IPInfoList ( ipinfo ) #NEWLINE# system . network_interface_list = NetworkInterfaceList ( iface ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( content_string == 'SystemInfoItem/networkArray/networkInfo/ipArray/ipInfo/subnetMask' ) : #NEWLINE# #INDENT# addr = Address ( xml . sanitize ( content_string ) , category = Address . CAT_IPV4_NETMASK ) #NEWLINE# ipinfo . subnet_mask = addr #NEWLINE# iface . ip_list = IPInfoList ( ipinfo ) #NEWLINE# system . network_interface_list = NetworkInterfaceList ( iface ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return Object ( system )