summaryrefslogtreecommitdiff
path: root/source4/torture/smb2/scan.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-11-12 07:48:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:46:15 -0500
commit67a85b3f1bca7e0590ae97d07a6ef32c418e64d1 (patch)
treecfa60883edcaf23ea6ecd0742247100322d45e40 /source4/torture/smb2/scan.c
parenta1562e23800caef20730db9d1e5006d3a9ea4298 (diff)
downloadsamba-67a85b3f1bca7e0590ae97d07a6ef32c418e64d1.tar.gz
samba-67a85b3f1bca7e0590ae97d07a6ef32c418e64d1.tar.bz2
samba-67a85b3f1bca7e0590ae97d07a6ef32c418e64d1.zip
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)
Diffstat (limited to 'source4/torture/smb2/scan.c')
-rw-r--r--source4/torture/smb2/scan.c73
1 files changed, 73 insertions, 0 deletions
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
@@ -29,6 +29,79 @@
/*
+ 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
*/
BOOL torture_smb2_scan(void)