]>
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 const char tstr
[] = "[|SMB]" ;
29 static int request
= 0 ;
30 static int unicodestr
= 0 ;
32 const u_char
* startbuf
= NULL
;
39 void (* fn
)( const u_char
*, const u_char
*, const u_char
*, const u_char
*);
42 struct smbdescriptint
{
47 void (* fn
)( const u_char
*, const u_char
*, int , int );
55 struct smbdescript descript
;
63 struct smbdescriptint descript
;
66 #define DEFDESCRIPT { NULL, NULL, NULL, NULL, NULL }
68 #define FLG_CHAIN (1 << 0)
70 static const struct smbfns
*
71 smbfind ( int id
, const struct smbfns
* list
)
75 for ( sindex
= 0 ; list
[ sindex
]. name
; sindex
++)
76 if ( list
[ sindex
]. id
== id
)
77 return (& list
[ sindex
]);
82 static const struct smbfnsint
*
83 smbfindint ( int id
, const struct smbfnsint
* list
)
87 for ( sindex
= 0 ; list
[ sindex
]. name
; sindex
++)
88 if ( list
[ sindex
]. id
== id
)
89 return (& list
[ sindex
]);
95 trans2_findfirst ( const u_char
* param
, const u_char
* data
, int pcnt
, int dcnt
)
100 fmt
= "Attribute=[A] \n SearchCount=[d] \n Flags=[w] \n Level=[dP4] \n File=[S] \n " ;
102 fmt
= "Handle=[w] \n Count=[d] \n EOS=[w] \n Eoffset=[d] \n LastNameOfs=[w] \n " ;
104 smb_fdata ( param
, fmt
, param
+ pcnt
, unicodestr
);
107 print_data ( data
, dcnt
);
112 trans2_qfsinfo ( const u_char
* param
, const u_char
* data
, int pcnt
, int dcnt
)
114 static int level
= 0 ;
119 level
= EXTRACT_LE_16BITS ( param
);
120 fmt
= "InfoLevel=[d] \n " ;
121 smb_fdata ( param
, fmt
, param
+ pcnt
, unicodestr
);
125 fmt
= "idFileSystem=[W] \n SectorUnit=[D] \n Unit=[D] \n Avail=[D] \n SectorSize=[d] \n " ;
128 fmt
= "CreationTime=[T2]VolNameLength=[lb] \n VolumeLabel=[c] \n " ;
131 fmt
= "Capabilities=[W] \n MaxFileLen=[D] \n VolNameLen=[lD] \n Volume=[C] \n " ;
134 fmt
= "UnknownLevel \n " ;
137 smb_fdata ( data
, fmt
, data
+ dcnt
, unicodestr
);
141 print_data ( data
, dcnt
);
149 static const struct smbfnsint trans2_fns
[] = {
150 { 0 , "TRANSACT2_OPEN" , 0 ,
151 { "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]" ,
153 "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 " ,
155 { 1 , "TRANSACT2_FINDFIRST" , 0 ,
156 { NULL
, NULL
, NULL
, NULL
, trans2_findfirst
}},
157 { 2 , "TRANSACT2_FINDNEXT" , 0 , DEFDESCRIPT
},
158 { 3 , "TRANSACT2_QFSINFO" , 0 ,
159 { NULL
, NULL
, NULL
, NULL
, trans2_qfsinfo
}},
160 { 4 , "TRANSACT2_SETFSINFO" , 0 , DEFDESCRIPT
},
161 { 5 , "TRANSACT2_QPATHINFO" , 0 , DEFDESCRIPT
},
162 { 6 , "TRANSACT2_SETPATHINFO" , 0 , DEFDESCRIPT
},
163 { 7 , "TRANSACT2_QFILEINFO" , 0 , DEFDESCRIPT
},
164 { 8 , "TRANSACT2_SETFILEINFO" , 0 , DEFDESCRIPT
},
165 { 9 , "TRANSACT2_FSCTL" , 0 , DEFDESCRIPT
},
166 { 10 , "TRANSACT2_IOCTL" , 0 , DEFDESCRIPT
},
167 { 11 , "TRANSACT2_FINDNOTIFYFIRST" , 0 , DEFDESCRIPT
},
168 { 12 , "TRANSACT2_FINDNOTIFYNEXT" , 0 , DEFDESCRIPT
},
169 { 13 , "TRANSACT2_MKDIR" , 0 , DEFDESCRIPT
},
170 { - 1 , NULL
, 0 , DEFDESCRIPT
}
175 print_trans2 ( const u_char
* words
, const u_char
* dat
, const u_char
* buf
, const u_char
* maxbuf
)
178 static const struct smbfnsint
* fn
= & trans2_fns
[ 0 ];
179 const u_char
* data
, * param
;
180 const u_char
* w
= words
+ 1 ;
181 const char * f1
= NULL
, * f2
= NULL
;
186 TCHECK2 ( w
[ 14 * 2 ], 2 );
187 pcnt
= EXTRACT_LE_16BITS ( w
+ 9 * 2 );
188 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 10 * 2 );
189 dcnt
= EXTRACT_LE_16BITS ( w
+ 11 * 2 );
190 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 12 * 2 );
191 fn
= smbfindint ( EXTRACT_LE_16BITS ( w
+ 14 * 2 ), trans2_fns
);
194 printf ( "%s \n " , fn
-> name
);
195 printf ( "Trans2Interim \n " );
198 TCHECK2 ( w
[ 7 * 2 ], 2 );
199 pcnt
= EXTRACT_LE_16BITS ( w
+ 3 * 2 );
200 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 4 * 2 );
201 dcnt
= EXTRACT_LE_16BITS ( w
+ 6 * 2 );
202 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 7 * 2 );
205 printf ( "%s param_length=%d data_length=%d \n " , fn
-> name
, pcnt
, dcnt
);
210 "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 " ,
215 "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 " ,
216 words
+ 1 + 14 * 2 , unicodestr
);
218 f1
= fn
-> descript
. req_f1
;
219 f2
= fn
-> descript
. req_f2
;
222 "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 " ,
223 words
+ 1 + 10 * 2 , unicodestr
);
224 f1
= fn
-> descript
. rep_f1
;
225 f2
= fn
-> descript
. rep_f2
;
229 bcc
= EXTRACT_LE_16BITS ( dat
);
230 printf ( "smb_bcc=%u \n " , bcc
);
232 (* fn
-> descript
. fn
)( param
, data
, pcnt
, dcnt
);
234 smb_fdata ( param
, f1
? f1
: "Parameters= \n " , param
+ pcnt
, unicodestr
);
235 smb_fdata ( data
, f2
? f2
: "Data= \n " , data
+ dcnt
, unicodestr
);
245 print_browse ( const u_char
* param
, int paramlen
, const u_char
* data
, int datalen
)
247 const u_char
* maxbuf
= data
+ datalen
;
253 smb_fdata ( param
, "BROWSE PACKET \n |Param " , param
+ paramlen
, unicodestr
);
257 data
= smb_fdata ( data
,
258 "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 " ,
263 data
= smb_fdata ( data
,
264 "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 " ,
269 data
= smb_fdata ( data
,
270 "BROWSE PACKET: \n Type=[B] (AnnouncementRequest) \n Flags=[B] \n ReplySystemName=[S] \n " ,
275 data
= smb_fdata ( data
,
276 "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 " ,
281 data
= smb_fdata ( data
,
282 "BROWSE PACKET: \n Type=[B] (ElectionFrame) \n ElectionVersion=[B] \n OSSummary=[W] \n Uptime=[(W, W)] \n ServerName=[S] \n " ,
287 data
= smb_fdata ( data
,
288 "BROWSE PACKET: \n Type=[B] (BecomeBackupBrowser) \n Name=[S] \n " ,
293 data
= smb_fdata ( data
,
294 "BROWSE PACKET: \n Type=[B] (GetBackupList) \n ListCount?=[B] \n Token=[W] \n " ,
299 data
= smb_fdata ( data
,
300 "BROWSE PACKET: \n Type=[B] (BackupListResponse) \n ServerCount?=[B] \n Token=[W] \n *Name=[S] \n " ,
305 data
= smb_fdata ( data
,
306 "BROWSE PACKET: \n Type=[B] (MasterAnnouncement) \n MasterName=[S] \n " ,
311 data
= smb_fdata ( data
,
312 "BROWSE PACKET: \n Type=[B] (ResetBrowser) \n Options=[B] \n " , maxbuf
, unicodestr
);
316 data
= smb_fdata ( data
, "Unknown Browser Frame " , maxbuf
, unicodestr
);
327 print_ipc ( const u_char
* param
, int paramlen
, const u_char
* data
, int datalen
)
330 smb_fdata ( param
, "Command=[w] \n Str1=[S] \n Str2=[S] \n " , param
+ paramlen
,
333 smb_fdata ( data
, "IPC " , data
+ datalen
, unicodestr
);
338 print_trans ( const u_char
* words
, const u_char
* data1
, const u_char
* buf
, const u_char
* maxbuf
)
341 const char * f1
, * f2
, * f3
, * f4
;
342 const u_char
* data
, * param
;
343 const u_char
* w
= words
+ 1 ;
344 int datalen
, paramlen
;
347 TCHECK2 ( w
[ 12 * 2 ], 2 );
348 paramlen
= EXTRACT_LE_16BITS ( w
+ 9 * 2 );
349 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 10 * 2 );
350 datalen
= EXTRACT_LE_16BITS ( w
+ 11 * 2 );
351 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 12 * 2 );
352 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 " ;
357 TCHECK2 ( w
[ 7 * 2 ], 2 );
358 paramlen
= EXTRACT_LE_16BITS ( w
+ 3 * 2 );
359 param
= buf
+ EXTRACT_LE_16BITS ( w
+ 4 * 2 );
360 datalen
= EXTRACT_LE_16BITS ( w
+ 6 * 2 );
361 data
= buf
+ EXTRACT_LE_16BITS ( w
+ 7 * 2 );
362 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 " ;
368 smb_fdata ( words
+ 1 , f1
, SMBMIN ( words
+ 1 + 2 * words
[ 0 ], maxbuf
),
372 bcc
= EXTRACT_LE_16BITS ( data1
);
373 printf ( "smb_bcc=%u \n " , bcc
);
375 smb_fdata ( data1
+ 2 , f2
, maxbuf
- ( paramlen
+ datalen
), unicodestr
);
377 if ( strcmp (( const char *)( data1
+ 2 ), " \\ MAILSLOT \\ BROWSE" ) == 0 ) {
378 print_browse ( param
, paramlen
, data
, datalen
);
382 if ( strcmp (( const char *)( data1
+ 2 ), " \\ PIPE \\ LANMAN" ) == 0 ) {
383 print_ipc ( param
, paramlen
, data
, datalen
);
388 smb_fdata ( param
, f3
, SMBMIN ( param
+ paramlen
, maxbuf
), unicodestr
);
390 smb_fdata ( data
, f4
, SMBMIN ( data
+ datalen
, maxbuf
), unicodestr
);
400 print_negprot ( const u_char
* words
, const u_char
* data
, const u_char
* buf _U_
, const u_char
* maxbuf
)
403 const char * f1
= NULL
, * f2
= NULL
;
408 f2
= "*|Dialect=[Y] \n " ;
411 f1
= "Core Protocol \n DialectIndex=[d]" ;
413 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=" ;
415 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=" ;
419 smb_fdata ( words
+ 1 , f1
, SMBMIN ( words
+ 1 + wct
* 2 , maxbuf
),
422 print_data ( words
+ 1 , SMBMIN ( wct
* 2 , PTR_DIFF ( maxbuf
, words
+ 1 )));
425 bcc
= EXTRACT_LE_16BITS ( data
);
426 printf ( "smb_bcc=%u \n " , bcc
);
429 smb_fdata ( data
+ 2 , f2
, SMBMIN ( data
+ 2 + EXTRACT_LE_16BITS ( data
),
430 maxbuf
), unicodestr
);
432 print_data ( data
+ 2 , SMBMIN ( EXTRACT_LE_16BITS ( data
), PTR_DIFF ( maxbuf
, data
+ 2 )));
441 print_sesssetup ( const u_char
* words
, const u_char
* data
, const u_char
* buf _U_
, const u_char
* maxbuf
)
444 const char * f1
= NULL
, * f2
= NULL
;
450 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 " ;
452 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 " ;
455 f1
= "Com2=[w] \n Off2=[d] \n Action=[w] \n " ;
456 } else if ( wct
== 13 ) {
457 f1
= "Com2=[B] \n Res=[B] \n Off2=[d] \n Action=[w] \n " ;
458 f2
= "NativeOS=[S] \n NativeLanMan=[S] \n PrimaryDomain=[S] \n " ;
463 smb_fdata ( words
+ 1 , f1
, SMBMIN ( words
+ 1 + wct
* 2 , maxbuf
),
466 print_data ( words
+ 1 , SMBMIN ( wct
* 2 , PTR_DIFF ( maxbuf
, words
+ 1 )));
469 bcc
= EXTRACT_LE_16BITS ( data
);
470 printf ( "smb_bcc=%u \n " , bcc
);
473 smb_fdata ( data
+ 2 , f2
, SMBMIN ( data
+ 2 + EXTRACT_LE_16BITS ( data
),
474 maxbuf
), unicodestr
);
476 print_data ( data
+ 2 , SMBMIN ( EXTRACT_LE_16BITS ( data
), PTR_DIFF ( maxbuf
, data
+ 2 )));
485 print_lockingandx ( const u_char
* words
, const u_char
* data
, const u_char
* buf _U_
, const u_char
* maxbuf
)
488 const u_char
* maxwords
;
489 const char * f1
= NULL
, * f2
= NULL
;
494 f1
= "Com2=[w] \n Off2=[d] \n Handle=[d] \n LockType=[w] \n TimeOut=[D] \n UnlockCount=[d] \n LockCount=[d] \n " ;
497 f2
= "*Process=[d] \n [P2]Offset=[M] \n Length=[M] \n " ;
499 f2
= "*Process=[d] \n Offset=[D] \n Length=[D] \n " ;
501 f1
= "Com2=[w] \n Off2=[d] \n " ;
504 maxwords
= SMBMIN ( words
+ 1 + wct
* 2 , maxbuf
);
506 smb_fdata ( words
+ 1 , f1
, maxwords
, unicodestr
);
509 bcc
= EXTRACT_LE_16BITS ( data
);
510 printf ( "smb_bcc=%u \n " , bcc
);
513 smb_fdata ( data
+ 2 , f2
, SMBMIN ( data
+ 2 + EXTRACT_LE_16BITS ( data
),
514 maxbuf
), unicodestr
);
516 print_data ( data
+ 2 , SMBMIN ( EXTRACT_LE_16BITS ( data
), PTR_DIFF ( maxbuf
, data
+ 2 )));
525 static const struct smbfns smb_fns
[] = {
526 { - 1 , "SMBunknown" , 0 , DEFDESCRIPT
},
528 { SMBtcon
, "SMBtcon" , 0 ,
529 { NULL
, "Path=[Z] \n Password=[Z] \n Device=[Z] \n " ,
530 "MaxXmit=[d] \n TreeId=[d] \n " , NULL
,
533 { SMBtdis
, "SMBtdis" , 0 , DEFDESCRIPT
},
534 { SMBexit
, "SMBexit" , 0 , DEFDESCRIPT
},
535 { SMBioctl
, "SMBioctl" , 0 , DEFDESCRIPT
},
537 { SMBecho
, "SMBecho" , 0 ,
538 { "ReverbCount=[d] \n " , NULL
,
539 "SequenceNum=[d] \n " , NULL
,
542 { SMBulogoffX
, "SMBulogoffX" , FLG_CHAIN
, DEFDESCRIPT
},
544 { SMBgetatr
, "SMBgetatr" , 0 ,
545 { NULL
, "Path=[Z] \n " ,
546 "Attribute=[A] \n Time=[T2]Size=[D] \n Res=([w,w,w,w,w]) \n " , NULL
,
549 { SMBsetatr
, "SMBsetatr" , 0 ,
550 { "Attribute=[A] \n Time=[T2]Res=([w,w,w,w,w]) \n " , "Path=[Z] \n " ,
551 NULL
, NULL
, NULL
} },
553 { SMBchkpth
, "SMBchkpth" , 0 ,
554 { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
556 { SMBsearch
, "SMBsearch" , 0 ,
557 { "Count=[d] \n Attrib=[A] \n " ,
558 "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 " ,
560 "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 " ,
563 { SMBopen
, "SMBopen" , 0 ,
564 { "Mode=[w] \n Attribute=[A] \n " , "Path=[Z] \n " ,
565 "Handle=[d] \n OAttrib=[A] \n Time=[T2]Size=[D] \n Access=[w] \n " ,
568 { SMBcreate
, "SMBcreate" , 0 ,
569 { "Attrib=[A] \n Time=[T2]" , "Path=[Z] \n " , "Handle=[d] \n " , NULL
, NULL
} },
571 { SMBmknew
, "SMBmknew" , 0 ,
572 { "Attrib=[A] \n Time=[T2]" , "Path=[Z] \n " , "Handle=[d] \n " , NULL
, NULL
} },
574 { SMBunlink
, "SMBunlink" , 0 ,
575 { "Attrib=[A] \n " , "Path=[Z] \n " , NULL
, NULL
, NULL
} },
577 { SMBread
, "SMBread" , 0 ,
578 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
579 "Count=[d] \n Res=([w,w,w,w]) \n " , NULL
, NULL
} },
581 { SMBwrite
, "SMBwrite" , 0 ,
582 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
583 "Count=[d] \n " , NULL
, NULL
} },
585 { SMBclose
, "SMBclose" , 0 ,
586 { "Handle=[d] \n Time=[T2]" , NULL
, NULL
, NULL
, NULL
} },
588 { SMBmkdir
, "SMBmkdir" , 0 ,
589 { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
591 { SMBrmdir
, "SMBrmdir" , 0 ,
592 { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
594 { SMBdskattr
, "SMBdskattr" , 0 ,
596 "TotalUnits=[d] \n BlocksPerUnit=[d] \n BlockSize=[d] \n FreeUnits=[d] \n Media=[w] \n " ,
600 { "Attrib=[A] \n " , "OldPath=[Z] \n NewPath=[Z] \n " , NULL
, NULL
, NULL
} },
603 * this is a Pathworks specific call, allowing the
604 * changing of the root path
606 { pSETDIR
, "SMBsetdir" , 0 , { NULL
, "Path=[Z] \n " , NULL
, NULL
, NULL
} },
608 { SMBlseek
, "SMBlseek" , 0 ,
609 { "Handle=[d] \n Mode=[w] \n Offset=[D] \n " , "Offset=[D] \n " , NULL
, NULL
, NULL
} },
611 { SMBflush
, "SMBflush" , 0 , { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
613 { SMBsplopen
, "SMBsplopen" , 0 ,
614 { "SetupLen=[d] \n Mode=[w] \n " , "Ident=[Z] \n " , "Handle=[d] \n " ,
617 { SMBsplclose
, "SMBsplclose" , 0 ,
618 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
620 { SMBsplretq
, "SMBsplretq" , 0 ,
621 { "MaxCount=[d] \n StartIndex=[d] \n " , NULL
,
622 "Count=[d] \n Index=[d] \n " ,
623 "*Time=[T2]Status=[B] \n JobID=[d] \n Size=[D] \n Res=[B]Name=[s16] \n " ,
626 { SMBsplwr
, "SMBsplwr" , 0 ,
627 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
629 { SMBlock
, "SMBlock" , 0 ,
630 { "Handle=[d] \n Count=[D] \n Offset=[D] \n " , NULL
, NULL
, NULL
, NULL
} },
632 { SMBunlock
, "SMBunlock" , 0 ,
633 { "Handle=[d] \n Count=[D] \n Offset=[D] \n " , NULL
, NULL
, NULL
, NULL
} },
635 /* CORE+ PROTOCOL FOLLOWS */
637 { SMBreadbraw
, "SMBreadbraw" , 0 ,
638 { "Handle=[d] \n Offset=[D] \n MaxCount=[d] \n MinCount=[d] \n TimeOut=[D] \n Res=[d] \n " ,
639 NULL
, NULL
, NULL
, NULL
} },
641 { SMBwritebraw
, "SMBwritebraw" , 0 ,
642 { "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 " ,
643 NULL
, "WriteRawAck" , NULL
, NULL
} },
645 { SMBwritec
, "SMBwritec" , 0 ,
646 { NULL
, NULL
, "Count=[d] \n " , NULL
, NULL
} },
648 { SMBwriteclose
, "SMBwriteclose" , 0 ,
649 { "Handle=[d] \n Count=[d] \n Offset=[D] \n Time=[T2]Res=([w,w,w,w,w,w])" ,
650 NULL
, "Count=[d] \n " , NULL
, NULL
} },
652 { SMBlockread
, "SMBlockread" , 0 ,
653 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
654 "Count=[d] \n Res=([w,w,w,w]) \n " , NULL
, NULL
} },
656 { SMBwriteunlock
, "SMBwriteunlock" , 0 ,
657 { "Handle=[d] \n ByteCount=[d] \n Offset=[D] \n CountLeft=[d] \n " , NULL
,
658 "Count=[d] \n " , NULL
, NULL
} },
660 { SMBreadBmpx
, "SMBreadBmpx" , 0 ,
661 { "Handle=[d] \n Offset=[D] \n MaxCount=[d] \n MinCount=[d] \n TimeOut=[D] \n Res=[w] \n " ,
663 "Offset=[D] \n TotCount=[d] \n Remaining=[d] \n Res=([w,w]) \n DataSize=[d] \n DataOff=[d] \n " ,
666 { SMBwriteBmpx
, "SMBwriteBmpx" , 0 ,
667 { "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
,
668 "Remaining=[d] \n " , NULL
, NULL
} },
670 { SMBwriteBs
, "SMBwriteBs" , 0 ,
671 { "Handle=[d] \n TotCount=[d] \n Offset=[D] \n Res=[W] \n DataSize=[d] \n DataOff=[d] \n " ,
672 NULL
, "Count=[d] \n " , NULL
, NULL
} },
674 { SMBsetattrE
, "SMBsetattrE" , 0 ,
675 { "Handle=[d] \n CreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]" , NULL
,
676 NULL
, NULL
, NULL
} },
678 { SMBgetattrE
, "SMBgetattrE" , 0 ,
679 { "Handle=[d] \n " , NULL
,
680 "CreationTime=[T2]AccessTime=[T2]ModifyTime=[T2]Size=[D] \n AllocSize=[D] \n Attribute=[A] \n " ,
683 { SMBtranss
, "SMBtranss" , 0 , DEFDESCRIPT
},
684 { SMBioctls
, "SMBioctls" , 0 , DEFDESCRIPT
},
686 { SMBcopy
, "SMBcopy" , 0 ,
687 { "TreeID2=[d] \n OFun=[w] \n Flags=[w] \n " , "Path=[S] \n NewPath=[S] \n " ,
688 "CopyCount=[d] \n " , "|ErrStr=[S] \n " , NULL
} },
690 { SMBmove
, "SMBmove" , 0 ,
691 { "TreeID2=[d] \n OFun=[w] \n Flags=[w] \n " , "Path=[S] \n NewPath=[S] \n " ,
692 "MoveCount=[d] \n " , "|ErrStr=[S] \n " , NULL
} },
694 { SMBopenX
, "SMBopenX" , FLG_CHAIN
,
695 { "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 " ,
697 "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 " ,
700 { SMBreadX
, "SMBreadX" , FLG_CHAIN
,
701 { "Com2=[w] \n Off2=[d] \n Handle=[d] \n Offset=[D] \n MaxCount=[d] \n MinCount=[d] \n TimeOut=[D] \n CountLeft=[d] \n " ,
703 "Com2=[w] \n Off2=[d] \n Remaining=[d] \n Res=[W] \n DataSize=[d] \n DataOff=[d] \n Res=([w,w,w,w]) \n " ,
706 { SMBwriteX
, "SMBwriteX" , FLG_CHAIN
,
707 { "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 " ,
709 "Com2=[w] \n Off2=[d] \n Count=[d] \n Remaining=[d] \n Res=[W] \n " ,
712 { SMBffirst
, "SMBffirst" , 0 ,
713 { "Count=[d] \n Attrib=[A] \n " ,
714 "Path=[Z] \n BlkType=[B] \n BlkLen=[d] \n |Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n " ,
716 "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 " ,
719 { SMBfunique
, "SMBfunique" , 0 ,
720 { "Count=[d] \n Attrib=[A] \n " ,
721 "Path=[Z] \n BlkType=[B] \n BlkLen=[d] \n |Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n " ,
723 "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 " ,
726 { SMBfclose
, "SMBfclose" , 0 ,
727 { "Count=[d] \n Attrib=[A] \n " ,
728 "Path=[Z] \n BlkType=[B] \n BlkLen=[d] \n |Res1=[B] \n Mask=[s11] \n Srv1=[B] \n DirIndex=[d] \n Srv2=[w] \n " ,
730 "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 " ,
733 { SMBfindnclose
, "SMBfindnclose" , 0 ,
734 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
736 { SMBfindclose
, "SMBfindclose" , 0 ,
737 { "Handle=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
739 { SMBsends
, "SMBsends" , 0 ,
740 { NULL
, "Source=[Z] \n Dest=[Z] \n " , NULL
, NULL
, NULL
} },
742 { SMBsendstrt
, "SMBsendstrt" , 0 ,
743 { NULL
, "Source=[Z] \n Dest=[Z] \n " , "GroupID=[d] \n " , NULL
, NULL
} },
745 { SMBsendend
, "SMBsendend" , 0 ,
746 { "GroupID=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
748 { SMBsendtxt
, "SMBsendtxt" , 0 ,
749 { "GroupID=[d] \n " , NULL
, NULL
, NULL
, NULL
} },
751 { SMBsendb
, "SMBsendb" , 0 ,
752 { NULL
, "Source=[Z] \n Dest=[Z] \n " , NULL
, NULL
, NULL
} },
754 { SMBfwdname
, "SMBfwdname" , 0 , DEFDESCRIPT
},
755 { SMBcancelf
, "SMBcancelf" , 0 , DEFDESCRIPT
},
756 { SMBgetmac
, "SMBgetmac" , 0 , DEFDESCRIPT
},
758 { SMBnegprot
, "SMBnegprot" , 0 ,
759 { NULL
, NULL
, NULL
, NULL
, print_negprot
} },
761 { SMBsesssetupX
, "SMBsesssetupX" , FLG_CHAIN
,
762 { NULL
, NULL
, NULL
, NULL
, print_sesssetup
} },
764 { SMBtconX
, "SMBtconX" , FLG_CHAIN
,
765 { "Com2=[w] \n Off2=[d] \n Flags=[w] \n PassLen=[d] \n Passwd&Path&Device= \n " ,
766 NULL
, "Com2=[w] \n Off2=[d] \n " , "ServiceType=[R] \n " , NULL
} },
768 { SMBlockingX
, "SMBlockingX" , FLG_CHAIN
,
769 { NULL
, NULL
, NULL
, NULL
, print_lockingandx
} },
771 { SMBtrans2
, "SMBtrans2" , 0 , { NULL
, NULL
, NULL
, NULL
, print_trans2
} },
773 { SMBtranss2
, "SMBtranss2" , 0 , DEFDESCRIPT
},
774 { SMBctemp
, "SMBctemp" , 0 , DEFDESCRIPT
},
775 { SMBreadBs
, "SMBreadBs" , 0 , DEFDESCRIPT
},
776 { SMBtrans
, "SMBtrans" , 0 , { NULL
, NULL
, NULL
, NULL
, print_trans
} },
778 { SMBnttrans
, "SMBnttrans" , 0 , DEFDESCRIPT
},
779 { SMBnttranss
, "SMBnttranss" , 0 , DEFDESCRIPT
},
781 { SMBntcreateX
, "SMBntcreateX" , FLG_CHAIN
,
782 { "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 " ,
784 "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 " ,
787 { SMBntcancel
, "SMBntcancel" , 0 , DEFDESCRIPT
},
789 { - 1 , NULL
, 0 , DEFDESCRIPT
}
794 * print a SMB message
797 print_smb ( const u_char
* buf
, const u_char
* maxbuf
)
803 const u_char
* words
, * maxwords
, * data
;
804 const struct smbfns
* fn
;
805 const char * fmt_smbheader
=
806 "[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 " ;
810 request
= ( buf
[ 9 ] & 0x80 ) ? 0 : 1 ;
811 flags2
= EXTRACT_LE_16BITS (& buf
[ 10 ]);
812 unicodestr
= flags2
& 0x8000 ;
813 nterrcodes
= flags2
& 0x4000 ;
818 fn
= smbfind ( command
, smb_fns
);
823 printf ( "SMB PACKET: %s (%s) \n " , fn
-> name
, request
? "REQUEST" : "REPLY" );
828 /* print out the header */
829 smb_fdata ( buf
, fmt_smbheader
, buf
+ 33 , unicodestr
);
832 nterror
= EXTRACT_LE_32BITS (& buf
[ 5 ]);
834 printf ( "NTError = %s \n " , nt_errstr ( nterror
));
837 printf ( "SMBError = %s \n " , smb_errstr ( buf
[ 5 ], EXTRACT_LE_16BITS (& buf
[ 7 ])));
848 words
= buf
+ smboffset
;
851 data
= words
+ 1 + wct
* 2 ;
852 maxwords
= SMBMIN ( data
, maxbuf
);
855 f1
= fn
-> descript
. req_f1
;
856 f2
= fn
-> descript
. req_f2
;
858 f1
= fn
-> descript
. rep_f1
;
859 f2
= fn
-> descript
. rep_f2
;
863 (* fn
-> descript
. fn
)( words
, data
, buf
, maxbuf
);
867 smb_fdata ( words
+ 1 , f1
, words
+ 1 + wct
* 2 , unicodestr
);
872 for ( i
= 0 ; & words
[ 1 + 2 * i
] < maxwords
; i
++) {
873 TCHECK2 ( words
[ 1 + 2 * i
], 2 );
874 v
= EXTRACT_LE_16BITS ( words
+ 1 + 2 * i
);
875 printf ( "smb_vwv[%d]=%d (0x%X) \n " , i
, v
, v
);
881 bcc
= EXTRACT_LE_16BITS ( data
);
882 printf ( "smb_bcc=%u \n " , bcc
);
885 smb_fdata ( data
+ 2 , f2
, data
+ 2 + bcc
, unicodestr
);
888 printf ( "smb_buf[]= \n " );
889 print_data ( data
+ 2 , SMBMIN ( bcc
, PTR_DIFF ( maxbuf
, data
+ 2 )));
894 if (( fn
-> flags
& FLG_CHAIN
) == 0 )
902 TCHECK2 ( words
[ 3 ], 2 );
903 newsmboffset
= EXTRACT_LE_16BITS ( words
+ 3 );
905 fn
= smbfind ( command
, smb_fns
);
907 printf ( " \n SMB PACKET: %s (%s) (CHAINED) \n " ,
908 fn
-> name
, request
? "REQUEST" : "REPLY" );
909 if ( newsmboffset
<= smboffset
) {
910 printf ( "Bad andX offset: %u <= %u \n " , newsmboffset
, smboffset
);
913 smboffset
= newsmboffset
;
925 * print a NBT packet received across tcp on port 139
928 nbt_tcp_print ( const u_char
* data
, int length
)
933 const u_char
* maxbuf
;
939 caplen
= snapend
- data
;
942 maxbuf
= data
+ caplen
;
944 nbt_len
= EXTRACT_16BITS ( data
+ 2 );
951 printf ( " NBT Session Packet: " );
954 printf ( "Session Message" );
958 printf ( "Session Request" );
962 printf ( "Session Granted" );
977 printf ( "Session Reject, " );
980 printf ( "Not listening on called name" );
983 printf ( "Not listening for calling name" );
986 printf ( "Called name not present" );
989 printf ( "Called name present, but insufficient resources" );
992 printf ( "Unspecified error 0x%X" , ecode
);
999 printf ( "Session Keepalive" );
1003 data
= smb_fdata ( data
, "Unknown packet type [rB]" , maxbuf
, 0 );
1007 printf ( " \n >>> NBT Session Packet \n " );
1010 data
= smb_fdata ( data
, "[P1]NBT Session Message \n Flags=[B] \n Length=[rd] \n " ,
1014 if ( nbt_len
>= 4 && caplen
>= 4 && memcmp ( data
, " \377 SMB" , 4 ) == 0 ) {
1015 if (( int ) nbt_len
> caplen
) {
1016 if (( int ) nbt_len
> length
)
1017 printf ( "WARNING: Packet is continued in later TCP segments \n " );
1019 printf ( "WARNING: Short packet. Try increasing the snap length by %d \n " ,
1022 print_smb ( data
, maxbuf
> data
+ nbt_len
? data
+ nbt_len
: maxbuf
);
1024 printf ( "Session packet:(raw data or continuation?) \n " );
1028 data
= smb_fdata ( data
,
1029 "[P1]NBT Session Request \n Flags=[B] \n Length=[rd] \n Destination=[n1] \n Source=[n1] \n " ,
1034 data
= smb_fdata ( data
, "[P1]NBT Session Granted \n Flags=[B] \n Length=[rd] \n " , maxbuf
, 0 );
1039 const u_char
* origdata
;
1043 data
= smb_fdata ( data
, "[P1]NBT SessionReject \n Flags=[B] \n Length=[rd] \n Reason=[B] \n " ,
1047 if ( nbt_len
>= 1 && caplen
>= 1 ) {
1048 ecode
= origdata
[ 4 ];
1051 printf ( "Not listening on called name \n " );
1054 printf ( "Not listening for calling name \n " );
1057 printf ( "Called name not present \n " );
1060 printf ( "Called name present, but insufficient resources \n " );
1063 printf ( "Unspecified error 0x%X \n " , ecode
);
1071 data
= smb_fdata ( data
, "[P1]NBT Session Keepalive \n Flags=[B] \n Length=[rd] \n " , maxbuf
, 0 );
1075 data
= smb_fdata ( data
, "NBT - Unknown packet type \n Type=[B] \n " , maxbuf
, 0 );
1089 * print a NBT packet received across udp on port 137
1092 nbt_udp137_print ( const u_char
* data
, int length
)
1094 const u_char
* maxbuf
= data
+ length
;
1095 int name_trn_id
, response
, opcode
, nm_flags
, rcode
;
1096 int qdcount
, ancount
, nscount
, arcount
;
1097 const char * opcodestr
;
1101 TCHECK2 ( data
[ 10 ], 2 );
1102 name_trn_id
= EXTRACT_16BITS ( data
);
1103 response
= ( data
[ 2 ] >> 7 );
1104 opcode
= ( data
[ 2 ] >> 3 ) & 0xF ;
1105 nm_flags
= (( data
[ 2 ] & 0x7 ) << 4 ) + ( data
[ 3 ] >> 4 );
1106 rcode
= data
[ 3 ] & 0xF ;
1107 qdcount
= EXTRACT_16BITS ( data
+ 4 );
1108 ancount
= EXTRACT_16BITS ( data
+ 6 );
1109 nscount
= EXTRACT_16BITS ( data
+ 8 );
1110 arcount
= EXTRACT_16BITS ( data
+ 10 );
1119 printf ( "NBT UDP PACKET(137): " );
1122 case 0 : opcodestr
= "QUERY" ; break ;
1123 case 5 : opcodestr
= "REGISTRATION" ; break ;
1124 case 6 : opcodestr
= "RELEASE" ; break ;
1125 case 7 : opcodestr
= "WACK" ; break ;
1126 case 8 : opcodestr
= "REFRESH(8)" ; break ;
1127 case 9 : opcodestr
= "REFRESH" ; break ;
1128 case 15 : opcodestr
= "MULTIHOMED REGISTRATION" ; break ;
1129 default : opcodestr
= "OPUNKNOWN" ; break ;
1131 printf ( "%s" , opcodestr
);
1134 printf ( "; NEGATIVE" );
1136 printf ( "; POSITIVE" );
1140 printf ( "; RESPONSE" );
1142 printf ( "; REQUEST" );
1145 printf ( "; BROADCAST" );
1147 printf ( "; UNICAST" );
1152 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 " ,
1153 name_trn_id
, opcode
, nm_flags
, rcode
, qdcount
, ancount
, nscount
,
1158 total
= ancount
+ nscount
+ arcount
;
1160 if ( qdcount
> 100 || total
> 100 ) {
1161 printf ( "Corrupt packet?? \n " );
1166 printf ( "QuestionRecords: \n " );
1167 for ( i
= 0 ; i
< qdcount
; i
++) {
1169 "|Name=[n1] \n QuestionType=[rw] \n QuestionClass=[rw] \n #" ,
1177 printf ( " \n ResourceRecords: \n " );
1178 for ( i
= 0 ; i
< total
; i
++) {
1182 p
= smb_fdata ( p
, "Name=[n1] \n #" , maxbuf
, 0 );
1185 restype
= EXTRACT_16BITS ( p
);
1186 p
= smb_fdata ( p
, "ResType=[rw] \n ResClass=[rw] \n TTL=[rD] \n " , p
+ 8 , 0 );
1189 rdlen
= EXTRACT_16BITS ( p
);
1190 printf ( "ResourceLength=%d \n ResourceData= \n " , rdlen
);
1193 p
= smb_fdata ( p
, "AddrType=[rw] \n Address=[b.b.b.b] \n " , p
+ rdlen
, 0 );
1197 if ( restype
== 0x21 ) {
1202 p
= smb_fdata ( p
, "NumNames=[B] \n " , p
+ 1 , 0 );
1205 while ( numnames
--) {
1206 p
= smb_fdata ( p
, "Name=[n2] \t #" , maxbuf
, 0 );
1212 switch ( p
[ 0 ] & 0x60 ) {
1213 case 0x00 : printf ( "B " ); break ;
1214 case 0x20 : printf ( "P " ); break ;
1215 case 0x40 : printf ( "M " ); break ;
1216 case 0x60 : printf ( "_ " ); break ;
1219 printf ( "<DEREGISTERING> " );
1221 printf ( "<CONFLICT> " );
1223 printf ( "<ACTIVE> " );
1225 printf ( "<PERMANENT> " );
1230 print_data ( p
, min ( rdlen
, length
- ( p
- data
)));
1238 smb_fdata ( p
, "AdditionalData: \n " , maxbuf
, 0 );
1250 * Print an SMB-over-TCP packet received across tcp on port 445
1253 smb_tcp_print ( const u_char
* data
, int length
)
1257 const u_char
* maxbuf
;
1263 caplen
= snapend
- data
;
1266 maxbuf
= data
+ caplen
;
1267 smb_len
= EXTRACT_24BITS ( data
+ 1 );
1274 if ( smb_len
>= 4 && caplen
>= 4 && memcmp ( data
, " \377 SMB" , 4 ) == 0 ) {
1275 if (( int ) smb_len
> caplen
) {
1276 if (( int ) smb_len
> length
)
1277 printf ( "WARNING: Packet is continued in later TCP segments \n " );
1279 printf ( "WARNING: Short packet. Try increasing the snap length by %d \n " ,
1282 print_smb ( data
, maxbuf
> data
+ smb_len
? data
+ smb_len
: maxbuf
);
1284 printf ( "SMB-over-TCP packet:(raw data or continuation?) \n " );
1292 * print a NBT packet received across udp on port 138
1295 nbt_udp138_print ( const u_char
* data
, int length
)
1297 const u_char
* maxbuf
= data
+ length
;
1299 if ( maxbuf
> snapend
)
1306 printf ( "NBT UDP PACKET(138)" );
1310 data
= smb_fdata ( data
,
1311 " \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 #" ,
1315 /* If there isn't enough data for "\377SMB", don't check for it. */
1316 if (& data
[ 3 ] >= maxbuf
)
1319 if ( memcmp ( data
, " \377 SMB" , 4 ) == 0 )
1320 print_smb ( data
, maxbuf
);
1329 print netbeui frames
1331 struct nbf_strings
{
1333 const char * nonverbose
;
1334 const char * verbose
;
1335 } nbf_strings
[ 0x20 ] = {
1336 { "Add Group Name Query" , ", [P23]Name to add=[n2]#" ,
1337 "[P5]ResponseCorrelator=[w] \n [P16]Name to add=[n2] \n " },
1338 { "Add Name Query" , ", [P23]Name to add=[n2]#" ,
1339 "[P5]ResponseCorrelator=[w] \n [P16]Name to add=[n2] \n " },
1340 { "Name In Conflict" , NULL
, NULL
},
1341 { "Status Query" , NULL
, NULL
},
1342 { NULL
, NULL
, NULL
}, /* not used */
1343 { NULL
, NULL
, NULL
}, /* not used */
1344 { NULL
, NULL
, NULL
}, /* not used */
1345 { "Terminate Trace" , NULL
, NULL
},
1347 "[P7]Destination=[n2] \n Source=[n2] \n " },
1348 { "Broadcast Datagram" , NULL
,
1349 "[P7]Destination=[n2] \n Source=[n2] \n " },
1350 { "Name Query" , ", [P7]Name=[n2]#" ,
1351 "[P1]SessionNumber=[B] \n NameType=[B][P2] \n ResponseCorrelator=[w] \n Name=[n2] \n Name of sender=[n2] \n " },
1352 { NULL
, NULL
, NULL
}, /* not used */
1353 { NULL
, NULL
, NULL
}, /* not used */
1354 { "Add Name Response" , ", [P1]GroupName=[w] [P4]Destination=[n2] Source=[n2]#" ,
1355 "AddNameInProcess=[B] \n GroupName=[w] \n TransmitCorrelator=[w][P2] \n Destination=[n2] \n Source=[n2] \n " },
1356 { "Name Recognized" , NULL
,
1357 "[P1]Data2=[w] \n TransmitCorrelator=[w] \n ResponseCorelator=[w] \n Destination=[n2] \n Source=[n2] \n " },
1358 { "Status Response" , NULL
, NULL
},
1359 { NULL
, NULL
, NULL
}, /* not used */
1360 { NULL
, NULL
, NULL
}, /* not used */
1361 { NULL
, NULL
, NULL
}, /* not used */
1362 { "Terminate Trace" , NULL
, NULL
},
1364 "[P3]TransmitCorrelator=[w][P2] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1365 { "Data First/Middle" , NULL
,
1366 "Flags=[{RECEIVE_CONTINUE|NO_ACK||PIGGYBACK_ACK_INCLUDED|}] \n ResyncIndicator=[w][P2] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1367 { "Data Only/Last" , NULL
,
1368 "Flags=[{|NO_ACK|PIGGYBACK_ACK_ALLOWED|PIGGYBACK_ACK_INCLUDED|}] \n ResyncIndicator=[w][P2] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1369 { "Session Confirm" , NULL
,
1370 "Data1=[B] \n Data2=[w] \n TransmitCorrelator=[w] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1371 { "Session End" , NULL
,
1372 "[P1]Data2=[w][P4] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1373 { "Session Initialize" , NULL
,
1374 "Data1=[B] \n Data2=[w] \n TransmitCorrelator=[w] \n ResponseCorelator=[w] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1375 { "No Receive" , NULL
,
1376 "Flags=[{|SEND_NO_ACK}] \n DataBytesAccepted=[b][P4] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1377 { "Receive Outstanding" , NULL
,
1378 "[P1]DataBytesAccepted=[b][P4] \n RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1379 { "Receive Continue" , NULL
,
1380 "[P2]TransmitCorrelator=[w] \n [P2]RemoteSessionNumber=[B] \n LocalSessionNumber=[B] \n " },
1381 { NULL
, NULL
, NULL
}, /* not used */
1382 { NULL
, NULL
, NULL
}, /* not used */
1383 { "Session Alive" , NULL
, NULL
}
1387 netbeui_print ( u_short control
, const u_char
* data
, int length
)
1389 const u_char
* maxbuf
= data
+ length
;
1392 const u_char
* data2
;
1393 int is_truncated
= 0 ;
1395 if ( maxbuf
> snapend
)
1398 len
= EXTRACT_LE_16BITS ( data
);
1401 if ( data2
>= maxbuf
) {
1409 printf ( "NBF Packet: " );
1410 data
= smb_fdata ( data
, "[P5]#" , maxbuf
, 0 );
1412 printf ( " \n >>> NBF Packet \n Type=0x%X " , control
);
1413 data
= smb_fdata ( data
, "Length=[d] Signature=[w] Command=[B] \n #" , maxbuf
, 0 );
1418 if ( command
> 0x1f || nbf_strings
[ command
]. name
== NULL
) {
1420 data
= smb_fdata ( data
, "Unknown NBF Command#" , data2
, 0 );
1422 data
= smb_fdata ( data
, "Unknown NBF Command \n " , data2
, 0 );
1425 printf ( "%s" , nbf_strings
[ command
]. name
);
1426 if ( nbf_strings
[ command
]. nonverbose
!= NULL
)
1427 data
= smb_fdata ( data
, nbf_strings
[ command
]. nonverbose
, data2
, 0 );
1429 printf ( "%s: \n " , nbf_strings
[ command
]. name
);
1430 if ( nbf_strings
[ command
]. verbose
!= NULL
)
1431 data
= smb_fdata ( data
, nbf_strings
[ command
]. verbose
, data2
, 0 );
1444 /* data2 was past the end of the buffer */
1448 /* If this isn't a command that would contain an SMB message, quit. */
1449 if ( command
!= 0x08 && command
!= 0x09 && command
!= 0x15 &&
1453 /* If there isn't enough data for "\377SMB", don't look for it. */
1454 if (& data2
[ 3 ] >= maxbuf
)
1457 if ( memcmp ( data2
, " \377 SMB" , 4 ) == 0 )
1458 print_smb ( data2
, maxbuf
);
1461 for ( i
= 0 ; i
< 128 ; i
++) {
1462 if (& data2
[ i
+ 3 ] >= maxbuf
)
1464 if ( memcmp (& data2
[ i
], " \377 SMB" , 4 ) == 0 ) {
1465 printf ( "found SMB packet at %d \n " , i
);
1466 print_smb (& data2
[ i
], maxbuf
);
1482 * print IPX-Netbios frames
1485 ipx_netbios_print ( const u_char
* data
, u_int length
)
1488 * this is a hack till I work out how to parse the rest of the
1489 * NetBIOS-over-IPX stuff
1492 const u_char
* maxbuf
;
1494 maxbuf
= data
+ length
;
1495 /* Don't go past the end of the captured data in the packet. */
1496 if ( maxbuf
> snapend
)
1499 for ( i
= 0 ; i
< 128 ; i
++) {
1500 if (& data
[ i
+ 4 ] > maxbuf
)
1502 if ( memcmp (& data
[ i
], " \377 SMB" , 4 ) == 0 ) {
1503 smb_fdata ( data
, " \n >>> IPX transport " , & data
[ i
], 0 );
1504 print_smb (& data
[ i
], maxbuf
);
1511 smb_fdata ( data
, " \n >>> Unknown IPX " , maxbuf
, 0 );