Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Feature/smb/v18.0 #3266

Closed
wants to merge 17 commits into from
Closed

Conversation

victorjulien
Copy link
Member

Changes since #3260:

  • rebase to master
  • small update for der-parser 0.5.1

PRScript output (if applicable):

Implement SMB app-layer parser for SMB1/2/3. Features:
- file extraction
- eve logging
- existing dce keyword support
- smb_share/smb_named_pipe keyword support (stickybuffers)
- auth meta data extraction (ntlmssp, kerberos5)
Improve ntlmssp version extraction and logging, make its data structures
optional. Extract native os/lm from smb1 ssn setup.

Move session setup handling into their own files.

Only log auth data for the session setup tx.
Copy link
Member

@norg norg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs look good

@jasonish
Copy link
Member

jasonish commented Mar 6, 2018

Rather minor, but I just noticed that this, and nfs use "_" in filenames. Whereas the C code uses "-". Is there a specific reason for this?

@jasonish
Copy link
Member

jasonish commented Mar 7, 2018

My first look at this was as a user and here are some things I noticed:

  • My Linux to Linux CIFS shares use very long running sessions. So I had to remount those to get Suricata to pick anything up. This would be a good use case for per-protocol midstream pickup?

  • I think we need a way, right from the start to filter out certain types of SMB logging. One example is to play a movie from an SMB mount and watch the flood of SMB2_COMMAND_READ messages go by. Is there a default set that would give us the following information: who mounted it, files created/deleted/read - without logging ever read block?

  • The statux field looks like its the status-code. Can we call it "status_code" even though its logged as a hex string. The other option is to log it as an integer, but we do have some other cases where flags are logged as a hex string as well.

  • Can the disposition field use a value in ALL_CAPS? Looks like the MSDN docs use FILE_OPEN, FILE_CREATE, etc.

  • Can the access field also use ALL_CAPS values? Again the MSDN docs use strings like DELETE_ON_CLOSE.

  • Rename "file" to "filename". It looks like NFS uses "filename", as well as fileinfo.

But overall this looks great! I think there's just too much information for the basic use case.

@@ -798,13 +800,12 @@ app-layer:
enabled: detection-only
msn:
enabled: detection-only
# Note: --enable-rust is required for full SMB1/2 support. W/o rust
# only minimal SMB1 support is available.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're missing an "smb" stub in the eve-log types.

@pevma
Copy link
Member

pevma commented Mar 8, 2018

I see a lot of these in verbose mode (though I have no debugging enabled but running with -vvv on the command line):

...
smb.rs:974) <Notice> (<rust>) -- check_gap_resync2: TX 2 is done post-GAP, mark all older ones complete
[32316] 8/3/2018 -- 00:56:06 - (debug.rs:27) <Notice> (<rust>) -- TXs 3 MIN 1 MAX 3
[32316] 8/3/2018 -- 00:56:06 - (debug.rs:28) <Notice> (<rust>) -- - OLD tx.id 1: SMBTransaction { id: 1, vercmd: SMBVerCmdStat { smb_ver: 1, smb1_cmd: 114, smb2_cmd: 0, status_set: false, status_is_dos_error: false, status: 0 }, hdr: SMBCommonHdr { ssn_id: 0, tree_id: 0, rec_type: 0, msg_id: 0 }, request_done: true, response_done: true, type_data: Some(NEGOTIATE(SMBTransactionNegotiate { smb_ver: 1, dialects: [[76, 65, 78, 77, 65, 78, 49, 46, 48], [76, 77, 49, 46, 50, 88, 48, 48, 50], [78, 84, 32, 76, 65, 78, 77, 65, 78, 32, 49, 46, 48], [78, 84, 32, 76, 77, 32, 48, 46, 49, 50]], dialects2: [] })), detect_flags_ts: 9223372036854775808, detect_flags_tc: 0, logged: LoggerFlags { flags: 0 }, de_state: Some(0x6040030add90), events: 0x0 }
[32316] 8/3/2018 -- 00:56:06 - (debug.rs:29) <Notice> (<rust>) -- - NEW tx.id 3: SMBTransaction { id: 3, vercmd: SMBVerCmdStat { smb_ver: 1, smb1_cmd: 117, smb2_cmd: 0, status_set: false, status_is_dos_error: false, status: 0 }, hdr: SMBCommonHdr { ssn_id: 30721, tree_id: 0, rec_type: 10, msg_id: 24261 }, request_done: true, response_done: false, type_data: Some(TREECONNECT(SMBTransactionTreeConnect { is_pipe: false, tree_id: 0, share_name: [92, 49, 48, 46, 51, 50, 46, 51, 52, 46, 56, 92, 73, 80, 67, 36, 63, 63, 63] })), detect_flags_ts: 0, detect_flags_tc: 0, logged: LoggerFlags { flags: 0 }, de_state: None, events: 0x0 }
[32316] 8/3/2018 -- 00:56:06 - (debug.rs:55) <Notice> (<rust>) -- idx 0 tx id 1 ver:1 cmd:114 progress true/true type_data Some(NEGOTIATE(SMBTransactionNegotiate { smb_ver: 1, dialects: [[76, 65, 78, 77, 65, 78, 49, 46, 48], [76, 77, 49, 46, 50, 88, 48, 48, 50], [78, 84, 32, 76, 65, 78, 77, 65, 78, 32, 49, 46, 48], [78, 84, 32, 76, 77, 32, 48, 46, 49, 50]], dialects2: [] })) tx SMBTransaction { id: 1, vercmd: SMBVerCmdStat { smb_ver: 1, smb1_cmd: 114, smb2_cmd: 0, status_set: false, status_is_dos_error: false, status: 0 }, hdr: SMBCommonHdr { ssn_id: 0, tree_id: 0, rec_type: 0, msg_id: 0 }, request_done: true, response_done: true, type_data: Some(NEGOTIATE(SMBTransactionNegotiate { smb_ver: 1, dialects: [[76, 65, 78, 77, 65, 78, 49, 46, 48], [76, 77, 49, 46, 50, 88, 48, 48, 50], [78, 84, 32, 76, 65, 78, 77, 65, 78, 32, 49, 46, 48], [78, 84, 32, 76, 77, 32, 48, 46, 49, 50]], dialects2: [] })), detect_flags_ts: 9223372036854775808, detect_flags_tc: 0, logged: LoggerFlags { flags: 0 }, de_state: Some(0x6040030add90), events: 0x0 }
....

