]>
The Tcpdump Group git mirrors - tcpdump/blob - print-smb.c
2 * Copyright (C) Andrew Tridgell 1995-1999
4 * This software may be distributed either under the terms of the
5 * BSD-style license that accompanies tcpdump or the GNU GPL version 2
14 static const char rcsid
[] _U_
=
15 "@(#) $Header: /tcpdump/master/tcpdump/print-smb.c,v 1.47 2007-12-09 00:30:47 guy Exp $" ;
18 #include <tcpdump-stdinc.h>
23 #include "interface.h"
27 static int request
= 0 ;
28 static int unicodestr
= 0 ;
30 const u_char
* startbuf
= NULL
;
37 void (* fn
)( const u_char
*, const u_char
*, const u_char
*, const u_char
*);
40 struct smbdescriptint
{
45 void (* fn
)( const u_char
*, const u_char
*, int , int );
53 struct smbdescript descript
;
61 struct smbdescriptint descript
;
64 #define DEFDESCRIPT { NULL, NULL, NULL, NULL, NULL }
66 #define FLG_CHAIN (1 << 0)
68 static struct smbfns
*
69 smbfind ( int id
, struct smbfns
* list
)
73 for ( sindex
= 0 ; list
[ sindex
]. name
; sindex
++)
74 if ( list
[ sindex
]. id
== id
)
75 return (& list
[ sindex
]);
80 static struct smbfnsint
*
81 smbfindint ( int id
, struct smbfnsint
* list
)
85 for ( sindex
= 0 ; list
[ sindex
]. name
; sindex
++)
86 if ( list
[ sindex
]. id
== id
)
87 return (& list
[ sindex
]);
93 trans2_findfirst ( const u_char
* param
, const u_char
* data
, int pcnt
, int dcnt
)
98 fmt
= "Attribute=[A] \n SearchCount=[d] \n Flags=[w] \n Level=[dP4] \n File=[S] \n " ;
100 fmt
= "Handle=[w] \n Count=[d] \n EOS=[w] \n Eoffset=[d] \n LastNameOfs=[w] \n " ;
102 smb_fdata ( param
, fmt
, param
+ pcnt
, unicodestr
);
105 print_data ( data
, dcnt
);
110 trans2_qfsinfo ( const u_char
* param
, const u_char
* data
, int pcnt
, int dcnt
)
112 static int level
= 0 ;
117 level
= EXTRACT_LE_16BITS ( param
);
118 fmt
= "InfoLevel=[d] \n " ;
119 smb_fdata ( param
, fmt
, param
+ pcnt
, unicodestr
);
123 fmt
= "idFileSystem=[W] \n SectorUnit=[D] \n Unit=[D] \n Avail=[D] \n SectorSize=[d] \n " ;
126 fmt
= "CreationTime=[T2]VolNameLength=[lb] \n VolumeLabel=[c] \n " ;
129 fmt
= "Capabilities=[W] \n MaxFileLen=[D] \n VolNameLen=[lD] \n Volume=[C] \n " ;
132 fmt
= "UnknownLevel \n " ;
135 smb_fdata ( data
, fmt
, data
+ dcnt
, unicodestr
);
139 print_data ( data
, dcnt
);
147 struct smbfnsint trans2_fns
[] = {
148 { 0 , "TRANSACT2_OPEN" , 0 ,
149 { "Flags2=[w] \n Mode=[w] \n SearchAttrib=[A] \n Attrib=[A] \n Time=[T2] \n OFun=[w] \n Size=[D] \n Res=([w, w, w, w, w]) \n Path=[S]" ,
151 "Handle=[d] \n Attrib=[A] \n Time=[T2] \n Size=[D] \n Access=[w] \n Type=[w] \n State=[w] \n Action=[w] \n Inode=[W] \n OffErr=[d] \n |EALength=[d] \n " ,
153 { 1 , "TRANSACT2_FINDFIRST" , 0 ,
154 { NULL
, NULL
, NULL
, NULL
, trans2_findfirst
}},
155 { 2 , "TRANSACT2_FINDNEXT" , 0 , DEFDESCRIPT
},
156 { 3 , "TRANSACT2_QFSINFO" , 0 ,
157 { NULL
, NULL
, NULL
, NULL
, trans2_qfsinfo
}},
158 { 4 , "TRANSACT2_SETFSINFO" , 0 , DEFDESCRIPT
},
159 { 5 , "TRANSACT2_QPATHINFO" , 0 , DEFDESCRIPT
},
160 { 6 , "TRANSACT2_SETPATHINFO" , 0 , DEFDESCRIPT
},
161 { 7 , "TRANSACT2_QFILEINFO" , 0 , DEFDESCRIPT
},
162 { 8 , "TRANSACT2_SETFILEINFO" , 0 , DEFDESCRIPT
},
163 { 9 , "TRANSACT2_FSCTL" , 0 , DEFDESCRIPT
},
164 { 10 , "TRANSACT2_IOCTL" , 0 , DEFDESCRIPT
},
165 { 11 , "TRANSACT2_FINDNOTIFYFIRST" , 0 , DEFDESCRIPT
},
166 { 12 , "TRANSACT2_FINDNOTIFYNEXT" , 0 , DEFDESCRIPT
},
167 { 13 , "TRANSACT2_MKDIR" , 0 , DEFDESCRIPT
},
168 { - 1 , NULL
, 0 , DEFDESCRIPT
}
173 print_trans2 ( const u_char
* words
, const u_char
* dat
, const u_char
* buf
, const u_char
* maxbuf
)
176 static struct smbfnsint
* fn
= & trans2_fns
[ 0 ];
177 const u_char
* data
, * param
;
178 const u_char
* w
= words
+ 1 ;
179 const char * f1
= NULL
, * f2
= NULL
;
184 TCHECK2 ( w
[ 14 * 2 ], 2 );
185 pcnt
= EXTRACT_LE_16BITS ( w
+ 9 * 2 );
186 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 10 * 2 );
187 dcnt
= EXTRACT_LE_16BITS ( w
+ 11 * 2 );
188 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 12 * 2 );
189 fn
= smbfindint ( EXTRACT_LE_16BITS ( w
+ 14 * 2 ), trans2_fns
);
192 printf ( "%s \n " , fn
-> name
);
193 printf ( "Trans2Interim \n " );
196 TCHECK2 ( w
[ 7 * 2 ], 2 );
197 pcnt
= EXTRACT_LE_16BITS ( w
+ 3 * 2 );
198 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 4 * 2 );
199 dcnt
= EXTRACT_LE_16BITS ( w
+ 6 * 2 );
200 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 7 * 2 );
203 printf ( "%s param_length=%d data_length=%d \n " , fn
-> name
, pcnt
, dcnt
);
208 "Trans2Secondary \n TotParam=[d] \n TotData=[d] \n ParamCnt=[d] \n ParamOff=[d] \n ParamDisp=[d] \n DataCnt=[d] \n DataOff=[d] \n DataDisp=[d] \n Handle=[d] \n " ,
213 "TotParam=[d] \n TotData=[d] \n MaxParam=[d] \n MaxData=[d] \n MaxSetup=[b][P1] \n Flags=[w] \n TimeOut=[D] \n Res1=[w] \n ParamCnt=[d] \n ParamOff=[d] \n DataCnt=[d] \n DataOff=[d] \n SetupCnt=[b][P1] \n " ,
214 words
+ 1 + 14 * 2 , unicodestr
);
216 f1
= fn
-> descript
. req_f1
;
217 f2
= fn
-> descript
. req_f2
;
220 "TotParam=[d] \n TotData=[d] \n Res1=[w] \n ParamCnt=[d] \n ParamOff=[d] \n ParamDisp[d] \n DataCnt=[d] \n DataOff=[d] \n DataDisp=[d] \n SetupCnt=[b][P1] \n " ,
221 words
+ 1 + 10 * 2 , unicodestr
);
222 f1
= fn
-> descript
. rep_f1
;
223 f2
= fn
-> descript
. rep_f2
;
227 bcc
= EXTRACT_LE_16BITS ( dat
);
228 printf ( "smb_bcc=%u \n " , bcc
);
230 (* fn
-> descript
. fn
)( param
, data
, pcnt
, dcnt
);
232 smb_fdata ( param
, f1
? f1
: "Parameters= \n " , param
+ pcnt
, unicodestr
);
233 smb_fdata ( data
, f2
? f2
: "Data= \n " , data
+ dcnt
, unicodestr
);
243 print_browse ( const u_char
* param
, int paramlen
, const u_char
* data
, int datalen
)
245 const u_char
* maxbuf
= data
+ datalen
;
251 smb_fdata ( param
, "BROWSE PACKET \n |Param " , param
+ paramlen
, unicodestr
);
255 data
= smb_fdata ( data
,
256 "BROWSE PACKET: \n Type=[B] (LocalMasterAnnouncement) \n UpdateCount=[w] \n Res1=[B] \n AnnounceInterval=[d] \n Name=[n2] \n MajorVersion=[B] \n MinorVersion=[B] \n ServerType=[W] \n ElectionVersion=[w] \n BrowserConstant=[w] \n " ,
261 data
= smb_fdata ( data
,
262 "BROWSE PACKET: \n Type=[B] (HostAnnouncement) \n UpdateCount=[w] \n Res1=[B] \n AnnounceInterval=[d] \n Name=[n2] \n MajorVersion=[B] \n MinorVersion=[B] \n ServerType=[W] \n ElectionVersion=[w] \n BrowserConstant=[w] \n " ,
267 data
= smb_fdata ( data
,
268 "BROWSE PACKET: \n Type=[B] (AnnouncementRequest) \n Flags=[B] \n ReplySystemName=[S] \n " ,
273 data
= smb_fdata ( data
,
274 "BROWSE PACKET: \n Type=[B] (WorkgroupAnnouncement) \n UpdateCount=[w] \n Res1=[B] \n AnnounceInterval=[d] \n Name=[n2] \n MajorVersion=[B] \n MinorVersion=[B] \n ServerType=[W] \n CommentPointer=[W] \n ServerName=[S] \n " ,
279 data
= smb_fdata ( data
,
280 "BROWSE PACKET: \n Type=[B] (ElectionFrame) \n ElectionVersion=[B] \n OSSummary=[W] \n Uptime=[(W, W)] \n ServerName=[S] \n " ,
285 data
= smb_fdata ( data
,
286 "BROWSE PACKET: \n Type=[B] (BecomeBackupBrowser) \n Name=[S] \n " ,
291 data
= smb_fdata ( data
,
292 "BROWSE PACKET: \n Type=[B] (GetBackupList) \n ListCount?=[B] \n Token=[W] \n " ,
297 data
= smb_fdata ( data
,
298 "BROWSE PACKET: \n Type=[B] (BackupListResponse) \n ServerCount?=[B] \n Token=[W] \n *Name=[S] \n " ,
303 data
= smb_fdata ( data
,
304 "BROWSE PACKET: \n Type=[B] (MasterAnnouncement) \n MasterName=[S] \n " ,
309 data
= smb_fdata ( data
,
310 "BROWSE PACKET: \n Type=[B] (ResetBrowser) \n Options=[B] \n " , maxbuf
, unicodestr
);
314 data
= smb_fdata ( data
, "Unknown Browser Frame " , maxbuf
, unicodestr
);
325 print_ipc ( const u_char
* param
, int paramlen
, const u_char
* data
, int datalen
)
328 smb_fdata ( param
, "Command=[w] \n Str1=[S] \n Str2=[S] \n " , param
+ paramlen
,
331 smb_fdata ( data
, "IPC " , data
+ datalen
, unicodestr
);
336 print_trans ( const u_char
* words
, const u_char
* data1
, const u_char
* buf
, const u_char
* maxbuf
)
339 const char * f1
, * f2
, * f3
, * f4
;
340 const u_char
* data
, * param
;
341 const u_char
* w
= words
+ 1 ;
342 int datalen
, paramlen
;
345 TCHECK2 ( w
[ 12 * 2 ], 2 );
346 paramlen
= EXTRACT_LE_16BITS ( w
+ 9 * 2 );
347 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 10 * 2 );
348 datalen
= EXTRACT_LE_16BITS ( w
+ 11 * 2 );
349 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 12 * 2 );
350 f1
= "TotParamCnt=[d] \n TotDataCnt=[d] \n MaxParmCnt=[d] \n MaxDataCnt=[d] \n MaxSCnt=[d] \n TransFlags=[w] \n Res1=[w] \n Res2=[w] \n Res3=[w] \n ParamCnt=[d] \n ParamOff=[d] \n DataCnt=[d] \n DataOff=[d] \n SUCnt=[d] \n " ;
355 TCHECK2 ( w
[ 7 * 2 ], 2 );
356 paramlen
= EXTRACT_LE_16BITS ( w
+ 3 * 2 );
357 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 4 * 2 );
358 datalen
= EXTRACT_LE_16BITS ( w
+ 6 * 2 );
359 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 7 * 2 );
360 f1
= "TotParamCnt=[d] \n TotDataCnt=[d] \n Res1=[d] \n ParamCnt=[d] \n ParamOff=[d] \n Res2=[d] \n DataCnt=[d] \n DataOff=[d] \n Res3=[d] \n Lsetup=[d] \n " ;
366 smb_fdata ( words
+ 1 , f1
, SMBMIN ( words
+ 1 + 2 * words
[ 0 ], maxbuf
),
370 bcc
= EXTRACT_LE_16BITS ( data1
);
371 printf ( "smb_bcc=%u \n " , bcc
);
373 smb_fdata ( data1
+ 2 , f2
, maxbuf
- ( paramlen
+ datalen
), unicodestr
);
375 if ( strcmp (( const char *)( data1
+ 2 ), " \\ MAILSLOT \\ BROWSE" ) == 0 ) {
376 print_browse ( param
, paramlen
, data
, datalen
);
380 if ( strcmp (( const char *)( data1
+ 2 ), " \\ PIPE \\ LANMAN" ) == 0 ) {
381 print_ipc ( param
, paramlen
, data
, datalen
);
386 smb_fdata ( param
, f3
, SMBMIN ( param
+ paramlen
, maxbuf
), unicodestr
);
388 smb_fdata ( data
, f4
, SMBMIN ( data
+ datalen
, maxbuf
), unicodestr
);
398 print_negprot ( const u_char
* words
, const u_char
* data
, const u_char
* buf _U_
, const u_char
* maxbuf
)
401 const char * f1
= NULL
, * f2
= NULL
;
406 f2
= "*|Dialect=[Y] \n " ;
409 f1
= "Core Protocol \n DialectIndex=[d]" ;
411 f1
= "NT1 Protocol \n DialectIndex=[d] \n SecMode=[B] \n MaxMux=[d] \n NumVcs=[d] \n MaxBuffer=[D] \n RawSize=[D] \n SessionKey=[W] \n Capabilities=[W] \n ServerTime=[T3]TimeZone=[d] \n CryptKey=" ;
413 f1
= "Coreplus/Lanman1/Lanman2 Protocol \n DialectIndex=[d] \n SecMode=[w] \n MaxXMit=[d] \n MaxMux=[d] \n MaxVcs=[d] \n BlkMode=[w] \n SessionKey=[W] \n ServerTime=[T1]TimeZone=[d] \n Res=[W] \n CryptKey=" ;
417 smb_fdata ( words
+ 1 , f1
, SMBMIN ( words
+ 1 + wct
* 2 , maxbuf
),
420 print_data ( words
+ 1 , SMBMIN ( wct
* 2 , PTR_DIFF ( maxbuf
, words
+ 1 )));
423 bcc
= EXTRACT_LE_16BITS ( data
);
424 printf ( "smb_bcc=%u \n " , bcc
);
427 smb_fdata ( data
+ 2 , f2
, SMBMIN ( data
+ 2 + EXTRACT_LE_16BITS ( data
),
428 maxbuf
), unicodestr
);
430 print_data ( data
+ 2 , SMBMIN ( EXTRACT_LE_16BITS ( data
), PTR_DIFF ( maxbuf
, data
+ 2 )));
439 print_sesssetup ( const u_char
* words
, const u_char
* data
, const u_char
* buf _U_
, const u_char
* maxbuf
)
442 const char * f1
= NULL
, * f2
= NULL
;
448 f1
= "Com2=[w] \n Off2=[d] \n BufSize=[d] \n MpxMax=[d] \n VcNum=[d] \n SessionKey=[W] \n PassLen=[d] \n CryptLen=[d] \n CryptOff=[d] \n Pass&Name= \n " ;
450 f1
= "Com2=[B] \n Res1=[B] \n Off2=[d] \n MaxBuffer=[d] \n MaxMpx=[d] \n VcNumber=[d] \n SessionKey=[W] \n CaseInsensitivePasswordLength=[d] \n CaseSensitivePasswordLength=[d] \n Res=[W] \n Capabilities=[W] \n Pass1&Pass2&Account&Domain&OS&LanMan= \n " ;
453 f1
= "Com2=[w] \n Off2=[d] \n Action=[w] \n " ;
454 } else if ( wct
== 13 ) {
455 f1
= "Com2=[B] \n Res=[B] \n Off2=[d] \n Action=[w] \n " ;
456 f2
= "NativeOS=[S] \n NativeLanMan=[S] \n PrimaryDomain=[S] \n " ;
461 smb_fdata ( words
+ 1 , f1
, SMBMIN ( words
+ 1 + wct
* 2 , maxbuf
),
464 print_data ( words
+ 1 , SMBMIN ( wct
* 2 , PTR_DIFF ( maxbuf
, words
+ 1 )));
467 bcc
= EXTRACT_LE_16BITS ( data
);
468 printf ( "smb_bcc=%u \n " , bcc
);
471 smb_fdata ( data
+ 2 , f2
, SMBMIN ( data
+ 2 + EXTRACT_LE_16BITS ( data
),
472 maxbuf
), unicodestr
);
474 print_data ( data
+ 2 , SMBMIN ( EXTRACT_LE_16BITS ( data
), PTR_DIFF ( maxbuf
, data
+ 2 )));
483 print_lockingandx ( const u_char
* words
, const u_char
* data
, const u_char
* buf _U_
, const u_char
* maxbuf
)
486 const u_char
* maxwords
;
487 const char * f1
= NULL
, * f2
= NULL
;
492 f1
= "Com2=[w] \n Off2=[d] \n Handle=[d] \n LockType=[w] \n TimeOut=[D] \n UnlockCount=[d] \n LockCount=[d] \n " ;
495 f2
= "*Process=[d] \n [P2]Offset=[M] \n Length=[M] \n " ;
497 f2
= "*Process=[d] \n Offset=[D] \n Length=[D] \n " ;
499 f1
= "Com2=[w] \n Off2=[d] \n " ;
502 maxwords
= SMBMIN ( words
+ 1 + wct
* 2 , maxbuf
);
504 smb_fdata ( words
+ 1 , f1
, maxwords
, unicodestr
);
507 bcc
= EXTRACT_LE_16BITS ( data
);
508 printf ( "smb_bcc=%u \n " , bcc
);
511 smb_fdata ( data
+ 2 , f2
, SMBMIN ( data
+ 2 + EXTRACT_LE_16BITS ( data
),
512 maxbuf
), unicodestr
);
514 print_data ( data
+ 2 , SMBMIN ( EXTRACT_LE_16BITS ( data
), PTR_DIFF ( maxbuf
, data
+ 2 )));
523 static struct smbfns smb_fns
[] = {
524 { - 1 , "SMBunknown" , 0 , DEFDESCRIPT
},
526 { SMBtcon
, "SMBtcon" , 0 ,
527 { NULL
, "Path=[Z] \n Password=[Z] \n Device=[Z] \n " ,
528 "MaxXmit=[d] \n TreeId=[d] \n " , NULL
,
531 { SMBtdis
, "SMBtdis" , 0 , DEFDESCRIPT
},
532 { SMBexit
, "SMBexit" , 0 , DEFDESCRIPT
},
533 { SMBioctl
, "SMBioctl" , 0 , DEFDESCRIPT
},
535 { SMBecho
, "SMBecho" , 0 ,
536 { "ReverbCount=[d] \n " , NULL
,
537 "SequenceNum=[d] \n " , NULL
,
540 { SMBulogoffX
, "SMBulogoffX" , FLG_CHAIN
, DEFDESCRIPT
},
542 { SMBgetatr
, "SMBgetatr" , 0 ,
543 { NULL
, "Path=[Z] \n " ,
544 "Attribute=[A] \n Time=[T2]Size=[D] \n Res=([w,w,w,w,w]) \n " , NULL
,
547 { SMBsetatr
, "SMBsetatr" , 0 ,
548 { "Attribute=[A] \n Time=[T2]Res=([w,w,w,w,w]) \n " , "Path=[Z] \n " ,
549 NULL
, NULL
, NULL
} },
551 { SMBchkpth
, "SMBchkpth" , 0 ,
552 { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
554 { SMBsearch
, "SMBsearch" , 0 ,
555 { "Count=[d] \n Attrib=[A] \n " ,
556 "Path=[Z] \n BlkType=[B] \n BlkLen=[d] \n |Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n Res2=[W] \n " ,
558 "BlkType=[B] \n BlkLen=[d] \n * \n Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n Res2=[W] \n Attrib=[a] \n Time=[T1]Size=[D] \n Name=[s13] \n " ,
561 { SMBopen
, "SMBopen" , 0 ,
562 { "Mode=[w] \n Attribute=[A] \n " , "Path=[Z] \n " ,
563 "Handle=[d] \n OAttrib=[A] \n Time=[T2]Size=[D] \n Access=[w] \n " ,
566 { SMBcreate
, "SMBcreate" , 0 ,
567 { "Attrib=[A] \n Time=[T2]" , "Path=[Z] \n " , "Handle=[d] \n " , NULL
, NULL
} },
569 { SMBmknew
, "SMBmknew" , 0 ,
570 { "Attrib=[A] \n Time=[T2]" , "Path=[Z] \n " , "Handle=[d] \n " , NULL
, NULL
} },
572 { SMBunlink
, "SMBunlink" , 0 ,
573 { "Attrib=[A] \n " , "Path=[Z] \n " , NULL
, NULL
, NULL
} },
575 { SMBread
, "SMBread" , 0 ,
576 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
577 "Count=[d] \n Res=([w,w,w,w]) \n " , NULL
, NULL
} },
579 { SMBwrite
, "SMBwrite" , 0 ,
580 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
581 "Count=[d] \n " , NULL
, NULL
} },
583 { SMBclose
, "SMBclose" , 0 ,
584 { "Handle=[d] \n Time=[T2]" , NULL
, NULL
, NULL
, NULL
} },
586 { SMBmkdir
, "SMBmkdir" , 0 ,
587 { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
589 { SMBrmdir
, "SMBrmdir" , 0 ,
590 { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
592 { SMBdskattr
, "SMBdskattr" , 0 ,
594 "TotalUnits=[d] \n BlocksPerUnit=[d] \n BlockSize=[d] \n FreeUnits=[d] \n Media=[w] \n " ,
598 { "Attrib=[A] \n " , "OldPath=[Z] \n NewPath=[Z] \n " , NULL
, NULL
, NULL
} },
601 * this is a Pathworks specific call, allowing the
602 * changing of the root path
604 { pSETDIR
, "SMBsetdir" , 0 , { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
606 { SMBlseek
, "SMBlseek" , 0 ,
607 { "Handle=[d] \n Mode=[w] \n Offset=[D] \n " , "Offset=[D] \n " , NULL
, NULL
, NULL
} },
609 { SMBflush
, "SMBflush" , 0 , { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
611 { SMBsplopen
, "SMBsplopen" , 0 ,
612 { "SetupLen=[d] \n Mode=[w] \n " , "Ident=[Z] \n " , "Handle=[d] \n " ,
615 { SMBsplclose
, "SMBsplclose" , 0 ,
616 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
618 { SMBsplretq
, "SMBsplretq" , 0 ,
619 { "MaxCount=[d] \n StartIndex=[d] \n " , NULL
,
620 "Count=[d] \n Index=[d] \n " ,
621 "*Time=[T2]Status=[B] \n JobID=[d] \n Size=[D] \n Res=[B]Name=[s16] \n " ,
624 { SMBsplwr
, "SMBsplwr" , 0 ,
625 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
627 { SMBlock
, "SMBlock" , 0 ,
628 { "Handle=[d] \n Count=[D] \n Offset=[D] \n " , NULL
, NULL
, NULL
, NULL
} },
630 { SMBunlock
, "SMBunlock" , 0 ,
631 { "Handle=[d] \n Count=[D] \n Offset=[D] \n " , NULL
, NULL
, NULL
, NULL
} },
633 /* CORE+ PROTOCOL FOLLOWS */
635 { SMBreadbraw
, "SMBreadbraw" , 0 ,
636 { "Handle=[d] \n Offset=[D] \n MaxCount=[d] \n MinCount=[d] \n TimeOut=[D] \n Res=[d] \n " ,
637 NULL
, NULL
, NULL
, NULL
} },
639 { SMBwritebraw
, "SMBwritebraw" , 0 ,
640 { "Handle=[d] \n TotalCount=[d] \n Res=[w] \n Offset=[D] \n TimeOut=[D] \n WMode=[w] \n Res2=[W] \n |DataSize=[d] \n DataOff=[d] \n " ,
641 NULL
, "WriteRawAck" , NULL
, NULL
} },
643 { SMBwritec
, "SMBwritec" , 0 ,
644 { NULL
, NULL
, "Count=[d] \n " , NULL
, NULL
} },
646 { SMBwriteclose
, "SMBwriteclose" , 0 ,
647 { "Handle=[d] \n Count=[d] \n Offset=[D] \n Time=[T2]Res=([w,w,w,w,w,w])" ,
648 NULL
, "Count=[d] \n " , NULL
, NULL
} },
650 { SMBlockread
, "SMBlockread" , 0 ,
651 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
652 "Count=[d] \n Res=([w,w,w,w]) \n " , NULL
, NULL
} },
654 { SMBwriteunlock
, "SMBwriteunlock" , 0 ,
655 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
656 "Count=[d] \n " , NULL
, NULL
} },
658 { SMBreadBmpx
, "SMBreadBmpx" , 0 ,
659 { "Handle=[d] \n Offset=[D] \n MaxCount=[d] \n MinCount=[d] \n TimeOut=[D] \n Res=[w] \n " ,
661 "Offset=[D] \n TotCount=[d] \n Remaining=[d] \n Res=([w,w]) \n DataSize=[d] \n DataOff=[d] \n " ,
664 { SMBwriteBmpx
, "SMBwriteBmpx" , 0 ,
665 { "Handle=[d] \n TotCount=[d] \n Res=[w] \n Offset=[D] \n TimeOut=[D] \n WMode=[w] \n Res2=[W] \n DataSize=[d] \n DataOff=[d] \n " , NULL
,
666 "Remaining=[d] \n " , NULL
, NULL
} },
668 { SMBwriteBs
, "SMBwriteBs" , 0 ,
669 { "Handle=[d] \n TotCount=[d] \n Offset=[D] \n Res=[W] \n DataSize=[d] \n DataOff=[d] \n " ,
670 NULL
, "Count=[d] \n " , NULL
, NULL
} },
672 { SMBsetattrE
, "SMBsetattrE" , 0 ,
673 { "Handle=[d] \n CreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]" , NULL
,
674 NULL
, NULL
, NULL
} },
676 { SMBgetattrE
, "SMBgetattrE" , 0 ,
677 { "Handle=[d] \n " , NULL
,
678 "CreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]Size=[D] \n AllocSize=[D] \n Attribute=[A] \n " ,
681 { SMBtranss
, "SMBtranss" , 0 , DEFDESCRIPT
},
682 { SMBioctls
, "SMBioctls" , 0 , DEFDESCRIPT
},
684 { SMBcopy
, "SMBcopy" , 0 ,
685 { "TreeID2=[d] \n OFun=[w] \n Flags=[w] \n " , "Path=[S] \n NewPath=[S] \n " ,
686 "CopyCount=[d] \n " , "|ErrStr=[S] \n " , NULL
} },
688 { SMBmove
, "SMBmove" , 0 ,
689 { "TreeID2=[d] \n OFun=[w] \n Flags=[w] \n " , "Path=[S] \n NewPath=[S] \n " ,
690 "MoveCount=[d] \n " , "|ErrStr=[S] \n " , NULL
} },
692 { SMBopenX
, "SMBopenX" , FLG_CHAIN
,
693 { "Com2=[w] \n Off2=[d] \n Flags=[w] \n Mode=[w] \n SearchAttrib=[A] \n Attrib=[A] \n Time=[T2]OFun=[w] \n Size=[D] \n TimeOut=[D] \n Res=[W] \n " ,
695 "Com2=[w] \n Off2=[d] \n Handle=[d] \n Attrib=[A] \n Time=[T2]Size=[D] \n Access=[w] \n Type=[w] \n State=[w] \n Action=[w] \n FileID=[W] \n Res=[w] \n " ,
698 { SMBreadX
, "SMBreadX" , FLG_CHAIN
,
699 { "Com2=[w] \n Off2=[d] \n Handle=[d] \n Offset=[D] \n MaxCount=[d] \n MinCount=[d] \n TimeOut=[D] \n CountLeft=[d] \n " ,
701 "Com2=[w] \n Off2=[d] \n Remaining=[d] \n Res=[W] \n DataSize=[d] \n DataOff=[d] \n Res=([w,w,w,w]) \n " ,
704 { SMBwriteX
, "SMBwriteX" , FLG_CHAIN
,
705 { "Com2=[w] \n Off2=[d] \n Handle=[d] \n Offset=[D] \n TimeOut=[D] \n WMode=[w] \n CountLeft=[d] \n Res=[w] \n DataSize=[d] \n DataOff=[d] \n " ,
707 "Com2=[w] \n Off2=[d] \n Count=[d] \n Remaining=[d] \n Res=[W] \n " ,
710 { SMBffirst
, "SMBffirst" , 0 ,
711 { "Count=[d] \n Attrib=[A] \n " ,
712 "Path=[Z] \n BlkType=[B] \n BlkLen=[d] \n |Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n " ,
714 "BlkType=[B] \n BlkLen=[d] \n * \n Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n Res2=[W] \n Attrib=[a] \n Time=[T1]Size=[D] \n Name=[s13] \n " ,
717 { SMBfunique
, "SMBfunique" , 0 ,
718 { "Count=[d] \n Attrib=[A] \n " ,
719 "Path=[Z] \n BlkType=[B] \n BlkLen=[d] \n |Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n " ,
721 "BlkType=[B] \n BlkLen=[d] \n * \n Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n Res2=[W] \n Attrib=[a] \n Time=[T1]Size=[D] \n Name=[s13] \n " ,
724 { SMBfclose
, "SMBfclose" , 0 ,
725 { "Count=[d] \n Attrib=[A] \n " ,
726 "Path=[Z] \n BlkType=[B] \n BlkLen=[d] \n |Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n " ,
728 "BlkType=[B] \n BlkLen=[d] \n * \n Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n Res2=[W] \n Attrib=[a] \n Time=[T1]Size=[D] \n Name=[s13] \n " ,
731 { SMBfindnclose
, "SMBfindnclose" , 0 ,
732 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
734 { SMBfindclose
, "SMBfindclose" , 0 ,
735 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
737 { SMBsends
, "SMBsends" , 0 ,
738 { NULL
, "Source=[Z] \n Dest=[Z] \n " , NULL
, NULL
, NULL
} },
740 { SMBsendstrt
, "SMBsendstrt" , 0 ,
741 { NULL
, "Source=[Z] \n Dest=[Z] \n " , "GroupID=[d] \n " , NULL
, NULL
} },
743 { SMBsendend
, "SMBsendend" , 0 ,
744 { "GroupID=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
746 { SMBsendtxt
, "SMBsendtxt" , 0 ,
747 { "GroupID=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
749 { SMBsendb
, "SMBsendb" , 0 ,
750 { NULL
, "Source=[Z] \n Dest=[Z] \n " , NULL
, NULL
, NULL
} },
752 { SMBfwdname
, "SMBfwdname" , 0 , DEFDESCRIPT
},
753 { SMBcancelf
, "SMBcancelf" , 0 , DEFDESCRIPT
},
754 { SMBgetmac
, "SMBgetmac" , 0 , DEFDESCRIPT
},
756 { SMBnegprot
, "SMBnegprot" , 0 ,
757 { NULL
, NULL
, NULL
, NULL
, print_negprot
} },
759 { SMBsesssetupX
, "SMBsesssetupX" , FLG_CHAIN
,
760 { NULL
, NULL
, NULL
, NULL
, print_sesssetup
} },
762 { SMBtconX
, "SMBtconX" , FLG_CHAIN
,
763 { "Com2=[w] \n Off2=[d] \n Flags=[w] \n PassLen=[d] \n Passwd&Path&Device= \n " ,
764 NULL
, "Com2=[w] \n Off2=[d] \n " , "ServiceType=[R] \n " , NULL
} },
766 { SMBlockingX
, "SMBlockingX" , FLG_CHAIN
,
767 { NULL
, NULL
, NULL
, NULL
, print_lockingandx
} },
769 { SMBtrans2
, "SMBtrans2" , 0 , { NULL
, NULL
, NULL
, NULL
, print_trans2
} },
771 { SMBtranss2
, "SMBtranss2" , 0 , DEFDESCRIPT
},
772 { SMBctemp
, "SMBctemp" , 0 , DEFDESCRIPT
},
773 { SMBreadBs
, "SMBreadBs" , 0 , DEFDESCRIPT
},
774 { SMBtrans
, "SMBtrans" , 0 , { NULL
, NULL
, NULL
, NULL
, print_trans
} },
776 { SMBnttrans
, "SMBnttrans" , 0 , DEFDESCRIPT
},
777 { SMBnttranss
, "SMBnttranss" , 0 , DEFDESCRIPT
},
779 { SMBntcreateX
, "SMBntcreateX" , FLG_CHAIN
,
780 { "Com2=[w] \n Off2=[d] \n Res=[b] \n NameLen=[ld] \n Flags=[W] \n RootDirectoryFid=[D] \n AccessMask=[W] \n AllocationSize=[L] \n ExtFileAttributes=[W] \n ShareAccess=[W] \n CreateDisposition=[W] \n CreateOptions=[W] \n ImpersonationLevel=[W] \n SecurityFlags=[b] \n " ,
782 "Com2=[w] \n Off2=[d] \n OplockLevel=[b] \n Fid=[d] \n CreateAction=[W] \n CreateTime=[T3]LastAccessTime=[T3]LastWriteTime=[T3]ChangeTime=[T3]ExtFileAttributes=[W] \n AllocationSize=[L] \n EndOfFile=[L] \n FileType=[w] \n DeviceState=[w] \n Directory=[b] \n " ,
785 { SMBntcancel
, "SMBntcancel" , 0 , DEFDESCRIPT
},
787 { - 1 , NULL
, 0 , DEFDESCRIPT
}
792 * print a SMB message
795 print_smb ( const u_char
* buf
, const u_char
* maxbuf
)
801 const u_char
* words
, * maxwords
, * data
;
803 const char * fmt_smbheader
=
804 "[P4]SMB Command = [B] \n Error class = [BP1] \n Error code = [d] \n Flags1 = [B] \n Flags2 = [B][P13] \n Tree ID = [d] \n Proc ID = [d] \n UID = [d] \n MID = [d] \n Word Count = [b] \n " ;
808 request
= ( buf
[ 9 ] & 0x80 ) ? 0 : 1 ;
809 flags2
= EXTRACT_LE_16BITS (& buf
[ 10 ]);
810 unicodestr
= flags2
& 0x8000 ;
811 nterrcodes
= flags2
& 0x4000 ;
816 fn
= smbfind ( command
, smb_fns
);
821 printf ( "SMB PACKET: %s (%s) \n " , fn
-> name
, request
? "REQUEST" : "REPLY" );
826 /* print out the header */
827 smb_fdata ( buf
, fmt_smbheader
, buf
+ 33 , unicodestr
);
830 nterror
= EXTRACT_LE_32BITS (& buf
[ 5 ]);
832 printf ( "NTError = %s \n " , nt_errstr ( nterror
));
835 printf ( "SMBError = %s \n " , smb_errstr ( buf
[ 5 ], EXTRACT_LE_16BITS (& buf
[ 7 ])));
846 words
= buf
+ smboffset
;
849 data
= words
+ 1 + wct
* 2 ;
850 maxwords
= SMBMIN ( data
, maxbuf
);
853 f1
= fn
-> descript
. req_f1
;
854 f2
= fn
-> descript
. req_f2
;
856 f1
= fn
-> descript
. rep_f1
;
857 f2
= fn
-> descript
. rep_f2
;
861 (* fn
-> descript
. fn
)( words
, data
, buf
, maxbuf
);
865 smb_fdata ( words
+ 1 , f1
, words
+ 1 + wct
* 2 , unicodestr
);
870 for ( i
= 0 ; & words
[ 1 + 2 * i
] < maxwords
; i
++) {
871 TCHECK2 ( words
[ 1 + 2 * i
], 2 );
872 v
= EXTRACT_LE_16BITS ( words
+ 1 + 2 * i
);
873 printf ( "smb_vwv[%d]=%d (0x%X) \n " , i
, v
, v
);
879 bcc
= EXTRACT_LE_16BITS ( data
);
880 printf ( "smb_bcc=%u \n " , bcc
);
883 smb_fdata ( data
+ 2 , f2
, data
+ 2 + bcc
, unicodestr
);
886 printf ( "smb_buf[]= \n " );
887 print_data ( data
+ 2 , SMBMIN ( bcc
, PTR_DIFF ( maxbuf
, data
+ 2 )));
892 if (( fn
-> flags
& FLG_CHAIN
) == 0 )
900 TCHECK2 ( words
[ 3 ], 2 );
901 newsmboffset
= EXTRACT_LE_16BITS ( words
+ 3 );
903 fn
= smbfind ( command
, smb_fns
);
905 printf ( " \n SMB PACKET: %s (%s) (CHAINED) \n " ,
906 fn
-> name
, request
? "REQUEST" : "REPLY" );
907 if ( newsmboffset
<= smboffset
) {
908 printf ( "Bad andX offset: %u <= %u \n " , newsmboffset
, smboffset
);
911 smboffset
= newsmboffset
;
923 * print a NBT packet received across tcp on port 139
926 nbt_tcp_print ( const u_char
* data
, int length
)
931 const u_char
* maxbuf
;
937 caplen
= snapend
- data
;
940 maxbuf
= data
+ caplen
;
942 nbt_len
= EXTRACT_16BITS ( data
+ 2 );
949 printf ( " NBT Session Packet: " );
952 printf ( "Session Message" );
956 printf ( "Session Request" );
960 printf ( "Session Granted" );
975 printf ( "Session Reject, " );
978 printf ( "Not listening on called name" );
981 printf ( "Not listening for calling name" );
984 printf ( "Called name not present" );
987 printf ( "Called name present, but insufficient resources" );
990 printf ( "Unspecified error 0x%X" , ecode
);
997 printf ( "Session Keepalive" );
1001 data
= smb_fdata ( data
, "Unknown packet type [rB]" , maxbuf
, 0 );
1005 printf ( " \n >>> NBT Session Packet \n " );
1008 data
= smb_fdata ( data
, "[P1]NBT Session Message \n Flags=[B] \n Length=[rd] \n " ,
1012 if ( nbt_len
>= 4 && caplen
>= 4 && memcmp ( data
, " \377 SMB" , 4 ) == 0 ) {
1013 if (( int ) nbt_len
> caplen
) {
1014 if (( int ) nbt_len
> length
)
1015 printf ( "WARNING: Packet is continued in later TCP segments \n " );
1017 printf ( "WARNING: Short packet. Try increasing the snap length by %d \n " ,
1020 print_smb ( data
, maxbuf
> data
+ nbt_len
? data
+ nbt_len
: maxbuf
);
1022 printf ( "Session packet:(raw data or continuation?) \n " );
1026 data
= smb_fdata ( data
,
1027 "[P1]NBT Session Request \n Flags=[B] \n Length=[rd] \n Destination=[n1] \n Source=[n1] \n " ,
1032 data
= smb_fdata ( data
, "[P1]NBT Session Granted \n Flags=[B] \n Length=[rd] \n " , maxbuf
, 0 );
1037 const u_char
* origdata
;
1041 data
= smb_fdata ( data
, "[P1]NBT SessionReject \n Flags=[B] \n Length=[rd] \n Reason=[B] \n " ,
1045 if ( nbt_len
>= 1 && caplen
>= 1 ) {
1046 ecode
= origdata
[ 4 ];
1049 printf ( "Not listening on called name \n " );
1052 printf ( "Not listening for calling name \n " );
1055 printf ( "Called name not present \n " );
1058 printf ( "Called name present, but insufficient resources \n " );
1061 printf ( "Unspecified error 0x%X \n " , ecode
);
1069 data
= smb_fdata ( data
, "[P1]NBT Session Keepalive \n Flags=[B] \n Length=[rd] \n " , maxbuf
, 0 );
1073 data
= smb_fdata ( data
, "NBT - Unknown packet type \n Type=[B] \n " , maxbuf
, 0 );
1087 * print a NBT packet received across udp on port 137
1090 nbt_udp137_print ( const u_char
* data
, int length
)
1092 const u_char
* maxbuf
= data
+ length
;
1093 int name_trn_id
, response
, opcode
, nm_flags
, rcode
;
1094 int qdcount
, ancount
, nscount
, arcount
;
1095 const char * opcodestr
;
1099 TCHECK2 ( data
[ 10 ], 2 );
1100 name_trn_id
= EXTRACT_16BITS ( data
);
1101 response
= ( data
[ 2 ] >> 7 );
1102 opcode
= ( data
[ 2 ] >> 3 ) & 0xF ;
1103 nm_flags
= (( data
[ 2 ] & 0x7 ) << 4 ) + ( data
[ 3 ] >> 4 );
1104 rcode
= data
[ 3 ] & 0xF ;
1105 qdcount
= EXTRACT_16BITS ( data
+ 4 );
1106 ancount
= EXTRACT_16BITS ( data
+ 6 );
1107 nscount
= EXTRACT_16BITS ( data
+ 8 );
1108 arcount
= EXTRACT_16BITS ( data
+ 10 );
1117 printf ( "NBT UDP PACKET(137): " );
1120 case 0 : opcodestr
= "QUERY" ; break ;
1121 case 5 : opcodestr
= "REGISTRATION" ; break ;
1122 case 6 : opcodestr
= "RELEASE" ; break ;
1123 case 7 : opcodestr
= "WACK" ; break ;
1124 case 8 : opcodestr
= "REFRESH(8)" ; break ;
1125 case 9 : opcodestr
= "REFRESH" ; break ;
1126 case 15 : opcodestr
= "MULTIHOMED REGISTRATION" ; break ;
1127 default : opcodestr
= "OPUNKNOWN" ; break ;
1129 printf ( "%s" , opcodestr
);
1132 printf ( "; NEGATIVE" );
1134 printf ( "; POSITIVE" );
1138 printf ( "; RESPONSE" );
1140 printf ( "; REQUEST" );
1143 printf ( "; BROADCAST" );
1145 printf ( "; UNICAST" );
1150 printf ( " \n TrnID=0x%X \n OpCode=%d \n NmFlags=0x%X \n Rcode=%d \n QueryCount=%d \n AnswerCount=%d \n AuthorityCount=%d \n AddressRecCount=%d \n " ,
1151 name_trn_id
, opcode
, nm_flags
, rcode
, qdcount
, ancount
, nscount
,
1156 total
= ancount
+ nscount
+ arcount
;
1158 if ( qdcount
> 100 || total
> 100 ) {
1159 printf ( "Corrupt packet?? \n " );
1164 printf ( "QuestionRecords: \n " );
1165 for ( i
= 0 ; i
< qdcount
; i
++) {
1167 "|Name=[n1] \n QuestionType=[rw] \n QuestionClass=[rw] \n #" ,
1175 printf ( " \n ResourceRecords: \n " );
1176 for ( i
= 0 ; i
< total
; i
++) {
1180 p
= smb_fdata ( p
, "Name=[n1] \n #" , maxbuf
, 0 );
1183 restype
= EXTRACT_16BITS ( p
);
1184 p
= smb_fdata ( p
, "ResType=[rw] \n ResClass=[rw] \n TTL=[rD] \n " , p
+ 8 , 0 );
1187 rdlen
= EXTRACT_16BITS ( p
);
1188 printf ( "ResourceLength=%d \n ResourceData= \n " , rdlen
);
1191 p
= smb_fdata ( p
, "AddrType=[rw] \n Address=[b.b.b.b] \n " , p
+ rdlen
, 0 );
1195 if ( restype
== 0x21 ) {
1200 p
= smb_fdata ( p
, "NumNames=[B] \n " , p
+ 1 , 0 );
1203 while ( numnames
--) {
1204 p
= smb_fdata ( p
, "Name=[n2] \t #" , maxbuf
, 0 );
1210 switch ( p
[ 0 ] & 0x60 ) {
1211 case 0x00 : printf ( "B " ); break ;
1212 case 0x20 : printf ( "P " ); break ;
1213 case 0x40 : printf ( "M " ); break ;
1214 case 0x60 : printf ( "_ " ); break ;
1217 printf ( "<DEREGISTERING> " );
1219 printf ( "<CONFLICT> " );
1221 printf ( "<ACTIVE> " );
1223 printf ( "<PERMANENT> " );
1228 print_data ( p
, min ( rdlen
, length
- ( p
- data
)));
1236 smb_fdata ( p
, "AdditionalData: \n " , maxbuf
, 0 );
1248 * Print an SMB-over-TCP packet received across tcp on port 445
1251 smb_tcp_print ( const u_char
* data
, int length
)
1255 const u_char
* maxbuf
;
1261 caplen
= snapend
- data
;
1264 maxbuf
= data
+ caplen
;
1265 smb_len
= EXTRACT_24BITS ( data
+ 1 );
1272 if ( smb_len
>= 4 && caplen
>= 4 && memcmp ( data
, " \377 SMB" , 4 ) == 0 ) {
1273 if (( int ) smb_len
> caplen
) {
1274 if (( int ) smb_len
> length
)
1275 printf ( "WARNING: Packet is continued in later TCP segments \n " );
1277 printf ( "WARNING: Short packet. Try increasing the snap length by %d \n " ,
1280 print_smb ( data
, maxbuf
> data
+ smb_len
? data
+ smb_len
: maxbuf
);
1282 printf ( "SMB-over-TCP packet:(raw data or continuation?) \n " );
1290 * print a NBT packet received across udp on port 138
1293 nbt_udp138_print ( const u_char
* data
, int length
)
1295 const u_char
* maxbuf
= data
+ length
;
1297 if ( maxbuf
> snapend
)
1304 printf ( "NBT UDP PACKET(138)" );
1308 data
= smb_fdata ( data
,
1309 " \n >>> NBT UDP PACKET(138) Res=[rw] ID=[rw] IP=[b.b.b.b] Port=[rd] Length=[rd] Res2=[rw] \n SourceName=[n1] \n DestName=[n1] \n #" ,
1313 /* If there isn't enough data for "\377SMB", don't check for it. */
1314 if (& data
[ 3 ] >= maxbuf
)
1317 if ( memcmp ( data
, " \377 SMB" , 4 ) == 0 )
1318 print_smb ( data
, maxbuf
);
1327 print netbeui frames
1329 struct nbf_strings
{
1331 const char * nonverbose
;
1332 const char * verbose
;
1333 } nbf_strings
[ 0x20 ] = {
1334 { "Add Group Name Query" , ", [P23]Name to add=[n2]#" ,
1335 "[P5]ResponseCorrelator=[w] \n [P16]Name to add=[n2] \n " },
1336 { "Add Name Query" , ", [P23]Name to add=[n2]#" ,
1337 "[P5]ResponseCorrelator=[w] \n [P16]Name to add=[n2] \n " },
1338 { "Name In Conflict" , NULL
, NULL
},
1339 { "Status Query" , NULL
, NULL
},
1340 { NULL
, NULL
, NULL
}, /* not used */
1341 { NULL
, NULL
, NULL
}, /* not used */
1342 { NULL
, NULL
, NULL
}, /* not used */
1343 { "Terminate Trace" , NULL
, NULL
},
1345 "[P7]Destination=[n2] \n Source=[n2] \n " },
1346 { "Broadcast Datagram" , NULL
,
1347 "[P7]Destination=[n2] \n Source=[n2] \n " },
1348 { "Name Query" , ", [P7]Name=[n2]#" ,
1349 "[P1]SessionNumber=[B] \n NameType=[B][P2] \n ResponseCorrelator=[w] \n Name=[n2] \n Name of sender=[n2] \n " },
1350 { NULL
, NULL
, NULL
}, /* not used */
1351 { NULL
, NULL
, NULL
}, /* not used */
1352 { "Add Name Response" , ", [P1]GroupName=[w] [P4]Destination=[n2] Source=[n2]#" ,
1353 "AddNameInProcess=[B] \n GroupName=[w] \n TransmitCorrelator=[w][P2] \n Destination=[n2] \n Source=[n2] \n " },
1354 { "Name Recognized" , NULL
,
1355 "[P1]Data2=[w] \n TransmitCorrelator=[w] \n ResponseCorelator=[w] \n Destination=[n2] \n Source=[n2] \n " },
1356 { "Status Response" , NULL
, NULL
},
1357 { NULL
, NULL
, NULL
}, /* not used */
1358 { NULL
, NULL
, NULL
}, /* not used */
1359 { NULL
, NULL
, NULL
}, /* not used */
1360 { "Terminate Trace" , NULL
, NULL
},
1362 "[P3]TransmitCorrelator=[w][P2] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1363 { "Data First/Middle" , NULL
,
1364 "Flags=[{RECEIVE_CONTINUE|NO_ACK||PIGGYBACK_ACK_INCLUDED|}] \n ResyncIndicator=[w][P2] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1365 { "Data Only/Last" , NULL
,
1366 "Flags=[{|NO_ACK|PIGGYBACK_ACK_ALLOWED|PIGGYBACK_ACK_INCLUDED|}] \n ResyncIndicator=[w][P2] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1367 { "Session Confirm" , NULL
,
1368 "Data1=[B] \n Data2=[w] \n TransmitCorrelator=[w] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1369 { "Session End" , NULL
,
1370 "[P1]Data2=[w][P4] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1371 { "Session Initialize" , NULL
,
1372 "Data1=[B] \n Data2=[w] \n TransmitCorrelator=[w] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1373 { "No Receive" , NULL
,
1374 "Flags=[{|SEND_NO_ACK}] \n DataBytesAccepted=[b][P4] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1375 { "Receive Outstanding" , NULL
,
1376 "[P1]DataBytesAccepted=[b][P4] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1377 { "Receive Continue" , NULL
,
1378 "[P2]TransmitCorrelator=[w] \n [P2]RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1379 { NULL
, NULL
, NULL
}, /* not used */
1380 { NULL
, NULL
, NULL
}, /* not used */
1381 { "Session Alive" , NULL
, NULL
}
1385 netbeui_print ( u_short control
, const u_char
* data
, int length
)
1387 const u_char
* maxbuf
= data
+ length
;
1390 const u_char
* data2
;
1391 int is_truncated
= 0 ;
1393 if ( maxbuf
> snapend
)
1396 len
= EXTRACT_LE_16BITS ( data
);
1399 if ( data2
>= maxbuf
) {
1407 printf ( "NBF Packet: " );
1408 data
= smb_fdata ( data
, "[P5]#" , maxbuf
, 0 );
1410 printf ( " \n >>> NBF Packet \n Type=0x%X " , control
);
1411 data
= smb_fdata ( data
, "Length=[d] Signature=[w] Command=[B] \n #" , maxbuf
, 0 );
1416 if ( command
> 0x1f || nbf_strings
[ command
]. name
== NULL
) {
1418 data
= smb_fdata ( data
, "Unknown NBF Command#" , data2
, 0 );
1420 data
= smb_fdata ( data
, "Unknown NBF Command \n " , data2
, 0 );
1423 printf ( "%s" , nbf_strings
[ command
]. name
);
1424 if ( nbf_strings
[ command
]. nonverbose
!= NULL
)
1425 data
= smb_fdata ( data
, nbf_strings
[ command
]. nonverbose
, data2
, 0 );
1427 printf ( "%s: \n " , nbf_strings
[ command
]. name
);
1428 if ( nbf_strings
[ command
]. verbose
!= NULL
)
1429 data
= smb_fdata ( data
, nbf_strings
[ command
]. verbose
, data2
, 0 );
1442 /* data2 was past the end of the buffer */
1446 /* If this isn't a command that would contain an SMB message, quit. */
1447 if ( command
!= 0x08 && command
!= 0x09 && command
!= 0x15 &&
1451 /* If there isn't enough data for "\377SMB", don't look for it. */
1452 if (& data2
[ 3 ] >= maxbuf
)
1455 if ( memcmp ( data2
, " \377 SMB" , 4 ) == 0 )
1456 print_smb ( data2
, maxbuf
);
1459 for ( i
= 0 ; i
< 128 ; i
++) {
1460 if (& data2
[ i
+ 3 ] >= maxbuf
)
1462 if ( memcmp (& data2
[ i
], " \377 SMB" , 4 ) == 0 ) {
1463 printf ( "found SMB packet at %d \n " , i
);
1464 print_smb (& data2
[ i
], maxbuf
);
1480 * print IPX-Netbios frames
1483 ipx_netbios_print ( const u_char
* data
, u_int length
)
1486 * this is a hack till I work out how to parse the rest of the
1487 * NetBIOS-over-IPX stuff
1490 const u_char
* maxbuf
;
1492 maxbuf
= data
+ length
;
1493 /* Don't go past the end of the captured data in the packet. */
1494 if ( maxbuf
> snapend
)
1497 for ( i
= 0 ; i
< 128 ; i
++) {
1498 if (& data
[ i
+ 4 ] > maxbuf
)
1500 if ( memcmp (& data
[ i
], " \377 SMB" , 4 ) == 0 ) {
1501 smb_fdata ( data
, " \n >>> IPX transport " , & data
[ i
], 0 );
1502 print_smb (& data
[ i
], maxbuf
);
1509 smb_fdata ( data
, " \n >>> Unknown IPX " , maxbuf
, 0 );