Next: Configuration
Up: DCE/RPC 2 Preprocessor
Previous: Dependency Requirements
Contents
There are enough important differences between Windows and Samba versions that
a target based approach has been implemented. Some important differences:
Named pipe instance tracking
- A combination of valid login handle or UID, share handle or TID and
file/named pipe handle or FID must be used to write data to a named pipe. The
binding between these is dependent on OS/software version.
- Samba 3.0.22 and earlier
- Any valid UID and TID, along with a valid FID can be used to make a
request, however, if the TID used in creating the FID is deleted (via a tree
disconnect), the FID that was created using this TID becomes invalid, i.e. no
more requests can be written to that named pipe instance.
- Samba greater than 3.0.22
- Any valid TID, along with a valid FID can be used to make a request.
However, only the UID used in opening the named pipe can be used to make a
request using the FID handle to the named pipe instance. If the TID used to
create the FID is deleted (via a tree disconnect), the FID that was created
using this TID becomes invalid, i.e. no more requests can be written to that
named pipe instance. If the UID used to create the named pipe instance is
deleted (via a Logoff AndX), since it is necessary in making a request
to the named pipe, the FID becomes invalid.
- Windows 2003
- Windows XP
- Windows Vista
- These Windows versions require strict binding between the UID, TID and
FID used to make a request to a named pipe instance. Both the UID and TID used
to open the named pipe instance must be used when writing data to the same
named pipe instance. Therefore, deleting either the UID or TID invalidates the
FID.
- Windows 2000
- Windows 2000 is interesting in that the first request to a named pipe
must use the same binding as that of the other Windows versions. However,
requests after that follow the same binding as Samba 3.0.22 and earlier, i.e.
no binding. It also follows Samba greater than 3.0.22 in that deleting the UID
or TID used to create the named pipe instance also invalidates it.
Accepted SMB commands
- Samba in particular does not recognize certain commands under an
IPC$ tree.
- Samba (all versions)
- Under an IPC$ tree, does not accept:
- Open
- Write And Close
- Read
- Read Block Raw
- Write Block Raw
- Windows (all versions)
- Accepts all of the above commands under an IPC$ tree.
AndX command chaining
- Windows is very strict in what command combinations it allows to be
chained. Samba, on the other hand, is very lax and allows some nonsensical
combinations, e.g. multiple logins and tree connects (only one place to return
handles for these), login/logoff and tree connect/tree disconnect. Ultimately,
we don't want to keep track of data that the server won't accept. An evasion
possibility would be accepting a fragment in a request that the server won't
accept that gets sandwiched between an exploit.
Transaction tracking
- The differences between a Transaction request and using one of
the Write* commands to write data to a named pipe are that (1) a
Transaction performs the operations of a write and a read from the
named pipe, whereas in using the Write* commands, the client has to
explicitly send one of the Read* requests to tell the server to send
the response and (2) a Transaction request is not written to the named
pipe until all of the data is received (via potential Transaction
Secondary requests) whereas with the Write* commands, data is written
to the named pipe as it is received by the server. Multiple Transaction
requests can be made simultaneously to the same named pipe. These requests can
also be segmented with Transaction Secondary commands. What
distinguishes them (when the same named pipe is being written to, i.e. having
the same FID) are fields in the SMB header representing a process id (PID) and
multiplex id (MID). The PID represents the process this request is a part of.
An MID represents different sub-processes within a process (or under a PID).
Segments for each "thread" are stored separately and written to the named pipe
when all segments are received. It is necessary to track this so as not to
munge these requests together (which would be a potential evasion opportunity).
- Windows (all versions)
- Uses a combination of PID and MID to define a "thread".
- Samba (all versions)
- Uses just the MID to define a "thread".
Multiple Bind Requests
- A Bind request is the first request that must be made in a
connection-oriented DCE/RPC session in order to specify the
interface/interfaces that one wants to communicate with.
- Windows (all versions)
- For all of the Windows versions, only one Bind can ever be
made on a session whether or not it succeeds or fails. Any binding after that
must use the Alter Context request. If another Bind is made,
all previous interface bindings are invalidated.
- Samba 3.0.20 and earlier
- Any amount of Bind requests can be made.
- Samba later than 3.0.20
- Another Bind request can be made if the first failed and no
interfaces were successfully bound to. If a Bind after a successful
Bind is made, all previous interface bindings are invalidated.
DCE/RPC Fragmented requests - Context ID
- Each fragment in a fragmented request carries the context id of the
bound interface it wants to make the request to.
- Windows (all versions)
- The context id that is ultimately used for the request is contained in
the first fragment. The context id field in any other fragment can contain any
value.
- Samba (all versions)
- The context id that is ultimately used for the request is contained in
the last fragment. The context id field in any other fragment can contain any
value.
DCE/RPC Fragmented requests - Operation number
- Each fragment in a fragmented request carries an operation number
(opnum) which is more or less a handle to a function offered by the interface.
- Samba (all versions)
- Windows 2000
- Windows 2003
- Windows XP
- The opnum that is ultimately used for the request is contained in the
last fragment. The opnum field in any other fragment can contain any value.
- Windows Vista
- The opnum that is ultimately used for the request is contained in the
first fragment. The opnum field in any other fragment can contain any value.
DCE/RPC Stub data byte order
- The byte order of the stub data is determined differently for Windows
and Samba.
- Windows (all versions)
- The byte order of the stub data is that which was used in the
Bind request.
- Samba (all versions)
- The byte order of the stub data is that which is used in the request
carrying the stub data.
Next: Configuration
Up: DCE/RPC 2 Preprocessor
Previous: Dependency Requirements
Contents
Eugene Misnik
2013-05-08