Package rekall :: Package plugins :: Package overlays :: Package darwin :: Module darwin :: Class socket
[frames] | no frames]

Class socket

source code


Provides human-readable accessors for sockets of the more common AFs.

This class has two basic ways of getting information. Most attributes are computed using the method fill_socketinfo, which is directly adapted from the kernel function of the same name. For the few things that fill_socketinfo doesn't care about, the properties themselves get the data and provide references to the kernel source for anyone wondering why and how all this works.

Nested Classes
  __metaclass__
Give each object a unique ID. (Inherited from rekall.obj.BaseObject)
Instance Methods
 
fill_socketinfo(self)
Computes information about sockets of some addressing families.
source code
 
get_socketinfo_attr(self, attr)
Run fill_socketinfo if needed, cache result, return value of attr.
source code
 
GetData(self)
Returns the raw data of this object. (Inherited from rekall.obj.BaseObject)
source code
 
SetMember(self, attr, value)
Write a value to a member. (Inherited from rekall.obj.Struct)
source code
 
__comparator__(self, other, method) (Inherited from rekall.obj.BaseAddressComparisonMixIn) source code
 
__dir__(self)
Hide any members with _. (Inherited from rekall.obj.BaseObject)
source code
 
__eq__(self, other) (Inherited from rekall.obj.BaseAddressComparisonMixIn) source code
 
__format__(self, formatspec)
default object formatter (Inherited from rekall.obj.BaseObject)
source code
 
__ge__(self, other) (Inherited from rekall.obj.BaseAddressComparisonMixIn) source code
 
__getattr__(self, attr) (Inherited from rekall.obj.Struct) source code
 
__gt__(self, other) (Inherited from rekall.obj.BaseAddressComparisonMixIn) source code
 
__hash__(self)
hash(x) (Inherited from rekall.obj.Struct)
source code
 
__init__(self, members=None, struct_size=0, callable_members=None, **kwargs)
This must be instantiated with a dict of members. (Inherited from rekall.obj.Struct)
source code
 
__int__(self)
Return our offset as an integer. (Inherited from rekall.obj.Struct)
source code
 
__le__(self, other) (Inherited from rekall.obj.BaseAddressComparisonMixIn) source code
 
__long__(self) (Inherited from rekall.obj.Struct) source code
 
__lt__(self, other) (Inherited from rekall.obj.BaseAddressComparisonMixIn) source code
 
__ne__(self, other) (Inherited from rekall.obj.BaseAddressComparisonMixIn) source code
 
__nonzero__(self)
This method is called when we test the truth value of an Object. (Inherited from rekall.obj.BaseObject)
source code
 
__repr__(self)
repr(x) (Inherited from rekall.obj.Struct)
source code
 
__str__(self)
str(x) (Inherited from rekall.obj.BaseObject)
source code
 
__unicode__(self) (Inherited from rekall.obj.Struct) source code
 
cast(self, type_name=None, vm=None, **kwargs) (Inherited from rekall.obj.BaseObject) source code
 
deref(self, vm=None)
An alias for dereference - less to type. (Inherited from rekall.obj.BaseObject)
source code
 
dereference(self, vm=None) (Inherited from rekall.obj.BaseObject) source code
 
is_valid(self) (Inherited from rekall.obj.BaseObject) source code
 
m(self, attr, allow_callable_attributes=False)
Fetch the member named by attr. (Inherited from rekall.obj.Struct)
source code
 
multi_m(self, *args, **opts)
Retrieve a set of fields in order. (Inherited from rekall.obj.Struct)
source code
 
preamble_size(self)
The number of bytes before the object which are part of the object. (Inherited from rekall.obj.Struct)
source code
 
proxied(self) (Inherited from rekall.obj.BaseObject) source code
 
reference(self)
Produces a pointer to this object. (Inherited from rekall.obj.BaseObject)
source code
 
v(self, vm=None)
When a struct is evaluated we just return our offset. (Inherited from rekall.obj.Struct)
source code
 
walk_list(self, list_member, include_current=True, deref_as=None)
Walk a single linked list in this struct. (Inherited from rekall.obj.Struct)
source code
 
write(self, value)
Function for writing the object back to disk (Inherited from rekall.obj.BaseObject)
source code

Inherited from object: __delattr__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Methods
 
getproperties(cls)
Return all members that are intended to represent some data. (Inherited from rekall.obj.BaseObject)
source code
Class Variables
  cached_socketinfo = None
