]>
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
13 #include <tcpdump-stdinc.h>
18 #include "interface.h"
22 static const char tstr
[] = "[|SMB]" ;
24 static int request
= 0 ;
25 static int unicodestr
= 0 ;
27 const u_char
* startbuf
= NULL
;
34 void (* fn
)( const u_char
*, const u_char
*, const u_char
*, const u_char
*);
37 struct smbdescriptint
{
42 void (* fn
)( const u_char
*, const u_char
*, int , int );
50 struct smbdescript descript
;
58 struct smbdescriptint descript
;
61 #define DEFDESCRIPT { NULL, NULL, NULL, NULL, NULL }
63 #define FLG_CHAIN (1 << 0)
65 static const struct smbfns
*
66 smbfind ( int id
, const struct smbfns
* list
)
70 for ( sindex
= 0 ; list
[ sindex
]. name
; sindex
++)
71 if ( list
[ sindex
]. id
== id
)
72 return (& list
[ sindex
]);
77 static const struct smbfnsint
*
78 smbfindint ( int id
, const struct smbfnsint
* list
)
82 for ( sindex
= 0 ; list
[ sindex
]. name
; sindex
++)
83 if ( list
[ sindex
]. id
== id
)
84 return (& list
[ sindex
]);
90 trans2_findfirst ( const u_char
* param
, const u_char
* data
, int pcnt
, int dcnt
)
95 fmt
= "Attribute=[A] \n SearchCount=[d] \n Flags=[w] \n Level=[dP4] \n File=[S] \n " ;
97 fmt
= "Handle=[w] \n Count=[d] \n EOS=[w] \n Eoffset=[d] \n LastNameOfs=[w] \n " ;
99 smb_fdata ( param
, fmt
, param
+ pcnt
, unicodestr
);
102 print_data ( data
, dcnt
);
107 trans2_qfsinfo ( const u_char
* param
, const u_char
* data
, int pcnt
, int dcnt
)
109 static int level
= 0 ;
114 level
= EXTRACT_LE_16BITS ( param
);
115 fmt
= "InfoLevel=[d] \n " ;
116 smb_fdata ( param
, fmt
, param
+ pcnt
, unicodestr
);
120 fmt
= "idFileSystem=[W] \n SectorUnit=[D] \n Unit=[D] \n Avail=[D] \n SectorSize=[d] \n " ;
123 fmt
= "CreationTime=[T2]VolNameLength=[lb] \n VolumeLabel=[c] \n " ;
126 fmt
= "Capabilities=[W] \n MaxFileLen=[D] \n VolNameLen=[lD] \n Volume=[C] \n " ;
129 fmt
= "UnknownLevel \n " ;
132 smb_fdata ( data
, fmt
, data
+ dcnt
, unicodestr
);
136 print_data ( data
, dcnt
);
144 static const struct smbfnsint trans2_fns
[] = {
145 { 0 , "TRANSACT2_OPEN" , 0 ,
146 { "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]" ,
148 "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 " ,
150 { 1 , "TRANSACT2_FINDFIRST" , 0 ,
151 { NULL
, NULL
, NULL
, NULL
, trans2_findfirst
}},
152 { 2 , "TRANSACT2_FINDNEXT" , 0 , DEFDESCRIPT
},
153 { 3 , "TRANSACT2_QFSINFO" , 0 ,
154 { NULL
, NULL
, NULL
, NULL
, trans2_qfsinfo
}},
155 { 4 , "TRANSACT2_SETFSINFO" , 0 , DEFDESCRIPT
},
156 { 5 , "TRANSACT2_QPATHINFO" , 0 , DEFDESCRIPT
},
157 { 6 , "TRANSACT2_SETPATHINFO" , 0 , DEFDESCRIPT
},
158 { 7 , "TRANSACT2_QFILEINFO" , 0 , DEFDESCRIPT
},
159 { 8 , "TRANSACT2_SETFILEINFO" , 0 , DEFDESCRIPT
},
160 { 9 , "TRANSACT2_FSCTL" , 0 , DEFDESCRIPT
},
161 { 10 , "TRANSACT2_IOCTL" , 0 , DEFDESCRIPT
},
162 { 11 , "TRANSACT2_FINDNOTIFYFIRST" , 0 , DEFDESCRIPT
},
163 { 12 , "TRANSACT2_FINDNOTIFYNEXT" , 0 , DEFDESCRIPT
},
164 { 13 , "TRANSACT2_MKDIR" , 0 , DEFDESCRIPT
},
165 { - 1 , NULL
, 0 , DEFDESCRIPT
}
170 print_trans2 ( const u_char
* words
, const u_char
* dat
, const u_char
* buf
, const u_char
* maxbuf
)
173 static const struct smbfnsint
* fn
= & trans2_fns
[ 0 ];
174 const u_char
* data
, * param
;
175 const u_char
* w
= words
+ 1 ;
176 const char * f1
= NULL
, * f2
= NULL
;
181 TCHECK2 ( w
[ 14 * 2 ], 2 );
182 pcnt
= EXTRACT_LE_16BITS ( w
+ 9 * 2 );
183 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 10 * 2 );
184 dcnt
= EXTRACT_LE_16BITS ( w
+ 11 * 2 );
185 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 12 * 2 );
186 fn
= smbfindint ( EXTRACT_LE_16BITS ( w
+ 14 * 2 ), trans2_fns
);
189 printf ( "%s \n " , fn
-> name
);
190 printf ( "Trans2Interim \n " );
193 TCHECK2 ( w
[ 7 * 2 ], 2 );
194 pcnt
= EXTRACT_LE_16BITS ( w
+ 3 * 2 );
195 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 4 * 2 );
196 dcnt
= EXTRACT_LE_16BITS ( w
+ 6 * 2 );
197 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 7 * 2 );
200 printf ( "%s param_length=%d data_length=%d \n " , fn
-> name
, pcnt
, dcnt
);
205 "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 " ,
210 "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 " ,
211 words
+ 1 + 14 * 2 , unicodestr
);
213 f1
= fn
-> descript
. req_f1
;
214 f2
= fn
-> descript
. req_f2
;
217 "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 " ,
218 words
+ 1 + 10 * 2 , unicodestr
);
219 f1
= fn
-> descript
. rep_f1
;
220 f2
= fn
-> descript
. rep_f2
;
224 bcc
= EXTRACT_LE_16BITS ( dat
);
225 printf ( "smb_bcc=%u \n " , bcc
);
227 (* fn
-> descript
. fn
)( param
, data
, pcnt
, dcnt
);
229 smb_fdata ( param
, f1
? f1
: "Parameters= \n " , param
+ pcnt
, unicodestr
);
230 smb_fdata ( data
, f2
? f2
: "Data= \n " , data
+ dcnt
, unicodestr
);
240 print_browse ( const u_char
* param
, int paramlen
, const u_char
* data
, int datalen
)
242 const u_char
* maxbuf
= data
+ datalen
;
248 smb_fdata ( param
, "BROWSE PACKET \n |Param " , param
+ paramlen
, unicodestr
);
252 data
= smb_fdata ( data
,
253 "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 " ,
258 data
= smb_fdata ( data
,
259 "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 " ,
264 data
= smb_fdata ( data
,
265 "BROWSE PACKET: \n Type=[B] (AnnouncementRequest) \n Flags=[B] \n ReplySystemName=[S] \n " ,
270 data
= smb_fdata ( data
,
271 "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 " ,
276 data
= smb_fdata ( data
,
277 "BROWSE PACKET: \n Type=[B] (ElectionFrame) \n ElectionVersion=[B] \n OSSummary=[W] \n Uptime=[(W, W)] \n ServerName=[S] \n " ,
282 data
= smb_fdata ( data
,
283 "BROWSE PACKET: \n Type=[B] (BecomeBackupBrowser) \n Name=[S] \n " ,
288 data
= smb_fdata ( data
,
289 "BROWSE PACKET: \n Type=[B] (GetBackupList) \n ListCount?=[B] \n Token=[W] \n " ,
294 data
= smb_fdata ( data
,
295 "BROWSE PACKET: \n Type=[B] (BackupListResponse) \n ServerCount?=[B] \n Token=[W] \n *Name=[S] \n " ,
300 data
= smb_fdata ( data
,
301 "BROWSE PACKET: \n Type=[B] (MasterAnnouncement) \n MasterName=[S] \n " ,
306 data
= smb_fdata ( data
,
307 "BROWSE PACKET: \n Type=[B] (ResetBrowser) \n Options=[B] \n " , maxbuf
, unicodestr
);
311 data
= smb_fdata ( data
, "Unknown Browser Frame " , maxbuf
, unicodestr
);
322 print_ipc ( const u_char
* param
, int paramlen
, const u_char
* data
, int datalen
)
325 smb_fdata ( param
, "Command=[w] \n Str1=[S] \n Str2=[S] \n " , param
+ paramlen
,
328 smb_fdata ( data
, "IPC " , data
+ datalen
, unicodestr
);
333 print_trans ( const u_char
* words
, const u_char
* data1
, const u_char
* buf
, const u_char
* maxbuf
)
336 const char * f1
, * f2
, * f3
, * f4
;
337 const u_char
* data
, * param
;
338 const u_char
* w
= words
+ 1 ;
339 int datalen
, paramlen
;
342 TCHECK2 ( w
[ 12 * 2 ], 2 );
343 paramlen
= EXTRACT_LE_16BITS ( w
+ 9 * 2 );
344 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 10 * 2 );
345 datalen
= EXTRACT_LE_16BITS ( w
+ 11 * 2 );
346 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 12 * 2 );
347 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 " ;
352 TCHECK2 ( w
[ 7 * 2 ], 2 );
353 paramlen
= EXTRACT_LE_16BITS ( w
+ 3 * 2 );
354 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 4 * 2 );
355 datalen
= EXTRACT_LE_16BITS ( w
+ 6 * 2 );
356 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 7 * 2 );
357 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 " ;
363 smb_fdata ( words
+ 1 , f1
, min ( words
+ 1 + 2 * words
[ 0 ], maxbuf
),
367 bcc
= EXTRACT_LE_16BITS ( data1
);
368 printf ( "smb_bcc=%u \n " , bcc
);
370 smb_fdata ( data1
+ 2 , f2
, maxbuf
- ( paramlen
+ datalen
), unicodestr
);
372 if ( strcmp (( const char *)( data1
+ 2 ), " \\ MAILSLOT \\ BROWSE" ) == 0 ) {
373 print_browse ( param
, paramlen
, data
, datalen
);
377 if ( strcmp (( const char *)( data1
+ 2 ), " \\ PIPE \\ LANMAN" ) == 0 ) {
378 print_ipc ( param
, paramlen
, data
, datalen
);
383 smb_fdata ( param
, f3
, min ( param
+ paramlen
, maxbuf
), unicodestr
);
385 smb_fdata ( data
, f4
, min ( data
+ datalen
, maxbuf
), unicodestr
);
395 print_negprot ( const u_char
* words
, const u_char
* data
, const u_char
* buf _U_
, const u_char
* maxbuf
)
398 const char * f1
= NULL
, * f2
= NULL
;
403 f2
= "*|Dialect=[Y] \n " ;
406 f1
= "Core Protocol \n DialectIndex=[d]" ;
408 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=" ;
410 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=" ;
414 smb_fdata ( words
+ 1 , f1
, min ( words
+ 1 + wct
* 2 , maxbuf
),
417 print_data ( words
+ 1 , min ( wct
* 2 , PTR_DIFF ( maxbuf
, words
+ 1 )));
420 bcc
= EXTRACT_LE_16BITS ( data
);
421 printf ( "smb_bcc=%u \n " , bcc
);
424 smb_fdata ( data
+ 2 , f2
, min ( data
+ 2 + EXTRACT_LE_16BITS ( data
),
425 maxbuf
), unicodestr
);
427 print_data ( data
+ 2 , min ( EXTRACT_LE_16BITS ( data
), PTR_DIFF ( maxbuf
, data
+ 2 )));
436 print_sesssetup ( const u_char
* words
, const u_char
* data
, const u_char
* buf _U_
, const u_char
* maxbuf
)
439 const char * f1
= NULL
, * f2
= NULL
;
445 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 " ;
447 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 " ;
450 f1
= "Com2=[w] \n Off2=[d] \n Action=[w] \n " ;
451 } else if ( wct
== 13 ) {
452 f1
= "Com2=[B] \n Res=[B] \n Off2=[d] \n Action=[w] \n " ;
453 f2
= "NativeOS=[S] \n NativeLanMan=[S] \n PrimaryDomain=[S] \n " ;
458 smb_fdata ( words
+ 1 , f1
, min ( words
+ 1 + wct
* 2 , maxbuf
),
461 print_data ( words
+ 1 , min ( wct
* 2 , PTR_DIFF ( maxbuf
, words
+ 1 )));
464 bcc
= EXTRACT_LE_16BITS ( data
);
465 printf ( "smb_bcc=%u \n " , bcc
);
468 smb_fdata ( data
+ 2 , f2
, min ( data
+ 2 + EXTRACT_LE_16BITS ( data
),
469 maxbuf
), unicodestr
);
471 print_data ( data
+ 2 , min ( EXTRACT_LE_16BITS ( data
), PTR_DIFF ( maxbuf
, data
+ 2 )));
480 print_lockingandx ( const u_char
* words
, const u_char
* data
, const u_char
* buf _U_
, const u_char
* maxbuf
)
483 const u_char
* maxwords
;
484 const char * f1
= NULL
, * f2
= NULL
;
489 f1
= "Com2=[w] \n Off2=[d] \n Handle=[d] \n LockType=[w] \n TimeOut=[D] \n UnlockCount=[d] \n LockCount=[d] \n " ;
492 f2
= "*Process=[d] \n [P2]Offset=[M] \n Length=[M] \n " ;
494 f2
= "*Process=[d] \n Offset=[D] \n Length=[D] \n " ;
496 f1
= "Com2=[w] \n Off2=[d] \n " ;
499 maxwords
= min ( words
+ 1 + wct
* 2 , maxbuf
);
501 smb_fdata ( words
+ 1 , f1
, maxwords
, unicodestr
);
504 bcc
= EXTRACT_LE_16BITS ( data
);
505 printf ( "smb_bcc=%u \n " , bcc
);
508 smb_fdata ( data
+ 2 , f2
, min ( data
+ 2 + EXTRACT_LE_16BITS ( data
),
509 maxbuf
), unicodestr
);
511 print_data ( data
+ 2 , min ( EXTRACT_LE_16BITS ( data
), PTR_DIFF ( maxbuf
, data
+ 2 )));
520 static const struct smbfns smb_fns
[] = {
521 { - 1 , "SMBunknown" , 0 , DEFDESCRIPT
},
523 { SMBtcon
, "SMBtcon" , 0 ,
524 { NULL
, "Path=[Z] \n Password=[Z] \n Device=[Z] \n " ,
525 "MaxXmit=[d] \n TreeId=[d] \n " , NULL
,
528 { SMBtdis
, "SMBtdis" , 0 , DEFDESCRIPT
},
529 { SMBexit
, "SMBexit" , 0 , DEFDESCRIPT
},
530 { SMBioctl
, "SMBioctl" , 0 , DEFDESCRIPT
},
532 { SMBecho
, "SMBecho" , 0 ,
533 { "ReverbCount=[d] \n " , NULL
,
534 "SequenceNum=[d] \n " , NULL
,
537 { SMBulogoffX
, "SMBulogoffX" , FLG_CHAIN
, DEFDESCRIPT
},
539 { SMBgetatr
, "SMBgetatr" , 0 ,
540 { NULL
, "Path=[Z] \n " ,
541 "Attribute=[A] \n Time=[T2]Size=[D] \n Res=([w,w,w,w,w]) \n " , NULL
,
544 { SMBsetatr
, "SMBsetatr" , 0 ,
545 { "Attribute=[A] \n Time=[T2]Res=([w,w,w,w,w]) \n " , "Path=[Z] \n " ,
546 NULL
, NULL
, NULL
} },
548 { SMBchkpth
, "SMBchkpth" , 0 ,
549 { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
551 { SMBsearch
, "SMBsearch" , 0 ,
552 { "Count=[d] \n Attrib=[A] \n " ,
553 "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 " ,
555 "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 " ,
558 { SMBopen
, "SMBopen" , 0 ,
559 { "Mode=[w] \n Attribute=[A] \n " , "Path=[Z] \n " ,
560 "Handle=[d] \n OAttrib=[A] \n Time=[T2]Size=[D] \n Access=[w] \n " ,
563 { SMBcreate
, "SMBcreate" , 0 ,
564 { "Attrib=[A] \n Time=[T2]" , "Path=[Z] \n " , "Handle=[d] \n " , NULL
, NULL
} },
566 { SMBmknew
, "SMBmknew" , 0 ,
567 { "Attrib=[A] \n Time=[T2]" , "Path=[Z] \n " , "Handle=[d] \n " , NULL
, NULL
} },
569 { SMBunlink
, "SMBunlink" , 0 ,
570 { "Attrib=[A] \n " , "Path=[Z] \n " , NULL
, NULL
, NULL
} },
572 { SMBread
, "SMBread" , 0 ,
573 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
574 "Count=[d] \n Res=([w,w,w,w]) \n " , NULL
, NULL
} },
576 { SMBwrite
, "SMBwrite" , 0 ,
577 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
578 "Count=[d] \n " , NULL
, NULL
} },
580 { SMBclose
, "SMBclose" , 0 ,
581 { "Handle=[d] \n Time=[T2]" , NULL
, NULL
, NULL
, NULL
} },
583 { SMBmkdir
, "SMBmkdir" , 0 ,
584 { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
586 { SMBrmdir
, "SMBrmdir" , 0 ,
587 { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
589 { SMBdskattr
, "SMBdskattr" , 0 ,
591 "TotalUnits=[d] \n BlocksPerUnit=[d] \n BlockSize=[d] \n FreeUnits=[d] \n Media=[w] \n " ,
595 { "Attrib=[A] \n " , "OldPath=[Z] \n NewPath=[Z] \n " , NULL
, NULL
, NULL
} },
598 * this is a Pathworks specific call, allowing the
599 * changing of the root path
601 { pSETDIR
, "SMBsetdir" , 0 , { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
603 { SMBlseek
, "SMBlseek" , 0 ,
604 { "Handle=[d] \n Mode=[w] \n Offset=[D] \n " , "Offset=[D] \n " , NULL
, NULL
, NULL
} },
606 { SMBflush
, "SMBflush" , 0 , { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
608 { SMBsplopen
, "SMBsplopen" , 0 ,
609 { "SetupLen=[d] \n Mode=[w] \n " , "Ident=[Z] \n " , "Handle=[d] \n " ,
612 { SMBsplclose
, "SMBsplclose" , 0 ,
613 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
615 { SMBsplretq
, "SMBsplretq" , 0 ,
616 { "MaxCount=[d] \n StartIndex=[d] \n " , NULL
,
617 "Count=[d] \n Index=[d] \n " ,
618 "*Time=[T2]Status=[B] \n JobID=[d] \n Size=[D] \n Res=[B]Name=[s16] \n " ,
621 { SMBsplwr
, "SMBsplwr" , 0 ,
622 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
624 { SMBlock
, "SMBlock" , 0 ,
625 { "Handle=[d] \n Count=[D] \n Offset=[D] \n " , NULL
, NULL
, NULL
, NULL
} },
627 { SMBunlock
, "SMBunlock" , 0 ,
628 { "Handle=[d] \n Count=[D] \n Offset=[D] \n " , NULL
, NULL
, NULL
, NULL
} },
630 /* CORE+ PROTOCOL FOLLOWS */
632 { SMBreadbraw
, "SMBreadbraw" , 0 ,
633 { "Handle=[d] \n Offset=[D] \n MaxCount=[d] \n MinCount=[d] \n TimeOut=[D] \n Res=[d] \n " ,
634 NULL
, NULL
, NULL
, NULL
} },
636 { SMBwritebraw
, "SMBwritebraw" , 0 ,
637 { "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 " ,
638 NULL
, "WriteRawAck" , NULL
, NULL
} },
640 { SMBwritec
, "SMBwritec" , 0 ,
641 { NULL
, NULL
, "Count=[d] \n " , NULL
, NULL
} },
643 { SMBwriteclose
, "SMBwriteclose" , 0 ,
644 { "Handle=[d] \n Count=[d] \n Offset=[D] \n Time=[T2]Res=([w,w,w,w,w,w])" ,
645 NULL
, "Count=[d] \n " , NULL
, NULL
} },
647 { SMBlockread
, "SMBlockread" , 0 ,
648 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
649 "Count=[d] \n Res=([w,w,w,w]) \n " , NULL
, NULL
} },
651 { SMBwriteunlock
, "SMBwriteunlock" , 0 ,
652 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
653 "Count=[d] \n " , NULL
, NULL
} },
655 { SMBreadBmpx
, "SMBreadBmpx" , 0 ,
656 { "Handle=[d] \n Offset=[D] \n MaxCount=[d] \n MinCount=[d] \n TimeOut=[D] \n Res=[w] \n " ,
658 "Offset=[D] \n TotCount=[d] \n Remaining=[d] \n Res=([w,w]) \n DataSize=[d] \n DataOff=[d] \n " ,
661 { SMBwriteBmpx
, "SMBwriteBmpx" , 0 ,
662 { "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
,
663 "Remaining=[d] \n " , NULL
, NULL
} },
665 { SMBwriteBs
, "SMBwriteBs" , 0 ,
666 { "Handle=[d] \n TotCount=[d] \n Offset=[D] \n Res=[W] \n DataSize=[d] \n DataOff=[d] \n " ,
667 NULL
, "Count=[d] \n " , NULL
, NULL
} },
669 { SMBsetattrE
, "SMBsetattrE" , 0 ,
670 { "Handle=[d] \n CreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]" , NULL
,
671 NULL
, NULL
, NULL
} },
673 { SMBgetattrE
, "SMBgetattrE" , 0 ,
674 { "Handle=[d] \n " , NULL
,
675 "CreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]Size=[D] \n AllocSize=[D] \n Attribute=[A] \n " ,
678 { SMBtranss
, "SMBtranss" , 0 , DEFDESCRIPT
},
679 { SMBioctls
, "SMBioctls" , 0 , DEFDESCRIPT
},
681 { SMBcopy
, "SMBcopy" , 0 ,
682 { "TreeID2=[d] \n OFun=[w] \n Flags=[w] \n " , "Path=[S] \n NewPath=[S] \n " ,
683 "CopyCount=[d] \n " , "|ErrStr=[S] \n " , NULL
} },
685 { SMBmove
, "SMBmove" , 0 ,
686 { "TreeID2=[d] \n OFun=[w] \n Flags=[w] \n " , "Path=[S] \n NewPath=[S] \n " ,
687 "MoveCount=[d] \n " , "|ErrStr=[S] \n " , NULL
} },
689 { SMBopenX
, "SMBopenX" , FLG_CHAIN
,
690 { "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 " ,
692 "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 " ,
695 { SMBreadX
, "SMBreadX" , FLG_CHAIN
,
696 { "Com2=[w] \n Off2=[d] \n Handle=[d] \n Offset=[D] \n MaxCount=[d] \n MinCount=[d] \n TimeOut=[D] \n CountLeft=[d] \n " ,
698 "Com2=[w] \n Off2=[d] \n Remaining=[d] \n Res=[W] \n DataSize=[d] \n DataOff=[d] \n Res=([w,w,w,w]) \n " ,
701 { SMBwriteX
, "SMBwriteX" , FLG_CHAIN
,
702 { "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 " ,
704 "Com2=[w] \n Off2=[d] \n Count=[d] \n Remaining=[d] \n Res=[W] \n " ,
707 { SMBffirst
, "SMBffirst" , 0 ,
708 { "Count=[d] \n Attrib=[A] \n " ,
709 "Path=[Z] \n BlkType=[B] \n BlkLen=[d] \n |Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n " ,
711 "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 " ,
714 { SMBfunique
, "SMBfunique" , 0 ,
715 { "Count=[d] \n Attrib=[A] \n " ,
716 "Path=[Z] \n BlkType=[B] \n BlkLen=[d] \n |Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n " ,
718 "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 " ,
721 { SMBfclose
, "SMBfclose" , 0 ,
722 { "Count=[d] \n Attrib=[A] \n " ,
723 "Path=[Z] \n BlkType=[B] \n BlkLen=[d] \n |Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n " ,
725 "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 " ,
728 { SMBfindnclose
, "SMBfindnclose" , 0 ,
729 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
731 { SMBfindclose
, "SMBfindclose" , 0 ,
732 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
734 { SMBsends
, "SMBsends" , 0 ,
735 { NULL
, "Source=[Z] \n Dest=[Z] \n " , NULL
, NULL
, NULL
} },
737 { SMBsendstrt
, "SMBsendstrt" , 0 ,
738 { NULL
, "Source=[Z] \n Dest=[Z] \n " , "GroupID=[d] \n " , NULL
, NULL
} },
740 { SMBsendend
, "SMBsendend" , 0 ,
741 { "GroupID=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
743 { SMBsendtxt
, "SMBsendtxt" , 0 ,
744 { "GroupID=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
746 { SMBsendb
, "SMBsendb" , 0 ,
747 { NULL
, "Source=[Z] \n Dest=[Z] \n " , NULL
, NULL
, NULL
} },
749 { SMBfwdname
, "SMBfwdname" , 0 , DEFDESCRIPT
},
750 { SMBcancelf
, "SMBcancelf" , 0 , DEFDESCRIPT
},
751 { SMBgetmac
, "SMBgetmac" , 0 , DEFDESCRIPT
},
753 { SMBnegprot
, "SMBnegprot" , 0 ,
754 { NULL
, NULL
, NULL
, NULL
, print_negprot
} },
756 { SMBsesssetupX
, "SMBsesssetupX" , FLG_CHAIN
,
757 { NULL
, NULL
, NULL
, NULL
, print_sesssetup
} },
759 { SMBtconX
, "SMBtconX" , FLG_CHAIN
,
760 { "Com2=[w] \n Off2=[d] \n Flags=[w] \n PassLen=[d] \n Passwd&Path&Device= \n " ,
761 NULL
, "Com2=[w] \n Off2=[d] \n " , "ServiceType=[R] \n " , NULL
} },
763 { SMBlockingX
, "SMBlockingX" , FLG_CHAIN
,
764 { NULL
, NULL
, NULL
, NULL
, print_lockingandx
} },
766 { SMBtrans2
, "SMBtrans2" , 0 , { NULL
, NULL
, NULL
, NULL
, print_trans2
} },
768 { SMBtranss2
, "SMBtranss2" , 0 , DEFDESCRIPT
},
769 { SMBctemp
, "SMBctemp" , 0 , DEFDESCRIPT
},
770 { SMBreadBs
, "SMBreadBs" , 0 , DEFDESCRIPT
},
771 { SMBtrans
, "SMBtrans" , 0 , { NULL
, NULL
, NULL
, NULL
, print_trans
} },
773 { SMBnttrans
, "SMBnttrans" , 0 , DEFDESCRIPT
},
774 { SMBnttranss
, "SMBnttranss" , 0 , DEFDESCRIPT
},
776 { SMBntcreateX
, "SMBntcreateX" , FLG_CHAIN
,
777 { "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 " ,
779 "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 " ,
782 { SMBntcancel
, "SMBntcancel" , 0 , DEFDESCRIPT
},
784 { - 1 , NULL
, 0 , DEFDESCRIPT
}
789 * print a SMB message
792 print_smb ( const u_char
* buf
, const u_char
* maxbuf
)
798 const u_char
* words
, * maxwords
, * data
;
799 const struct smbfns
* fn
;
800 const char * fmt_smbheader
=
801 "[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 " ;
805 request
= ( buf
[ 9 ] & 0x80 ) ? 0 : 1 ;
806 flags2
= EXTRACT_LE_16BITS (& buf
[ 10 ]);
807 unicodestr
= flags2
& 0x8000 ;
808 nterrcodes
= flags2
& 0x4000 ;
813 fn
= smbfind ( command
, smb_fns
);
818 printf ( "SMB PACKET: %s (%s) \n " , fn
-> name
, request
? "REQUEST" : "REPLY" );
823 /* print out the header */
824 smb_fdata ( buf
, fmt_smbheader
, buf
+ 33 , unicodestr
);
827 nterror
= EXTRACT_LE_32BITS (& buf
[ 5 ]);
829 printf ( "NTError = %s \n " , nt_errstr ( nterror
));
832 printf ( "SMBError = %s \n " , smb_errstr ( buf
[ 5 ], EXTRACT_LE_16BITS (& buf
[ 7 ])));
843 words
= buf
+ smboffset
;
846 data
= words
+ 1 + wct
* 2 ;
847 maxwords
= min ( data
, maxbuf
);
850 f1
= fn
-> descript
. req_f1
;
851 f2
= fn
-> descript
. req_f2
;
853 f1
= fn
-> descript
. rep_f1
;
854 f2
= fn
-> descript
. rep_f2
;
858 (* fn
-> descript
. fn
)( words
, data
, buf
, maxbuf
);
862 smb_fdata ( words
+ 1 , f1
, words
+ 1 + wct
* 2 , unicodestr
);
867 for ( i
= 0 ; & words
[ 1 + 2 * i
] < maxwords
; i
++) {
868 TCHECK2 ( words
[ 1 + 2 * i
], 2 );
869 v
= EXTRACT_LE_16BITS ( words
+ 1 + 2 * i
);
870 printf ( "smb_vwv[%d]=%d (0x%X) \n " , i
, v
, v
);
876 bcc
= EXTRACT_LE_16BITS ( data
);
877 printf ( "smb_bcc=%u \n " , bcc
);
880 smb_fdata ( data
+ 2 , f2
, data
+ 2 + bcc
, unicodestr
);
883 printf ( "smb_buf[]= \n " );
884 print_data ( data
+ 2 , min ( bcc
, PTR_DIFF ( maxbuf
, data
+ 2 )));
889 if (( fn
-> flags
& FLG_CHAIN
) == 0 )
897 TCHECK2 ( words
[ 3 ], 2 );
898 newsmboffset
= EXTRACT_LE_16BITS ( words
+ 3 );
900 fn
= smbfind ( command
, smb_fns
);
902 printf ( " \n SMB PACKET: %s (%s) (CHAINED) \n " ,
903 fn
-> name
, request
? "REQUEST" : "REPLY" );
904 if ( newsmboffset
<= smboffset
) {
905 printf ( "Bad andX offset: %u <= %u \n " , newsmboffset
, smboffset
);
908 smboffset
= newsmboffset
;
920 * print a NBT packet received across tcp on port 139
923 nbt_tcp_print ( const u_char
* data
, int length
)
928 const u_char
* maxbuf
;
934 caplen
= snapend
- data
;
937 maxbuf
= data
+ caplen
;
939 nbt_len
= EXTRACT_16BITS ( data
+ 2 );
946 printf ( " NBT Session Packet: " );
949 printf ( "Session Message" );
953 printf ( "Session Request" );
957 printf ( "Session Granted" );
972 printf ( "Session Reject, " );
975 printf ( "Not listening on called name" );
978 printf ( "Not listening for calling name" );
981 printf ( "Called name not present" );
984 printf ( "Called name present, but insufficient resources" );
987 printf ( "Unspecified error 0x%X" , ecode
);
994 printf ( "Session Keepalive" );
998 data
= smb_fdata ( data
, "Unknown packet type [rB]" , maxbuf
, 0 );
1002 printf ( " \n >>> NBT Session Packet \n " );
1005 data
= smb_fdata ( data
, "[P1]NBT Session Message \n Flags=[B] \n Length=[rd] \n " ,
1009 if ( nbt_len
>= 4 && caplen
>= 4 && memcmp ( data
, " \377 SMB" , 4 ) == 0 ) {
1010 if (( int ) nbt_len
> caplen
) {
1011 if (( int ) nbt_len
> length
)
1012 printf ( "WARNING: Packet is continued in later TCP segments \n " );
1014 printf ( "WARNING: Short packet. Try increasing the snap length by %d \n " ,
1017 print_smb ( data
, maxbuf
> data
+ nbt_len
? data
+ nbt_len
: maxbuf
);
1019 printf ( "Session packet:(raw data or continuation?) \n " );
1023 data
= smb_fdata ( data
,
1024 "[P1]NBT Session Request \n Flags=[B] \n Length=[rd] \n Destination=[n1] \n Source=[n1] \n " ,
1029 data
= smb_fdata ( data
, "[P1]NBT Session Granted \n Flags=[B] \n Length=[rd] \n " , maxbuf
, 0 );
1034 const u_char
* origdata
;
1038 data
= smb_fdata ( data
, "[P1]NBT SessionReject \n Flags=[B] \n Length=[rd] \n Reason=[B] \n " ,
1042 if ( nbt_len
>= 1 && caplen
>= 1 ) {
1043 ecode
= origdata
[ 4 ];
1046 printf ( "Not listening on called name \n " );
1049 printf ( "Not listening for calling name \n " );
1052 printf ( "Called name not present \n " );
1055 printf ( "Called name present, but insufficient resources \n " );
1058 printf ( "Unspecified error 0x%X \n " , ecode
);
1066 data
= smb_fdata ( data
, "[P1]NBT Session Keepalive \n Flags=[B] \n Length=[rd] \n " , maxbuf
, 0 );
1070 data
= smb_fdata ( data
, "NBT - Unknown packet type \n Type=[B] \n " , maxbuf
, 0 );
1084 * print a NBT packet received across udp on port 137
1087 nbt_udp137_print ( const u_char
* data
, int length
)
1089 const u_char
* maxbuf
= data
+ length
;
1090 int name_trn_id
, response
, opcode
, nm_flags
, rcode
;
1091 int qdcount
, ancount
, nscount
, arcount
;
1092 const char * opcodestr
;
1096 TCHECK2 ( data
[ 10 ], 2 );
1097 name_trn_id
= EXTRACT_16BITS ( data
);
1098 response
= ( data
[ 2 ] >> 7 );
1099 opcode
= ( data
[ 2 ] >> 3 ) & 0xF ;
1100 nm_flags
= (( data
[ 2 ] & 0x7 ) << 4 ) + ( data
[ 3 ] >> 4 );
1101 rcode
= data
[ 3 ] & 0xF ;
1102 qdcount
= EXTRACT_16BITS ( data
+ 4 );
1103 ancount
= EXTRACT_16BITS ( data
+ 6 );
1104 nscount
= EXTRACT_16BITS ( data
+ 8 );
1105 arcount
= EXTRACT_16BITS ( data
+ 10 );
1114 printf ( "NBT UDP PACKET(137): " );
1117 case 0 : opcodestr
= "QUERY" ; break ;
1118 case 5 : opcodestr
= "REGISTRATION" ; break ;
1119 case 6 : opcodestr
= "RELEASE" ; break ;
1120 case 7 : opcodestr
= "WACK" ; break ;
1121 case 8 : opcodestr
= "REFRESH(8)" ; break ;
1122 case 9 : opcodestr
= "REFRESH" ; break ;
1123 case 15 : opcodestr
= "MULTIHOMED REGISTRATION" ; break ;
1124 default : opcodestr
= "OPUNKNOWN" ; break ;
1126 printf ( "%s" , opcodestr
);
1129 printf ( "; NEGATIVE" );
1131 printf ( "; POSITIVE" );
1135 printf ( "; RESPONSE" );
1137 printf ( "; REQUEST" );
1140 printf ( "; BROADCAST" );
1142 printf ( "; UNICAST" );
1147 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 " ,
1148 name_trn_id
, opcode
, nm_flags
, rcode
, qdcount
, ancount
, nscount
,
1153 total
= ancount
+ nscount
+ arcount
;
1155 if ( qdcount
> 100 || total
> 100 ) {
1156 printf ( "Corrupt packet?? \n " );
1161 printf ( "QuestionRecords: \n " );
1162 for ( i
= 0 ; i
< qdcount
; i
++) {
1164 "|Name=[n1] \n QuestionType=[rw] \n QuestionClass=[rw] \n #" ,
1172 printf ( " \n ResourceRecords: \n " );
1173 for ( i
= 0 ; i
< total
; i
++) {
1177 p
= smb_fdata ( p
, "Name=[n1] \n #" , maxbuf
, 0 );
1180 restype
= EXTRACT_16BITS ( p
);
1181 p
= smb_fdata ( p
, "ResType=[rw] \n ResClass=[rw] \n TTL=[rD] \n " , p
+ 8 , 0 );
1184 rdlen
= EXTRACT_16BITS ( p
);
1185 printf ( "ResourceLength=%d \n ResourceData= \n " , rdlen
);
1188 p
= smb_fdata ( p
, "AddrType=[rw] \n Address=[b.b.b.b] \n " , p
+ rdlen
, 0 );
1192 if ( restype
== 0x21 ) {
1197 p
= smb_fdata ( p
, "NumNames=[B] \n " , p
+ 1 , 0 );
1200 while ( numnames
--) {
1201 p
= smb_fdata ( p
, "Name=[n2] \t #" , maxbuf
, 0 );
1207 switch ( p
[ 0 ] & 0x60 ) {
1208 case 0x00 : printf ( "B " ); break ;
1209 case 0x20 : printf ( "P " ); break ;
1210 case 0x40 : printf ( "M " ); break ;
1211 case 0x60 : printf ( "_ " ); break ;
1214 printf ( "<DEREGISTERING> " );
1216 printf ( "<CONFLICT> " );
1218 printf ( "<ACTIVE> " );
1220 printf ( "<PERMANENT> " );
1225 print_data ( p
, min ( rdlen
, length
- ( p
- data
)));
1233 smb_fdata ( p
, "AdditionalData: \n " , maxbuf
, 0 );
1245 * Print an SMB-over-TCP packet received across tcp on port 445
1248 smb_tcp_print ( const u_char
* data
, int length
)
1252 const u_char
* maxbuf
;
1258 caplen
= snapend
- data
;
1261 maxbuf
= data
+ caplen
;
1262 smb_len
= EXTRACT_24BITS ( data
+ 1 );
1269 if ( smb_len
>= 4 && caplen
>= 4 && memcmp ( data
, " \377 SMB" , 4 ) == 0 ) {
1270 if (( int ) smb_len
> caplen
) {
1271 if (( int ) smb_len
> length
)
1272 printf ( "WARNING: Packet is continued in later TCP segments \n " );
1274 printf ( "WARNING: Short packet. Try increasing the snap length by %d \n " ,
1277 print_smb ( data
, maxbuf
> data
+ smb_len
? data
+ smb_len
: maxbuf
);
1279 printf ( "SMB-over-TCP packet:(raw data or continuation?) \n " );
1287 * print a NBT packet received across udp on port 138
1290 nbt_udp138_print ( const u_char
* data
, int length
)
1292 const u_char
* maxbuf
= data
+ length
;
1294 if ( maxbuf
> snapend
)
1301 printf ( "NBT UDP PACKET(138)" );
1305 data
= smb_fdata ( data
,
1306 " \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 #" ,
1310 /* If there isn't enough data for "\377SMB", don't check for it. */
1311 if (& data
[ 3 ] >= maxbuf
)
1314 if ( memcmp ( data
, " \377 SMB" , 4 ) == 0 )
1315 print_smb ( data
, maxbuf
);
1324 print netbeui frames
1326 struct nbf_strings
{
1328 const char * nonverbose
;
1329 const char * verbose
;
1330 } nbf_strings
[ 0x20 ] = {
1331 { "Add Group Name Query" , ", [P23]Name to add=[n2]#" ,
1332 "[P5]ResponseCorrelator=[w] \n [P16]Name to add=[n2] \n " },
1333 { "Add Name Query" , ", [P23]Name to add=[n2]#" ,
1334 "[P5]ResponseCorrelator=[w] \n [P16]Name to add=[n2] \n " },
1335 { "Name In Conflict" , NULL
, NULL
},
1336 { "Status Query" , NULL
, NULL
},
1337 { NULL
, NULL
, NULL
}, /* not used */
1338 { NULL
, NULL
, NULL
}, /* not used */
1339 { NULL
, NULL
, NULL
}, /* not used */
1340 { "Terminate Trace" , NULL
, NULL
},
1342 "[P7]Destination=[n2] \n Source=[n2] \n " },
1343 { "Broadcast Datagram" , NULL
,
1344 "[P7]Destination=[n2] \n Source=[n2] \n " },
1345 { "Name Query" , ", [P7]Name=[n2]#" ,
1346 "[P1]SessionNumber=[B] \n NameType=[B][P2] \n ResponseCorrelator=[w] \n Name=[n2] \n Name of sender=[n2] \n " },
1347 { NULL
, NULL
, NULL
}, /* not used */
1348 { NULL
, NULL
, NULL
}, /* not used */
1349 { "Add Name Response" , ", [P1]GroupName=[w] [P4]Destination=[n2] Source=[n2]#" ,
1350 "AddNameInProcess=[B] \n GroupName=[w] \n TransmitCorrelator=[w][P2] \n Destination=[n2] \n Source=[n2] \n " },
1351 { "Name Recognized" , NULL
,
1352 "[P1]Data2=[w] \n TransmitCorrelator=[w] \n ResponseCorelator=[w] \n Destination=[n2] \n Source=[n2] \n " },
1353 { "Status Response" , NULL
, NULL
},
1354 { NULL
, NULL
, NULL
}, /* not used */
1355 { NULL
, NULL
, NULL
}, /* not used */
1356 { NULL
, NULL
, NULL
}, /* not used */
1357 { "Terminate Trace" , NULL
, NULL
},
1359 "[P3]TransmitCorrelator=[w][P2] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1360 { "Data First/Middle" , NULL
,
1361 "Flags=[{RECEIVE_CONTINUE|NO_ACK||PIGGYBACK_ACK_INCLUDED|}] \n ResyncIndicator=[w][P2] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1362 { "Data Only/Last" , NULL
,
1363 "Flags=[{|NO_ACK|PIGGYBACK_ACK_ALLOWED|PIGGYBACK_ACK_INCLUDED|}] \n ResyncIndicator=[w][P2] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1364 { "Session Confirm" , NULL
,
1365 "Data1=[B] \n Data2=[w] \n TransmitCorrelator=[w] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1366 { "Session End" , NULL
,
1367 "[P1]Data2=[w][P4] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1368 { "Session Initialize" , NULL
,
1369 "Data1=[B] \n Data2=[w] \n TransmitCorrelator=[w] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1370 { "No Receive" , NULL
,
1371 "Flags=[{|SEND_NO_ACK}] \n DataBytesAccepted=[b][P4] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1372 { "Receive Outstanding" , NULL
,
1373 "[P1]DataBytesAccepted=[b][P4] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1374 { "Receive Continue" , NULL
,
1375 "[P2]TransmitCorrelator=[w] \n [P2]RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1376 { NULL
, NULL
, NULL
}, /* not used */
1377 { NULL
, NULL
, NULL
}, /* not used */
1378 { "Session Alive" , NULL
, NULL
}
1382 netbeui_print ( u_short control
, const u_char
* data
, int length
)
1384 const u_char
* maxbuf
= data
+ length
;
1387 const u_char
* data2
;
1388 int is_truncated
= 0 ;
1390 if ( maxbuf
> snapend
)
1393 len
= EXTRACT_LE_16BITS ( data
);
1396 if ( data2
>= maxbuf
) {
1404 printf ( "NBF Packet: " );
1405 data
= smb_fdata ( data
, "[P5]#" , maxbuf
, 0 );
1407 printf ( " \n >>> NBF Packet \n Type=0x%X " , control
);
1408 data
= smb_fdata ( data
, "Length=[d] Signature=[w] Command=[B] \n #" , maxbuf
, 0 );
1413 if ( command
> 0x1f || nbf_strings
[ command
]. name
== NULL
) {
1415 data
= smb_fdata ( data
, "Unknown NBF Command#" , data2
, 0 );
1417 data
= smb_fdata ( data
, "Unknown NBF Command \n " , data2
, 0 );
1420 printf ( "%s" , nbf_strings
[ command
]. name
);
1421 if ( nbf_strings
[ command
]. nonverbose
!= NULL
)
1422 data
= smb_fdata ( data
, nbf_strings
[ command
]. nonverbose
, data2
, 0 );
1424 printf ( "%s: \n " , nbf_strings
[ command
]. name
);
1425 if ( nbf_strings
[ command
]. verbose
!= NULL
)
1426 data
= smb_fdata ( data
, nbf_strings
[ command
]. verbose
, data2
, 0 );
1439 /* data2 was past the end of the buffer */
1443 /* If this isn't a command that would contain an SMB message, quit. */
1444 if ( command
!= 0x08 && command
!= 0x09 && command
!= 0x15 &&
1448 /* If there isn't enough data for "\377SMB", don't look for it. */
1449 if (& data2
[ 3 ] >= maxbuf
)
1452 if ( memcmp ( data2
, " \377 SMB" , 4 ) == 0 )
1453 print_smb ( data2
, maxbuf
);
1456 for ( i
= 0 ; i
< 128 ; i
++) {
1457 if (& data2
[ i
+ 3 ] >= maxbuf
)
1459 if ( memcmp (& data2
[ i
], " \377 SMB" , 4 ) == 0 ) {
1460 printf ( "found SMB packet at %d \n " , i
);
1461 print_smb (& data2
[ i
], maxbuf
);
1477 * print IPX-Netbios frames
1480 ipx_netbios_print ( const u_char
* data
, u_int length
)
1483 * this is a hack till I work out how to parse the rest of the
1484 * NetBIOS-over-IPX stuff
1487 const u_char
* maxbuf
;
1489 maxbuf
= data
+ length
;
1490 /* Don't go past the end of the captured data in the packet. */
1491 if ( maxbuf
> snapend
)
1494 for ( i
= 0 ; i
< 128 ; i
++) {
1495 if (& data
[ i
+ 4 ] > maxbuf
)
1497 if ( memcmp (& data
[ i
], " \377 SMB" , 4 ) == 0 ) {
1498 smb_fdata ( data
, " \n >>> IPX transport " , & data
[ i
], 0 );
1499 print_smb (& data
[ i
], maxbuf
);
1506 smb_fdata ( data
, " \n >>> Unknown IPX " , maxbuf
, 0 );