summaryrefslogtreecommitdiffstats
path: root/source4/utils/net
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2005-12-21 22:02:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:35 -0500
commit221c1512a8b4de9a568c0a0cdafa97ab5c53368c (patch)
treea3c696e37929ef2b758ba9466a07b0779b659b61 /source4/utils/net
parentf45b0ff698414f4fcdb49f1324ebfc5576f785ae (diff)
downloadsamba-221c1512a8b4de9a568c0a0cdafa97ab5c53368c.tar.gz
samba-221c1512a8b4de9a568c0a0cdafa97ab5c53368c.tar.xz
samba-221c1512a8b4de9a568c0a0cdafa97ab5c53368c.zip
r12411: Add 'net samdump keytab <keytab>'.
This extracts a remote windows domain into a keytab, suitable for use in ethereal for kerberos decryption. For the moment, like net samdump and net samsync, the 'password server' smb.conf option must be set to the binding string for the server. eg: password server = ncacn_np:mypdc Andrew Bartlett (This used to be commit 272013438f53bb168f74e09eb70fc96112b84772)
Diffstat (limited to 'source4/utils/net')
-rw-r--r--source4/utils/net/net_vampire.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c
index e898352cfc..75ad175c66 100644
--- a/source4/utils/net/net_vampire.c
+++ b/source4/utils/net/net_vampire.c
@@ -25,11 +25,77 @@
#include "libnet/libnet.h"
#include "librpc/gen_ndr/ndr_samr.h"
+static int net_samdump_keytab_usage(struct net_context *ctx, int argc, const char **argv)
+{
+ d_printf("net samdump keytab <keytab>\n");
+ return 0;
+}
+
+static int net_samdump_keytab_help(struct net_context *ctx, int argc, const char **argv)
+{
+ d_printf("Dumps kerberos keys of a domain into a keytab.\n");
+ return 0;
+}
+
+static int net_samdump_keytab(struct net_context *ctx, int argc, const char **argv)
+{
+ NTSTATUS status;
+ struct libnet_context *libnetctx;
+ struct libnet_SamDump_keytab r;
+
+ switch (argc) {
+ case 0:
+ return net_samdump_keytab_usage(ctx, argc, argv);
+ break;
+ case 1:
+ r.keytab_name = argv[0];
+ break;
+ }
+
+ libnetctx = libnet_context_init(NULL);
+ if (!libnetctx) {
+ return -1;
+ }
+ libnetctx->cred = ctx->credentials;
+
+ r.level = LIBNET_SAMDUMP_GENERIC;
+ r.error_string = NULL;
+
+ status = libnet_SamDump_keytab(libnetctx, ctx->mem_ctx, &r);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("libnet_SamDump returned %s: %s\n",
+ nt_errstr(status),
+ r.error_string));
+ return -1;
+ }
+
+ talloc_free(libnetctx);
+
+ return 0;
+}
+
+/* main function table */
+static const struct net_functable net_samdump_functable[] = {
+ {"keytab", "dump keys into a keytab\n", net_samdump_keytab, net_samdump_keytab_usage},
+ {NULL, NULL, NULL, NULL}
+};
+
int net_samdump(struct net_context *ctx, int argc, const char **argv)
{
NTSTATUS status;
struct libnet_context *libnetctx;
struct libnet_SamDump r;
+ int rc;
+
+ switch (argc) {
+ case 0:
+ break;
+ case 1:
+ default:
+ rc = net_run_function(ctx, argc, argv, net_samdump_functable,
+ net_samdump_usage);
+ return rc;
+ }
libnetctx = libnet_context_init(NULL);
if (!libnetctx) {
@@ -56,6 +122,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv)
int net_samdump_usage(struct net_context *ctx, int argc, const char **argv)
{
d_printf("net samdump\n");
+ d_printf("net samdump keytab <keytab>\n");
return 0;
}