Commit Graph

18 Commits

Author SHA1 Message Date
Elliot Cubit
a1d5e930ca
smb: allow dynamic length fields of exact length (#323) 2021-07-26 15:57:24 -04:00
Elliot Cubit
17a5257565
Add NativeOS, NTLM, and GroupName to SMBv1 results (#286)
* add smbv1 session setup scan

* remove unused values

* rename os_name to native_os to match smb documentation

* remove superfluous comment

* update zschema to include new SMB fields

* improve clarity on bounds checking for SMBv1 requests
2021-03-15 09:23:55 -04:00
Elliot Cubit
3c17bf32e8
Fix SMB scanner marshaller panic (#299) 2021-02-11 14:44:36 -05:00
Jeff Cody
b69c22c532
SMB: Probe for SMB1 in addition to SMB2
If the probe for SMB2 fails, close the connection and then try probing
for SMB1 as a backup.

Since there are more SMB2 servers in the wild, that is the first
attempt.
2019-06-10 17:17:20 -04:00
Jeff Cody
1232ca4e60
SMB: Add Negotiation Req & Response for v1
Send SMB1 header, and Negotiation Request message for SMB1.

This brings the zgrab2 smb1 scanner to parity with the zgrab smb1
scanner, with presence detection via smbv1_support.

We check the ProtocolID in the raw data response, for two reasons:

1. Even if the full unmarshal fails for the message, we will log
   that it is an smbv1 server

2. We need to add more response types structs, because the format
   is different for various SMB1 dialects.

The negotiation response v1 structure is for the SMB1 "NT LM 0.12"
dialect, and is essentially placeholder for now for future parsing.

TODO: Unmarshal into the appropriate message struct based on
SMB1 dialect, and parse dialect and capabilities, and return those
results.
2019-06-10 17:17:20 -04:00
Jeff Cody
f2b76412fb
SMB: Combine 'GetSMBLog()' and 'GetSMBBanner()'
These two functions are largely duplicates, and only differ in the
boolean option passed to LoggedNegotiateProtocol().  Combine the
functions, and just take that option in as an argument to pass along.
2019-06-07 16:54:26 -04:00
Jeff Cody
c0f5084a6a
Merge pull request #205 from codyprime/jcody/lib-smbfix
SMB: Bounds check slice index before access
2019-06-05 14:02:20 -04:00
Jeff Cody
2e67991362
SMB: Bounds check slice index before access
The smb library bounds checks for a message size that is too large, but
does not check for a message size that is way too small.  Error out if
the message size is not at least as large as the ProtocolID 4-byte
preamble.

This fixes slice out of bound panics when checking the buffer for the
protID string for certain hosts.

Signed-off-by: Jeff Cody <jcody@censys.io>
2019-06-04 22:26:27 -04:00
Jeff Cody
37bb923ce4
SMB: Parse capabilties flags for the server
This parses the capabilities flags for the server, masking off invalid
flags based on dialect.

While both the NegotiationLogs and SessionSetupLog contain capabilities
flags, we extract the flags from the NegotiationLogs to represent the
server, as it is explicitly stated in [MS-SMB2] that those are the ones
that represent the capabilities of the server.
2019-05-24 15:47:22 -04:00
Jeff Cody
79a96f08ae
SMB: Parse SMB Versions and Dialects.
This parses the SMB Version response, and the dialect, to determine the
full SMB version.  This is done in accordance to "[MS-SMB2] - v20190430"
from Microsoft, Section 2.2.4.
2019-05-24 15:47:10 -04:00
Jeff Cody
2e71f25c85
SMB: Omit Negotiation adn Session logs if empty
Currently, we will output 'null' json fields for either of
these logs if they are not present; instead, let's just omit
them entirely.
2019-05-24 15:33:25 -04:00
Jeff Cody
da90d489b1
SMB: Formatting, line-wrap comments 2019-05-23 13:45:18 -04:00
Justin Bastress
199fe5d8e5 PEP8 updates; fix NTLM typo 2018-03-16 14:39:06 -04:00
Justin Bastress
1024fb4619 break out early if !setup-session; make debug configurable 2018-03-16 14:34:15 -04:00
Justin Bastress
586992cb15 More comments; make old zgrab behavior the default 2018-03-16 14:00:12 -04:00
Justin Bastress
65d1789860 comments; update schema 2018-03-16 13:21:05 -04:00
Justin Bastress
c05c00a743 Pull in updated SMB library, modify it to take logs, use it in scanner 2018-03-16 12:08:59 -04:00
Justin Bastress
70314ce92b Port SMB (???) scanner from ZGrab 2018-03-15 16:58:57 -04:00