hash(x)
  obj_name = <No name> (Inherited from rekall.obj.BaseObject)
  obj_parent = <No parent> (Inherited from rekall.obj.BaseObject)
  obj_producers = None
hash(x) (Inherited from rekall.obj.BaseObject)
Properties
  src_addr
For IPv[46] sockets, return source IP as string.
  dst_addr
For IPv[46] sockets, return destination IP as string.
  addressing_family
The Addressing Family corresponds roughly to OSI layer 3.
  tcp_state
  vnode
For Unix sockets, pointer to vnode, if any.
  unp_conn
For Unix sockets, the pcb of the paired socket.
  src_port
  dst_port
  l4_protocol
  unix_type
  human_name
  human_type
  indices
Returns (usually 1) representation(s) of self usable as dict keys. (Inherited from rekall.obj.Struct)
  obj_end (Inherited from rekall.obj.BaseObject)
  obj_size (Inherited from rekall.obj.Struct)
  parents
Returns all the parents of this object. (Inherited from rekall.obj.BaseObject)

Inherited from object: __class__

Method Details

fill_socketinfo(self)

source code 
Computes information about sockets of some addressing families.

This function is directly adapted from the kernel function
fill_socketinfo [1]. The original function is used to fill a struct
with addressing and other useful information about sockets of a few
key addressing families. All families are supported, but only the
following will return useful information:
  - AF_INET (IPv4)
  - AF_INET6 (IPv6)
  - AF_UNIX (Unix socket)
  - AF_NDRV (Network driver raw access)
  - AF_SYSTEM (Darwin-specific; see documentation [3])

Differences between the kernel function and this adaptation:
  - The kernel uses Protocol Families (prefixed with PF_). Rekall
  relies on Addressing Families (AF_) which are exactly the same.

  - The kernel fills a struct; this function returns a dict with the
  same members.

  - The kernel returns the data raw. This function converts endianness
  and unions to human-readable representations, as appropriate.

  - Only a subset of members are filled in.

  - Other differences as documented in code.

Returns:
  A dict with the same members as struct socket_info and related.
  Only member that's always filled is "soi_kind". That's not Spanish,
  but one of the values in this anonymous enum [2], which determines
  what other members are present. (Read the code.)

[1]
https://github.com/opensource-apple/xnu/blob/10.9/bsd/kern/socket_info.c#L98
[2]
https://github.com/opensource-apple/xnu/blob/10.9/bsd/sys/proc_info.h#L503
[3] "KEXT Controls and Notifications"
https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/NKEConceptual/control/control.html


Property Details

src_addr

For IPv[46] sockets, return source IP as string.

Get Method:
unreachable.src_addr(self) - For IPv[46] sockets, return source IP as string.

dst_addr

For IPv[46] sockets, return destination IP as string.

Get Method:
unreachable.dst_addr(self) - For IPv[46] sockets, return destination IP as string.

addressing_family

The Addressing Family corresponds roughly to OSI layer 3.

Get Method:
unreachable.addressing_family(self) - The Addressing Family corresponds roughly to OSI layer 3.

tcp_state

Get Method:
unreachable.tcp_state(self)

vnode

For Unix sockets, pointer to vnode, if any.

This is the same way that OS gathers this information in response to syscall [1] (this is the API used by netstat, among others).

1: https://github.com/opensource-apple/xnu/blob/10.9/bsd/kern/uipc_usrreq.c#L1683

Get Method:
unreachable.vnode(self) - For Unix sockets, pointer to vnode, if any.

unp_conn

For Unix sockets, the pcb of the paired socket. [1]

You most likely want to do sock.conn_pcb.unp_socket to get at the other socket in the pair. However, because the sockets are paired through the protocol control block, it's actually useful to have a direct pointer at it in order to be able to spot paired sockets.

1: https://github.com/opensource-apple/xnu/blob/10.9/bsd/sys/unpcb.h#L128

Get Method:
unreachable.unp_conn(self) - For Unix sockets, the pcb of the paired socket.

src_port

Get Method:
unreachable.src_port(self)

dst_port

Get Method:
unreachable.dst_port(self)

l4_protocol

Get Method:
unreachable.l4_protocol(self)

unix_type

Get Method:
unreachable.unix_type(self)

human_name

Get Method:
unreachable.human_name(self)

human_type

Get Method:
unreachable.human_type(self)