From 67a85b3f1bca7e0590ae97d07a6ef32c418e64d1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 12 Nov 2005 07:48:56 +0000 Subject: r11697: - added a generic SMB2 getinfo call - added a SMB2-SCANGETINFO test for scanning for available info levels - added names for the info levels I recognise to smb2.h (This used to be commit fe5986067e2aaca039d70393ccc8761434f18fe6) --- source4/torture/smb2/scan.c | 73 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'source4/torture/smb2/scan.c') diff --git a/source4/torture/smb2/scan.c b/source4/torture/smb2/scan.c index 0fcd3250fb..3946d19496 100644 --- a/source4/torture/smb2/scan.c +++ b/source4/torture/smb2/scan.c @@ -28,6 +28,79 @@ #include "lib/events/events.h" +/* + scan for valid SMB2 getinfo levels +*/ +BOOL torture_smb2_getinfo_scan(void) +{ + TALLOC_CTX *mem_ctx = talloc_new(NULL); + struct smb2_tree *tree; + const char *host = lp_parm_string(-1, "torture", "host"); + const char *share = lp_parm_string(-1, "torture", "share"); + struct cli_credentials *credentials = cmdline_credentials; + NTSTATUS status; + struct smb2_getinfo io; + struct smb2_create cr; + struct smb2_handle handle; + int c, i; + const char *fname = "scan-getinfo.dat"; + + status = smb2_connect(mem_ctx, host, share, credentials, &tree, + event_context_find(mem_ctx)); + if (!NT_STATUS_IS_OK(status)) { + printf("Connection failed - %s\n", nt_errstr(status)); + return False; + } + + ZERO_STRUCT(cr); + cr.in.buffer_code = 0x39; + cr.in.oplock_flags = 0; + cr.in.access_mask = SEC_RIGHTS_FILE_ALL; + cr.in.file_attr = FILE_ATTRIBUTE_NORMAL; + cr.in.open_disposition = NTCREATEX_DISP_OPEN_IF; + cr.in.share_access = + NTCREATEX_SHARE_ACCESS_DELETE| + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE; + cr.in.create_options = NTCREATEX_OPTIONS_WRITE_THROUGH; + cr.in.fname = fname; + + status = smb2_create(tree, &cr); + if (!NT_STATUS_IS_OK(status)) { + printf("create of '%s' failed - %s\n", fname, nt_errstr(status)); + return False; + } + + handle = cr.out.handle; + + + ZERO_STRUCT(io); + io.in.buffer_code = 0x29; + io.in.max_response_size = 0xFFFF; + io.in.handle = handle; + + for (c=0;c<5;c++) { + for (i=0;i<0x100;i++) { + io.in.level = (i<<8) | c; + status = smb2_getinfo(tree, mem_ctx, &io); + if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER) || + NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS) || + NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { + continue; + } + if (NT_STATUS_IS_OK(status)) { + printf("level 0x%04x is %d bytes\n", + io.in.level, io.out.blob.length); + dump_data(1, io.out.blob.data, io.out.blob.length); + } + } + } + + talloc_free(mem_ctx); + + return True; +} + /* scan for valid SMB2 opcodes */ -- cgit