was wondering if that is expected?

@inliniac
Copy link
Contributor

inliniac commented Mar 9, 2018 via email

@inliniac
Copy link
Contributor

inliniac commented Mar 9, 2018 via email

@victorjulien
Copy link
Member Author

victorjulien commented Mar 9, 2018 via email

@inliniac
Copy link
Contributor

inliniac commented Mar 9, 2018 via email

@inliniac
Copy link
Contributor

inliniac commented Mar 9, 2018 via email

@inliniac
Copy link
Contributor

inliniac commented Mar 9, 2018 via email

@victorjulien
Copy link
Member Author

In general I think I'd like to break out some of the sub-objects I created:

smb.dcerpc: dcerpc can be on it's own as well on the wire
smb.kerberos: same, plus it's used by other protocols too
smb.ntlmssp: same as kerberos
smb.filestuff: as discussed above

@victorjulien
Copy link
Member Author

victorjulien commented Mar 9, 2018 via email

@jasonish
Copy link
Member

jasonish commented Mar 9, 2018

On 07-03-18 18:41, Jason Ish wrote:

Can the disposition field use a value in ALL_CAPS? Looks like the MSDN
docs use FILE_OPEN, FILE_CREATE, etc.

Can the access field also use ALL_CAPS values? Again the MSDN docs use
strings like DELETE_ON_CLOSE.
Can you add a link?

https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx - See FILE_FLAG_DELETE_ON_CLOSE. I think this is more of Windows programming guide, but its pretty closely tied to SMB.

@jasonish
Copy link
Member

jasonish commented Mar 9, 2018 via email

@jasonish
Copy link
Member

jasonish commented Mar 9, 2018 via email

@victorjulien
Copy link
Member Author

Replaced by #3281

This was referenced Mar 12, 2018
@victorjulien victorjulien deleted the feature/smb/v18.0 branch April 16, 2018 05:17
catenacyber added a commit to catenacyber/suricata that referenced this pull request Oct 30, 2019
catenacyber added a commit to catenacyber/suricata that referenced this pull request Oct 30, 2019
catenacyber added a commit to catenacyber/suricata that referenced this pull request Nov 12, 2019
catenacyber added a commit to catenacyber/suricata that referenced this pull request Nov 12, 2019
victorjulien pushed a commit to victorjulien/suricata that referenced this pull request Dec 5, 2019
catenacyber added a commit to catenacyber/suricata that referenced this pull request Dec 6, 2019
victorjulien pushed a commit to victorjulien/suricata that referenced this pull request Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants