2001-06-26 12:16:27 +08:00
|
|
|
/*
|
2001-06-25 11:07:30 +08:00
|
|
|
* Copyright (C) Andrew Tridgell 1995-1999
|
|
|
|
*
|
|
|
|
* This software may be distributed either under the terms of the
|
|
|
|
* BSD-style license that accompanies tcpdump or the GNU GPL version 2
|
|
|
|
* or later
|
|
|
|
*/
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2016-08-14 21:42:19 +08:00
|
|
|
/* \summary: SMB/CIFS printer */
|
|
|
|
|
1999-11-22 00:01:56 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2018-01-22 04:27:08 +08:00
|
|
|
#include <config.h>
|
1999-11-22 00:01:56 +08:00
|
|
|
#endif
|
|
|
|
|
2018-01-20 22:59:49 +08:00
|
|
|
#include "netdissect-stdinc.h"
|
2002-08-01 16:52:55 +08:00
|
|
|
|
1999-12-15 15:05:58 +08:00
|
|
|
#include <string.h>
|
2002-02-06 19:14:51 +08:00
|
|
|
|
2015-09-06 05:35:58 +08:00
|
|
|
#include "netdissect.h"
|
2002-01-17 12:38:29 +08:00
|
|
|
#include "extract.h"
|
1999-11-22 00:01:56 +08:00
|
|
|
#include "smb.h"
|
|
|
|
|
2013-12-26 22:08:06 +08:00
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
static int request = 0;
|
2004-12-29 06:29:44 +08:00
|
|
|
static int unicodestr = 0;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2017-12-31 04:32:40 +08:00
|
|
|
extern const u_char *startbuf;
|
|
|
|
|
2001-09-18 05:57:50 +08:00
|
|
|
const u_char *startbuf = NULL;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
struct smbdescript {
|
2002-01-17 12:38:29 +08:00
|
|
|
const char *req_f1;
|
|
|
|
const char *req_f2;
|
|
|
|
const char *rep_f1;
|
|
|
|
const char *rep_f2;
|
2014-04-02 12:14:19 +08:00
|
|
|
void (*fn)(netdissect_options *, const u_char *, const u_char *, const u_char *, const u_char *);
|
2002-01-17 12:38:29 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct smbdescriptint {
|
|
|
|
const char *req_f1;
|
|
|
|
const char *req_f2;
|
|
|
|
const char *rep_f1;
|
|
|
|
const char *rep_f2;
|
2018-01-07 14:18:00 +08:00
|
|
|
void (*fn)(netdissect_options *, const u_char *, const u_char *, u_int, u_int);
|
1999-11-22 00:01:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct smbfns
|
|
|
|
{
|
2001-06-25 11:07:30 +08:00
|
|
|
int id;
|
2002-01-17 12:38:29 +08:00
|
|
|
const char *name;
|
2001-06-25 11:07:30 +08:00
|
|
|
int flags;
|
|
|
|
struct smbdescript descript;
|
1999-11-22 00:01:56 +08:00
|
|
|
};
|
|
|
|
|
2002-01-17 12:38:29 +08:00
|
|
|
struct smbfnsint
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
const char *name;
|
|
|
|
int flags;
|
|
|
|
struct smbdescriptint descript;
|
|
|
|
};
|
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
#define DEFDESCRIPT { NULL, NULL, NULL, NULL, NULL }
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
#define FLG_CHAIN (1 << 0)
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2013-12-19 18:05:59 +08:00
|
|
|
static const struct smbfns *
|
|
|
|
smbfind(int id, const struct smbfns *list)
|
1999-11-22 00:01:56 +08:00
|
|
|
{
|
2001-06-25 11:07:30 +08:00
|
|
|
int sindex;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 12:16:27 +08:00
|
|
|
for (sindex = 0; list[sindex].name; sindex++)
|
2001-06-25 11:07:30 +08:00
|
|
|
if (list[sindex].id == id)
|
|
|
|
return(&list[sindex]);
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
return(&list[0]);
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
|
2013-12-19 18:05:59 +08:00
|
|
|
static const struct smbfnsint *
|
|
|
|
smbfindint(int id, const struct smbfnsint *list)
|
1999-11-22 00:01:56 +08:00
|
|
|
{
|
2002-01-17 12:38:29 +08:00
|
|
|
int sindex;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2002-01-17 12:38:29 +08:00
|
|
|
for (sindex = 0; list[sindex].name; sindex++)
|
|
|
|
if (list[sindex].id == id)
|
|
|
|
return(&list[sindex]);
|
|
|
|
|
|
|
|
return(&list[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-04-02 12:14:19 +08:00
|
|
|
trans2_findfirst(netdissect_options *ndo,
|
2018-01-07 14:18:00 +08:00
|
|
|
const u_char *param, const u_char *data, u_int pcnt, u_int dcnt)
|
2002-01-17 12:38:29 +08:00
|
|
|
{
|
|
|
|
const char *fmt;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
if (request)
|
2018-01-07 14:18:00 +08:00
|
|
|
fmt = "Attribute=[A]\nSearchCount=[u]\nFlags=[w]\nLevel=[uP4]\nFile=[S]\n";
|
2001-06-25 11:07:30 +08:00
|
|
|
else
|
2018-01-07 14:18:00 +08:00
|
|
|
fmt = "Handle=[w]\nCount=[u]\nEOS=[w]\nEoffset=[u]\nLastNameOfs=[w]\n";
|
2001-06-25 11:07:30 +08:00
|
|
|
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, param, fmt, param + pcnt, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
if (dcnt) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("data:\n");
|
2018-02-22 21:19:42 +08:00
|
|
|
smb_data_print(ndo, data, dcnt);
|
2001-06-25 11:07:30 +08:00
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
static void
|
2014-04-02 12:14:19 +08:00
|
|
|
trans2_qfsinfo(netdissect_options *ndo,
|
2018-01-07 14:18:00 +08:00
|
|
|
const u_char *param, const u_char *data, u_int pcnt, u_int dcnt)
|
1999-11-22 00:01:56 +08:00
|
|
|
{
|
2018-01-07 14:18:00 +08:00
|
|
|
static u_int level = 0;
|
2002-01-17 12:38:29 +08:00
|
|
|
const char *fmt="";
|
2001-06-25 11:07:30 +08:00
|
|
|
|
|
|
|
if (request) {
|
2018-06-16 23:23:21 +08:00
|
|
|
level = GET_LE_U_2(param);
|
2018-01-07 14:18:00 +08:00
|
|
|
fmt = "InfoLevel=[u]\n";
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, param, fmt, param + pcnt, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
} else {
|
|
|
|
switch (level) {
|
|
|
|
case 1:
|
2018-01-07 14:18:00 +08:00
|
|
|
fmt = "idFileSystem=[W]\nSectorUnit=[U]\nUnit=[U]\nAvail=[U]\nSectorSize=[u]\n";
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
2004-12-29 11:10:24 +08:00
|
|
|
fmt = "CreationTime=[T2]VolNameLength=[lb]\nVolumeLabel=[c]\n";
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
case 0x105:
|
2018-01-07 14:18:00 +08:00
|
|
|
fmt = "Capabilities=[W]\nMaxFileLen=[U]\nVolNameLen=[lU]\nVolume=[C]\n";
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fmt = "UnknownLevel\n";
|
|
|
|
break;
|
|
|
|
}
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, data, fmt, data + dcnt, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
}
|
|
|
|
if (dcnt) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("data:\n");
|
2018-02-22 21:19:42 +08:00
|
|
|
smb_data_print(ndo, data, dcnt);
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-19 18:05:59 +08:00
|
|
|
static const struct smbfnsint trans2_fns[] = {
|
2001-06-26 12:16:27 +08:00
|
|
|
{ 0, "TRANSACT2_OPEN", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Flags2=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]\nOFun=[w]\nSize=[U]\nRes=([w, w, w, w, w])\nPath=[S]",
|
2001-06-26 12:16:27 +08:00
|
|
|
NULL,
|
2018-01-07 14:18:00 +08:00
|
|
|
"Handle=[u]\nAttrib=[A]\nTime=[T2]\nSize=[U]\nAccess=[w]\nType=[w]\nState=[w]\nAction=[w]\nInode=[W]\nOffErr=[u]\n|EALength=[u]\n",
|
2001-06-26 12:16:27 +08:00
|
|
|
NULL, NULL }},
|
|
|
|
{ 1, "TRANSACT2_FINDFIRST", 0,
|
|
|
|
{ NULL, NULL, NULL, NULL, trans2_findfirst }},
|
|
|
|
{ 2, "TRANSACT2_FINDNEXT", 0, DEFDESCRIPT },
|
|
|
|
{ 3, "TRANSACT2_QFSINFO", 0,
|
|
|
|
{ NULL, NULL, NULL, NULL, trans2_qfsinfo }},
|
|
|
|
{ 4, "TRANSACT2_SETFSINFO", 0, DEFDESCRIPT },
|
|
|
|
{ 5, "TRANSACT2_QPATHINFO", 0, DEFDESCRIPT },
|
|
|
|
{ 6, "TRANSACT2_SETPATHINFO", 0, DEFDESCRIPT },
|
|
|
|
{ 7, "TRANSACT2_QFILEINFO", 0, DEFDESCRIPT },
|
|
|
|
{ 8, "TRANSACT2_SETFILEINFO", 0, DEFDESCRIPT },
|
|
|
|
{ 9, "TRANSACT2_FSCTL", 0, DEFDESCRIPT },
|
|
|
|
{ 10, "TRANSACT2_IOCTL", 0, DEFDESCRIPT },
|
|
|
|
{ 11, "TRANSACT2_FINDNOTIFYFIRST", 0, DEFDESCRIPT },
|
|
|
|
{ 12, "TRANSACT2_FINDNOTIFYNEXT", 0, DEFDESCRIPT },
|
|
|
|
{ 13, "TRANSACT2_MKDIR", 0, DEFDESCRIPT },
|
2001-06-25 11:07:30 +08:00
|
|
|
{ -1, NULL, 0, DEFDESCRIPT }
|
|
|
|
};
|
1999-11-22 00:01:56 +08:00
|
|
|
|
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
static void
|
2014-04-02 12:14:19 +08:00
|
|
|
print_trans2(netdissect_options *ndo,
|
|
|
|
const u_char *words, const u_char *dat, const u_char *buf, const u_char *maxbuf)
|
1999-11-22 00:01:56 +08:00
|
|
|
{
|
2004-12-29 08:06:28 +08:00
|
|
|
u_int bcc;
|
2013-12-19 18:05:59 +08:00
|
|
|
static const struct smbfnsint *fn = &trans2_fns[0];
|
2002-01-17 12:38:29 +08:00
|
|
|
const u_char *data, *param;
|
|
|
|
const u_char *w = words + 1;
|
2002-04-25 12:54:02 +08:00
|
|
|
const char *f1 = NULL, *f2 = NULL;
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int pcnt, dcnt;
|
2001-06-25 11:07:30 +08:00
|
|
|
|
2017-12-04 01:18:58 +08:00
|
|
|
ND_TCHECK_1(words);
|
2001-06-25 11:07:30 +08:00
|
|
|
if (request) {
|
2017-11-25 05:48:55 +08:00
|
|
|
ND_TCHECK_2(w + (14 * 2));
|
2018-06-16 23:23:21 +08:00
|
|
|
pcnt = GET_LE_U_2(w + 9 * 2);
|
|
|
|
param = buf + GET_LE_U_2(w + 10 * 2);
|
|
|
|
dcnt = GET_LE_U_2(w + 11 * 2);
|
|
|
|
data = buf + GET_LE_U_2(w + 12 * 2);
|
|
|
|
fn = smbfindint(GET_LE_U_2(w + 14 * 2), trans2_fns);
|
1999-11-22 00:01:56 +08:00
|
|
|
} else {
|
2018-06-16 23:23:21 +08:00
|
|
|
if (GET_U_1(words) == 0) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("%s\n", fn->name);
|
|
|
|
ND_PRINT("Trans2Interim\n");
|
2002-01-17 12:38:29 +08:00
|
|
|
return;
|
|
|
|
}
|
2017-11-25 05:48:55 +08:00
|
|
|
ND_TCHECK_2(w + (7 * 2));
|
2018-06-16 23:23:21 +08:00
|
|
|
pcnt = GET_LE_U_2(w + 3 * 2);
|
|
|
|
param = buf + GET_LE_U_2(w + 4 * 2);
|
|
|
|
dcnt = GET_LE_U_2(w + 6 * 2);
|
|
|
|
data = buf + GET_LE_U_2(w + 7 * 2);
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
2001-06-25 11:07:30 +08:00
|
|
|
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("%s param_length=%u data_length=%u\n", fn->name, pcnt, dcnt);
|
2001-06-25 11:07:30 +08:00
|
|
|
|
|
|
|
if (request) {
|
2018-06-16 23:23:21 +08:00
|
|
|
if (GET_U_1(words) == 8) {
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, words + 1,
|
2018-01-07 14:18:00 +08:00
|
|
|
"Trans2Secondary\nTotParam=[u]\nTotData=[u]\nParamCnt=[u]\nParamOff=[u]\nParamDisp=[u]\nDataCnt=[u]\nDataOff=[u]\nDataDisp=[u]\nHandle=[u]\n",
|
2004-12-29 06:29:44 +08:00
|
|
|
maxbuf, unicodestr);
|
2001-06-26 12:16:27 +08:00
|
|
|
return;
|
2001-06-25 11:07:30 +08:00
|
|
|
} else {
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, words + 1,
|
2018-01-07 14:18:00 +08:00
|
|
|
"TotParam=[u]\nTotData=[u]\nMaxParam=[u]\nMaxData=[u]\nMaxSetup=[b][P1]\nFlags=[w]\nTimeOut=[D]\nRes1=[w]\nParamCnt=[u]\nParamOff=[u]\nDataCnt=[u]\nDataOff=[u]\nSetupCnt=[b][P1]\n",
|
2004-12-29 06:29:44 +08:00
|
|
|
words + 1 + 14 * 2, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
}
|
|
|
|
f1 = fn->descript.req_f1;
|
|
|
|
f2 = fn->descript.req_f2;
|
1999-11-22 00:01:56 +08:00
|
|
|
} else {
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, words + 1,
|
2018-01-07 14:18:00 +08:00
|
|
|
"TotParam=[u]\nTotData=[u]\nRes1=[w]\nParamCnt=[u]\nParamOff=[u]\nParamDisp[u]\nDataCnt=[u]\nDataOff=[u]\nDataDisp=[u]\nSetupCnt=[b][P1]\n",
|
2004-12-29 06:29:44 +08:00
|
|
|
words + 1 + 10 * 2, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
f1 = fn->descript.rep_f1;
|
|
|
|
f2 = fn->descript.rep_f2;
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
bcc = GET_LE_U_2(dat);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("smb_bcc=%u\n", bcc);
|
2001-06-25 11:07:30 +08:00
|
|
|
if (fn->descript.fn)
|
2014-04-02 12:14:19 +08:00
|
|
|
(*fn->descript.fn)(ndo, param, data, pcnt, dcnt);
|
2001-06-25 11:07:30 +08:00
|
|
|
else {
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, param, f1 ? f1 : "Parameters=\n", param + pcnt, unicodestr);
|
|
|
|
smb_fdata(ndo, data, f2 ? f2 : "Data=\n", data + dcnt, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
}
|
2002-01-17 12:38:29 +08:00
|
|
|
return;
|
|
|
|
trunc:
|
2018-05-02 23:15:04 +08:00
|
|
|
nd_print_trunc(ndo);
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
static void
|
2014-04-02 12:14:19 +08:00
|
|
|
print_browse(netdissect_options *ndo,
|
2018-01-07 14:18:00 +08:00
|
|
|
const u_char *param, u_int paramlen, const u_char *data, u_int datalen)
|
1999-11-22 00:01:56 +08:00
|
|
|
{
|
2001-09-18 05:57:50 +08:00
|
|
|
const u_char *maxbuf = data + datalen;
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int command;
|
2002-01-17 12:38:29 +08:00
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
command = GET_U_1(data);
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, param, "BROWSE PACKET\n|Param ", param+paramlen, unicodestr);
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
switch (command) {
|
|
|
|
case 0xF:
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data,
|
2018-01-07 14:18:00 +08:00
|
|
|
"BROWSE PACKET:\nType=[B] (LocalMasterAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[u]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",
|
2004-12-29 06:29:44 +08:00
|
|
|
maxbuf, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
case 0x1:
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data,
|
2018-01-07 14:18:00 +08:00
|
|
|
"BROWSE PACKET:\nType=[B] (HostAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[u]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nElectionVersion=[w]\nBrowserConstant=[w]\n",
|
2004-12-29 06:29:44 +08:00
|
|
|
maxbuf, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x2:
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data,
|
2001-06-25 11:07:30 +08:00
|
|
|
"BROWSE PACKET:\nType=[B] (AnnouncementRequest)\nFlags=[B]\nReplySystemName=[S]\n",
|
2004-12-29 06:29:44 +08:00
|
|
|
maxbuf, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xc:
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data,
|
2018-01-07 14:18:00 +08:00
|
|
|
"BROWSE PACKET:\nType=[B] (WorkgroupAnnouncement)\nUpdateCount=[w]\nRes1=[B]\nAnnounceInterval=[u]\nName=[n2]\nMajorVersion=[B]\nMinorVersion=[B]\nServerType=[W]\nCommentPointer=[W]\nServerName=[S]\n",
|
2004-12-29 06:29:44 +08:00
|
|
|
maxbuf, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x8:
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data,
|
2001-06-25 11:07:30 +08:00
|
|
|
"BROWSE PACKET:\nType=[B] (ElectionFrame)\nElectionVersion=[B]\nOSSummary=[W]\nUptime=[(W, W)]\nServerName=[S]\n",
|
2004-12-29 06:29:44 +08:00
|
|
|
maxbuf, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xb:
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data,
|
2001-06-25 11:07:30 +08:00
|
|
|
"BROWSE PACKET:\nType=[B] (BecomeBackupBrowser)\nName=[S]\n",
|
2004-12-29 06:29:44 +08:00
|
|
|
maxbuf, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x9:
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data,
|
2004-12-29 10:43:24 +08:00
|
|
|
"BROWSE PACKET:\nType=[B] (GetBackupList)\nListCount?=[B]\nToken=[W]\n",
|
2004-12-29 06:29:44 +08:00
|
|
|
maxbuf, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xa:
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data,
|
2004-12-29 10:43:24 +08:00
|
|
|
"BROWSE PACKET:\nType=[B] (BackupListResponse)\nServerCount?=[B]\nToken=[W]\n*Name=[S]\n",
|
2004-12-29 06:29:44 +08:00
|
|
|
maxbuf, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xd:
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data,
|
2001-06-25 11:07:30 +08:00
|
|
|
"BROWSE PACKET:\nType=[B] (MasterAnnouncement)\nMasterName=[S]\n",
|
2004-12-29 06:29:44 +08:00
|
|
|
maxbuf, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xe:
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data,
|
2004-12-29 06:29:44 +08:00
|
|
|
"BROWSE PACKET:\nType=[B] (ResetBrowser)\nOptions=[B]\n", maxbuf, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data, "Unknown Browser Frame ", maxbuf, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
static void
|
2014-04-02 12:14:19 +08:00
|
|
|
print_ipc(netdissect_options *ndo,
|
2018-01-07 14:18:00 +08:00
|
|
|
const u_char *param, u_int paramlen, const u_char *data, u_int datalen)
|
1999-11-22 00:01:56 +08:00
|
|
|
{
|
2001-06-25 11:07:30 +08:00
|
|
|
if (paramlen)
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, param, "Command=[w]\nStr1=[S]\nStr2=[S]\n", param + paramlen,
|
2004-12-29 06:29:44 +08:00
|
|
|
unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
if (datalen)
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, data, "IPC ", data + datalen, unicodestr);
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
static void
|
2014-04-02 12:14:19 +08:00
|
|
|
print_trans(netdissect_options *ndo,
|
|
|
|
const u_char *words, const u_char *data1, const u_char *buf, const u_char *maxbuf)
|
1999-11-22 00:01:56 +08:00
|
|
|
{
|
2004-12-28 17:16:09 +08:00
|
|
|
u_int bcc;
|
2002-04-25 12:54:02 +08:00
|
|
|
const char *f1, *f2, *f3, *f4;
|
2002-01-17 12:38:29 +08:00
|
|
|
const u_char *data, *param;
|
|
|
|
const u_char *w = words + 1;
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int datalen, paramlen;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
if (request) {
|
2017-11-25 05:48:55 +08:00
|
|
|
ND_TCHECK_2(w + (12 * 2));
|
2018-06-16 23:23:21 +08:00
|
|
|
paramlen = GET_LE_U_2(w + 9 * 2);
|
|
|
|
param = buf + GET_LE_U_2(w + 10 * 2);
|
|
|
|
datalen = GET_LE_U_2(w + 11 * 2);
|
|
|
|
data = buf + GET_LE_U_2(w + 12 * 2);
|
2019-02-01 20:59:45 +08:00
|
|
|
f1 = "TotParamCnt=[u]\nTotDataCnt=[u]\nMaxParmCnt=[u]\nMaxDataCnt=[u]\nMaxSCnt=[u]\nTransFlags=[w]\nRes1=[w]\nRes2=[w]\nRes3=[w]\nParamCnt=[u]\nParamOff=[u]\nDataCnt=[u]\nDataOff=[u]\nSUCnt=[u]\n";
|
2001-06-26 11:33:44 +08:00
|
|
|
f2 = "|Name=[S]\n";
|
|
|
|
f3 = "|Param ";
|
|
|
|
f4 = "|Data ";
|
1999-11-22 00:01:56 +08:00
|
|
|
} else {
|
2017-11-25 05:48:55 +08:00
|
|
|
ND_TCHECK_2(w + (7 * 2));
|
2018-06-16 23:23:21 +08:00
|
|
|
paramlen = GET_LE_U_2(w + 3 * 2);
|
|
|
|
param = buf + GET_LE_U_2(w + 4 * 2);
|
|
|
|
datalen = GET_LE_U_2(w + 6 * 2);
|
|
|
|
data = buf + GET_LE_U_2(w + 7 * 2);
|
2019-02-01 20:59:45 +08:00
|
|
|
f1 = "TotParamCnt=[u]\nTotDataCnt=[u]\nRes1=[u]\nParamCnt=[u]\nParamOff=[u]\nRes2=[u]\nDataCnt=[u]\nDataOff=[u]\nRes3=[u]\nLsetup=[u]\n";
|
2001-06-26 11:33:44 +08:00
|
|
|
f2 = "|Unknown ";
|
|
|
|
f3 = "|Param ";
|
|
|
|
f4 = "|Data ";
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
|
2017-12-17 04:24:37 +08:00
|
|
|
smb_fdata(ndo, words + 1, f1,
|
2020-08-25 04:53:58 +08:00
|
|
|
ND_MIN(words + 1 + 2 * GET_U_1(words), maxbuf),
|
2017-12-17 04:24:37 +08:00
|
|
|
unicodestr);
|
2004-12-28 17:16:09 +08:00
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
bcc = GET_LE_U_2(data1);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("smb_bcc=%u\n", bcc);
|
2004-12-28 19:18:29 +08:00
|
|
|
if (bcc > 0) {
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, data1 + 2, f2, maxbuf - (paramlen + datalen), unicodestr);
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2019-06-06 20:47:58 +08:00
|
|
|
#define MAILSLOT_BROWSE_STR "\\MAILSLOT\\BROWSE"
|
|
|
|
ND_TCHECK_LEN(data1 + 2, strlen(MAILSLOT_BROWSE_STR) + 1);
|
|
|
|
if (strcmp((const char *)(data1 + 2), MAILSLOT_BROWSE_STR) == 0) {
|
2014-04-02 12:14:19 +08:00
|
|
|
print_browse(ndo, param, paramlen, data, datalen);
|
2004-12-28 19:18:29 +08:00
|
|
|
return;
|
|
|
|
}
|
2019-06-06 20:47:58 +08:00
|
|
|
#undef MAILSLOT_BROWSE_STR
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2019-06-06 20:47:58 +08:00
|
|
|
#define PIPE_LANMAN_STR "\\PIPE\\LANMAN"
|
|
|
|
ND_TCHECK_LEN(data1 + 2, strlen(PIPE_LANMAN_STR) + 1);
|
|
|
|
if (strcmp((const char *)(data1 + 2), PIPE_LANMAN_STR) == 0) {
|
2014-04-02 12:14:19 +08:00
|
|
|
print_ipc(ndo, param, paramlen, data, datalen);
|
2004-12-28 19:18:29 +08:00
|
|
|
return;
|
|
|
|
}
|
2019-06-06 20:47:58 +08:00
|
|
|
#undef PIPE_LANMAN_STR
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2004-12-28 19:18:29 +08:00
|
|
|
if (paramlen)
|
2020-08-25 04:53:58 +08:00
|
|
|
smb_fdata(ndo, param, f3, ND_MIN(param + paramlen, maxbuf), unicodestr);
|
2004-12-28 19:18:29 +08:00
|
|
|
if (datalen)
|
2020-08-25 04:53:58 +08:00
|
|
|
smb_fdata(ndo, data, f4, ND_MIN(data + datalen, maxbuf), unicodestr);
|
2004-12-28 19:18:29 +08:00
|
|
|
}
|
2002-01-17 12:38:29 +08:00
|
|
|
return;
|
|
|
|
trunc:
|
2018-05-02 23:15:04 +08:00
|
|
|
nd_print_trunc(ndo);
|
2001-06-26 11:33:44 +08:00
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
|
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
static void
|
2014-04-02 12:14:19 +08:00
|
|
|
print_negprot(netdissect_options *ndo,
|
|
|
|
const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
|
2001-06-26 11:33:44 +08:00
|
|
|
{
|
2004-12-28 17:16:09 +08:00
|
|
|
u_int wct, bcc;
|
2002-04-25 12:54:02 +08:00
|
|
|
const char *f1 = NULL, *f2 = NULL;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
wct = GET_U_1(words);
|
2001-06-26 11:33:44 +08:00
|
|
|
if (request)
|
2004-12-29 06:29:44 +08:00
|
|
|
f2 = "*|Dialect=[Y]\n";
|
2001-06-26 11:33:44 +08:00
|
|
|
else {
|
2004-12-28 17:16:09 +08:00
|
|
|
if (wct == 1)
|
2018-01-07 14:18:00 +08:00
|
|
|
f1 = "Core Protocol\nDialectIndex=[u]";
|
2004-12-28 17:16:09 +08:00
|
|
|
else if (wct == 17)
|
2018-01-07 14:18:00 +08:00
|
|
|
f1 = "NT1 Protocol\nDialectIndex=[u]\nSecMode=[B]\nMaxMux=[u]\nNumVcs=[u]\nMaxBuffer=[U]\nRawSize=[U]\nSessionKey=[W]\nCapabilities=[W]\nServerTime=[T3]TimeZone=[u]\nCryptKey=";
|
2004-12-28 17:16:09 +08:00
|
|
|
else if (wct == 13)
|
2018-01-07 14:18:00 +08:00
|
|
|
f1 = "Coreplus/Lanman1/Lanman2 Protocol\nDialectIndex=[u]\nSecMode=[w]\nMaxXMit=[u]\nMaxMux=[u]\nMaxVcs=[u]\nBlkMode=[w]\nSessionKey=[W]\nServerTime=[T1]TimeZone=[u]\nRes=[W]\nCryptKey=";
|
2001-06-26 11:33:44 +08:00
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 12:16:27 +08:00
|
|
|
if (f1)
|
2020-08-25 04:53:58 +08:00
|
|
|
smb_fdata(ndo, words + 1, f1, ND_MIN(words + 1 + wct * 2, maxbuf),
|
2004-12-29 06:29:44 +08:00
|
|
|
unicodestr);
|
2001-06-26 11:33:44 +08:00
|
|
|
else
|
2020-08-25 04:53:58 +08:00
|
|
|
smb_data_print(ndo, words + 1, ND_MIN(wct * 2, ND_BYTES_BETWEEN(maxbuf, words + 1)));
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
bcc = GET_LE_U_2(data);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("smb_bcc=%u\n", bcc);
|
2004-12-28 19:18:29 +08:00
|
|
|
if (bcc > 0) {
|
|
|
|
if (f2)
|
2020-08-25 04:53:58 +08:00
|
|
|
smb_fdata(ndo, data + 2, f2, ND_MIN(data + 2 + GET_LE_U_2(data),
|
2017-11-23 06:54:09 +08:00
|
|
|
maxbuf), unicodestr);
|
2004-12-28 19:18:29 +08:00
|
|
|
else
|
2018-02-22 21:19:42 +08:00
|
|
|
smb_data_print(ndo, data + 2,
|
2020-08-25 04:53:58 +08:00
|
|
|
ND_MIN(GET_LE_U_2(data), ND_BYTES_BETWEEN(maxbuf, data + 2)));
|
2004-12-28 19:18:29 +08:00
|
|
|
}
|
2001-06-26 11:33:44 +08:00
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
static void
|
2014-04-02 12:14:19 +08:00
|
|
|
print_sesssetup(netdissect_options *ndo,
|
|
|
|
const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
|
2001-06-26 11:33:44 +08:00
|
|
|
{
|
2004-12-28 17:16:09 +08:00
|
|
|
u_int wct, bcc;
|
2002-04-25 12:54:02 +08:00
|
|
|
const char *f1 = NULL, *f2 = NULL;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
wct = GET_U_1(words);
|
2001-06-26 11:33:44 +08:00
|
|
|
if (request) {
|
2004-12-28 17:16:09 +08:00
|
|
|
if (wct == 10)
|
2018-01-07 14:18:00 +08:00
|
|
|
f1 = "Com2=[w]\nOff2=[u]\nBufSize=[u]\nMpxMax=[u]\nVcNum=[u]\nSessionKey=[W]\nPassLen=[u]\nCryptLen=[u]\nCryptOff=[u]\nPass&Name=\n";
|
2001-06-26 11:33:44 +08:00
|
|
|
else
|
2018-01-07 14:18:00 +08:00
|
|
|
f1 = "Com2=[B]\nRes1=[B]\nOff2=[u]\nMaxBuffer=[u]\nMaxMpx=[u]\nVcNumber=[u]\nSessionKey=[W]\nCaseInsensitivePasswordLength=[u]\nCaseSensitivePasswordLength=[u]\nRes=[W]\nCapabilities=[W]\nPass1&Pass2&Account&Domain&OS&LanMan=\n";
|
2001-06-26 11:33:44 +08:00
|
|
|
} else {
|
2004-12-28 17:16:09 +08:00
|
|
|
if (wct == 3) {
|
2018-01-07 14:18:00 +08:00
|
|
|
f1 = "Com2=[w]\nOff2=[u]\nAction=[w]\n";
|
2004-12-28 17:16:09 +08:00
|
|
|
} else if (wct == 13) {
|
2018-01-07 14:18:00 +08:00
|
|
|
f1 = "Com2=[B]\nRes=[B]\nOff2=[u]\nAction=[w]\n";
|
2002-01-17 12:38:29 +08:00
|
|
|
f2 = "NativeOS=[S]\nNativeLanMan=[S]\nPrimaryDomain=[S]\n";
|
2001-06-26 11:33:44 +08:00
|
|
|
}
|
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 12:16:27 +08:00
|
|
|
if (f1)
|
2020-08-25 04:53:58 +08:00
|
|
|
smb_fdata(ndo, words + 1, f1, ND_MIN(words + 1 + wct * 2, maxbuf),
|
2004-12-29 06:29:44 +08:00
|
|
|
unicodestr);
|
2001-06-26 11:33:44 +08:00
|
|
|
else
|
2020-08-25 04:53:58 +08:00
|
|
|
smb_data_print(ndo, words + 1, ND_MIN(wct * 2, ND_BYTES_BETWEEN(maxbuf, words + 1)));
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
bcc = GET_LE_U_2(data);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("smb_bcc=%u\n", bcc);
|
2004-12-28 19:18:29 +08:00
|
|
|
if (bcc > 0) {
|
|
|
|
if (f2)
|
2020-08-25 04:53:58 +08:00
|
|
|
smb_fdata(ndo, data + 2, f2, ND_MIN(data + 2 + GET_LE_U_2(data),
|
2017-11-23 06:54:09 +08:00
|
|
|
maxbuf), unicodestr);
|
2004-12-28 19:18:29 +08:00
|
|
|
else
|
2018-02-22 21:19:42 +08:00
|
|
|
smb_data_print(ndo, data + 2,
|
2020-08-25 04:53:58 +08:00
|
|
|
ND_MIN(GET_LE_U_2(data), ND_BYTES_BETWEEN(maxbuf, data + 2)));
|
2004-12-28 19:18:29 +08:00
|
|
|
}
|
2001-06-26 11:33:44 +08:00
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2004-12-29 04:38:27 +08:00
|
|
|
static void
|
2014-04-02 12:14:19 +08:00
|
|
|
print_lockingandx(netdissect_options *ndo,
|
|
|
|
const u_char *words, const u_char *data, const u_char *buf _U_, const u_char *maxbuf)
|
2004-12-29 04:38:27 +08:00
|
|
|
{
|
|
|
|
u_int wct, bcc;
|
|
|
|
const u_char *maxwords;
|
|
|
|
const char *f1 = NULL, *f2 = NULL;
|
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
wct = GET_U_1(words);
|
2004-12-29 04:38:27 +08:00
|
|
|
if (request) {
|
2018-01-07 14:18:00 +08:00
|
|
|
f1 = "Com2=[w]\nOff2=[u]\nHandle=[u]\nLockType=[w]\nTimeOut=[D]\nUnlockCount=[u]\nLockCount=[u]\n";
|
2018-06-16 23:23:21 +08:00
|
|
|
if (GET_U_1(words + 7) & 0x10)
|
2018-01-07 14:18:00 +08:00
|
|
|
f2 = "*Process=[u]\n[P2]Offset=[M]\nLength=[M]\n";
|
2004-12-29 04:38:27 +08:00
|
|
|
else
|
2018-01-07 14:18:00 +08:00
|
|
|
f2 = "*Process=[u]\nOffset=[D]\nLength=[U]\n";
|
2004-12-29 04:38:27 +08:00
|
|
|
} else {
|
2018-01-07 14:18:00 +08:00
|
|
|
f1 = "Com2=[w]\nOff2=[u]\n";
|
2004-12-29 04:38:27 +08:00
|
|
|
}
|
|
|
|
|
2020-08-25 04:53:58 +08:00
|
|
|
maxwords = ND_MIN(words + 1 + wct * 2, maxbuf);
|
2004-12-29 04:38:27 +08:00
|
|
|
if (wct)
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, words + 1, f1, maxwords, unicodestr);
|
2004-12-29 04:38:27 +08:00
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
bcc = GET_LE_U_2(data);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("smb_bcc=%u\n", bcc);
|
2004-12-29 04:38:27 +08:00
|
|
|
if (bcc > 0) {
|
|
|
|
if (f2)
|
2020-08-25 04:53:58 +08:00
|
|
|
smb_fdata(ndo, data + 2, f2, ND_MIN(data + 2 + GET_LE_U_2(data),
|
2017-11-23 06:54:09 +08:00
|
|
|
maxbuf), unicodestr);
|
2004-12-29 04:38:27 +08:00
|
|
|
else
|
2018-02-22 21:19:42 +08:00
|
|
|
smb_data_print(ndo, data + 2,
|
2020-08-25 04:53:58 +08:00
|
|
|
ND_MIN(GET_LE_U_2(data), ND_BYTES_BETWEEN(maxbuf, data + 2)));
|
2004-12-29 04:38:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2013-12-19 18:05:59 +08:00
|
|
|
static const struct smbfns smb_fns[] = {
|
2001-06-26 11:33:44 +08:00
|
|
|
{ -1, "SMBunknown", 0, DEFDESCRIPT },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBtcon, "SMBtcon", 0,
|
|
|
|
{ NULL, "Path=[Z]\nPassword=[Z]\nDevice=[Z]\n",
|
2018-01-07 14:18:00 +08:00
|
|
|
"MaxXmit=[u]\nTreeId=[u]\n", NULL,
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBtdis, "SMBtdis", 0, DEFDESCRIPT },
|
|
|
|
{ SMBexit, "SMBexit", 0, DEFDESCRIPT },
|
|
|
|
{ SMBioctl, "SMBioctl", 0, DEFDESCRIPT },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBecho, "SMBecho", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "ReverbCount=[u]\n", NULL,
|
|
|
|
"SequenceNum=[u]\n", NULL,
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBulogoffX, "SMBulogoffX", FLG_CHAIN, DEFDESCRIPT },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBgetatr, "SMBgetatr", 0,
|
|
|
|
{ NULL, "Path=[Z]\n",
|
2018-01-07 14:18:00 +08:00
|
|
|
"Attribute=[A]\nTime=[T2]Size=[U]\nRes=([w,w,w,w,w])\n", NULL,
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBsetatr, "SMBsetatr", 0,
|
|
|
|
{ "Attribute=[A]\nTime=[T2]Res=([w,w,w,w,w])\n", "Path=[Z]\n",
|
|
|
|
NULL, NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBchkpth, "SMBchkpth", 0,
|
|
|
|
{ NULL, "Path=[Z]\n", NULL, NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBsearch, "SMBsearch", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Count=[u]\nAttrib=[A]\n",
|
|
|
|
"Path=[Z]\nBlkType=[B]\nBlkLen=[u]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[u]\nSrv2=[w]\nRes2=[W]\n",
|
|
|
|
"Count=[u]\n",
|
|
|
|
"BlkType=[B]\nBlkLen=[u]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[u]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[U]\nName=[s13]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBopen, "SMBopen", 0,
|
|
|
|
{ "Mode=[w]\nAttribute=[A]\n", "Path=[Z]\n",
|
2018-01-07 14:18:00 +08:00
|
|
|
"Handle=[u]\nOAttrib=[A]\nTime=[T2]Size=[U]\nAccess=[w]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBcreate, "SMBcreate", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Attrib=[A]\nTime=[T2]", "Path=[Z]\n", "Handle=[u]\n", NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBmknew, "SMBmknew", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Attrib=[A]\nTime=[T2]", "Path=[Z]\n", "Handle=[u]\n", NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBunlink, "SMBunlink", 0,
|
|
|
|
{ "Attrib=[A]\n", "Path=[Z]\n", NULL, NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBread, "SMBread", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\nByteCount=[u]\nOffset=[D]\nCountLeft=[u]\n", NULL,
|
|
|
|
"Count=[u]\nRes=([w,w,w,w])\n", NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBwrite, "SMBwrite", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\nByteCount=[u]\nOffset=[D]\nCountLeft=[u]\n", NULL,
|
|
|
|
"Count=[u]\n", NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBclose, "SMBclose", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\nTime=[T2]", NULL, NULL, NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBmkdir, "SMBmkdir", 0,
|
2001-06-26 12:16:27 +08:00
|
|
|
{ NULL, "Path=[Z]\n", NULL, NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBrmdir, "SMBrmdir", 0,
|
2001-06-26 12:16:27 +08:00
|
|
|
{ NULL, "Path=[Z]\n", NULL, NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBdskattr, "SMBdskattr", 0,
|
|
|
|
{ NULL, NULL,
|
2018-01-07 14:18:00 +08:00
|
|
|
"TotalUnits=[u]\nBlocksPerUnit=[u]\nBlockSize=[u]\nFreeUnits=[u]\nMedia=[w]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBmv, "SMBmv", 0,
|
|
|
|
{ "Attrib=[A]\n", "OldPath=[Z]\nNewPath=[Z]\n", NULL, NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
/*
|
|
|
|
* this is a Pathworks specific call, allowing the
|
|
|
|
* changing of the root path
|
|
|
|
*/
|
|
|
|
{ pSETDIR, "SMBsetdir", 0, { NULL, "Path=[Z]\n", NULL, NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBlseek, "SMBlseek", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\nMode=[w]\nOffset=[D]\n", "Offset=[D]\n", NULL, NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2018-01-07 14:18:00 +08:00
|
|
|
{ SMBflush, "SMBflush", 0, { "Handle=[u]\n", NULL, NULL, NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBsplopen, "SMBsplopen", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "SetupLen=[u]\nMode=[w]\n", "Ident=[Z]\n", "Handle=[u]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBsplclose, "SMBsplclose", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\n", NULL, NULL, NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBsplretq, "SMBsplretq", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "MaxCount=[u]\nStartIndex=[u]\n", NULL,
|
|
|
|
"Count=[u]\nIndex=[u]\n",
|
|
|
|
"*Time=[T2]Status=[B]\nJobID=[u]\nSize=[U]\nRes=[B]Name=[s16]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL } },
|
|
|
|
|
|
|
|
{ SMBsplwr, "SMBsplwr", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\n", NULL, NULL, NULL, NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
|
|
|
{ SMBlock, "SMBlock", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\nCount=[U]\nOffset=[D]\n", NULL, NULL, NULL, NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
|
|
|
{ SMBunlock, "SMBunlock", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\nCount=[U]\nOffset=[D]\n", NULL, NULL, NULL, NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
|
|
|
/* CORE+ PROTOCOL FOLLOWS */
|
|
|
|
|
|
|
|
{ SMBreadbraw, "SMBreadbraw", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\nOffset=[D]\nMaxCount=[u]\nMinCount=[u]\nTimeOut=[D]\nRes=[u]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL, NULL, NULL, NULL } },
|
|
|
|
|
|
|
|
{ SMBwritebraw, "SMBwritebraw", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\nTotalCount=[u]\nRes=[w]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nRes2=[W]\n|DataSize=[u]\nDataOff=[u]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL, "WriteRawAck", NULL, NULL } },
|
|
|
|
|
|
|
|
{ SMBwritec, "SMBwritec", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ NULL, NULL, "Count=[u]\n", NULL, NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
|
|
|
{ SMBwriteclose, "SMBwriteclose", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\nCount=[u]\nOffset=[D]\nTime=[T2]Res=([w,w,w,w,w,w])",
|
|
|
|
NULL, "Count=[u]\n", NULL, NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
|
|
|
{ SMBlockread, "SMBlockread", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\nByteCount=[u]\nOffset=[D]\nCountLeft=[u]\n", NULL,
|
|
|
|
"Count=[u]\nRes=([w,w,w,w])\n", NULL, NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
|
|
|
{ SMBwriteunlock, "SMBwriteunlock", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\nByteCount=[u]\nOffset=[D]\nCountLeft=[u]\n", NULL,
|
|
|
|
"Count=[u]\n", NULL, NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
|
|
|
{ SMBreadBmpx, "SMBreadBmpx", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\nOffset=[D]\nMaxCount=[u]\nMinCount=[u]\nTimeOut=[D]\nRes=[w]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL,
|
2018-01-07 14:18:00 +08:00
|
|
|
"Offset=[D]\nTotCount=[u]\nRemaining=[u]\nRes=([w,w])\nDataSize=[u]\nDataOff=[u]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL, NULL } },
|
|
|
|
|
|
|
|
{ SMBwriteBmpx, "SMBwriteBmpx", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\nTotCount=[u]\nRes=[w]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nRes2=[W]\nDataSize=[u]\nDataOff=[u]\n", NULL,
|
|
|
|
"Remaining=[u]\n", NULL, NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
|
|
|
{ SMBwriteBs, "SMBwriteBs", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\nTotCount=[u]\nOffset=[D]\nRes=[W]\nDataSize=[u]\nDataOff=[u]\n",
|
|
|
|
NULL, "Count=[u]\n", NULL, NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
|
|
|
{ SMBsetattrE, "SMBsetattrE", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\nCreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]", NULL,
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL, NULL, NULL } },
|
|
|
|
|
|
|
|
{ SMBgetattrE, "SMBgetattrE", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\n", NULL,
|
|
|
|
"CreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]Size=[U]\nAllocSize=[U]\nAttribute=[A]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBtranss, "SMBtranss", 0, DEFDESCRIPT },
|
|
|
|
{ SMBioctls, "SMBioctls", 0, DEFDESCRIPT },
|
|
|
|
|
|
|
|
{ SMBcopy, "SMBcopy", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "TreeID2=[u]\nOFun=[w]\nFlags=[w]\n", "Path=[S]\nNewPath=[S]\n",
|
|
|
|
"CopyCount=[u]\n", "|ErrStr=[S]\n", NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
|
|
|
{ SMBmove, "SMBmove", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "TreeID2=[u]\nOFun=[w]\nFlags=[w]\n", "Path=[S]\nNewPath=[S]\n",
|
|
|
|
"MoveCount=[u]\n", "|ErrStr=[S]\n", NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBopenX, "SMBopenX", FLG_CHAIN,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Com2=[w]\nOff2=[u]\nFlags=[w]\nMode=[w]\nSearchAttrib=[A]\nAttrib=[A]\nTime=[T2]OFun=[w]\nSize=[U]\nTimeOut=[D]\nRes=[W]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
"Path=[S]\n",
|
2018-01-07 14:18:00 +08:00
|
|
|
"Com2=[w]\nOff2=[u]\nHandle=[u]\nAttrib=[A]\nTime=[T2]Size=[U]\nAccess=[w]\nType=[w]\nState=[w]\nAction=[w]\nFileID=[W]\nRes=[w]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBreadX, "SMBreadX", FLG_CHAIN,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Com2=[w]\nOff2=[u]\nHandle=[u]\nOffset=[D]\nMaxCount=[u]\nMinCount=[u]\nTimeOut=[D]\nCountLeft=[u]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL,
|
2018-01-07 14:18:00 +08:00
|
|
|
"Com2=[w]\nOff2=[u]\nRemaining=[u]\nRes=[W]\nDataSize=[u]\nDataOff=[u]\nRes=([w,w,w,w])\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL, NULL } },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBwriteX, "SMBwriteX", FLG_CHAIN,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Com2=[w]\nOff2=[u]\nHandle=[u]\nOffset=[D]\nTimeOut=[D]\nWMode=[w]\nCountLeft=[u]\nRes=[w]\nDataSize=[u]\nDataOff=[u]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL,
|
2018-01-07 14:18:00 +08:00
|
|
|
"Com2=[w]\nOff2=[u]\nCount=[u]\nRemaining=[u]\nRes=[W]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL, NULL } },
|
|
|
|
|
|
|
|
{ SMBffirst, "SMBffirst", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Count=[u]\nAttrib=[A]\n",
|
|
|
|
"Path=[Z]\nBlkType=[B]\nBlkLen=[u]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[u]\nSrv2=[w]\n",
|
|
|
|
"Count=[u]\n",
|
|
|
|
"BlkType=[B]\nBlkLen=[u]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[u]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[U]\nName=[s13]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL } },
|
|
|
|
|
|
|
|
{ SMBfunique, "SMBfunique", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Count=[u]\nAttrib=[A]\n",
|
|
|
|
"Path=[Z]\nBlkType=[B]\nBlkLen=[u]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[u]\nSrv2=[w]\n",
|
|
|
|
"Count=[u]\n",
|
|
|
|
"BlkType=[B]\nBlkLen=[u]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[u]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[U]\nName=[s13]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL } },
|
|
|
|
|
|
|
|
{ SMBfclose, "SMBfclose", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Count=[u]\nAttrib=[A]\n",
|
|
|
|
"Path=[Z]\nBlkType=[B]\nBlkLen=[u]\n|Res1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[u]\nSrv2=[w]\n",
|
|
|
|
"Count=[u]\n",
|
|
|
|
"BlkType=[B]\nBlkLen=[u]\n*\nRes1=[B]\nMask=[s11]\nSrv1=[B]\nDirIndex=[u]\nSrv2=[w]\nRes2=[W]\nAttrib=[a]\nTime=[T1]Size=[U]\nName=[s13]\n",
|
2001-06-26 11:33:44 +08:00
|
|
|
NULL } },
|
|
|
|
|
|
|
|
{ SMBfindnclose, "SMBfindnclose", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\n", NULL, NULL, NULL, NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
|
|
|
{ SMBfindclose, "SMBfindclose", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Handle=[u]\n", NULL, NULL, NULL, NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
|
|
|
{ SMBsends, "SMBsends", 0,
|
|
|
|
{ NULL, "Source=[Z]\nDest=[Z]\n", NULL, NULL, NULL } },
|
|
|
|
|
|
|
|
{ SMBsendstrt, "SMBsendstrt", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ NULL, "Source=[Z]\nDest=[Z]\n", "GroupID=[u]\n", NULL, NULL } },
|
2001-06-26 12:16:27 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBsendend, "SMBsendend", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "GroupID=[u]\n", NULL, NULL, NULL, NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
|
|
|
{ SMBsendtxt, "SMBsendtxt", 0,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "GroupID=[u]\n", NULL, NULL, NULL, NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
|
|
|
{ SMBsendb, "SMBsendb", 0,
|
|
|
|
{ NULL, "Source=[Z]\nDest=[Z]\n", NULL, NULL, NULL } },
|
|
|
|
|
|
|
|
{ SMBfwdname, "SMBfwdname", 0, DEFDESCRIPT },
|
|
|
|
{ SMBcancelf, "SMBcancelf", 0, DEFDESCRIPT },
|
|
|
|
{ SMBgetmac, "SMBgetmac", 0, DEFDESCRIPT },
|
|
|
|
|
2001-06-26 12:16:27 +08:00
|
|
|
{ SMBnegprot, "SMBnegprot", 0,
|
2001-06-26 11:33:44 +08:00
|
|
|
{ NULL, NULL, NULL, NULL, print_negprot } },
|
|
|
|
|
|
|
|
{ SMBsesssetupX, "SMBsesssetupX", FLG_CHAIN,
|
|
|
|
{ NULL, NULL, NULL, NULL, print_sesssetup } },
|
|
|
|
|
|
|
|
{ SMBtconX, "SMBtconX", FLG_CHAIN,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Com2=[w]\nOff2=[u]\nFlags=[w]\nPassLen=[u]\nPasswd&Path&Device=\n",
|
|
|
|
NULL, "Com2=[w]\nOff2=[u]\n", "ServiceType=[R]\n", NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
2004-12-29 04:38:27 +08:00
|
|
|
{ SMBlockingX, "SMBlockingX", FLG_CHAIN,
|
|
|
|
{ NULL, NULL, NULL, NULL, print_lockingandx } },
|
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ SMBtrans2, "SMBtrans2", 0, { NULL, NULL, NULL, NULL, print_trans2 } },
|
|
|
|
|
|
|
|
{ SMBtranss2, "SMBtranss2", 0, DEFDESCRIPT },
|
|
|
|
{ SMBctemp, "SMBctemp", 0, DEFDESCRIPT },
|
|
|
|
{ SMBreadBs, "SMBreadBs", 0, DEFDESCRIPT },
|
|
|
|
{ SMBtrans, "SMBtrans", 0, { NULL, NULL, NULL, NULL, print_trans } },
|
|
|
|
|
|
|
|
{ SMBnttrans, "SMBnttrans", 0, DEFDESCRIPT },
|
|
|
|
{ SMBnttranss, "SMBnttranss", 0, DEFDESCRIPT },
|
|
|
|
|
|
|
|
{ SMBntcreateX, "SMBntcreateX", FLG_CHAIN,
|
2018-01-07 14:18:00 +08:00
|
|
|
{ "Com2=[w]\nOff2=[u]\nRes=[b]\nNameLen=[lu]\nFlags=[W]\nRootDirectoryFid=[U]\nAccessMask=[W]\nAllocationSize=[L]\nExtFileAttributes=[W]\nShareAccess=[W]\nCreateDisposition=[W]\nCreateOptions=[W]\nImpersonationLevel=[W]\nSecurityFlags=[b]\n",
|
2004-12-29 11:10:24 +08:00
|
|
|
"Path=[C]\n",
|
2018-01-07 14:18:00 +08:00
|
|
|
"Com2=[w]\nOff2=[u]\nOplockLevel=[b]\nFid=[u]\nCreateAction=[W]\nCreateTime=[T3]LastAccessTime=[T3]LastWriteTime=[T3]ChangeTime=[T3]ExtFileAttributes=[W]\nAllocationSize=[L]\nEndOfFile=[L]\nFileType=[w]\nDeviceState=[w]\nDirectory=[b]\n",
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
NULL, NULL } },
|
2001-06-26 11:33:44 +08:00
|
|
|
|
|
|
|
{ SMBntcancel, "SMBntcancel", 0, DEFDESCRIPT },
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 11:33:44 +08:00
|
|
|
{ -1, NULL, 0, DEFDESCRIPT }
|
|
|
|
};
|
1999-11-22 00:01:56 +08:00
|
|
|
|
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
/*
|
|
|
|
* print a SMB message
|
|
|
|
*/
|
|
|
|
static void
|
2014-04-02 12:14:19 +08:00
|
|
|
print_smb(netdissect_options *ndo,
|
|
|
|
const u_char *buf, const u_char *maxbuf)
|
1999-11-22 00:01:56 +08:00
|
|
|
{
|
2014-04-23 15:20:40 +08:00
|
|
|
uint16_t flags2;
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int nterrcodes;
|
|
|
|
u_int command;
|
2014-04-23 15:20:40 +08:00
|
|
|
uint32_t nterror;
|
2004-12-28 19:18:29 +08:00
|
|
|
const u_char *words, *maxwords, *data;
|
2013-12-19 18:05:59 +08:00
|
|
|
const struct smbfns *fn;
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
const char *fmt_smbheader =
|
2018-01-07 14:18:00 +08:00
|
|
|
"[P4]SMB Command = [B]\nError class = [BP1]\nError code = [u]\nFlags1 = [B]\nFlags2 = [B][P13]\nTree ID = [u]\nProc ID = [u]\nUID = [u]\nMID = [u]\nWord Count = [b]\n";
|
|
|
|
u_int smboffset;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2019-05-19 05:54:06 +08:00
|
|
|
ndo->ndo_protocol = "smb";
|
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
request = (GET_U_1(buf + 9) & 0x80) ? 0 : 1;
|
2004-12-29 06:29:44 +08:00
|
|
|
startbuf = buf;
|
2002-01-17 12:38:29 +08:00
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
command = GET_U_1(buf + 4);
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
fn = smbfind(command, smb_fns);
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2014-04-02 12:14:19 +08:00
|
|
|
if (ndo->ndo_vflag > 1)
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("\n");
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2019-08-14 02:37:35 +08:00
|
|
|
ND_PRINT("SMB PACKET: %s (%s)", fn->name, request ? "REQUEST" : "REPLY");
|
2001-02-21 03:28:02 +08:00
|
|
|
|
2014-04-02 12:14:19 +08:00
|
|
|
if (ndo->ndo_vflag < 2)
|
2001-06-25 11:07:30 +08:00
|
|
|
return;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2019-08-14 02:37:35 +08:00
|
|
|
ND_PRINT("\n");
|
2018-06-16 23:23:21 +08:00
|
|
|
flags2 = GET_LE_U_2(buf + 10);
|
2016-10-06 03:21:28 +08:00
|
|
|
unicodestr = flags2 & 0x8000;
|
|
|
|
nterrcodes = flags2 & 0x4000;
|
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
/* print out the header */
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, buf, fmt_smbheader, buf + 33, unicodestr);
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2004-12-30 11:36:50 +08:00
|
|
|
if (nterrcodes) {
|
2018-06-16 23:23:21 +08:00
|
|
|
nterror = GET_LE_U_4(buf + 5);
|
2004-12-30 11:36:50 +08:00
|
|
|
if (nterror)
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("NTError = %s\n", nt_errstr(nterror));
|
2004-12-30 11:36:50 +08:00
|
|
|
} else {
|
2018-06-16 23:23:21 +08:00
|
|
|
if (GET_U_1(buf + 5))
|
|
|
|
ND_PRINT("SMBError = %s\n", smb_errstr(GET_U_1(buf + 5),
|
|
|
|
GET_LE_U_2(buf + 7)));
|
2004-12-30 11:36:50 +08:00
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2004-12-28 19:18:29 +08:00
|
|
|
smboffset = 32;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2002-01-17 12:38:29 +08:00
|
|
|
for (;;) {
|
2002-04-25 12:54:02 +08:00
|
|
|
const char *f1, *f2;
|
2002-01-17 12:38:29 +08:00
|
|
|
int wct;
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
u_int bcc;
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int newsmboffset;
|
2002-01-17 12:38:29 +08:00
|
|
|
|
2004-12-28 19:18:29 +08:00
|
|
|
words = buf + smboffset;
|
2018-06-16 23:23:21 +08:00
|
|
|
wct = GET_U_1(words);
|
2002-01-17 12:38:29 +08:00
|
|
|
data = words + 1 + wct * 2;
|
2020-08-25 04:53:58 +08:00
|
|
|
maxwords = ND_MIN(data, maxbuf);
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
if (request) {
|
|
|
|
f1 = fn->descript.req_f1;
|
|
|
|
f2 = fn->descript.req_f2;
|
|
|
|
} else {
|
|
|
|
f1 = fn->descript.rep_f1;
|
|
|
|
f2 = fn->descript.rep_f2;
|
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2019-05-23 00:15:34 +08:00
|
|
|
smb_reset();
|
2001-06-25 11:07:30 +08:00
|
|
|
if (fn->descript.fn)
|
2014-04-02 12:14:19 +08:00
|
|
|
(*fn->descript.fn)(ndo, words, data, buf, maxbuf);
|
2001-06-25 11:07:30 +08:00
|
|
|
else {
|
2002-01-17 12:38:29 +08:00
|
|
|
if (wct) {
|
|
|
|
if (f1)
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, words + 1, f1, words + 1 + wct * 2, unicodestr);
|
2002-01-17 12:38:29 +08:00
|
|
|
else {
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int i;
|
|
|
|
u_int v;
|
2002-01-17 12:38:29 +08:00
|
|
|
|
2017-12-17 03:46:46 +08:00
|
|
|
for (i = 0; words + 1 + 2 * i < maxwords; i++) {
|
2018-06-16 23:23:21 +08:00
|
|
|
v = GET_LE_U_2(words + 1 + 2 * i);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("smb_vwv[%u]=%u (0x%X)\n", i, v, v);
|
2002-01-17 12:38:29 +08:00
|
|
|
}
|
2001-06-25 11:07:30 +08:00
|
|
|
}
|
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
bcc = GET_LE_U_2(data);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("smb_bcc=%u\n", bcc);
|
2001-06-25 11:07:30 +08:00
|
|
|
if (f2) {
|
2004-12-28 17:16:09 +08:00
|
|
|
if (bcc > 0)
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, data + 2, f2, data + 2 + bcc, unicodestr);
|
2001-06-25 11:07:30 +08:00
|
|
|
} else {
|
|
|
|
if (bcc > 0) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("smb_buf[]=\n");
|
2020-08-25 04:53:58 +08:00
|
|
|
smb_data_print(ndo, data + 2, ND_MIN(bcc, ND_BYTES_BETWEEN(maxbuf, data + 2)));
|
2001-06-25 11:07:30 +08:00
|
|
|
}
|
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
|
2002-01-17 12:38:29 +08:00
|
|
|
if ((fn->flags & FLG_CHAIN) == 0)
|
|
|
|
break;
|
|
|
|
if (wct == 0)
|
|
|
|
break;
|
2018-06-16 23:23:21 +08:00
|
|
|
command = GET_U_1(words + 1);
|
2002-01-17 12:38:29 +08:00
|
|
|
if (command == 0xFF)
|
|
|
|
break;
|
2018-06-16 23:23:21 +08:00
|
|
|
newsmboffset = GET_LE_U_2(words + 3);
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2002-01-17 12:38:29 +08:00
|
|
|
fn = smbfind(command, smb_fns);
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("\nSMB PACKET: %s (%s) (CHAINED)\n",
|
|
|
|
fn->name, request ? "REQUEST" : "REPLY");
|
2007-07-15 05:08:57 +08:00
|
|
|
if (newsmboffset <= smboffset) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Bad andX offset: %u <= %u\n", newsmboffset, smboffset);
|
2004-12-28 19:18:29 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
smboffset = newsmboffset;
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-06-25 11:07:30 +08:00
|
|
|
* print a NBT packet received across tcp on port 139
|
|
|
|
*/
|
|
|
|
void
|
2014-04-02 12:14:19 +08:00
|
|
|
nbt_tcp_print(netdissect_options *ndo,
|
2018-01-07 14:18:00 +08:00
|
|
|
const u_char *data, u_int length)
|
1999-11-22 00:01:56 +08:00
|
|
|
{
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int caplen;
|
|
|
|
u_int type;
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
u_int nbt_len;
|
2005-05-09 03:59:57 +08:00
|
|
|
const u_char *maxbuf;
|
|
|
|
|
2018-03-14 23:54:17 +08:00
|
|
|
ndo->ndo_protocol = "nbt_tcp";
|
2005-05-09 03:59:57 +08:00
|
|
|
if (length < 4)
|
|
|
|
goto trunc;
|
2014-04-02 12:14:19 +08:00
|
|
|
if (ndo->ndo_snapend < data)
|
2005-05-09 03:59:57 +08:00
|
|
|
goto trunc;
|
2020-05-25 17:02:34 +08:00
|
|
|
caplen = ND_BYTES_AVAILABLE_AFTER(data);
|
2005-05-09 03:59:57 +08:00
|
|
|
if (caplen < 4)
|
|
|
|
goto trunc;
|
|
|
|
maxbuf = data + caplen;
|
2018-06-16 23:23:21 +08:00
|
|
|
type = GET_U_1(data);
|
|
|
|
nbt_len = GET_BE_U_2(data + 2);
|
2005-05-09 03:59:57 +08:00
|
|
|
length -= 4;
|
|
|
|
caplen -= 4;
|
1999-12-22 14:27:19 +08:00
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
startbuf = data;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2014-04-02 12:14:19 +08:00
|
|
|
if (ndo->ndo_vflag < 2) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(" NBT Session Packet: ");
|
2004-05-31 09:55:07 +08:00
|
|
|
switch (type) {
|
|
|
|
case 0x00:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Session Message");
|
2004-05-31 09:55:07 +08:00
|
|
|
break;
|
2001-02-21 03:28:02 +08:00
|
|
|
|
2004-05-31 09:55:07 +08:00
|
|
|
case 0x81:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Session Request");
|
2004-05-31 09:55:07 +08:00
|
|
|
break;
|
2001-02-21 03:28:02 +08:00
|
|
|
|
2004-05-31 09:55:07 +08:00
|
|
|
case 0x82:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Session Granted");
|
2004-05-31 09:55:07 +08:00
|
|
|
break;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2004-05-31 09:55:07 +08:00
|
|
|
case 0x83:
|
|
|
|
{
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int ecode;
|
2004-05-31 09:55:07 +08:00
|
|
|
|
2005-05-09 03:59:57 +08:00
|
|
|
if (nbt_len < 4)
|
|
|
|
goto trunc;
|
|
|
|
if (length < 4)
|
|
|
|
goto trunc;
|
|
|
|
if (caplen < 4)
|
|
|
|
goto trunc;
|
2018-06-16 23:23:21 +08:00
|
|
|
ecode = GET_U_1(data + 4);
|
2004-05-31 09:55:07 +08:00
|
|
|
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Session Reject, ");
|
2004-05-31 09:55:07 +08:00
|
|
|
switch (ecode) {
|
|
|
|
case 0x80:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Not listening on called name");
|
2004-05-31 09:55:07 +08:00
|
|
|
break;
|
|
|
|
case 0x81:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Not listening for calling name");
|
2004-05-31 09:55:07 +08:00
|
|
|
break;
|
|
|
|
case 0x82:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Called name not present");
|
2004-05-31 09:55:07 +08:00
|
|
|
break;
|
|
|
|
case 0x83:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Called name present, but insufficient resources");
|
2004-05-31 09:55:07 +08:00
|
|
|
break;
|
|
|
|
default:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Unspecified error 0x%X", ecode);
|
2004-05-31 09:55:07 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2001-06-25 11:07:30 +08:00
|
|
|
|
2004-05-31 09:55:07 +08:00
|
|
|
case 0x85:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Session Keepalive");
|
2004-05-31 09:55:07 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data, "Unknown packet type [rB]", maxbuf, 0);
|
2004-05-31 09:55:07 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("\n>>> NBT Session Packet\n");
|
2004-05-31 09:55:07 +08:00
|
|
|
switch (type) {
|
|
|
|
case 0x00:
|
2018-01-07 14:18:00 +08:00
|
|
|
data = smb_fdata(ndo, data, "[P1]NBT Session Message\nFlags=[B]\nLength=[ru]\n",
|
2004-12-29 06:29:44 +08:00
|
|
|
data + 4, 0);
|
2004-05-31 09:55:07 +08:00
|
|
|
if (data == NULL)
|
|
|
|
break;
|
2005-05-09 03:59:57 +08:00
|
|
|
if (nbt_len >= 4 && caplen >= 4 && memcmp(data,"\377SMB",4) == 0) {
|
2018-01-07 14:18:00 +08:00
|
|
|
if (nbt_len > caplen) {
|
|
|
|
if (nbt_len > length)
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("WARNING: Packet is continued in later TCP segments\n");
|
2005-05-09 03:59:57 +08:00
|
|
|
else
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("WARNING: Short packet. Try increasing the snap length by %u\n",
|
|
|
|
nbt_len - caplen);
|
2005-05-09 03:59:57 +08:00
|
|
|
}
|
2014-04-02 12:14:19 +08:00
|
|
|
print_smb(ndo, data, maxbuf > data + nbt_len ? data + nbt_len : maxbuf);
|
2004-05-31 09:55:07 +08:00
|
|
|
} else
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Session packet:(raw data or continuation?)\n");
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
case 0x81:
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data,
|
2018-01-07 14:18:00 +08:00
|
|
|
"[P1]NBT Session Request\nFlags=[B]\nLength=[ru]\nDestination=[n1]\nSource=[n1]\n",
|
2004-12-29 06:29:44 +08:00
|
|
|
maxbuf, 0);
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x82:
|
2018-01-07 14:18:00 +08:00
|
|
|
data = smb_fdata(ndo, data, "[P1]NBT Session Granted\nFlags=[B]\nLength=[ru]\n", maxbuf, 0);
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x83:
|
|
|
|
{
|
2005-05-09 03:59:57 +08:00
|
|
|
const u_char *origdata;
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int ecode;
|
2002-01-17 12:38:29 +08:00
|
|
|
|
2005-05-09 03:59:57 +08:00
|
|
|
origdata = data;
|
2018-01-07 14:18:00 +08:00
|
|
|
data = smb_fdata(ndo, data, "[P1]NBT SessionReject\nFlags=[B]\nLength=[ru]\nReason=[B]\n",
|
2004-12-29 06:29:44 +08:00
|
|
|
maxbuf, 0);
|
2005-05-09 03:59:57 +08:00
|
|
|
if (data == NULL)
|
2001-06-26 12:16:27 +08:00
|
|
|
break;
|
2005-05-09 03:59:57 +08:00
|
|
|
if (nbt_len >= 1 && caplen >= 1) {
|
2018-06-16 23:23:21 +08:00
|
|
|
ecode = GET_U_1(origdata + 4);
|
2005-05-09 03:59:57 +08:00
|
|
|
switch (ecode) {
|
|
|
|
case 0x80:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Not listening on called name\n");
|
2005-05-09 03:59:57 +08:00
|
|
|
break;
|
|
|
|
case 0x81:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Not listening for calling name\n");
|
2005-05-09 03:59:57 +08:00
|
|
|
break;
|
|
|
|
case 0x82:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Called name not present\n");
|
2005-05-09 03:59:57 +08:00
|
|
|
break;
|
|
|
|
case 0x83:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Called name present, but insufficient resources\n");
|
2005-05-09 03:59:57 +08:00
|
|
|
break;
|
|
|
|
default:
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Unspecified error 0x%X\n", ecode);
|
2005-05-09 03:59:57 +08:00
|
|
|
break;
|
|
|
|
}
|
2001-06-25 11:07:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
case 0x85:
|
2018-01-07 14:18:00 +08:00
|
|
|
data = smb_fdata(ndo, data, "[P1]NBT Session Keepalive\nFlags=[B]\nLength=[ru]\n", maxbuf, 0);
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-25 11:07:30 +08:00
|
|
|
default:
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data, "NBT - Unknown packet type\nType=[B]\n", maxbuf, 0);
|
2004-05-31 09:55:07 +08:00
|
|
|
break;
|
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
2002-01-17 12:38:29 +08:00
|
|
|
return;
|
|
|
|
trunc:
|
2018-05-02 23:15:04 +08:00
|
|
|
nd_print_trunc(ndo);
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
|
2014-04-14 15:40:51 +08:00
|
|
|
static const struct tok opcode_str[] = {
|
|
|
|
{ 0, "QUERY" },
|
|
|
|
{ 5, "REGISTRATION" },
|
|
|
|
{ 6, "RELEASE" },
|
|
|
|
{ 7, "WACK" },
|
|
|
|
{ 8, "REFRESH(8)" },
|
|
|
|
{ 9, "REFRESH" },
|
|
|
|
{ 15, "MULTIHOMED REGISTRATION" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
1999-11-22 00:01:56 +08:00
|
|
|
|
|
|
|
/*
|
2001-06-25 11:07:30 +08:00
|
|
|
* print a NBT packet received across udp on port 137
|
|
|
|
*/
|
|
|
|
void
|
2014-04-02 12:14:19 +08:00
|
|
|
nbt_udp137_print(netdissect_options *ndo,
|
2018-01-07 14:18:00 +08:00
|
|
|
const u_char *data, u_int length)
|
1999-11-22 00:01:56 +08:00
|
|
|
{
|
2001-09-18 05:57:50 +08:00
|
|
|
const u_char *maxbuf = data + length;
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int name_trn_id, response, opcode, nm_flags, rcode;
|
|
|
|
u_int qdcount, ancount, nscount, arcount;
|
2002-04-25 12:54:02 +08:00
|
|
|
const u_char *p;
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int total, i;
|
2001-06-26 12:16:27 +08:00
|
|
|
|
2018-03-14 23:54:17 +08:00
|
|
|
ndo->ndo_protocol = "nbt_udp137";
|
2018-06-16 23:23:21 +08:00
|
|
|
name_trn_id = GET_BE_U_2(data);
|
|
|
|
response = (GET_U_1(data + 2) >> 7);
|
|
|
|
opcode = (GET_U_1(data + 2) >> 3) & 0xF;
|
|
|
|
nm_flags = ((GET_U_1(data + 2) & 0x7) << 4) + (GET_U_1(data + 3) >> 4);
|
|
|
|
rcode = GET_U_1(data + 3) & 0xF;
|
|
|
|
qdcount = GET_BE_U_2(data + 4);
|
|
|
|
ancount = GET_BE_U_2(data + 6);
|
|
|
|
nscount = GET_BE_U_2(data + 8);
|
|
|
|
arcount = GET_BE_U_2(data + 10);
|
2001-06-26 12:16:27 +08:00
|
|
|
startbuf = data;
|
|
|
|
|
|
|
|
if (maxbuf <= data)
|
|
|
|
return;
|
|
|
|
|
2014-04-02 12:14:19 +08:00
|
|
|
if (ndo->ndo_vflag > 1)
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("\n>>> ");
|
2001-06-26 12:16:27 +08:00
|
|
|
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("NBT UDP PACKET(137): %s", tok2str(opcode_str, "OPUNKNOWN", opcode));
|
2001-06-26 12:16:27 +08:00
|
|
|
if (response) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("; %s", rcode ? "NEGATIVE" : "POSITIVE");
|
2001-06-26 12:16:27 +08:00
|
|
|
}
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("; %s; %s", response ? "RESPONSE" : "REQUEST",
|
|
|
|
(nm_flags & 1) ? "BROADCAST" : "UNICAST");
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2014-04-02 12:14:19 +08:00
|
|
|
if (ndo->ndo_vflag < 2)
|
2001-06-26 12:16:27 +08:00
|
|
|
return;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("\nTrnID=0x%X\nOpCode=%u\nNmFlags=0x%X\nRcode=%u\nQueryCount=%u\nAnswerCount=%u\nAuthorityCount=%u\nAddressRecCount=%u\n",
|
2001-06-26 12:16:27 +08:00
|
|
|
name_trn_id, opcode, nm_flags, rcode, qdcount, ancount, nscount,
|
2018-01-07 18:47:30 +08:00
|
|
|
arcount);
|
2001-06-26 12:16:27 +08:00
|
|
|
|
|
|
|
p = data + 12;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 12:16:27 +08:00
|
|
|
total = ancount + nscount + arcount;
|
|
|
|
|
|
|
|
if (qdcount > 100 || total > 100) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("Corrupt packet??\n");
|
2001-06-26 12:16:27 +08:00
|
|
|
return;
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qdcount) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("QuestionRecords:\n");
|
2005-05-06 06:30:03 +08:00
|
|
|
for (i = 0; i < qdcount; i++) {
|
2014-04-02 12:14:19 +08:00
|
|
|
p = smb_fdata(ndo, p,
|
2001-06-26 12:16:27 +08:00
|
|
|
"|Name=[n1]\nQuestionType=[rw]\nQuestionClass=[rw]\n#",
|
2004-12-29 06:29:44 +08:00
|
|
|
maxbuf, 0);
|
2005-05-06 06:30:03 +08:00
|
|
|
if (p == NULL)
|
|
|
|
goto out;
|
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (total) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("\nResourceRecords:\n");
|
2001-06-26 12:16:27 +08:00
|
|
|
for (i = 0; i < total; i++) {
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int rdlen;
|
|
|
|
u_int restype;
|
2001-06-26 12:16:27 +08:00
|
|
|
|
2014-04-02 12:14:19 +08:00
|
|
|
p = smb_fdata(ndo, p, "Name=[n1]\n#", maxbuf, 0);
|
2000-12-04 08:35:44 +08:00
|
|
|
if (p == NULL)
|
2001-06-26 12:16:27 +08:00
|
|
|
goto out;
|
2018-06-16 23:23:21 +08:00
|
|
|
restype = GET_BE_U_2(p);
|
2018-01-07 14:18:00 +08:00
|
|
|
p = smb_fdata(ndo, p, "ResType=[rw]\nResClass=[rw]\nTTL=[rU]\n", p + 8, 0);
|
2001-06-26 12:16:27 +08:00
|
|
|
if (p == NULL)
|
|
|
|
goto out;
|
2018-06-16 23:23:21 +08:00
|
|
|
rdlen = GET_BE_U_2(p);
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("ResourceLength=%u\nResourceData=\n", rdlen);
|
2001-06-26 12:16:27 +08:00
|
|
|
p += 2;
|
|
|
|
if (rdlen == 6) {
|
2014-04-02 12:14:19 +08:00
|
|
|
p = smb_fdata(ndo, p, "AddrType=[rw]\nAddress=[b.b.b.b]\n", p + rdlen, 0);
|
2001-06-26 12:16:27 +08:00
|
|
|
if (p == NULL)
|
|
|
|
goto out;
|
|
|
|
} else {
|
|
|
|
if (restype == 0x21) {
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int numnames;
|
2002-01-17 12:38:29 +08:00
|
|
|
|
2018-06-16 23:23:21 +08:00
|
|
|
numnames = GET_U_1(p);
|
2014-04-02 12:14:19 +08:00
|
|
|
p = smb_fdata(ndo, p, "NumNames=[B]\n", p + 1, 0);
|
2001-06-26 12:16:27 +08:00
|
|
|
if (p == NULL)
|
|
|
|
goto out;
|
2019-03-08 20:23:34 +08:00
|
|
|
while (numnames) {
|
2014-04-02 12:14:19 +08:00
|
|
|
p = smb_fdata(ndo, p, "Name=[n2]\t#", maxbuf, 0);
|
2005-05-06 06:30:03 +08:00
|
|
|
if (p == NULL)
|
|
|
|
goto out;
|
2017-12-05 03:21:48 +08:00
|
|
|
ND_TCHECK_1(p);
|
2018-01-07 14:18:00 +08:00
|
|
|
if (p >= maxbuf)
|
|
|
|
goto out;
|
2018-06-16 23:23:21 +08:00
|
|
|
if (GET_U_1(p) & 0x80)
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("<GROUP> ");
|
2018-06-16 23:23:21 +08:00
|
|
|
switch (GET_U_1(p) & 0x60) {
|
2018-01-07 18:47:30 +08:00
|
|
|
case 0x00: ND_PRINT("B "); break;
|
|
|
|
case 0x20: ND_PRINT("P "); break;
|
|
|
|
case 0x40: ND_PRINT("M "); break;
|
|
|
|
case 0x60: ND_PRINT("_ "); break;
|
2001-06-26 12:16:27 +08:00
|
|
|
}
|
2018-06-16 23:23:21 +08:00
|
|
|
if (GET_U_1(p) & 0x10)
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("<DEREGISTERING> ");
|
2018-06-16 23:23:21 +08:00
|
|
|
if (GET_U_1(p) & 0x08)
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("<CONFLICT> ");
|
2018-06-16 23:23:21 +08:00
|
|
|
if (GET_U_1(p) & 0x04)
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("<ACTIVE> ");
|
2018-06-16 23:23:21 +08:00
|
|
|
if (GET_U_1(p) & 0x02)
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("<PERMANENT> ");
|
|
|
|
ND_PRINT("\n");
|
2001-06-26 12:16:27 +08:00
|
|
|
p += 2;
|
2019-03-08 20:23:34 +08:00
|
|
|
numnames--;
|
2001-06-26 12:16:27 +08:00
|
|
|
}
|
|
|
|
} else {
|
2018-01-07 14:18:00 +08:00
|
|
|
if (p >= maxbuf)
|
|
|
|
goto out;
|
2020-08-25 04:53:58 +08:00
|
|
|
smb_data_print(ndo, p, ND_MIN(rdlen, length - ND_BYTES_BETWEEN(p, data)));
|
2001-06-26 12:16:27 +08:00
|
|
|
p += rdlen;
|
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-25 12:54:02 +08:00
|
|
|
if (p < maxbuf)
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, p, "AdditionalData:\n", maxbuf, 0);
|
2001-06-26 12:16:27 +08:00
|
|
|
|
2000-12-04 08:35:44 +08:00
|
|
|
out:
|
2002-01-17 12:38:29 +08:00
|
|
|
return;
|
|
|
|
trunc:
|
2018-05-02 23:15:04 +08:00
|
|
|
nd_print_trunc(ndo);
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
|
2007-12-09 08:30:47 +08:00
|
|
|
/*
|
|
|
|
* Print an SMB-over-TCP packet received across tcp on port 445
|
|
|
|
*/
|
|
|
|
void
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_tcp_print(netdissect_options *ndo,
|
2018-01-07 14:18:00 +08:00
|
|
|
const u_char * data, u_int length)
|
2007-12-09 08:30:47 +08:00
|
|
|
{
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int caplen;
|
2007-12-09 08:30:47 +08:00
|
|
|
u_int smb_len;
|
|
|
|
const u_char *maxbuf;
|
|
|
|
|
2018-03-14 23:54:17 +08:00
|
|
|
ndo->ndo_protocol = "smb_tcp";
|
2007-12-09 08:30:47 +08:00
|
|
|
if (length < 4)
|
|
|
|
goto trunc;
|
2014-04-02 12:14:19 +08:00
|
|
|
if (ndo->ndo_snapend < data)
|
2007-12-09 08:30:47 +08:00
|
|
|
goto trunc;
|
2020-05-25 17:02:34 +08:00
|
|
|
caplen = ND_BYTES_AVAILABLE_AFTER(data);
|
2007-12-09 08:30:47 +08:00
|
|
|
if (caplen < 4)
|
|
|
|
goto trunc;
|
|
|
|
maxbuf = data + caplen;
|
2018-06-16 23:23:21 +08:00
|
|
|
smb_len = GET_BE_U_3(data + 1);
|
2007-12-09 08:30:47 +08:00
|
|
|
length -= 4;
|
|
|
|
caplen -= 4;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2007-12-09 08:30:47 +08:00
|
|
|
startbuf = data;
|
|
|
|
data += 4;
|
|
|
|
|
|
|
|
if (smb_len >= 4 && caplen >= 4 && memcmp(data,"\377SMB",4) == 0) {
|
2018-01-07 14:18:00 +08:00
|
|
|
if (smb_len > caplen) {
|
|
|
|
if (smb_len > length)
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(" WARNING: Packet is continued in later TCP segments\n");
|
2007-12-09 08:30:47 +08:00
|
|
|
else
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(" WARNING: Short packet. Try increasing the snap length by %u\n",
|
|
|
|
smb_len - caplen);
|
2014-10-20 04:58:20 +08:00
|
|
|
} else
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(" ");
|
2014-04-02 12:14:19 +08:00
|
|
|
print_smb(ndo, data, maxbuf > data + smb_len ? data + smb_len : maxbuf);
|
2007-12-09 08:30:47 +08:00
|
|
|
} else
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT(" SMB-over-TCP packet:(raw data or continuation?)\n");
|
2007-12-09 08:30:47 +08:00
|
|
|
return;
|
|
|
|
trunc:
|
2018-05-02 23:15:04 +08:00
|
|
|
nd_print_trunc(ndo);
|
2007-12-09 08:30:47 +08:00
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
|
|
|
|
/*
|
2001-06-25 11:07:30 +08:00
|
|
|
* print a NBT packet received across udp on port 138
|
|
|
|
*/
|
2001-06-28 11:15:38 +08:00
|
|
|
void
|
2014-04-02 12:14:19 +08:00
|
|
|
nbt_udp138_print(netdissect_options *ndo,
|
2018-01-07 14:18:00 +08:00
|
|
|
const u_char *data, u_int length)
|
1999-11-22 00:01:56 +08:00
|
|
|
{
|
2001-09-18 05:57:50 +08:00
|
|
|
const u_char *maxbuf = data + length;
|
2001-01-15 11:59:13 +08:00
|
|
|
|
2018-03-14 23:54:17 +08:00
|
|
|
ndo->ndo_protocol = "nbt_udp138";
|
2014-04-02 12:14:19 +08:00
|
|
|
if (maxbuf > ndo->ndo_snapend)
|
|
|
|
maxbuf = ndo->ndo_snapend;
|
2001-06-26 12:16:27 +08:00
|
|
|
if (maxbuf <= data)
|
|
|
|
return;
|
|
|
|
startbuf = data;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2014-04-02 12:14:19 +08:00
|
|
|
if (ndo->ndo_vflag < 2) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("NBT UDP PACKET(138)");
|
2001-06-26 12:16:27 +08:00
|
|
|
return;
|
|
|
|
}
|
2001-02-21 03:28:02 +08:00
|
|
|
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data,
|
2018-01-07 14:18:00 +08:00
|
|
|
"\n>>> NBT UDP PACKET(138) Res=[rw] ID=[rw] IP=[b.b.b.b] Port=[ru] Length=[ru] Res2=[rw]\nSourceName=[n1]\nDestName=[n1]\n#",
|
2004-12-29 06:29:44 +08:00
|
|
|
maxbuf, 0);
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2002-01-17 12:38:29 +08:00
|
|
|
if (data != NULL) {
|
|
|
|
/* If there isn't enough data for "\377SMB", don't check for it. */
|
2017-12-03 18:13:27 +08:00
|
|
|
if ((data + 3) >= maxbuf)
|
2002-01-17 12:38:29 +08:00
|
|
|
goto out;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2002-01-17 12:38:29 +08:00
|
|
|
if (memcmp(data, "\377SMB",4) == 0)
|
2014-04-02 12:14:19 +08:00
|
|
|
print_smb(ndo, data, maxbuf);
|
2002-01-17 12:38:29 +08:00
|
|
|
}
|
|
|
|
out:
|
2019-08-14 02:37:35 +08:00
|
|
|
return;
|
2001-06-26 12:16:27 +08:00
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-06-26 12:16:27 +08:00
|
|
|
print netbeui frames
|
1999-11-22 00:01:56 +08:00
|
|
|
*/
|
2016-09-12 03:45:26 +08:00
|
|
|
static struct nbf_strings {
|
2004-05-31 09:19:10 +08:00
|
|
|
const char *name;
|
|
|
|
const char *nonverbose;
|
|
|
|
const char *verbose;
|
|
|
|
} nbf_strings[0x20] = {
|
|
|
|
{ "Add Group Name Query", ", [P23]Name to add=[n2]#",
|
|
|
|
"[P5]ResponseCorrelator=[w]\n[P16]Name to add=[n2]\n" },
|
|
|
|
{ "Add Name Query", ", [P23]Name to add=[n2]#",
|
|
|
|
"[P5]ResponseCorrelator=[w]\n[P16]Name to add=[n2]\n" },
|
|
|
|
{ "Name In Conflict", NULL, NULL },
|
|
|
|
{ "Status Query", NULL, NULL },
|
|
|
|
{ NULL, NULL, NULL }, /* not used */
|
|
|
|
{ NULL, NULL, NULL }, /* not used */
|
|
|
|
{ NULL, NULL, NULL }, /* not used */
|
|
|
|
{ "Terminate Trace", NULL, NULL },
|
|
|
|
{ "Datagram", NULL,
|
|
|
|
"[P7]Destination=[n2]\nSource=[n2]\n" },
|
|
|
|
{ "Broadcast Datagram", NULL,
|
|
|
|
"[P7]Destination=[n2]\nSource=[n2]\n" },
|
|
|
|
{ "Name Query", ", [P7]Name=[n2]#",
|
|
|
|
"[P1]SessionNumber=[B]\nNameType=[B][P2]\nResponseCorrelator=[w]\nName=[n2]\nName of sender=[n2]\n" },
|
|
|
|
{ NULL, NULL, NULL }, /* not used */
|
|
|
|
{ NULL, NULL, NULL }, /* not used */
|
|
|
|
{ "Add Name Response", ", [P1]GroupName=[w] [P4]Destination=[n2] Source=[n2]#",
|
|
|
|
"AddNameInProcess=[B]\nGroupName=[w]\nTransmitCorrelator=[w][P2]\nDestination=[n2]\nSource=[n2]\n" },
|
|
|
|
{ "Name Recognized", NULL,
|
|
|
|
"[P1]Data2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nDestination=[n2]\nSource=[n2]\n" },
|
|
|
|
{ "Status Response", NULL, NULL },
|
|
|
|
{ NULL, NULL, NULL }, /* not used */
|
|
|
|
{ NULL, NULL, NULL }, /* not used */
|
|
|
|
{ NULL, NULL, NULL }, /* not used */
|
|
|
|
{ "Terminate Trace", NULL, NULL },
|
|
|
|
{ "Data Ack", NULL,
|
|
|
|
"[P3]TransmitCorrelator=[w][P2]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
|
|
|
|
{ "Data First/Middle", NULL,
|
|
|
|
"Flags=[{RECEIVE_CONTINUE|NO_ACK||PIGGYBACK_ACK_INCLUDED|}]\nResyncIndicator=[w][P2]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
|
|
|
|
{ "Data Only/Last", NULL,
|
|
|
|
"Flags=[{|NO_ACK|PIGGYBACK_ACK_ALLOWED|PIGGYBACK_ACK_INCLUDED|}]\nResyncIndicator=[w][P2]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
|
|
|
|
{ "Session Confirm", NULL,
|
|
|
|
"Data1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
|
|
|
|
{ "Session End", NULL,
|
|
|
|
"[P1]Data2=[w][P4]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
|
|
|
|
{ "Session Initialize", NULL,
|
|
|
|
"Data1=[B]\nData2=[w]\nTransmitCorrelator=[w]\nResponseCorelator=[w]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
|
|
|
|
{ "No Receive", NULL,
|
|
|
|
"Flags=[{|SEND_NO_ACK}]\nDataBytesAccepted=[b][P4]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
|
|
|
|
{ "Receive Outstanding", NULL,
|
|
|
|
"[P1]DataBytesAccepted=[b][P4]\nRemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
|
|
|
|
{ "Receive Continue", NULL,
|
|
|
|
"[P2]TransmitCorrelator=[w]\n[P2]RemoteSessionNumber=[B]\nLocalSessionNumber=[B]\n" },
|
|
|
|
{ NULL, NULL, NULL }, /* not used */
|
|
|
|
{ NULL, NULL, NULL }, /* not used */
|
|
|
|
{ "Session Alive", NULL, NULL }
|
|
|
|
};
|
|
|
|
|
2001-06-28 11:15:38 +08:00
|
|
|
void
|
2014-04-02 12:14:19 +08:00
|
|
|
netbeui_print(netdissect_options *ndo,
|
2018-01-07 14:18:00 +08:00
|
|
|
u_short control, const u_char *data, u_int length)
|
1999-11-22 00:01:56 +08:00
|
|
|
{
|
2001-09-18 05:57:50 +08:00
|
|
|
const u_char *maxbuf = data + length;
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int len;
|
|
|
|
u_int command;
|
2001-09-18 05:57:50 +08:00
|
|
|
const u_char *data2;
|
2001-06-26 12:16:27 +08:00
|
|
|
int is_truncated = 0;
|
2000-12-05 14:42:47 +08:00
|
|
|
|
2018-03-14 23:54:17 +08:00
|
|
|
ndo->ndo_protocol = "netbeui";
|
2014-04-02 12:14:19 +08:00
|
|
|
if (maxbuf > ndo->ndo_snapend)
|
|
|
|
maxbuf = ndo->ndo_snapend;
|
2018-06-16 23:23:21 +08:00
|
|
|
len = GET_LE_U_2(data);
|
|
|
|
command = GET_U_1(data + 4);
|
2001-06-26 12:16:27 +08:00
|
|
|
data2 = data + len;
|
|
|
|
if (data2 >= maxbuf) {
|
2001-06-28 11:15:38 +08:00
|
|
|
data2 = maxbuf;
|
|
|
|
is_truncated = 1;
|
2001-06-26 12:16:27 +08:00
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 12:16:27 +08:00
|
|
|
startbuf = data;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2014-04-02 12:14:19 +08:00
|
|
|
if (ndo->ndo_vflag < 2) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("NBF Packet: ");
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data, "[P5]#", maxbuf, 0);
|
2004-05-31 09:19:10 +08:00
|
|
|
} else {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("\n>>> NBF Packet\nType=0x%X ", control);
|
2018-01-07 14:18:00 +08:00
|
|
|
data = smb_fdata(ndo, data, "Length=[u] Signature=[w] Command=[B]\n#", maxbuf, 0);
|
2001-06-26 12:16:27 +08:00
|
|
|
}
|
|
|
|
if (data == NULL)
|
2001-06-28 11:15:38 +08:00
|
|
|
goto out;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2004-05-31 09:19:10 +08:00
|
|
|
if (command > 0x1f || nbf_strings[command].name == NULL) {
|
2014-04-02 12:14:19 +08:00
|
|
|
if (ndo->ndo_vflag < 2)
|
|
|
|
data = smb_fdata(ndo, data, "Unknown NBF Command#", data2, 0);
|
2004-05-31 09:19:10 +08:00
|
|
|
else
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data, "Unknown NBF Command\n", data2, 0);
|
2004-05-31 09:19:10 +08:00
|
|
|
} else {
|
2014-04-02 12:14:19 +08:00
|
|
|
if (ndo->ndo_vflag < 2) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("%s", nbf_strings[command].name);
|
2004-05-31 09:19:10 +08:00
|
|
|
if (nbf_strings[command].nonverbose != NULL)
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data, nbf_strings[command].nonverbose, data2, 0);
|
2004-05-31 09:19:10 +08:00
|
|
|
} else {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("%s:\n", nbf_strings[command].name);
|
2004-05-31 09:19:10 +08:00
|
|
|
if (nbf_strings[command].verbose != NULL)
|
2014-04-02 12:14:19 +08:00
|
|
|
data = smb_fdata(ndo, data, nbf_strings[command].verbose, data2, 0);
|
2004-05-31 09:19:10 +08:00
|
|
|
else
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("\n");
|
2004-05-31 09:19:10 +08:00
|
|
|
}
|
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2014-04-02 12:14:19 +08:00
|
|
|
if (ndo->ndo_vflag < 2)
|
2004-05-31 09:19:10 +08:00
|
|
|
return;
|
2000-12-05 14:42:47 +08:00
|
|
|
|
2001-06-26 12:16:27 +08:00
|
|
|
if (data == NULL)
|
2001-06-28 11:15:38 +08:00
|
|
|
goto out;
|
1999-11-22 00:01:56 +08:00
|
|
|
|
2001-06-26 12:16:27 +08:00
|
|
|
if (is_truncated) {
|
|
|
|
/* data2 was past the end of the buffer */
|
|
|
|
goto out;
|
|
|
|
}
|
2000-12-05 14:42:47 +08:00
|
|
|
|
2004-05-31 09:19:10 +08:00
|
|
|
/* If this isn't a command that would contain an SMB message, quit. */
|
|
|
|
if (command != 0x08 && command != 0x09 && command != 0x15 &&
|
|
|
|
command != 0x16)
|
|
|
|
goto out;
|
|
|
|
|
2001-06-26 12:16:27 +08:00
|
|
|
/* If there isn't enough data for "\377SMB", don't look for it. */
|
2017-12-03 18:13:27 +08:00
|
|
|
if ((data2 + 3) >= maxbuf)
|
2001-06-26 12:16:27 +08:00
|
|
|
goto out;
|
2001-01-15 11:23:58 +08:00
|
|
|
|
2001-06-26 12:16:27 +08:00
|
|
|
if (memcmp(data2, "\377SMB",4) == 0)
|
2014-04-02 12:14:19 +08:00
|
|
|
print_smb(ndo, data2, maxbuf);
|
2001-06-26 12:16:27 +08:00
|
|
|
else {
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int i;
|
2001-06-26 12:16:27 +08:00
|
|
|
for (i = 0; i < 128; i++) {
|
2017-12-03 18:13:27 +08:00
|
|
|
if ((data2 + i + 3) >= maxbuf)
|
2001-06-26 12:16:27 +08:00
|
|
|
break;
|
2017-12-02 21:56:12 +08:00
|
|
|
if (memcmp(data2 + i, "\377SMB", 4) == 0) {
|
2018-01-07 18:47:30 +08:00
|
|
|
ND_PRINT("found SMB packet at %u\n", i);
|
2017-12-02 21:56:12 +08:00
|
|
|
print_smb(ndo, data2 + i, maxbuf);
|
2001-06-26 12:16:27 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
|
2000-12-04 08:35:44 +08:00
|
|
|
out:
|
2002-01-17 12:38:29 +08:00
|
|
|
return;
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-06-26 12:16:27 +08:00
|
|
|
* print IPX-Netbios frames
|
2001-06-25 11:07:30 +08:00
|
|
|
*/
|
2001-06-28 11:15:38 +08:00
|
|
|
void
|
2014-04-02 12:14:19 +08:00
|
|
|
ipx_netbios_print(netdissect_options *ndo,
|
|
|
|
const u_char *data, u_int length)
|
1999-11-22 00:01:56 +08:00
|
|
|
{
|
2001-06-25 11:07:30 +08:00
|
|
|
/*
|
|
|
|
* this is a hack till I work out how to parse the rest of the
|
|
|
|
* NetBIOS-over-IPX stuff
|
|
|
|
*/
|
2018-01-07 14:18:00 +08:00
|
|
|
u_int i;
|
2001-09-18 05:57:50 +08:00
|
|
|
const u_char *maxbuf;
|
2001-06-25 11:07:30 +08:00
|
|
|
|
2018-03-14 23:54:17 +08:00
|
|
|
ndo->ndo_protocol = "ipx_netbios";
|
2001-06-25 11:07:30 +08:00
|
|
|
maxbuf = data + length;
|
|
|
|
/* Don't go past the end of the captured data in the packet. */
|
2014-04-02 12:14:19 +08:00
|
|
|
if (maxbuf > ndo->ndo_snapend)
|
|
|
|
maxbuf = ndo->ndo_snapend;
|
2001-06-25 11:07:30 +08:00
|
|
|
startbuf = data;
|
|
|
|
for (i = 0; i < 128; i++) {
|
2017-12-03 18:13:27 +08:00
|
|
|
if ((data + i + 4) > maxbuf)
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
2017-12-02 21:56:12 +08:00
|
|
|
if (memcmp(data + i, "\377SMB", 4) == 0) {
|
|
|
|
smb_fdata(ndo, data, "\n>>> IPX transport ", data + i, 0);
|
|
|
|
print_smb(ndo, data + i, maxbuf);
|
2001-06-25 11:07:30 +08:00
|
|
|
break;
|
|
|
|
}
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|
2001-06-25 11:07:30 +08:00
|
|
|
if (i == 128)
|
2014-04-02 12:14:19 +08:00
|
|
|
smb_fdata(ndo, data, "\n>>> Unknown IPX ", maxbuf, 0);
|
1999-11-22 00:01:56 +08:00
|
|
|
}
|