diff options
author | Luke Leighton <lkcl@samba.org> | 1998-11-10 19:05:00 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1998-11-10 19:05:00 +0000 |
commit | 1e1c2ec93c204e6fd3ebba6dfb11e4fbc136e10c (patch) | |
tree | 1bf71664960c671d6447a085a5087ce13bb14fea /source3/rpcclient | |
parent | 313d8ef27df81118b57f3d214db75be25e38b612 (diff) | |
download | samba-1e1c2ec93c204e6fd3ebba6dfb11e4fbc136e10c.tar.gz samba-1e1c2ec93c204e6fd3ebba6dfb11e4fbc136e10c.tar.bz2 samba-1e1c2ec93c204e6fd3ebba6dfb11e4fbc136e10c.zip |
rpcclient registry commands.
(This used to be commit 36fcb4a6e643a05d06a2a273d74318fee7f2c647)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r-- | source3/rpcclient/cmd_reg.c | 389 | ||||
-rw-r--r-- | source3/rpcclient/display.c | 375 | ||||
-rw-r--r-- | source3/rpcclient/rpcclient.c | 40 |
3 files changed, 725 insertions, 79 deletions
diff --git a/source3/rpcclient/cmd_reg.c b/source3/rpcclient/cmd_reg.c index 399fb30603..48b6d385bb 100644 --- a/source3/rpcclient/cmd_reg.c +++ b/source3/rpcclient/cmd_reg.c @@ -42,9 +42,6 @@ nt registry enum ****************************************************************************/ void cmd_reg_enum(struct client_info *info) { - fstring type; - uint32 unk_0; - uint32 unk_1; BOOL res = True; BOOL res1 = True; BOOL res2 = True; @@ -57,15 +54,15 @@ void cmd_reg_enum(struct client_info *info) * query key info */ - uint32 unknown_0; - uint32 unknown_1; + fstring key_class; + uint32 max_class_len = 0; uint32 num_subkeys; uint32 max_subkeylen; - uint32 unknown_4; + uint32 max_subkeysize; uint32 num_values; uint32 max_valnamelen; uint32 max_valbufsize; - uint32 unknown_8; + uint32 sec_desc; NTTIME mod_time; /* @@ -94,28 +91,12 @@ void cmd_reg_enum(struct client_info *info) res1 = res ? do_reg_open_entry(smb_cli, &info->dom.reg_pol_connect, key_name, 0x02000000, &key_pol) : False; - /* query it */ - res1 = res1 ? do_reg_query_info(smb_cli, &key_pol, - type, &unk_0, &unk_1) : False; - - res1 = res1 ? do_reg_query_unk_10(smb_cli, + res1 = res1 ? do_reg_query_key(smb_cli, &key_pol, - &unknown_0, &unknown_1, - &num_subkeys, &max_subkeylen, - &unknown_4, &num_values, - &max_valnamelen, &max_valbufsize, - &unknown_8, &mod_time) : False; - - if (res1) - { - fprintf(out_hnd,"Registry Query Info Key\n"); - fprintf(out_hnd,"unk_0,1 : 0x%x 0x%x\n", unknown_0, unknown_1); - fprintf(out_hnd,"subkeys, max_len: %d %d\n", num_subkeys, max_subkeylen); - fprintf(out_hnd,"unk_4 : 0x%x\n", unknown_4); - fprintf(out_hnd,"vals, max_len, max_size: 0x%x 0x%x 0x%x\n", num_values, max_valnamelen, max_valbufsize); - fprintf(out_hnd,"unk_8: 0x%x\n", unknown_8); - fprintf(out_hnd,"mod time: %s\n", http_timestring(nt_time_to_unix(&mod_time))); - } + key_class, &max_class_len, + &num_subkeys, &max_subkeylen, &max_subkeysize, + &num_values, &max_valnamelen, &max_valbufsize, + &sec_desc, &mod_time) : False; for (i = 0; i < num_subkeys; i++) { @@ -194,8 +175,6 @@ void cmd_reg_enum(struct client_info *info) if (res && res1 && res2) { DEBUG(5,("cmd_reg_enum: query succeeded\n")); - fprintf(out_hnd,"Registry Enumeration\n"); - fprintf(out_hnd,"Type: %s unk_0:%x unk_1:%x\n", type, unk_0, unk_1); } else { @@ -204,6 +183,96 @@ void cmd_reg_enum(struct client_info *info) } /**************************************************************************** +nt registry query key +****************************************************************************/ +void cmd_reg_query_key(struct client_info *info) +{ + BOOL res = True; + BOOL res1 = True; + + POLICY_HND key_pol; + fstring key_name; + + /* + * query key info + */ + + fstring key_class; + uint32 key_class_len = 0; + uint32 num_subkeys; + uint32 max_subkeylen; + uint32 max_subkeysize; + uint32 num_values; + uint32 max_valnamelen; + uint32 max_valbufsize; + uint32 sec_desc; + NTTIME mod_time; + + DEBUG(5, ("cmd_reg_enum: smb_cli->fd:%d\n", smb_cli->fd)); + + if (!next_token(NULL, key_name, NULL, sizeof(key_name))) + { + fprintf(out_hnd, "regquery key_name\n"); + return; + } + + /* open WINREG session. */ + res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG) : False; + + /* open registry receive a policy handle */ + res = res ? do_reg_open_policy(smb_cli, + 0x84E0, 0x02000000, + &info->dom.reg_pol_connect) : False; + + /* open an entry */ + res1 = res ? do_reg_open_entry(smb_cli, &info->dom.reg_pol_connect, + key_name, 0x02000000, &key_pol) : False; + + res1 = res1 ? do_reg_query_key(smb_cli, + &key_pol, + key_class, &key_class_len, + &num_subkeys, &max_subkeylen, &max_subkeysize, + &num_values, &max_valnamelen, &max_valbufsize, + &sec_desc, &mod_time) : False; + + if (res1 && key_class_len != 0) + { + res1 = res1 ? do_reg_query_key(smb_cli, + &key_pol, + key_class, &key_class_len, + &num_subkeys, &max_subkeylen, &max_subkeysize, + &num_values, &max_valnamelen, &max_valbufsize, + &sec_desc, &mod_time) : False; + } + + if (res1) + { + fprintf(out_hnd,"Registry Query Info Key\n"); + fprintf(out_hnd,"key class: %s\n", key_class); + fprintf(out_hnd,"subkeys, max_len, max_size: %d %d %d\n", num_subkeys, max_subkeylen, max_subkeysize); + fprintf(out_hnd,"vals, max_len, max_size: 0x%x 0x%x 0x%x\n", num_values, max_valnamelen, max_valbufsize); + fprintf(out_hnd,"sec desc: 0x%x\n", sec_desc); + fprintf(out_hnd,"mod time: %s\n", http_timestring(nt_time_to_unix(&mod_time))); + } + + /* close the handles */ + res1 = res1 ? do_reg_close(smb_cli, &key_pol) : False; + res = res ? do_reg_close(smb_cli, &info->dom.reg_pol_connect) : False; + + /* close the session */ + cli_nt_session_close(smb_cli); + + if (res && res1) + { + DEBUG(5,("cmd_reg_query: query succeeded\n")); + } + else + { + DEBUG(5,("cmd_reg_query: query failed\n")); + } +} + +/**************************************************************************** nt registry test ****************************************************************************/ void cmd_reg_test2(struct client_info *info) @@ -211,21 +280,23 @@ void cmd_reg_test2(struct client_info *info) BOOL res = True; BOOL res1 = True; BOOL res2 = True; + BOOL res3 = True; int i; /* * query key info */ - uint32 unknown_0; - uint32 unknown_1; + POLICY_HND key_pol; + fstring key_class; + uint32 max_class_len; uint32 num_subkeys; uint32 max_subkeylen; - uint32 unknown_4; + uint32 max_subkeysize; uint32 num_values; uint32 max_valnamelen; - uint32 unknown_7; - uint32 unknown_8; + uint32 max_valbufsize; + uint32 sec_desc; NTTIME mod_time; /* @@ -257,43 +328,31 @@ void cmd_reg_test2(struct client_info *info) 0x84E0, 0x02000000, &info->dom.reg_pol_unk_4 ) : False; - res2 = res1 ? do_reg_query_unk_10(smb_cli, - &info->dom.reg_pol_connect, - &unknown_0, &unknown_1, - &num_subkeys, &max_subkeylen, - &unknown_4, &num_values, - &max_valnamelen, &unknown_7, - &unknown_8, &mod_time) : False; - - if (res2) - { - fprintf(out_hnd,"Registry Query Info Key\n"); - fprintf(out_hnd,"unk_0,1 : 0x%x 0x%x\n", unknown_0, unknown_1); - fprintf(out_hnd,"subkeys, max_len: %d %d\n", num_subkeys, max_subkeylen); - fprintf(out_hnd,"unk_4 : 0x%x\n", unknown_4); - fprintf(out_hnd,"vals, max_len : 0x%x 0x%x\n", num_values, max_valnamelen); - fprintf(out_hnd,"unk_7, 8: 0x%x 0x%x\n", unknown_7, unknown_8); - fprintf(out_hnd,"mod time: %s\n", http_timestring(nt_time_to_unix(&mod_time))); - } + res2 = res1 ? do_reg_query_key(smb_cli, + &key_pol, + key_class, &max_class_len, + &num_subkeys, &max_subkeylen, &max_subkeysize, + &num_values, &max_valnamelen, &max_valbufsize, + &sec_desc, &mod_time) : False; for (i = 0; i < num_subkeys; i++) { /* unknown 1a it */ - res2 = res1 ? do_reg_unknown_1a(smb_cli, &info->dom.reg_pol_connect, + res3 = res2 ? do_reg_unknown_1a(smb_cli, &info->dom.reg_pol_connect, &unk_1a_response) : False; - if (res2) + if (res3) { fprintf(out_hnd,"Unknown 1a response: %x\n", unk_1a_response); } /* enum key */ - res2 = res2 ? do_reg_enum_key(smb_cli, &info->dom.reg_pol_connect, + res3 = res3 ? do_reg_enum_key(smb_cli, &info->dom.reg_pol_connect, i, enum_name, &enum_unk1, &enum_unk2, &key_mod_time) : False; - if (res2) + if (res3) { fprintf(out_hnd,"Enum Key: %s ", enum_name); fprintf(out_hnd,"unk (%08x %08x) ", enum_unk1, enum_unk2); @@ -302,6 +361,7 @@ void cmd_reg_test2(struct client_info *info) } /* close the handles */ + res2 = res2 ? do_reg_close(smb_cli, &key_pol ) : False; res1 = res1 ? do_reg_close(smb_cli, &info->dom.reg_pol_unk_4 ) : False; res = res ? do_reg_close(smb_cli, &info->dom.reg_pol_connect) : False; @@ -320,6 +380,221 @@ void cmd_reg_test2(struct client_info *info) } /**************************************************************************** +nt registry create value +****************************************************************************/ +void cmd_reg_create_val(struct client_info *info) +{ + BOOL res = True; + BOOL res3 = True; + BOOL res4 = True; + + POLICY_HND parent_pol; + fstring parent_name; + fstring val_name; + fstring tmp; + uint32 val_type; + BUFFER3 value; + +#if 0 + uint32 unk_0; + uint32 unk_1; + /* query it */ + res1 = res1 ? do_reg_query_info(smb_cli, &val_pol, + type, &unk_0, &unk_1) : False; +#endif + + DEBUG(5, ("cmd_reg_get_val_sec: smb_cli->fd:%d\n", smb_cli->fd)); + + if (!next_token(NULL, parent_name, NULL, sizeof(parent_name))) + { + fprintf(out_hnd, "regcreate <parent val name> <val_name> <val_type> <val>\n"); + return; + } + + if (!next_token(NULL, val_name , NULL, sizeof(val_name ))) + { + fprintf(out_hnd, "regcreate <parent val name> <val_name> <val_type> <val>\n"); + return; + } + + if (!next_token(NULL, tmp, NULL, sizeof(tmp))) + { + fprintf(out_hnd, "regcreate <parent val name> <val_name> <val_type (1|4)> <val>\n"); + return; + } + + val_type = atoi(tmp); + + if (val_type != 1 && val_type != 3 && val_type != 4) + { + fprintf(out_hnd, "val_type 1=UNISTR, 3=BYTES, 4=DWORD supported\n"); + return; + } + + if (!next_token(NULL, tmp, NULL, sizeof(tmp))) + { + fprintf(out_hnd, "regcreate <parent val name> <val_name> <val_type (1|4)> <val>\n"); + return; + } + + switch (val_type) + { + case 0x01: /* UNISTR */ + { + make_buffer3_str(&value, tmp, strlen(tmp)+1); + break; + } + case 0x03: /* BYTES */ + { + make_buffer3_hex(&value, tmp); + break; + } + case 0x04: /* DWORD */ + { + uint32 tmp_val; + if (strnequal(tmp, "0x", 2)) + { + tmp_val = strtol(tmp, (char**)NULL, 16); + } + else + { + tmp_val = strtol(tmp, (char**)NULL, 10); + } + make_buffer3_uint32(&value, tmp_val); + break; + } + default: + { + fprintf(out_hnd, "i told you i only deal with UNISTR, DWORD and BYTES!\n"); + return; + } + } + + DEBUG(10,("key data:\n")); + dump_data(10, value.buffer, value.buf_len); + + /* open WINREG session. */ + res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG) : False; + + /* open registry receive a policy handle */ + res = res ? do_reg_open_policy(smb_cli, + 0x84E0, 0x02000000, + &info->dom.reg_pol_connect) : False; + + /* open an entry */ + res3 = res ? do_reg_open_entry(smb_cli, &info->dom.reg_pol_connect, + parent_name, 0x02000000, &parent_pol) : False; + + /* create an entry */ + res4 = res3 ? do_reg_create_val(smb_cli, &parent_pol, + val_name, val_type, &value) : False; + + /* close the val handle */ + res3 = res3 ? do_reg_close(smb_cli, &parent_pol) : False; + + /* close the registry handles */ + res = res ? do_reg_close(smb_cli, &info->dom.reg_pol_connect) : False; + + /* close the session */ + cli_nt_session_close(smb_cli); + + if (res && res3 && res4) + { + DEBUG(5,("cmd_reg_create_val: query succeeded\n")); + fprintf(out_hnd,"OK\n"); + } + else + { + DEBUG(5,("cmd_reg_create_val: query failed\n")); + } +} + +/**************************************************************************** +nt registry create key +****************************************************************************/ +void cmd_reg_create_key(struct client_info *info) +{ + BOOL res = True; + BOOL res3 = True; + BOOL res4 = True; + + POLICY_HND parent_pol; + POLICY_HND key_pol; + fstring parent_name; + fstring key_name; + fstring key_class; + SEC_INFO sam_access; + +#if 0 + uint32 unk_0; + uint32 unk_1; + /* query it */ + res1 = res1 ? do_reg_query_info(smb_cli, &key_pol, + type, &unk_0, &unk_1) : False; +#endif + + DEBUG(5, ("cmd_reg_create_key: smb_cli->fd:%d\n", smb_cli->fd)); + + if (!next_token(NULL, parent_name, NULL, sizeof(parent_name))) + { + fprintf(out_hnd, "regcreate <parent key name> <key_name> [key_class]\n"); + return; + } + + if (!next_token(NULL, key_name , NULL, sizeof(key_name ))) + { + fprintf(out_hnd, "regcreate <parent key name> <key_name> [key_class]\n"); + return; + } + + if (!next_token(NULL, key_class, NULL, sizeof(key_class))) + { + memset(key_class, 0, sizeof(key_class)); + } + + /* set access permissions */ + sam_access.perms = SEC_RIGHTS_READ; + + /* open WINREG session. */ + res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG) : False; + + /* open registry receive a policy handle */ + res = res ? do_reg_open_policy(smb_cli, + 0x84E0, 0x02000000, + &info->dom.reg_pol_connect) : False; + + /* open an entry */ + res3 = res ? do_reg_open_entry(smb_cli, &info->dom.reg_pol_connect, + parent_name, 0x02000000, &parent_pol) : False; + + /* create an entry */ + res4 = res3 ? do_reg_create_key(smb_cli, &parent_pol, + key_name, key_class, &sam_access, &key_pol) : False; + + /* close the key handle */ + res4 = res4 ? do_reg_close(smb_cli, &key_pol) : False; + + /* close the key handle */ + res3 = res3 ? do_reg_close(smb_cli, &parent_pol) : False; + + /* close the registry handles */ + res = res ? do_reg_close(smb_cli, &info->dom.reg_pol_connect) : False; + + /* close the session */ + cli_nt_session_close(smb_cli); + + if (res && res3 && res4) + { + DEBUG(5,("cmd_reg_create_key: query succeeded\n")); + fprintf(out_hnd,"OK\n"); + } + else + { + DEBUG(5,("cmd_reg_create_key: query failed\n")); + } +} + +/**************************************************************************** nt registry security info ****************************************************************************/ void cmd_reg_get_key_sec(struct client_info *info) diff --git a/source3/rpcclient/display.c b/source3/rpcclient/display.c index f399b7fc03..e173ced009 100644 --- a/source3/rpcclient/display.c +++ b/source3/rpcclient/display.c @@ -977,12 +977,12 @@ void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_I fprintf(out_hnd, "\t\tUnknown Str : %s\n", unistrn2(usr->uni_unknown_str .buffer, usr->uni_unknown_str .uni_str_len)); /* unknown string unicode string */ fprintf(out_hnd, "\t\tRemote Dial : %s\n", unistrn2(usr->uni_munged_dial .buffer, usr->uni_munged_dial .uni_str_len)); /* munged remote access unicode string */ - fprintf(out_hnd, "\t\tLogon Time : %s\n", http_timestring(interpret_nt_time(&(usr->logon_time )))); - fprintf(out_hnd, "\t\tLogoff Time : %s\n", http_timestring(interpret_nt_time(&(usr->logoff_time )))); - fprintf(out_hnd, "\t\tKickoff Time : %s\n", http_timestring(interpret_nt_time(&(usr->kickoff_time )))); - fprintf(out_hnd, "\t\tPassword last set Time : %s\n", http_timestring(interpret_nt_time(&(usr->pass_last_set_time )))); - fprintf(out_hnd, "\t\tPassword can change Time : %s\n", http_timestring(interpret_nt_time(&(usr->pass_can_change_time )))); - fprintf(out_hnd, "\t\tPassword must change Time: %s\n", http_timestring(interpret_nt_time(&(usr->pass_must_change_time)))); + fprintf(out_hnd, "\t\tLogon Time : %s\n", http_timestring(nt_time_to_unix(&(usr->logon_time )))); + fprintf(out_hnd, "\t\tLogoff Time : %s\n", http_timestring(nt_time_to_unix(&(usr->logoff_time )))); + fprintf(out_hnd, "\t\tKickoff Time : %s\n", http_timestring(nt_time_to_unix(&(usr->kickoff_time )))); + fprintf(out_hnd, "\t\tPassword last set Time : %s\n", http_timestring(nt_time_to_unix(&(usr->pass_last_set_time )))); + fprintf(out_hnd, "\t\tPassword can change Time : %s\n", http_timestring(nt_time_to_unix(&(usr->pass_can_change_time )))); + fprintf(out_hnd, "\t\tPassword must change Time: %s\n", http_timestring(nt_time_to_unix(&(usr->pass_must_change_time)))); fprintf(out_hnd, "\t\tunknown_2[0..31]...\n"); /* user passwords? */ @@ -1011,3 +1011,366 @@ void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_I } } + +/**************************************************************************** +convert a security permissions into a string +****************************************************************************/ +char *get_sec_perms_str(uint32 type) +{ + static fstring typestr; + int i; + + switch (type) + { + case SEC_RIGHTS_FULL_CONTROL: + { + fstrcpy(typestr, "Full Control"); + return typestr; + } + + case SEC_RIGHTS_READ: + { + fstrcpy(typestr, "Read"); + return typestr; + } + default: + { + break; + } + } + + typestr[0] = 0; + for (i = 0; i < 32; i++) + { + if (IS_BITS_SET_ALL(type, 1 << i)) + { + switch (1 << i) + { + case SEC_RIGHTS_QUERY_VALUE : fstrcat(typestr, "Query " ); break; + case SEC_RIGHTS_SET_VALUE : fstrcat(typestr, "Set " ); break; + case SEC_RIGHTS_CREATE_SUBKEY : fstrcat(typestr, "Create "); break; + case SEC_RIGHTS_ENUM_SUBKEYS : fstrcat(typestr, "Enum "); break; + case SEC_RIGHTS_NOTIFY : fstrcat(typestr, "Notify "); break; + case SEC_RIGHTS_CREATE_LINK : fstrcat(typestr, "CreateLink "); break; + case SEC_RIGHTS_DELETE : fstrcat(typestr, "Delete "); break; + case SEC_RIGHTS_READ_CONTROL : fstrcat(typestr, "ReadControl "); break; + case SEC_RIGHTS_WRITE_DAC : fstrcat(typestr, "WriteDAC "); break; + case SEC_RIGHTS_WRITE_OWNER : fstrcat(typestr, "WriteOwner "); break; + } + type &= ~(1 << i); + } + } + + /* remaining bits get added on as-is */ + if (type != 0) + { + fstring tmp; + snprintf(tmp, sizeof(tmp), "[%08x]", type); + fstrcat(typestr, tmp); + } + + /* remove last space */ + i = strlen(typestr)-1; + if (typestr[i] == ' ') typestr[i] = 0; + + return typestr; +} + +/**************************************************************************** + display sec_info structure + ****************************************************************************/ +void display_sec_info(FILE *out_hnd, enum action_type action, SEC_INFO *info) +{ + switch (action) + { + case ACTION_HEADER: + { + break; + } + case ACTION_ENUMERATE: + { + fprintf(out_hnd, "\t\tPermissions: %s\n", + get_sec_perms_str(info->perms)); + } + case ACTION_FOOTER: + { + break; + } + } +} + +/**************************************************************************** + display sec_ace structure + ****************************************************************************/ +void display_sec_ace(FILE *out_hnd, enum action_type action, SEC_ACE *ace) +{ + switch (action) + { + case ACTION_HEADER: + { + fprintf(out_hnd, "\tACE\n"); + break; + } + case ACTION_ENUMERATE: + { + fstring sid_str; + + display_sec_info(out_hnd, ACTION_HEADER , &ace->info); + display_sec_info(out_hnd, ACTION_ENUMERATE, &ace->info); + display_sec_info(out_hnd, ACTION_FOOTER , &ace->info); + + sid_to_string(sid_str, &ace->sid); + fprintf(out_hnd, "\t\tSID: %s\n", sid_str); + } + case ACTION_FOOTER: + { + break; + } + } +} + +/**************************************************************************** + display sec_acl structure + ****************************************************************************/ +void display_sec_acl(FILE *out_hnd, enum action_type action, SEC_ACL *acl) +{ + switch (action) + { + case ACTION_HEADER: + { + fprintf(out_hnd, "\tACL\tNum ACEs: %d\tunk 1: %x\n", acl->num_aces, acl->unknown_1); + fprintf(out_hnd, "\t---\n"); + + break; + } + case ACTION_ENUMERATE: + { + if (acl->acl_size != 0 && acl->num_aces != 0) + { + int i; + for (i = 0; i < acl->num_aces; i++) + { + display_sec_ace(out_hnd, ACTION_HEADER , &acl->ace[i]); + display_sec_ace(out_hnd, ACTION_ENUMERATE, &acl->ace[i]); + display_sec_ace(out_hnd, ACTION_FOOTER , &acl->ace[i]); + } + } + + break; + } + case ACTION_FOOTER: + { + fprintf(out_hnd, "\n"); + break; + } + } +} + +/**************************************************************************** + display sec_desc structure + ****************************************************************************/ +void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *sec) +{ + switch (action) + { + case ACTION_HEADER: + { + fprintf(out_hnd, "\tSecurity Descriptor\tunk 1,2: %x %x\n", sec->unknown_1, sec->unknown_2); + fprintf(out_hnd, "\t-------------------\n"); + + break; + } + case ACTION_ENUMERATE: + { + fstring sid_str; + + if (sec->off_acl != 0) + { + display_sec_acl(out_hnd, ACTION_HEADER , &sec->acl); + display_sec_acl(out_hnd, ACTION_ENUMERATE, &sec->acl); + display_sec_acl(out_hnd, ACTION_FOOTER , &sec->acl); + } + if (sec->off_owner_sid != 0) + { + sid_to_string(sid_str, &sec->owner_sid); + fprintf(out_hnd, "\tOwner SID: %s\n", sid_str); + } + if (sec->off_pnt_sid != 0) + { + sid_to_string(sid_str, &sec->parent_sid); + fprintf(out_hnd, "\tParent SID: %s\n", sid_str); + } + + break; + } + case ACTION_FOOTER: + { + fprintf(out_hnd, "\n"); + break; + } + } +} + +/**************************************************************************** +convert a security permissions into a string +****************************************************************************/ +char *get_reg_val_type_str(uint32 type) +{ + static fstring typestr; + + switch (type) + { + case 0x01: + { + fstrcpy(typestr, "string"); + return typestr; + } + + case 0x03: + { + fstrcpy(typestr, "bytes"); + return typestr; + } + + case 0x04: + { + fstrcpy(typestr, "uint32"); + return typestr; + } + + case 0x07: + { + fstrcpy(typestr, "multi"); + return typestr; + } + default: + { + snprintf(typestr, sizeof(typestr), "[%d]", type); + return typestr; + break; + } + } + return typestr; +} + + +static void print_reg_value(FILE *out_hnd, char *val_name, uint32 val_type, BUFFER2 *value) +{ + fstring type; + fstrcpy(type, get_reg_val_type_str(val_type)); + + switch (val_type) + { + case 0x01: /* unistr */ + { + fprintf(out_hnd,"\t%s:\t%s:\t%s\n", val_name, type, buffer2_to_str(value)); + break; + } + + default: /* unknown */ + case 0x03: /* bytes */ + { + if (value->buf_len <= 8) + { + fprintf(out_hnd,"\t%s:\t%s:\t", val_name, type); + out_data(out_hnd, (char*)value->buffer, value->buf_len, 8); + } + else + { + fprintf(out_hnd,"\t%s:\t%s:\n", val_name, type); + out_data(out_hnd, (char*)value->buffer, value->buf_len, 16); + } + break; + } + + case 0x04: /* uint32 */ + { + fprintf(out_hnd,"\t%s:\t%s: 0x%08x\n", val_name, type, buffer2_to_uint32(value)); + break; + } + + case 0x07: /* multiunistr */ + { + fprintf(out_hnd,"\t%s:\t%s:\t%s\n", val_name, type, buffer2_to_multistr(value)); + break; + } + } +} + +/**************************************************************************** + display structure + ****************************************************************************/ +void display_reg_value_info(FILE *out_hnd, enum action_type action, + char *val_name, uint32 val_type, BUFFER2 *value) +{ + switch (action) + { + case ACTION_HEADER: + { + break; + } + case ACTION_ENUMERATE: + { + print_reg_value(out_hnd, val_name, val_type, value); + break; + } + case ACTION_FOOTER: + { + break; + } + } +} + +/**************************************************************************** + display structure + ****************************************************************************/ +void display_reg_key_info(FILE *out_hnd, enum action_type action, + char *key_name, time_t key_mod_time) +{ + switch (action) + { + case ACTION_HEADER: + { + break; + } + case ACTION_ENUMERATE: + { + fprintf(out_hnd, "\t%s\t(%s)\n", + key_name, http_timestring(key_mod_time)); + break; + } + case ACTION_FOOTER: + { + break; + } + } +} + +#if COPY_THIS_TEMPLATE +/**************************************************************************** + display structure + ****************************************************************************/ + void display_(FILE *out_hnd, enum action_type action, *) +{ + switch (action) + { + case ACTION_HEADER: + { + fprintf(out_hnd, "\t\n"); + fprintf(out_hnd, "\t-------------------\n"); + + break; + } + case ACTION_ENUMERATE: + { + break; + } + case ACTION_FOOTER: + { + fprintf(out_hnd, "\n"); + break; + } + } +} + +#endif diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index ba7f7d0180..017183fa1d 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -29,13 +29,13 @@ #define REGISTER 0 #endif +extern pstring debugf; extern pstring scope; extern pstring global_myname; extern pstring user_socket_options; -extern pstring debugf; extern int DEBUGLEVEL; @@ -105,6 +105,12 @@ struct char *description; } commands[] = { + {"regenum", cmd_reg_enum, "<keyname> Registry Enumeration (keys, values)"}, + {"regcreatekey",cmd_reg_create_key, "<parentname> <keyname> [keyclass] Registry Key Create"}, + {"regquerykey",cmd_reg_query_key, "<keyname> Registry Key Query"}, + {"regcreateval",cmd_reg_create_val, "<parentname> <valname> <valtype> <value> Registry Key Create"}, + {"regtest2", cmd_reg_test2, "Registry Testing No 2"}, + {"reggetsec", cmd_reg_get_key_sec, "<keyname> | <valname> Registry Key Security"}, {"ntlogin", cmd_netlogon_login_test, "[username] [password] NT Domain login test"}, {"wksinfo", cmd_wks_query_info, "Workstation Query Info"}, {"srvinfo", cmd_srv_query_info, "Server Query Info"}, @@ -386,7 +392,8 @@ enum client_action ****************************************************************************/ int main(int argc,char *argv[]) { - char *pname = argv[0]; + BOOL interactive = True; + int opt; extern FILE *dbf; extern char *optarg; @@ -404,6 +411,7 @@ enum client_action pstring password; /* local copy only, if one is entered */ out_hnd = stdout; + fstrcpy(debugf, argv[0]); rpcclient_init(); @@ -446,18 +454,15 @@ enum client_action pstrcpy(cli_info.share, ""); pstrcpy(cli_info.service, ""); - pstrcpy(cli_info.dom.level3_sid, ""); - pstrcpy(cli_info.dom.level3_dom, ""); - pstrcpy(cli_info.dom.level5_sid, ""); - pstrcpy(cli_info.dom.level5_dom, ""); + ZERO_STRUCT(cli_info.dom.level3_sid); + ZERO_STRUCT(cli_info.dom.level5_sid); + fstrcpy(cli_info.dom.level3_dom, ""); + fstrcpy(cli_info.dom.level5_dom, ""); smb_cli->nt_pipe_fnum = 0xffff; - setup_logging(pname, True); - TimeInit(); charset_initialise(); -/* crc32_build_table(); */ myumask = umask(0); umask(myumask); @@ -501,7 +506,7 @@ enum client_action if (argc < 2) { - usage(pname); + usage(argv[0]); exit(1); } @@ -514,11 +519,11 @@ enum client_action argc--; argv++; - DEBUG(1,("service: %s\n", cli_info.service)); + fprintf(out_hnd, "service: %s\n", cli_info.service); if (count_chars(cli_info.service,'\\') < 3) { - usage(pname); + usage(argv[0]); printf("\n%s: Not enough '\\' characters in service\n", cli_info.service); exit(1); } @@ -644,7 +649,8 @@ enum client_action case 'l': { slprintf(debugf, sizeof(debugf)-1, - "%s.client",optarg); + "%s.client", optarg); + interactive = False; break; } @@ -657,7 +663,7 @@ enum client_action case 'h': { - usage(pname); + usage(argv[0]); exit(0); break; } @@ -676,16 +682,18 @@ enum client_action default: { - usage(pname); + usage(argv[0]); exit(1); break; } } } + setup_logging(debugf, interactive); + if (cli_action == CLIENT_NONE) { - usage(pname); + usage(argv[0]); exit(1); } |