/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
/*
* References used throughout this code:
*
* [CIFS/1.0] : A Common Internet File System (CIFS/1.0) Protocol
* Internet Engineering Task Force (IETF) draft
* Paul J. Leach, Microsoft, Dec. 1997
*
*/
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "snoop.h"
/*
* SMB Format (header)
*/
struct smb {
/*
* immediately after the above 32 byte header:
* unsigned char WordCount;
* unsigned short ParameterWords[ WordCount ];
* unsigned short ByteCount;
* unsigned char ParameterBytes[ ByteCount ];
*/
};
/* smb flags */
/* smb flags2 */
static void interpret_sesssetupX(int, uchar_t *, int, char *, int);
static void interpret_tconX(int, uchar_t *, int, char *, int);
static void interpret_trans(int, uchar_t *, int, char *, int);
static void interpret_trans2(int, uchar_t *, int, char *, int);
static void interpret_negprot(int, uchar_t *, int, char *, int);
static void interpret_default(int, uchar_t *, int, char *, int);
/*
* Trans2 subcommand codes
*/
struct decode {
char *name;
char *callfmt;
char *replyfmt;
};
/*
* SMB command codes (function names)
*/
/* 0x00 */
{ "mkdir", 0, 0, 0 },
{ "rmdir", 0, 0, 0 },
{ "open", 0, 0, 0 },
{ "create", 0, 0, 0 },
{
"close", 0,
"WFileID\0"
"lLastModTime\0"
"dByteCount\0\0",
"dByteCount\0\0"
},
{ "flush", 0, 0, 0 },
{ "unlink", 0, 0, 0 },
{
"move", 0,
"wFileAttributes\0"
"dByteCount\0r\0"
"UFileName\0r\0"
"UNewPath\0\0",
"dByteCount\0\0"
},
{
"getatr", 0,
"dBytecount\0r\0"
"UFileName\0\0",
"wFileAttributes\0"
"lTime\0"
"lSize\0"
"R\0R\0R\0R\0R\0"
"dByteCount\0\0"
},
{ "setatr", 0, 0, 0 },
{
"read", 0,
"WFileID\0"
"wI/0 Bytes\0"
"LFileOffset\0"
"WBytesLeft\0"
"dByteCount\0\0",
"WDataLength\0"
"R\0R\0R\0R\0"
"dByteCount\0\0"
},
{
"write", 0,
"WFileID\0"
"wI/0 Bytes\0"
"LFileOffset\0"
"WBytesLeft\0"
"dByteCount\0\0",
"WDataLength\0"
"dByteCount\0\0"
},
{ "lock", 0, 0, 0 },
{ "unlock", 0, 0, 0 },
{ "ctemp", 0, 0, 0 },
{ "mknew", 0, 0, 0 },
/* 0x10 */
{
"chkpth", 0,
"dByteCount\0r\0"
"UFile\0\0",
"dByteCount\0\0"
},
{ "exit", 0, 0, 0 },
{ "lseek", 0, 0, 0 },
{ "lockread", 0, 0, 0 },
{ "writeunlock", 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{
"readbraw", 0,
"WFileID\0"
"LFileOffset\0"
"wMaxCount\0"
"wMinCount\0"
"lTimeout\0R\0"
"dByteCount\0\0", 0
},
{ "readbmpx", 0, 0, 0 },
{ "readbs", 0, 0, 0 },
{ "writebraw", 0, 0, 0 },
{ "writebmpx", 0, 0, 0 },
{ "writebs", 0, 0, 0 },
/* 0x20 */
{ "writec", 0, 0, 0 },
{ "qrysrv", 0, 0, 0 },
{ "setattrE", 0, 0, 0 },
{ "getattrE", 0, 0, 0 },
{
"lockingX", 0,
"wChainedCommand\0"
"wNextOffset\0"
"WFileID\0"
"wLockType\0"
"lOpenTimeout\0"
"W#Unlocks\0"
"W#Locks\0"
"dByteCount\0\0", 0
},
{ "trans", interpret_trans, 0, 0 },
{ "transs", 0, 0, 0 },
{ "ioctl", 0, 0, 0 },
{ "ioctls", 0, 0, 0 },
{ "copy", 0, 0, 0 },
{ "move", 0, 0, 0 },
{ "echo", 0, 0, 0 },
{ "writeclose", 0, 0, 0 },
{
"openX", 0,
/* call */
"wChainedCommand\0"
"wNextOffset\0"
"wFlags\0"
"wMode\0"
"wSearchAttributes\0"
"wFileAttributes\0"
"lTime\0"
"wOpenFunction\0"
"lFileSize\0"
"lOpenTimeout\0R\0R\0"
"dByteCount\0r\0"
"UFileName\0\0",
/* reply */
"wChainedCommand\0"
"wNextOffset\0"
"WFileID\0"
"wAttributes\0"
"lTime\0"
"LSize\0"
"wOpenMode\0"
"wFileType\0"
"wDeviceState\0"
"wActionTaken\0"
"lUniqueFileID\0R\0"
"wBytecount\0\0"
},
{
/* [CIFS 4.2.4] */
"readX", 0,
/* call */
"wChainedCommand\0"
"wNextOffset\0"
"WFileID\0"
"LOffset\0"
"DMaxCount\0"
"dMinCount\0"
"dMaxCountHigh\0"
"R\0"
"wRemaining\0"
"lOffsetHigh\0"
"dByteCount\0\0",
/* reply */
"wChainedCommand\0"
"wNextOffset\0"
"dRemaining\0R\0R\0"
"DCount\0"
"dDataOffset\0"
"dCountHigh\0"
"R\0R\0R\0R\0"
"dByteCount\0\0"
},
{
/* [CIFS 4.2.5] */
"writeX", 0,
/* call */
"wChainedCommand\0"
"wNextOffset\0"
"WFileID\0"
"LOffset\0R\0R\0"
"wWriteMode\0"
"wRemaining\0"
"dDataLenHigh\0"
"DDataLen\0"
"dDataOffset\0"
"lOffsetHigh\0\0",
/* reply */
"wChainedCommand\0"
"wNextOffset\0"
"DCount\0"
"wRemaining\0"
"wCountHigh\0\0"
},
/* 0x30 */
{ 0, 0, 0, 0 },
{ "closeTD", 0, 0, 0 },
{ "trans2", interpret_trans2, 0, 0 },
{ "trans2s", 0, 0, 0 },
{
"findclose", 0,
"WFileID\0"
"dByteCount\0\0",
"dByteCount\0\0"
},
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
/* 0x40 */
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
/* 0x50 */
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
/* 0x60 */
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
/* 0x70 */
{ "tcon", 0, 0, 0 },
{
"tdis", 0,
"dByteCount\0\0",
"dByteCount\0\0"
},
{ "negprot", interpret_negprot, 0, 0 },
{ "sesssetupX", interpret_sesssetupX, 0, 0 },
{
"uloggoffX", 0,
"wChainedCommand\0"
"wNextOffset\0\0",
"wChainedCommnad\0"
"wNextOffset\0\0" },
{ "tconX", interpret_tconX, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
/* 0x80 */
{ "dskattr", 0, 0, 0 },
{ "search", 0, 0, 0 },
{ "ffirst", 0, 0, 0 },
{ "funique", 0, 0, 0 },
{ "fclose", 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
/* 0x90 */
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
/* 0xa0 */
/*
* Command codes 0xa0 to 0xa7 are from
* [CIFS/1.0, Sec. 5.1]
*/
{ "_NT_Trans", 0, 0, 0 },
{ "_NT_Trans2", 0, 0, 0 },
{
/* [CIFS/1.0, Sec. 4.2.1] */
"_NT_CreateX", 0,
/* Call */
"wChainedCommand\0"
"wNextOffset\0r\0"
"dNameLength\0"
"lCreateFlags\0"
"lRootDirFID\0"
"lDesiredAccess\0"
"lAllocSizeLow\0"
"lAllocSizeHigh\0"
"lNTFileAttributes\0"
"lShareAccess\0"
"lOpenDisposition\0"
"lCreateOption\0"
"lImpersonationLevel\0"
"bSecurityFlags\0"
"dByteCount\0r\0"
"UFileName\0\0",
/* Reply */
"wChainedCommand\0"
"wNextOffset\0"
"bOplockLevel\0"
"WFileID\0"
"lCreateAction\0\0"
},
{ 0, 0, 0, 0 },
{
"_NT_Cancel", 0,
/* [CIFS/1.0, Sec. 4.1.8] */
"dByteCount\0", 0
},
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
/* 0xb0 */
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
/* 0xc0 */
{ "splopen", 0, 0, 0 },
{ "splwr", 0, 0, 0 },
{ "splclose", 0, 0, 0 },
{ "splretq", 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
/* 0xd0 */
{ "sends", 0, 0, 0 },
{ "sendb", 0, 0, 0 },
{ "fwdname", 0, 0, 0 },
{ "cancelf", 0, 0, 0 },
{ "getmac", 0, 0, 0 },
{ "sendstrt", 0, 0, 0 },
{ "sendend", 0, 0, 0 },
{ "sendtxt", 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
/* 0xe0 */
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
/* 0xf0 */
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 }
};
/* Helpers to get values in Intel order (often mis-aligned). */
static uint16_t
return (p[0] + (p[1]<<8));
}
static uint32_t
return (p[0] + (p[1]<<8) + (p[2]<<16) + (p[3]<<24));
}
static uint64_t
}
/*
* Support displaying NT times.
* Number of seconds between 1970 and 1601 year
* (134774 days)
*/
static char *
{
/* Optimize time zero. */
if (nt_time == 0) {
ux_sec = 0;
ux_nsec = 0;
goto out;
}
if (nt_sec <= DIFF1970TO1601) {
ux_sec = 0;
ux_nsec = 0;
goto out;
}
out:
}
/*
* This is called by snoop_netbios.c.
* This is the external entry point.
*/
void
{
return;
xtra[0] = '\0';
/*
* SMB Header description
*/
show_space();
show_line("SERVER RESPONSE");
else
show_line("CLIENT REQUEST");
show_printf("Command code = 0x%x (SMB%s)",
else
/*
*/
if (smb_flags2 & FLAGS2_NT_STATUS) {
} else {
show_printf("Error class/code = %d/%d",
}
show_space();
}
char *p;
/* Will advance p and decr. sz */
p = get_sum_line();
/* Call or Reply */
else
p += tl;
/* The name, if known, else the cmd code */
} else {
}
p += tl;
/*
* The "extra" (cmd-specific summary).
* If non-null, has leading blank.
*/
if (xtra[0] != '\0') {
p += tl;
}
/*
*
* Only show for response, not call.
*/
if (smb_flags2 & FLAGS2_NT_STATUS) {
} else {
}
}
}
show_trailer();
}
static void
{
int i;
for (i = 0; i < bytecount; i++) {
}
}
}
/*
* Based on the Unicode Standard, http://www.unicode.org/
* "The Unicode Standard: A Technical Introduction", June 1998
*/
static int
{
int i = 0, j = 0;
char c;
/* Show unicode chars >= 256 as '?' */
if (instr[i+1])
c = '?';
else
c = instr[i];
if (c == '\0')
break;
outstr[j] = c;
i += 2;
j++;
}
outstr[j] = '\0';
return (j);
}
/*
* Convenience macro to copy a string from the data,
* either in UCS-2 or ASCII as indicated by UCS.
* OBUF must be an array type (see sizeof) and
* DP must be an L-value (this increments it).
*/
{ \
if (UCS) { \
DP++; \
} else { \
} \
}
/*
* TRANS2 information levels
*/
static void
{
switch (value) {
case 1:
break;
case 2:
break;
case 3:
break;
case 0x101:
break;
case 0x102:
break;
case 0x103:
break;
case 0x104:
break;
default:
break;
}
}
/*
* Interpret TRANS2_QUERY_PATH subcommand
*/
/* ARGSUSED */
static void
{
int length;
data += 6;
}
show_line("FunctionName = QueryPathInfo");
data += 6;
}
}
/*
* Interpret TRANS2_QUERY_FILE subcommand
*/
/* ARGSUSED */
static void
{
int length;
}
show_line("FunctionName = QueryFileInfo");
data += 2;
}
}
/*
* Interpret TRANS2_SET_FILE subcommand
*/
/* ARGSUSED */
static void
{
int length;
}
show_line("FunctionName = SetFileInfo");
data += 2;
}
}
/*
* Interpret TRANS2_FIND_FIRST subcommand
*/
/* ARGSUSED */
static void
{
int length;
data += 12;
}
show_line("FunctionName = Findfirst");
data += 2;
data += 2;
data += 2;
data += 6;
}
}
/*
* Interpret TRANS2_FIND_NEXT subcommand
*/
/* ARGSUSED */
static void
{
int length;
data += 12;
}
show_line("FunctionName = Findnext");
data += 2;
data += 2;
data += 2;
data += 4;
data += 2;
}
}
/*
* Interpret a "Negprot" SMB
*/
/* ARGSUSED */
static void
{
int bytecount;
int key_len;
int wordcount;
/*
* request packet:
* short bytecount;
* struct { char fmt; char name[]; } dialects
*/
protodata += 2;
/* Walk the list of dialects. */
i = last = 0;
tbuf[0] = '\0';
break;
sizeof (tbuf));
show_printf("Dialect[%d] = %s",
i, tbuf);
}
last = i++;
}
/*
* Just print the last dialect, which is
* normally the interesting one.
*/
}
} else {
/* Parse reply */
}
return;
if (wordcount < 13)
return;
protodata += 2;
protodata++;
protodata += 2;
protodata += 2;
protodata += 4;
protodata += 4;
protodata += 4;
protodata += 4;
/* Server Time */
protodata += 8;
protodata += 2;
protodata += 2;
if (smb_flags2 & FLAGS2_EXT_SEC) {
show_printf("Server GUID (16)");
protodata += 16;
show_printf("Security Blob (SPNEGO)");
} else {
/*
* Get Unicode from capabilities here,
* as flags2 typically doesn't have it.
* Also, this one is NOT aligned!
*/
tbuf[0] = '\0';
if (caps & 4) {
} else {
sizeof (tbuf));
}
}
}
}
/*
* LAN Manager remote admin function names.
*/
static const char *apiname_table[] = {
"RNetShareEnum",
"RNetShareGetInfo",
"NetShareSetInfo",
"NetShareAdd",
"NetShareDel",
"NetShareCheck",
"NetSessionEnum",
"NetSessionGetInfo",
"NetSessionDel",
"NetConnectionEnum",
"NetFileEnum",
"NetFileGetInfo",
"NetFileClose",
"RNetServerGetInfo",
"NetServerSetInfo",
"NetServerDiskEnum",
"NetServerAdminCommand",
"NetAuditOpen",
"NetAuditClear",
"NetErrorLogOpen",
"NetErrorLogClear",
"NetCharDevEnum",
"NetCharDevGetInfo",
"NetCharDevControl",
"NetCharDevQEnum",
"NetCharDevQGetInfo",
"NetCharDevQSetInfo",
"NetCharDevQPurge",
"RNetCharDevQPurgeSelf",
"NetMessageNameEnum",
"NetMessageNameGetInfo",
"NetMessageNameAdd",
"NetMessageNameDel",
"NetMessageNameFwd",
"NetMessageNameUnFwd",
"NetMessageBufferSend",
"NetMessageFileSend",
"NetMessageLogFileSet",
"NetMessageLogFileGet",
"NetServiceEnum",
"RNetServiceInstall",
"RNetServiceControl",
"RNetAccessEnum",
"RNetAccessGetInfo",
"RNetAccessSetInfo",
"RNetAccessAdd",
"RNetAccessDel",
"NetGroupEnum",
"NetGroupAdd",
"NetGroupDel",
"NetGroupAddUser",
"NetGroupDelUser",
"NetGroupGetUsers",
"NetUserEnum",
"RNetUserAdd",
"NetUserDel",
"NetUserGetInfo",
"RNetUserSetInfo",
"RNetUserPasswordSet",
"NetUserGetGroups",
"NetWkstaLogon",
"NetWkstaLogoff",
"NetWkstaSetUID",
"NetWkstaGetInfo",
"NetWkstaSetInfo",
"NetUseEnum",
"NetUseAdd",
"NetUseDel",
"NetUseGetInfo",
"DosPrintQEnum",
"DosPrintQGetInfo",
"DosPrintQSetInfo",
"DosPrintQAdd",
"DosPrintQDel",
"DosPrintQPause",
"DosPrintQContinue",
"DosPrintJobEnum",
"DosPrintJobGetInfo",
"RDosPrintJobSetInfo",
"DosPrintJobAdd",
"DosPrintJobSchedule",
"RDosPrintJobDel",
"RDosPrintJobPause",
"RDosPrintJobContinue",
"DosPrintDestEnum",
"DosPrintDestGetInfo",
"DosPrintDestControl",
"NetProfileSave",
"NetProfileLoad",
"NetStatisticsGet",
"NetStatisticsClear",
"NetRemoteTOD",
"NetBiosEnum",
"NetBiosGetInfo",
"NetServerEnum",
"I_NetServerEnum",
"NetServiceGetInfo",
"NetSplQmAbort",
"NetSplQmClose",
"NetSplQmEndDoc",
"NetSplQmOpen",
"NetSplQmStartDoc",
"NetSplQmWrite",
"DosPrintQPurge",
"NetServerEnum2"
};
static const int apinum_max = (
sizeof (apiname_table) /
sizeof (apiname_table[0]));
static const char *
{
char *name;
switch (code) {
case 0x01:
name = "SetNmPipeState";
break;
case 0x11:
name = "RawReadNmPipe";
break;
case 0x21:
name = "QueryNmPipeState";
break;
case 0x22:
name = "QueryNmPipeInfo";
break;
case 0x23:
name = "PeekNmPipe";
break;
case 0x26:
name = "XactNmPipe";
break;
case 0x31:
name = "RawWriteNmPipe";
break;
case 0x36:
name = "ReadNmPipe";
break;
case 0x37:
name = "WriteNmPipe";
break;
case 0x53:
name = "WaitNmPipe";
break;
case 0x54:
name = "CallNmPipe";
break;
default:
name = "?";
break;
}
return (name);
}
/*
* Interpret a "trans" SMB
*
* This is very much like "trans2" below.
*/
/* ARGSUSED */
static void
{
int wordcount;
int bytecount;
int parambytes;
int paramoffset;
int setupcount;
int subcode;
int apinum;
int isunicode;
const char *apiname;
const char *subcname;
/* Is the pathname in unicode? */
byteparms += 2;
/*
* Print the lengths before we (potentially) bail out
* due to lack of data (so the user knows why we did).
*/
/* Get length and location of params and setup data. */
/* CALL */
if (wordcount < 14)
return;
} else {
/* REPLY */
if (wordcount < 10)
return;
}
/* The parameters are offset from the SMB header. */
/* This is a CALL. */
if (setupcount > 0)
else
if (parambytes > 0)
else
else
apiname = "?";
int tl;
/* Only get one or the other */
if (*subcname != '?') {
" Func=%s", subcname);
}
if (*apiname != '?')
" Func=%s", apiname);
return;
}
return;
/* print the word parameters */
/* skip Reserved2 */
/* That finishes the VWV, now the misc. stuff. */
if (setupcount > 0)
show_printf("NmPipeFunc = 0x%x (%s)",
if (parambytes > 0)
show_printf("RAP_Func = %d (%s)",
/* Finally, print the byte parameters. */
} else {
/* This is a REPLY. */
return;
return;
/* print the word parameters */
/* skip Reserved */
}
}
/*
* Interpret a "TconX" SMB
*/
/* ARGSUSED */
static void
{
int length;
int isunicode;
int bytecount;
int wordcount;
int andxcmd;
int andxoffset;
int tconflags;
int pw_len;
/* Request */
if (wordcount < 4)
return;
tcondata += 2;
tcondata += 2;
tcondata += 2;
tcondata += 2;
tcondata += 2;
/* skip password */
return;
}
return;
} else {
/* response */
if (wordcount < 3)
return;
tcondata += 2;
tcondata += 2;
tcondata += 2;
tcondata += 2;
return;
}
return;
}
}
/*
* Interpret a "SesssetupX" SMB
*/
/* ARGSUSED */
static void
{
int bytecount;
int lm_pw_len;
int ext_security;
int sec_blob_len;
int isunicode;
int nt_pw_len;
int wordcount;
int cap;
/* request summary */
if (ext_security) {
/* No decoder for SPNEGO */
return;
}
if (wordcount != 13)
return;
setupdata += 14;
setupdata += 2;
setupdata += 6;
}
return;
/* request detail */
if (wordcount < 7)
return;
/* words 0 - 6 */
setupdata += 2;
setupdata += 2;
setupdata += 2;
setupdata += 2;
setupdata += 2;
setupdata += 4;
if (ext_security) {
if (wordcount != 12)
return;
/* word 7 */
setupdata += 2;
/* words 8, 9 (reserved) */
setupdata += 4;
} else {
if (wordcount != 13)
return;
/* word 7 */
setupdata += 2;
/* word 8 */
setupdata += 2;
/* words 9, 10 (reserved) */
setupdata += 4;
}
setupdata += 4;
setupdata += 2;
if (ext_security) {
/* No decoder for SPNEGO. Just dump hex. */
show_printf("Security blob: (SPNEGO)");
} else {
/* Dump password hashes */
if (lm_pw_len > 0) {
}
if (nt_pw_len > 0) {
}
/* User */
/* Domain */
}
/*
* Remainder is the same for etc. sec. or not
* Native OS, Native LanMan
*/
} else {
/* response summary */
if (ext_security) {
/* No decoder for SPNEGO */
}
return;
}
return;
/* response detail */
if (wordcount < 3)
return;
setupdata += 2;
setupdata += 2;
setupdata += 2;
if (ext_security) {
if (wordcount != 4)
return;
setupdata += 2;
} else {
if (wordcount != 3)
return;
}
setupdata += 2;
if (ext_security) {
/* No decoder for SPNEGO. Just dump hex. */
show_line("Security blob: (SPNEGO)");
}
/*
* Native OS, Native LanMan
*/
if (ext_security == 0) {
}
}
}
/*
* Interpret "Trans2" SMB
*
* This is very much like "trans" above.
*/
/* ARGSUSED */
static void
{
int wordcount;
int bytecount;
int parambytes;
int paramoffset;
int setupcount;
int subcode;
char *name;
byteparms += 2;
/*
* Print the lengths before we (potentially) bail out
* due to lack of data (so the user knows why we did).
*/
}
/* Get length and location of params and setup data. */
/* CALL */
if (wordcount < 14)
return;
} else {
/* REPLY */
if (wordcount < 10)
return;
}
if (setupcount > 0)
else
/* The parameters are offset from the SMB header. */
/* This is a CALL. */
/* print the word parameters */
/* skip Reserved2 */
/* That finishes the VWV, now the misc. stuff. */
}
/* This is a CALL. Do sub-function. */
switch (subcode) {
case TRANS2_OPEN:
name = "Open";
goto name_only;
case TRANS2_FIND_FIRST:
break;
case TRANS2_FIND_NEXT2:
break;
name = "QueryFSInfo";
goto name_only;
break;
name = "SetPathInfo";
goto name_only;
break;
break;
case TRANS2_CREATE_DIRECTORY:
name = "CreateDir";
goto name_only;
default:
name = "Unknown";
/* fall through */
break;
}
}
/* This is a REPLY. */
/* print the word parameters */
/* skip Reserved */
}
}
static void
{
int slength;
int i, tl;
int isunicode;
int printit;
int wordcount;
int outsz;
char *outstr;
char *format;
char valuetype;
char *label;
else
return;
if (wordcount == 0)
return;
show_line("Word values (in hex):");
buff[0] = '\0';
for (i = 0; i < wordcount; i++) {
comdata += 2;
}
}
return;
}
while (valuetype != '\0') {
break;
switch (valuetype) {
case 'W':
case 'w':
comdata += 2;
if (!printit)
break;
else {
}
break;
case 'D':
case 'd':
comdata += 2;
if (!printit)
break;
else {
}
break;
case 'L':
case 'l':
comdata += 4;
if (!printit)
break;
else {
}
break;
case 'B':
case 'b':
comdata += 1;
if (!printit)
break;
else {
}
break;
case 'r':
comdata++;
break;
case 'R':
comdata += 2;
break;
case 'U':
case 'u':
/* Unicode or ASCII string. */
if (!printit)
break;
else {
}
break;
case 'S':
case 's':
sizeof (tempstr));
if (!printit)
break;
else {
}
break;
}
}
}