hivetools-commits Mailing List for hivetools
Status: Alpha
Brought to you by:
jasta
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(33) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(25) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <ja...@us...> - 2007-01-16 01:45:56
|
Revision: 73
http://hivetools.svn.sourceforge.net/hivetools/?rev=73&view=rev
Author: jasta
Date: 2007-01-15 17:45:54 -0800 (Mon, 15 Jan 2007)
Log Message:
-----------
oops, make sure we use ERR_WIN
Modified Paths:
--------------
lib/libhive.c
Modified: lib/libhive.c
===================================================================
--- lib/libhive.c 2007-01-16 01:35:26 UTC (rev 72)
+++ lib/libhive.c 2007-01-16 01:45:54 UTC (rev 73)
@@ -546,7 +546,10 @@
vbuf_strnset(vb, skname, sk1len);
if ((link = lookup_mount(hkey, vb->b, NULL)) == NULL)
+ {
+ ERR_WIN(rlERROR_NOT_FOUND, "no mount point at \"%s\"", skname);
return rlERROR_NOT_FOUND;
+ }
return rlRegOpenKeyEx(link->hive, skname + sk1len,
options, rsam, result);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-16 01:35:27
|
Revision: 72
http://hivetools.svn.sourceforge.net/hivetools/?rev=72&view=rev
Author: jasta
Date: 2007-01-15 17:35:26 -0800 (Mon, 15 Jan 2007)
Log Message:
-----------
fixed spelling mistake
Modified Paths:
--------------
lib/winerr.c
Modified: lib/winerr.c
===================================================================
--- lib/winerr.c 2007-01-16 01:31:11 UTC (rev 71)
+++ lib/winerr.c 2007-01-16 01:35:26 UTC (rev 72)
@@ -33,7 +33,7 @@
{
"This is the error you get when there was no error.",
"Buffer too small. Need more buffer.",
- "There are no more idems.",
+ "There are no more items.",
"Generic error - please write real error.",
"Not found.",
"Open failed."
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-16 01:31:15
|
Revision: 71
http://hivetools.svn.sourceforge.net/hivetools/?rev=71&view=rev
Author: jasta
Date: 2007-01-15 17:31:11 -0800 (Mon, 15 Jan 2007)
Log Message:
-----------
some versions of automake don't like this nonsense
Modified Paths:
--------------
bin/Makefile.am
Modified: bin/Makefile.am
===================================================================
--- bin/Makefile.am 2007-01-15 01:21:40 UTC (rev 70)
+++ bin/Makefile.am 2007-01-16 01:31:11 UTC (rev 71)
@@ -12,7 +12,7 @@
hiveshell
hiveshell_SOURCES = hiveshell.c
-cpnt_SOURCES = cpnt.c
-regmod_SOURCES = regmod.c
-sam_SOURCES = sam.c
-template_SOURCES = template.c
+#cpnt_SOURCES = cpnt.c
+#regmod_SOURCES = regmod.c
+#sam_SOURCES = sam.c
+#template_SOURCES = template.c
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-15 01:21:41
|
Revision: 70
http://hivetools.svn.sourceforge.net/hivetools/?rev=70&view=rev
Author: jasta
Date: 2007-01-14 17:21:40 -0800 (Sun, 14 Jan 2007)
Log Message:
-----------
initial work to update hiveshell to a new libhive usage paradigm
Modified Paths:
--------------
bin/hiveshell.c
Modified: bin/hiveshell.c
===================================================================
--- bin/hiveshell.c 2007-01-15 01:17:58 UTC (rev 69)
+++ bin/hiveshell.c 2007-01-15 01:21:40 UTC (rev 70)
@@ -42,12 +42,13 @@
#include <unistd.h>
#include <iconv.h>
#include <errno.h>
+#include <assert.h>
+
#include <readline/readline.h>
#include <readline/history.h>
#include <openssl/des.h>
#include <openssl/md4.h>
-#define uchar u_char
#define MD4Init MD4_Init
#define MD4Update MD4_Update
#define MD4Final MD4_Final
@@ -230,6 +231,7 @@
void cmd_cat( FILE *fp, NREGDIR **h, int argc, char **argv );
void cmd_hd( FILE *fp, NREGDIR **h, int argc, char **argv );
void cmd_find( FILE *fp, NREGDIR **h, int argc, char **argv );
+void cmd_mount( FILE *fp, NREGDIR **h, int argc, char **argv );
void cmd_nv( FILE *fp, NREGDIR **h, int argc, char **argv );
void cmd_mkdir( FILE *fp, NREGDIR **h, int argc, char **argv );
void cmd_lsusers( FILE *fp, NREGDIR **h ,int argc, char **argv );
@@ -272,8 +274,18 @@
{ "nk", "key", "create a new key", "", &cmd_mkdir },
{ "rm", "path", "delete a key or value (is recursive)", "", &cmd_rm },
- { "SEP", "MOUNTING", "", "", NULL },
+ { "SEP", "MOUNT MANAGEMENT", "", "", NULL },
+ { "mount",
+ "filename [mount-point]",
+ "mount a hive file into the registry",
+""
+"Mounts a Windows hive file into the shell registry structure. The mount\n"
+"point may be optional if it can be guessed by the hive filename or from the\n"
+"file's metadata.",
+ &cmd_mount
+ },
+
{ "SEP", "SAM", "", "", NULL },
{ "lsusers", "", "list users", "", &cmd_lsusers },
{ "userinfo", "username", "detailed user information", "", &cmd_userinfo },
@@ -525,6 +537,108 @@
}
}
} // }}}
+
+struct mp
+{
+ rl_hkey key;
+ const char *path;
+};
+
+static struct mp resolve_mount_point(const char *mpoint) // {{{ convert a user-expressed mount point to something we can use internally.
+{
+ rl_hkey key = NULL;
+ size_t keyln;
+ struct mp mount = { NULL, NULL };
+
+ if (mpoint == NULL)
+ return mount;
+
+ if (mpoint[0] == '\\' || mpoint[0] == '/')
+ mpoint++;
+
+ keyln = strcspn(mpoint, "\\/");
+
+ if (keyln == 0 || keyln + 1 >= strlen(mpoint))
+ return mount;
+
+ if (strncmp(mpoint, "HKEY_LOCAL_MACHINE", keyln) == 0)
+ key = HKEY_LOCAL_MACHINE;
+ else if (strncmp(mpoint, "HKEY_USERS", keyln) == 0)
+ key = HKEY_USERS;
+ else if (strncmp(mpoint, "HKEY_CLASSES_ROOT", keyln) == 0)
+ key = HKEY_CLASSES_ROOT;
+
+ if (key != NULL)
+ {
+ mount.key = key;
+ mount.path = mpoint + keyln + 1;
+ }
+
+ return mount;
+} // }}}
+
+void cmd_mount(FILE *fp, NREGDIR **h, int argc, char **argv) // {{{
+{
+ struct mp mp;
+ static char mpoint[SZ_MAX];
+ char *hfile;
+ long ret;
+
+ if (argc < 2)
+ {
+ printf("mount requires at least one parameter\n");
+ return;
+ }
+
+ hfile = argv[1];
+
+ if (argc > 2)
+ {
+ if (argv[2][0] == '\\')
+ snprintf(mpoint, sizeof(mpoint), "%s", argv[2]);
+ else
+ snprintf(mpoint, sizeof(mpoint), "%s%s", ns_get_cwd(*h), argv[2]);
+ }
+ else
+ {
+ /* TODO: Guess based on hive type. */
+ abort();
+ }
+
+ /* Parse `mpoint' into base metakey and root path for rlRegMountHive(). */
+ mp = resolve_mount_point(mpoint);
+
+ if (mp.key == NULL)
+ {
+ printf("couldn't identify HKEY portion of the supplied mount point\n");
+ return;
+ }
+
+ assert(mp.path != NULL);
+
+ /* Make sure they don't supply a path deep inside some meta key. */
+ if (strpbrk(mp.path, "/\\") != NULL)
+ {
+ printf("you may only mount to one of the HKEY meta keys.\n");
+ return;
+ }
+
+ /* TODO: Use HMODE_RW (conditionally?). */
+ ret = rlRegMountHive(hfile, HMODE_RO, mp.key, mp.path);
+
+ switch (ret)
+ {
+ case rlERROR_SUCCESS:
+ printf("successfully mounted %s to %s\n", hfile, mpoint);
+ break;
+ case rlERROR_NOT_FOUND:
+ printf("mount already exists at %s\n", mpoint);
+ break;
+ default:
+ puts(uerr_str(uerr_get()));
+ break;
+ }
+} // }}}
void cmd_nv( FILE *fp, NREGDIR **h, int argc, char **argv ) // {{{
{
char *vpath;
@@ -925,13 +1039,19 @@
char *rlbuf=NULL, *bp;
int i,t; //len;
char *next;
+ VBUF_STATIC(cmd_buf, 0);
- static struct varbuf *cmd_buf = NULL;
- if( cmd_buf == NULL ) cmd_buf = vbuf_alloc( 0 );
-
*argc = 0;
- rlbuf = readline( prompt );
+ if ((rlbuf = readline(prompt)) == NULL)
+ {
+ /* Pressed ^D or some other kind of end-of-input condition. */
+ done = 1;
+ printf("\n");
+
+ return -2;
+ }
+
add_history( rlbuf );
bp = rlbuf;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-15 01:18:12
|
Revision: 69
http://hivetools.svn.sourceforge.net/hivetools/?rev=69&view=rev
Author: jasta
Date: 2007-01-14 17:17:58 -0800 (Sun, 14 Jan 2007)
Log Message:
-----------
fix dubious misuse of exit from within openHive during fstat failure
Modified Paths:
--------------
lib/ntreg.c
Modified: lib/ntreg.c
===================================================================
--- lib/ntreg.c 2007-01-12 02:26:57 UTC (rev 68)
+++ lib/ntreg.c 2007-01-15 01:17:58 UTC (rev 69)
@@ -2716,8 +2716,8 @@
}
if ( fstat(hdesc->filedesc,&sbuf) ) {
- perror("stat()");
- exit(1);
+ ERR_UNIX(errno, "fstat(%s)\n", hdesc->filename);
+ return NULL;
}
hdesc->size = sbuf.st_size;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-12 02:26:58
|
Revision: 68
http://hivetools.svn.sourceforge.net/hivetools/?rev=68&view=rev
Author: jasta
Date: 2007-01-11 18:26:57 -0800 (Thu, 11 Jan 2007)
Log Message:
-----------
we need to dup NK_META keys for hiveshell, plus this makes logical sense so that we can properly 'scan' the mounted hives without internals to the library
Modified Paths:
--------------
lib/libhive.c
Modified: lib/libhive.c
===================================================================
--- lib/libhive.c 2007-01-12 02:25:38 UTC (rev 67)
+++ lib/libhive.c 2007-01-12 02:26:57 UTC (rev 68)
@@ -175,20 +175,30 @@
static rl_hkey dup_rl_hkey(rl_hkey hkey) { // {{{ dup an rl_hkey
rl_hkey result;
- assert(hkey->type == NK_NORMAL);
-
result = malloc(sizeof(struct rl_hkey_tag));
assert(result != NULL);
- result->type = NK_NORMAL;
+ result->type = hkey->type;
result->path = NULL;
result->id = 0;
- hkey->hd->refcount++;
- result->hd = hkey->hd;
- result->nk = hkey->nk;
- result->hm = NULL;
+ if (hkey->type == NK_NORMAL)
+ {
+ assert(hkey->hd != NULL);
+ hkey->hd->refcount++;
+ result->hd = hkey->hd;
+ result->nk = hkey->nk;
+ }
+ else if (hkey->type == NK_META)
+ {
+ result->hm = hkey->hm;
+ }
+ else
+ {
+ abort();
+ }
+
return result;
} // }}}
static void free_rl_hkey( rl_hkey hkey ) { // {{{ deallocate an rl_hkey
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-12 02:25:46
|
Revision: 67
http://hivetools.svn.sourceforge.net/hivetools/?rev=67&view=rev
Author: jasta
Date: 2007-01-11 18:25:38 -0800 (Thu, 11 Jan 2007)
Log Message:
-----------
started work on a new hive mounting interface
Modified Paths:
--------------
bin/hiveshell.c
Modified: bin/hiveshell.c
===================================================================
--- bin/hiveshell.c 2007-01-11 00:43:12 UTC (rev 66)
+++ bin/hiveshell.c 2007-01-12 02:25:38 UTC (rev 67)
@@ -177,14 +177,9 @@
extern char* optarg;
//char *filename,c;
char c;
- char *who = "Administrator";
- char *regpath;
- char iwho[100];
- FILE *ch; /* Write out names of touched files to this */
char *options = "LNhvurp:";
- libhive_init();
ns_init();
unicode_init();
@@ -205,14 +200,18 @@
}
}
+#if 0
if( 0 != hl_mount_list( argc - optind, argv + optind ) ) {
fprintf(stderr, "hl_mount_list() had issues (%s), I am going to continue...\n",
uerr_str( uerr_get() ));
}
+#endif
editor();
+#if 0
hl_close_all();
+#endif
return 0;
} // }}}
@@ -238,10 +237,12 @@
void cmd_samstuff( FILE *fp, NREGDIR **h ,int argc, char **argv );
void cmd_passwd( FILE *fp, NREGDIR **h ,int argc, char **argv );
+#if 0
void cmd_ls_hives( FILE *fp, NREGDIR **h, int argc, char **argv );
void cmd_scan_hive( FILE *fp, NREGDIR **h, int argc, char **argv );
void cmd_hive_alloc_graph( FILE *fp, NREGDIR **h, int argc, char **argv );
void cmd_hive_dump_unallocd( FILE *fp, NREGDIR **h, int argc, char **argv );
+#endif
void cmd_cd( FILE *fp, NREGDIR **h ,int argc, char **argv );
void cmd_ls( FILE *fp, NREGDIR **h ,int argc, char **argv );
@@ -271,6 +272,8 @@
{ "nk", "key", "create a new key", "", &cmd_mkdir },
{ "rm", "path", "delete a key or value (is recursive)", "", &cmd_rm },
+ { "SEP", "MOUNTING", "", "", NULL },
+
{ "SEP", "SAM", "", "", NULL },
{ "lsusers", "", "list users", "", &cmd_lsusers },
{ "userinfo", "username", "detailed user information", "", &cmd_userinfo },
@@ -278,11 +281,13 @@
{ "passwd", "username", "Set a user's password", "", &cmd_passwd },
{ "SEP", "DEBUG", "", "", NULL },
+#if 0
{ "lshives", "", "list loaded hives.", "", &cmd_ls_hives },
{ "uadump","hive_no. [file]", "dump unallocated blocks", "", &cmd_hive_dump_unallocd },
{ "allocgraph","hive_no. [file]", "dump allocation graph", "", &cmd_hive_alloc_graph },
{ "scanhive", "hive_no.", "hbin level hive scan.", "", &cmd_scan_hive },
+#endif
{ "SEP", "Misc", "", "", NULL },
{ "help", "<cmd>", "display help", "", &cmd_help },
@@ -681,6 +686,7 @@
return;
} // }}}
+#if 0
void cmd_ls_hives( FILE *fp, NREGDIR **h, int argc, char **argv ) // {{{
{
char *path;
@@ -692,7 +698,9 @@
fprintf(stderr, "% 2d %s\n", i, mp->b );
}
} // }}}
+#endif
+#if 0
void cmd_scan_hive( FILE *fp, NREGDIR **h, int argc, char **argv ) // {{{
{
char *path;
@@ -723,7 +731,9 @@
*/
}
} // }}}
+#endif
+#if 0
void cmd_hive_dump_unallocd( FILE *fp, NREGDIR **h, int argc, char **argv ) // {{{
{
char *path;
@@ -763,7 +773,9 @@
}while( b = hbinb_get_next( hkey->hd, p, b ) );
} while( p = hbinp_get_next_hbinp( hkey->hd, p ) );
} // }}}
+#endif
+#if 0
void cmd_hive_alloc_graph( FILE *fp, NREGDIR **h, int argc, char **argv ) // {{{
{
char *path;
@@ -828,6 +840,7 @@
fprintf(out,"\n");
} while( p = hbinp_get_next_hbinp( hkey->hd, p ) );
} // }}}
+#endif
// }}}
// Interactive Input {{{
// Readline -> argc,argv, etc
@@ -1022,7 +1035,6 @@
} // }}}
int user_get_password( char *buf, int len ) // {{{ Prompt the user for a password, dump it in buf, return length
{
- char yn[4];
printf("\n* = blank the password (This may work better than setting a new password!)\n");
/* printf("@ = promote user to administrator\n"); */
printf("Enter nothing to leave it unchanged\n");
@@ -1313,11 +1325,15 @@
printf("It's currently in mode = %d, %s-mode\n",secboot,
(secboot < 0 || secboot > 3) ? "Unknown" : syskeytypes[secboot]);
+#if 0
if (no_hives < 2) {
printf("\nSYSTEM (and possibly SECURITY) hives not loaded, unable to disable syskey!\n");
printf("Please start the program with at least SAM & SYSTEM-hive filenames as arguments!\n\n");
return;
}
+#else
+# warning "TODO: Check which hives are loaded..."
+#endif
printf("SYSKEY is on! However, DO NOT DISABLE IT UNLESS YOU HAVE TO!\n");
printf("This program can change passwords even if syskey is on, however\n");
printf("if you have lost the key-floppy or passphrase you can turn it off,\n");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-11 00:43:15
|
Revision: 66
http://hivetools.svn.sourceforge.net/hivetools/?rev=66&view=rev
Author: jasta
Date: 2007-01-10 16:43:12 -0800 (Wed, 10 Jan 2007)
Log Message:
-----------
lets just go back and hack hiveshell instead
Modified Paths:
--------------
bin/Makefile.am
Modified: bin/Makefile.am
===================================================================
--- bin/Makefile.am 2007-01-10 03:47:07 UTC (rev 65)
+++ bin/Makefile.am 2007-01-11 00:43:12 UTC (rev 66)
@@ -9,10 +9,8 @@
#bin_PROGRAMS=hiveshell cpnt regmod sam template
bin_PROGRAMS = \
- regedit
+ hiveshell
-regedit_SOURCES = regedit.c
-
hiveshell_SOURCES = hiveshell.c
cpnt_SOURCES = cpnt.c
regmod_SOURCES = regmod.c
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-10 03:47:08
|
Revision: 65
http://hivetools.svn.sourceforge.net/hivetools/?rev=65&view=rev
Author: jasta
Date: 2007-01-09 19:47:07 -0800 (Tue, 09 Jan 2007)
Log Message:
-----------
changed the mount/open api slightly
Modified Paths:
--------------
lib/libhive.c
lib/libhive.h
lib/ntreg.c
test/lshive.c
Modified: lib/libhive.c
===================================================================
--- lib/libhive.c 2007-01-10 03:46:45 UTC (rev 64)
+++ lib/libhive.c 2007-01-10 03:47:07 UTC (rev 65)
@@ -99,7 +99,7 @@
return NULL;
}
-long rlRegMountRegistry(const char *fname, int mode, rl_hkey hkey, // {{{
+long rlRegMountHive(const char *fname, int mode, rl_hkey hkey, // {{{
const char *mpoint) {
long ret;
struct hive_meta *meta;
@@ -111,7 +111,7 @@
if (lookup_mount(hkey, mpoint, NULL) != NULL)
return rlERROR_NOT_FOUND;
- if ((ret = rlRegOpenRegistry(fname, mode, &openkey)) != rlERROR_SUCCESS)
+ if ((ret = rlRegOpenHive(fname, mode, &openkey)) != rlERROR_SUCCESS)
return ret;
meta = malloc(sizeof(struct hive_meta));
@@ -140,7 +140,7 @@
return rlERROR_SUCCESS;
} // }}}
-long rlRegUnmountRegistry(rl_hkey hkey, const char *mpoint) { // {{{
+long rlRegUnmountHive(rl_hkey hkey, const char *mpoint) { // {{{
rl_hkey openkey;
struct hive_meta *link;
struct hive_meta *prev = NULL;
@@ -159,7 +159,7 @@
free(link->mount);
free(link);
- return rlRegCloseRegistry(openkey);
+ return rlRegCloseHive(openkey);
} // }}}
static rl_hkey alloc_rl_hkey( struct hive *h ) // {{{ allocate a new rl_hkey for a hive, increment reference count
@@ -202,7 +202,7 @@
free(hkey);
} // }}}
-long rlRegOpenRegistry(const char *fname, int mode, rl_hkey *result) // {{{
+long rlRegOpenHive(const char *fname, int mode, rl_hkey *result) // {{{
{
struct hive *h;
@@ -221,7 +221,7 @@
return rlERROR_SUCCESS;
}
// }}}
-long rlRegCloseRegistry(rl_hkey hkey) // {{{
+long rlRegCloseHive(rl_hkey hkey) // {{{
{
long ret = rlERROR_SUCCESS;
@@ -741,7 +741,7 @@
{
(*hkey)->hm = link->next;
- ret |= rlRegCloseRegistry(link->hive);
+ ret |= rlRegCloseHive(link->hive);
free(link->mount);
free(link);
}
Modified: lib/libhive.h
===================================================================
--- lib/libhive.h 2007-01-10 03:46:45 UTC (rev 64)
+++ lib/libhive.h 2007-01-10 03:47:07 UTC (rev 65)
@@ -104,13 +104,13 @@
*
* `mpoint' may not contain any registry delimiter characters.
*/
-long rlRegMountRegistry(const char *fname, int mode, rl_hkey hkey,
+long rlRegMountHive(const char *fname, int mode, rl_hkey hkey,
const char *mpoint);
/*
* Remove and close a mounted registry hive.
*/
-long rlRegUnmountRegistry(rl_hkey hkey, const char *mpoint);
+long rlRegUnmountHive(rl_hkey hkey, const char *mpoint);
/*
* Our specialized open function that acts somewhat similar to
@@ -124,7 +124,7 @@
*
* `mode' is passed to the open() call.
*/
-long rlRegOpenRegistry(const char *fname, int mode, rl_hkey *result);
+long rlRegOpenHive(const char *fname, int mode, rl_hkey *result);
/*
* Eventually I'd like to eliminate this function and integrate it's
@@ -135,7 +135,7 @@
* If the hive file was opened writable, and the hive is marked dirty, then the
* modifications will be written to disk by this method.
*/
-long rlRegCloseRegistry(rl_hkey hkey);
+long rlRegCloseHive(rl_hkey hkey);
long rlRegOpenKeyEx(rl_hkey hkey, const char *skname, ulong options,
REGSAM, rl_hkey *result);
Modified: lib/ntreg.c
===================================================================
--- lib/ntreg.c 2007-01-10 03:46:45 UTC (rev 64)
+++ lib/ntreg.c 2007-01-10 03:47:07 UTC (rev 65)
@@ -331,7 +331,7 @@
int used;
int free;
}; // }}}
-static int hbinb_is_allocd( struct hbin_block *p ) // {{{
+int hbinb_is_allocd( struct hbin_block *p ) // {{{
{
if (p->size < 0)
return 1;
Modified: test/lshive.c
===================================================================
--- test/lshive.c 2007-01-10 03:46:45 UTC (rev 64)
+++ test/lshive.c 2007-01-10 03:47:07 UTC (rev 65)
@@ -376,11 +376,11 @@
libhive_init();
- ret = rlRegMountRegistry("./data/software", HMODE_RO,
+ ret = rlRegMountHive("./data/software", HMODE_RO,
HKEY_LOCAL_MACHINE, "Software");
assert(ret == rlERROR_SUCCESS);
- ret = rlRegMountRegistry("./data/system", HMODE_RO,
+ ret = rlRegMountHive("./data/system", HMODE_RO,
HKEY_LOCAL_MACHINE, "System");
assert(ret == rlERROR_SUCCESS);
@@ -395,8 +395,8 @@
rlRegCloseKey(sk);
#endif
- rlRegUnmountRegistry(HKEY_LOCAL_MACHINE, "Software");
- rlRegUnmountRegistry(HKEY_LOCAL_MACHINE, "System");
+ rlRegUnmountHive(HKEY_LOCAL_MACHINE, "Software");
+ rlRegUnmountHive(HKEY_LOCAL_MACHINE, "System");
libhive_fini();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-10 03:46:46
|
Revision: 64
http://hivetools.svn.sourceforge.net/hivetools/?rev=64&view=rev
Author: jasta
Date: 2007-01-09 19:46:45 -0800 (Tue, 09 Jan 2007)
Log Message:
-----------
only build the new regedit for now
Modified Paths:
--------------
bin/Makefile.am
bin/hiveshell.c
Modified: bin/Makefile.am
===================================================================
--- bin/Makefile.am 2007-01-10 03:46:19 UTC (rev 63)
+++ bin/Makefile.am 2007-01-10 03:46:45 UTC (rev 64)
@@ -1,12 +1,20 @@
SUBDIRS=
+INCLUDES = \
+ -I$(top_srcdir)/lib
+
LDADD = \
$(top_builddir)/hivetools/libhivetools.la \
$(top_builddir)/lib/libhive.la
-bin_PROGRAMS=hiveshell cpnt regmod sam template
-hiveshell_SOURCES=hiveshell.c
-cpnt_SOURCES=cpnt.c
-regmod_SOURCES=regmod.c
-sam_SOURCES=sam.c
-template_SOURCES=template.c
+#bin_PROGRAMS=hiveshell cpnt regmod sam template
+bin_PROGRAMS = \
+ regedit
+
+regedit_SOURCES = regedit.c
+
+hiveshell_SOURCES = hiveshell.c
+cpnt_SOURCES = cpnt.c
+regmod_SOURCES = regmod.c
+sam_SOURCES = sam.c
+template_SOURCES = template.c
Modified: bin/hiveshell.c
===================================================================
--- bin/hiveshell.c 2007-01-10 03:46:19 UTC (rev 63)
+++ bin/hiveshell.c 2007-01-10 03:46:45 UTC (rev 64)
@@ -76,6 +76,7 @@
//const char chntpw_version[] = "chntpw version 0.99.2 040105, (c) Petter N Hagen";
int syskeyreset = 0;
+int dirty = 0;
/*
* of user with RID 500, because silly MS decided
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-10 03:46:23
|
Revision: 63
http://hivetools.svn.sourceforge.net/hivetools/?rev=63&view=rev
Author: jasta
Date: 2007-01-09 19:46:19 -0800 (Tue, 09 Jan 2007)
Log Message:
-----------
hmm, did a bunch of work i don't like to mount.c and gave up
Modified Paths:
--------------
hivetools/Makefile.am
hivetools/mount.c
hivetools/mount.h
Modified: hivetools/Makefile.am
===================================================================
--- hivetools/Makefile.am 2007-01-09 15:11:24 UTC (rev 62)
+++ hivetools/Makefile.am 2007-01-10 03:46:19 UTC (rev 63)
@@ -12,6 +12,4 @@
nstdreg.c \
nstdreg.h \
sam.c \
- sam.h \
- mount.c \
- mount.h
+ sam.h
Modified: hivetools/mount.c
===================================================================
--- hivetools/mount.c 2007-01-09 15:11:24 UTC (rev 62)
+++ hivetools/mount.c 2007-01-10 03:46:19 UTC (rev 63)
@@ -38,6 +38,9 @@
const char *path;
};
+rl_hkey mounts[MAX_HIVES + 1];
+int no_hives = 0;
+
char *hivepath[] =
{
NULL,
@@ -160,8 +163,10 @@
return -1;
}
- /* TODO: rlRegMountRegistry() */
- return rlRegMountRegistry(fname, HMODE_RO, mount.key, mount.path);
+ if ((ret = rlRegMountHive(fname, HMODE_RO, mount.key, mount.path)) == 0)
+ hl_mounts_add(mount);
+
+ return ret;
} // }}}
long hl_mount_list( int argc, char **argv ) // {{{
{
@@ -192,4 +197,199 @@
fprintf(stderr, "TODO: hl_close_all\n");
} // }}}
+int hl_get_no_hives() // {{{
+{
+ return no_hives;
+} // }}}
+int mount_seek_gr( const char *s ) // {{{ find the offset of either the first mount path > s or end of elements
+{
+ //TODO: this could easily be binary search
+ int i=0;
+ for( i=0; i<no_hives; i++ ) {
+ if( 0 < strcmp( s, mounts[i]->path ) ) return i;
+ }
+ return no_hives;
+} // }}}
+struct hive *hl_mounts_remove( int n ) // {{{ remove hive from mount table
+{
+ struct hive *result;
+ ASSERT( n >= 0 && n < no_hives, "hl_hive_remove(): n outside of bounds.");
+
+ //result = hive[hno];
+
+ result = mounts[n]->hd;
+
+ memmove( mounts + n, mounts + n + 1, sizeof( rl_hkey ) * (no_hives - 1 - n ) );
+
+ no_hives--;
+
+ return result;
+
+} // }}}
+int hl_mounts_add( rl_hkey hkey ) // {{{ insert a properly-opened hive into mount table
+{
+ if( no_hives == MAX_HIVES ) {
+ ERR_WIN( rlERROR_BROKEN_ERROR, "no_hives == MAX_HIVES, sorry" );
+ return -1;
+ }
+
+ ASSERT( hkey->path != NULL, "hl_mounts_add(): attempt to add hkey with no path.");
+
+ ulong n = mount_seek_gr( hkey->path );
+
+ //hive[no_hives] = h;
+
+ memmove( mounts + n + 1, mounts + n, sizeof( rl_hkey ) * (no_hives - n) );
+ mounts[n] = hkey;
+
+ /*
+ if( 0 != htype ) {
+ pathmap[no_hives] = hivepath[htype];
+ }
+ else {
+ WARN("Uhhhhh...Nothing assigned. TODO: fix this.");
+ parse_regf_header( h, h->head );
+ }
+ */
+
+ no_hives++;
+
+ return 0;
+} // }}}
+int meta_enum( rl_hkey hkey, ulong idx, vbuf *vb ) // {{{
+{
+ //TODO: not implemented?
+ int i=0;
+ int cnt=0;
+
+ for(i=0; i<no_hives; i++) {
+ if( mounts[i]->path == strstr( mounts[i]->path, hkey->path ) ) {
+ int inlen = strlen( hkey->path );
+ char *subpath = mounts[i]->path + inlen;
+ if( *subpath == '\\' ) {
+ while( *subpath == '\\' ) subpath++;
+ if( idx == cnt ) {
+ int splen;
+ char *element_end = index( subpath, '\\' );
+ if(!element_end)element_end = subpath + strlen( subpath );
+ splen = element_end - subpath;
+ vbuf_strnset( vb, subpath, splen );
+ return 0;
+ }
+ cnt++;
+ }
+ }
+ }
+ ERR_WIN( rlERROR_NO_MORE_ITEMS, "meta_enum() couldn't find anything at index %d.", idx );
+ return -1;
+} // }}}
+int hl_unload_hive( int hno ) // {{{
+{
+ struct hive *h = hl_mounts_remove( hno );
+ int result = 0;
+
+ ASSERT( NULL != h, "hl_hive_remove() returned NULL.\n");
+
+ if( 0 != writeHive( h ) )
+ result = -1;
+
+ closeHive( h );
+
+ return result;
+} // }}}
+long hl_mount( const char *fname, const char *mpoint, int mode ) // {{{
+{
+ struct hive *h = openHive(fname, mode);
+ const char *mp = mpoint;
+
+ DB(DB_1, "Attempting to load hive file %s.", fname);
+
+ if( NULL == h ) return rlERROR_OPEN_FAILED;
+
+ if( mpoint[0] == '\0' ) {
+ int htype = guess_hive_type( h );
+ if( !hivepath[htype] ) {
+ ERR_WIN( rlERROR_BROKEN_ERROR,
+ "no mount point specified for hive file %s and can not find default mount point.\n", fname );
+ return -1;
+ }
+
+ mp = hivepath[htype];
+ //fprintf(stderr, "hl_mount(): no mount point given for hive, using %s\n", mp );
+ }
+
+ DB(DB_0, "Attempting to mount hive file %s at %s.", fname, mp);
+
+ rl_hkey hkey = alloc_rl_meta( h, mp );
+
+ if( 0 != hl_mounts_add( hkey ) ) {
+ closeHive( h );
+ return -1;
+ }
+
+ return 0;
+} // }}}
+void hl_close_all() // {{{
+{
+ while( no_hives ) {
+ hl_unload_hive( 0 );
+ }
+} // }}}
+void flush_hives() // {{{
+{
+ int i;
+ for( i=0; i<no_hives; i++) {
+ writeHive( mounts[i]->hd );
+ }
+ /*
+ for( i=0; i<no_hives; i++) {
+ writeHive(hive[i]);
+ }
+ */
+} // }}}
+int hl_mount_list( int argc, char **argv ) // {{{
+{
+ int i=0;
+ static vbuf *fname = NULL;
+ static vbuf *mpoint = NULL;
+ char *p;
+
+ if( !fname ) fname = vbuf_alloc(0);
+ if( !mpoint ) mpoint = vbuf_alloc(0);
+
+ for(i=0; i<argc; i++) {
+
+ if( (p=esc_index( argv[i], '=')) ) {
+ vbuf_strnset( fname, argv[i], p - argv[i] );
+ vbuf_strset( mpoint, p + 1 );
+ }
+ else {
+ vbuf_strset( fname, argv[i] );
+ vbuf_strset( mpoint, "" );
+ }
+
+ if( 0 != hl_mount( fname->b, mpoint->b, 0 ) )
+ return -1;
+ }
+ return 0;
+} // }}}
+int hl_mount_count() // {{{ //TODO: maybe hl_get_no_hives() just calls this function... :P
+{
+ return hl_get_no_hives();
+} // }}}
+int hl_mount_get_point( vbuf *vb, int no ) // {{{
+{
+ ASSERT( no < no_hives, "no >= no_hives" );
+
+ rl_hkey hkey = hl_mount_get_hkey( no );
+ vbuf_strset( vb, hkey->path );
+
+ return 0;
+
+} // }}}
+rl_hkey hl_mount_get_hkey( int no ) // {{{
+{
+ return mounts[no];
+} // }}}
+
// vim600: set foldlevel=0 foldmethod=marker:
Modified: hivetools/mount.h
===================================================================
--- hivetools/mount.h 2007-01-09 15:11:24 UTC (rev 62)
+++ hivetools/mount.h 2007-01-10 03:46:19 UTC (rev 63)
@@ -19,6 +19,10 @@
/*****************************************************************************/
+extern int no_hives;
+
+/*****************************************************************************/
+
long hl_mount(const char *filename, const char *mpoint, int mode);
long hl_mount_list(int argc, char **argv);
long hl_close_all(void);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-09 15:11:26
|
Revision: 62
http://hivetools.svn.sourceforge.net/hivetools/?rev=62&view=rev
Author: jasta
Date: 2007-01-09 07:11:24 -0800 (Tue, 09 Jan 2007)
Log Message:
-----------
deleted if0'd code
Modified Paths:
--------------
bin/hiveshell.c
Modified: bin/hiveshell.c
===================================================================
--- bin/hiveshell.c 2007-01-09 15:09:06 UTC (rev 61)
+++ bin/hiveshell.c 2007-01-09 15:11:24 UTC (rev 62)
@@ -1561,333 +1561,6 @@
} // }}}
// }}}
// {{{ Almost Dumpster
-#if 0
-char *change_pw_orig(char *buf, int rid, int vlen, int stat) // {{{
-{
- /* Decode the V-struct, and change the password
- * vofs - offset into SAM buffer, start of V struct
- * rid - the users RID, required for the DES decrypt stage
- *
- * Some of this is ripped & modified from pwdump by Jeremy Allison
- *
- */
-
- uchar x1[] = {0x4B,0x47,0x53,0x21,0x40,0x23,0x24,0x25};
- int pl;
- char *vp;
- static char username[128],fullname[128];
- char comment[128],homedir[128],md4[32],lanman[32];
- char newunipw[34], newp[20], despw[20], newlanpw[16], newlandes[20];
- char yn[4];
- int username_offset,username_len;
- int fullname_offset,fullname_len;
- int comment_offset,comment_len;
- int homedir_offset,homedir_len;
- int ntpw_len,lmpw_len,ntpw_offs,lmpw_offs,i;
- int dontchange = 0;
- struct user_V *v;
-
- des_key_schedule ks[2];
- des_cblock deskey1, deskey2;
-
- MD4_CTX context;
- unsigned char digest[16];
- unsigned short acb;
-
- v = (struct user_V *)buf;
- vp = buf;
-
- username_offset = v->username_ofs;
- username_len = v->username_len;
- fullname_offset = v->fullname_ofs;
- fullname_len = v->fullname_len;
- comment_offset = v->comment_ofs;
- comment_len = v->comment_len;
- homedir_offset = v->homedir_ofs;
- homedir_len = v->homedir_len;
- lmpw_offs = v->lmpw_ofs;
- lmpw_len = v->lmpw_len;
- ntpw_offs = v->ntpw_ofs;
- ntpw_len = v->ntpw_len;
-
-#if 0
- printf("lmpw_offs: 0x%x, lmpw_len: %d (0x%x)\n",lmpw_offs,lmpw_len,lmpw_len);
- printf("ntpw_offs: 0x%x, ntpw_len: %d (0x%x)\n",ntpw_offs,ntpw_len,ntpw_len);
-#endif
-
- *username = 0;
- *fullname = 0;
- *comment = 0;
- *homedir = 0;
-
- if(
- username_len <= 0 ||
- username_len > vlen ||
- username_offset <= 0 ||
- username_offset >= vlen ||
- comment_len < 0 ||
- comment_len > vlen ||
- fullname_len < 0 ||
- fullname_len > vlen ||
- homedir_offset < 0 ||
- homedir_offset >= vlen ||
- comment_offset < 0 ||
- comment_offset >= vlen ||
- lmpw_offs < 0 ||
- lmpw_offs >= vlen)
- {
- if (stat != 1) printf("Not a legal struct? (negative struct lengths)\n");
- return(NULL);
- }
-
- /* Offsets in top of struct is relative to end of pointers, adjust */
- username_offset += 0xCC;
- fullname_offset += 0xCC;
- comment_offset += 0xCC;
- homedir_offset += 0xCC;
- ntpw_offs += 0xCC;
- lmpw_offs += 0xCC;
-
- cheap_uni2ascii(vp + username_offset,username,username_len);
- cheap_uni2ascii(vp + fullname_offset,fullname,fullname_len);
- cheap_uni2ascii(vp + comment_offset,comment,comment_len);
- cheap_uni2ascii(vp + homedir_offset,homedir,homedir_len);
-
-// #if 0
-// /* Reset hash-lengths to 16 if syskey has been reset */
-// if (syskeyreset && ntpw_len > 16 && !stat) {
-// ntpw_len = 16;
-// lmpw_len = 16;
-// ntpw_offs -= 4;
-// (unsigned int)*(vp+0xa8) = ntpw_offs - 0xcc;
-// *(vp + 0xa0) = 16;
-// *(vp + 0xac) = 16;
-// }
-// #endif
-
- if (stat) {
- acb = handle_F(rid,0);
- printf("RID: %04x, Username: <%s>%s\n",
- rid, username, ( acb & 0x8000 ? ", *disabled or locked*" : (ntpw_len < 16) ? ", *BLANK password*" : "") );
- return(username);
- }
-
- printf("RID : %04d [%04x]\n",rid,rid);
- printf("Username: %s\n",username);
- printf("fullname: %s\n",fullname);
- printf("comment : %s\n",comment);
- printf("homedir : %s\n\n",homedir);
-
- acb = handle_F(rid,2);
-
- if (lmpw_len < 16) {
- printf("** LANMAN password not set. User MAY have a blank password.\n** Usually safe to continue\n");
- }
-
- if (ntpw_len < 16) {
- printf("** No NT MD4 hash found. This user probably has a BLANK password!\n");
- if (lmpw_len < 16) {
- printf("** No LANMAN hash found either. Sorry, cannot change. Try login with no password!\n");
- dontchange = 1;
- } else {
- unsigned int *i = (unsigned int*)(vp+0xa8);
- printf("** LANMAN password IS however set. Will now install new password as NT pass instead.\n");
- printf("** NOTE: Continue at own risk!\n");
- ntpw_offs = lmpw_offs;
- *i = ntpw_offs - 0xcc;
- ntpw_len = 16;
- lmpw_len = 0;
- }
- }
-
- if (!rid) {
- printf("No RID given. Unable to change passwords..\n");
- return(0);
- }
-
- if (gverbose) {
- printf("Crypted NT pw: ");
- hexprnt(stdout, (vp+ntpw_offs),16);
- printf( "Crypted LM pw: ");
- hexprnt(stdout,(vp+lmpw_offs),16);
- }
-
- /* Get the two decrpt keys. */
- sid_to_key1(rid,(unsigned char *)deskey1);
- des_set_key((des_cblock *)deskey1,ks[0]);
- sid_to_key2(rid,(unsigned char *)deskey2);
- des_set_key((des_cblock *)deskey2,ks[1]);
-
- /* Decrypt the NT md4 password hash as two 8 byte blocks. */
- des_ecb_encrypt((des_cblock *)(vp+ntpw_offs ),
- (des_cblock *)md4, ks[0], DES_DECRYPT);
- des_ecb_encrypt((des_cblock *)(vp+ntpw_offs + 8),
- (des_cblock *)&md4[8], ks[1], DES_DECRYPT);
-
- /* Decrypt the lanman password hash as two 8 byte blocks. */
- des_ecb_encrypt((des_cblock *)(vp+lmpw_offs),
- (des_cblock *)lanman, ks[0], DES_DECRYPT);
- des_ecb_encrypt((des_cblock *)(vp+lmpw_offs + 8),
- (des_cblock *)&lanman[8], ks[1], DES_DECRYPT);
-
- if (gverbose) {
- printf("MD4 hash : ");
- hexprnt(stdout, md4,16);
- printf("LANMAN hash : ");
- hexprnt(stdout, lanman,16);
- }
-
- printf("\n* = blank the password (This may work better than setting a new password!)\n");
- /* printf("@ = promote user to administrator\n"); */
- printf("Enter nothing to leave it unchanged\n");
- pl = fmyinput("Please enter new password: ",newp,16);
-
- /* printf("password: [%s] have length %d\n",newp,pl); */
-
- if (!pl) { printf("Nothing changed.\n"); return(0); }
-
- if (pl == 1 && *newp == '*') {
- printf("Blanking password!\n");
- } else if (pl == 1 && *newp == '@') {
- promote_user(rid);
- printf("Changes saved!\n");
- return(username);
- } else {
-
- cheap_ascii2uni(newp,newunipw,pl);
-
- make_lanmpw(newp,newlanpw,pl);
-
- /* printf("Ucase Lanman: %s\n",newlanpw); */
-
- MD4Init (&context);
- MD4Update (&context, newunipw, pl<<1);
- MD4Final (digest, &context);
-
- if (gverbose) {
- printf("\nNEW MD4 hash : ");
- hexprnt(stdout,digest,16);
- }
-
- E1(newlanpw, x1, lanman);
- E1(newlanpw+7, x1, lanman+8);
-
- if (gverbose) {
- printf("NEW LANMAN hash : ");
- hexprnt(stdout,lanman,16);
- }
-
- /* Encrypt the NT md4 password hash as two 8 byte blocks. */
- des_ecb_encrypt((des_cblock *)digest,
- (des_cblock *)despw, ks[0], DES_ENCRYPT);
- des_ecb_encrypt((des_cblock *)(digest+8),
- (des_cblock *)&despw[8], ks[1], DES_ENCRYPT);
-
- des_ecb_encrypt((des_cblock *)lanman,
- (des_cblock *)newlandes, ks[0], DES_ENCRYPT);
- des_ecb_encrypt((des_cblock *)(lanman+8),
- (des_cblock *)&newlandes[8], ks[1], DES_ENCRYPT);
-
- if (gverbose) {
- printf("NEW DES crypt : ");
- hexprnt(stdout,despw,16);
- printf("NEW LANMAN crypt: ");
- hexprnt(stdout,newlandes,16);
- }
-
- } /* blankit check */
-
- fmyinput("\nDo you really wish to change it? (y/n) [n] ",yn,2);
-
- if (*yn == 'y') {
- if (pl == 1 && *newp == '*') {
- /* Setting hash lengths to zero seems to make NT think it is blank
- * However, since we cant cut the previous hash bytes out of the V value
- * due to missing resize-support of values, it may leak about 40 bytes
- * each time we do this.
- */
- v->ntpw_len = 0;
- v->lmpw_len = 0;
- } else if (pl > 1 && *newp != '@') {
- if (!dontchange) {
- /* Reset hash length to 16 if syskey enabled, this will cause
- * a conversion to syskey-hashes upon next boot */
- if (syskeyreset && ntpw_len > 16) {
- unsigned int *i = (unsigned int *)(vp+0xa8);
- ntpw_len = 16;
- lmpw_len = 16;
- ntpw_offs -= 4;
- *i = ntpw_offs - 0xcc;
- *(vp + 0xa0) = 16;
- *(vp + 0xac) = 16;
- }
-
- for (i = 0; i < 16; i++) {
- unsigned char *cfm = (unsigned char*)(vp+ntpw_offs+i);
- *cfm = despw[i];
- if (lmpw_len >= 16) *cfm = newlandes[i];
- }
- } else {
- printf("Unable to set since it is blank.\n");
- }
- }
-
-//#if 0
- hexprnt("Pw in buffer: ",(vp+ntpw_offs),16);
- hexprnt("Lm in buffer: ",(vp+lmpw_offs),16);
-//#endif
- dirty = 1;
- printf("Changed!\n");
- } else {
- printf("Password not changed.\n");
- }
-
- printf("\n");
- return(username);
-} // }}}
-#endif
-
-#if 0
-short handle_F(int rid, int mode) // {{{
-{
- /* Try to decode and possibly change account lockout etc
- * This is \SAM\Domains\Account\Users\<RID>\F
- * It's size seems to always be 0x50.
- * Params: RID - user ID, mode - 0 silent, 1 silent, 2 edit.
- * Returns: ACB bits with high bit set if lockout count is >0
- */
- struct varbuf *ufbuf;
- struct uf *userf;
-
- if( NULL == ( userf = sam_get_user_F( rid, ufbuf ) ) ) {
- //TODO: error
- printf("handle_F(): Couldn't read user F record.\n" );
- return -1;
- }
-
- if (mode) {
- acb_print( stdout, userf->acb );
-
- fprintf(stdout, "\nFailed login count: %u, while max tries is: %u\n",
- userf->bad_login_count,max_sam_lock);
- fprintf(stdout, "Total login count: %u\n",userf->no_login);
-
- if (mode > 1) acb_edit( userf );
- }
-
- return userf->acb;
-
- /* The following seems to only set fields in the ACB that have no known effect (???)
- return (userf->acb |
- (
- (userf->bad_login_count > 0 && userf->bad_login_count >= max_sam_lock)<<15
- ) |
- (userf->acb & ACB_AUTOLOCK)<<15 |
- (userf->acb & ACB_DISABLED)<<15);
- */
-} // }}}
-#endif
-
//TODO: this should be trash soon
long get_realloc( rl_hkey hk, char *path, long *type, char **buf, long *blen ) // {{{ realloc() buf (if needed), set blen to new size and retrieve value into buffer
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-09 15:09:14
|
Revision: 61
http://hivetools.svn.sourceforge.net/hivetools/?rev=61&view=rev
Author: jasta
Date: 2007-01-09 07:09:06 -0800 (Tue, 09 Jan 2007)
Log Message:
-----------
hl_close_all stub
Modified Paths:
--------------
hivetools/mount.c
hivetools/mount.h
Modified: hivetools/mount.c
===================================================================
--- hivetools/mount.c 2007-01-09 14:48:15 UTC (rev 60)
+++ hivetools/mount.c 2007-01-09 15:09:06 UTC (rev 61)
@@ -187,5 +187,9 @@
return 0;
} // }}}
+long hl_close_all(void) // {{{
+{
+ fprintf(stderr, "TODO: hl_close_all\n");
+} // }}}
// vim600: set foldlevel=0 foldmethod=marker:
Modified: hivetools/mount.h
===================================================================
--- hivetools/mount.h 2007-01-09 14:48:15 UTC (rev 60)
+++ hivetools/mount.h 2007-01-09 15:09:06 UTC (rev 61)
@@ -21,6 +21,7 @@
long hl_mount(const char *filename, const char *mpoint, int mode);
long hl_mount_list(int argc, char **argv);
+long hl_close_all(void);
/*****************************************************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-09 14:48:19
|
Revision: 60
http://hivetools.svn.sourceforge.net/hivetools/?rev=60&view=rev
Author: jasta
Date: 2007-01-09 06:48:15 -0800 (Tue, 09 Jan 2007)
Log Message:
-----------
oops, forgot to commit these
Added Paths:
-----------
hivetools/mount.c
hivetools/mount.h
Added: hivetools/mount.c
===================================================================
--- hivetools/mount.c (rev 0)
+++ hivetools/mount.c 2007-01-09 14:48:15 UTC (rev 60)
@@ -0,0 +1,191 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2005-2006 hivetools <http://hivetools.sourceforge.net/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+#include <string.h>
+
+#include <libhive.h>
+#include <ntreg.h>
+
+/*****************************************************************************/
+
+#define HTYPE_UNKNOWN 0
+#define HTYPE_SAM 1
+#define HTYPE_SYSTEM 2
+#define HTYPE_SECURITY 3
+#define HTYPE_SOFTWARE 4
+#define HTYPE_USER 5
+#define HTYPE_USERDIFF 6
+#define HTYPE_USRCLASS 7
+#define HTYPE_DEFAULT 8
+#define HTYPE_MAX 9
+
+struct mp
+{
+ rl_hkey key;
+ const char *path;
+};
+
+char *hivepath[] =
+{
+ NULL,
+ "\\HKEY_LOCAL_MACHINE\\SAM",
+ "\\HKEY_LOCAL_MACHINE\\system",
+ "\\HKEY_LOCAL_MACHINE\\SECURITY",
+ "\\HKEY_LOCAL_MACHINE\\software",
+ "\\HKEY_USERS\\todo", /* TODO */
+ NULL,
+ "\\HKEY_USERS\\SID-RID_Classes", /* TODO? */
+ NULL
+};
+
+/*****************************************************************************/
+
+#if 0
+char *hl_mount_help() // {{{
+{
+ return "mount options:\n"
+ " hive_file guess mount point\n"
+ " hive_file=mount_location specify mount point\n"
+ "\n"
+ " examples: \n"
+ " /mnt/hda1/winnt/system32/config/software\n"
+ " Load software hive, guess where it goes\n"
+ " (/HKEY_LOCAL_MACHINE/software)\n"
+ " /mnt/hda1/winnt/system32/config/SAM=/HKEY_LOCAL_MACHINE/software/foo\n"
+ " Mount a SAM hive as /HKEY_LOCAL_MACHINE/software/foo\n"
+ "\n"
+ " Note: See readme file on how to write using the Linux NTFS driver\n";
+
+} // }}}
+#endif
+
+/*
+ * Convert a user-expressed mount point to something we can use internally.
+ */
+static struct mp resolve_mount_point(const char *mpoint)
+{
+ rl_hkey key = NULL;
+ size_t keyln;
+ struct mp mount = { NULL, NULL };
+
+ if (mpoint == NULL)
+ return mount;
+
+ if (mpoint[0] == '\\')
+ mpoint++;
+
+ keyln = strcspn(mpoint, "\\");
+
+ if (keyln > 0 || keyln + 1 >= strlen(mpoint))
+ return mount;
+
+ if (strncmp(mpoint, "HKEY_LOCAL_MACHINE", keyln) == 0)
+ key = HKEY_LOCAL_MACHINE;
+ else if (strncmp(mpoint, "HKEY_USERS", keyln) == 0)
+ key = HKEY_USERS;
+ else if (strncmp(mpoint, "HKEY_CLASSES_ROOT", keyln) == 0)
+ key = HKEY_CLASSES_ROOT;
+
+ if (key != NULL)
+ {
+ mount.key = key;
+ mount.path = mpoint + keyln + 1;
+ }
+
+ return mount;
+}
+
+static int guess_hive_type( struct hive *hdesc ) // {{{ try to guess what type of hive hdesc refers to
+{
+ int result = HTYPE_UNKNOWN;
+ char *hname = regf_get_name( hdesc->head );
+
+ fprintf(stderr, "hname=%s\n", hname);
+
+ //So, let's guess what kind of hive this is, based on keys in its root
+
+ if( 0 == strcmp( hname, "stemRoot\\System32\\Config\\DEFAULT" )) return HTYPE_DEFAULT;
+
+ //TODO: is the path part of the constant or does it change from user to user?
+ if( 0 == strcmp( hname, "ettings\\Administrator\\ntuser.dat")) return HTYPE_USER;
+ if( 0 == strcmp( hname, "\\SystemRoot\\System32\\Config\\SAM" )) return HTYPE_SAM;
+ if( 0 == strcmp( hname, "emRoot\\System32\\Config\\SECURITY" )) return HTYPE_SECURITY;
+ if( 0 == strcmp( hname, "emRoot\\System32\\Config\\SOFTWARE" ) ) return HTYPE_SOFTWARE;
+ if( 0 == strcmp( hname, "SYSTEM" ) ) return HTYPE_SYSTEM;
+ if( 0 == strcmp( hname, "1\\WINNT\\SYSTEM32\\CONFIG\\userdiff" )) return HTYPE_USERDIFF;
+ if( 0 == strcmp( hname, "\\Microsoft\\Windows\\UsrClass.dat")) return HTYPE_USRCLASS;
+
+ if (trav_path(hdesc, 0, "\\SAM", 0)) result = HTYPE_SAM;
+ else if (trav_path(hdesc, 0, "\\ControlSet", 0)) result = HTYPE_SYSTEM;
+ else if (trav_path(hdesc, 0, "\\Policy", 0)) result = HTYPE_SECURITY;
+ else if (trav_path(hdesc, 0, "\\Microsoft", 0)) result = HTYPE_SOFTWARE;
+
+ return result;
+} // }}}
+
+long hl_mount( const char *fname, const char *mpoint, int mode ) // {{{
+{
+ struct hive *h;
+ struct mp mount;
+
+ if ((h = openHive(fname, mode)) == NULL)
+ return rlERROR_OPEN_FAILED;
+
+ if (mpoint == NULL || mpoint[0] == '\0')
+ {
+ int htype = guess_hive_type( h );
+ mpoint = hivepath[htype];
+ }
+
+ mount = resolve_mount_point(mpoint);
+
+ if (mount.key == NULL)
+ {
+ ERR_WIN(rlERROR_BROKEN_ERROR,
+ "cannot find default mount point for hive file %s\n", fname);
+
+ return -1;
+ }
+
+ /* TODO: rlRegMountRegistry() */
+ return rlRegMountRegistry(fname, HMODE_RO, mount.key, mount.path);
+} // }}}
+long hl_mount_list( int argc, char **argv ) // {{{
+{
+ int i=0;
+ VBUF_STATIC(fname, 0);
+ VBUF_STATIC(mpoint, 0);
+ char *p;
+
+ for (i = 0; i < argc; i++)
+ {
+ if( (p=esc_index( argv[i], '=')) ) {
+ vbuf_strnset( fname, argv[i], p - argv[i] );
+ vbuf_strset( mpoint, p + 1 );
+ }
+ else {
+ vbuf_strset( fname, argv[i] );
+ vbuf_strset( mpoint, "" );
+ }
+
+ if( 0 != hl_mount( fname->b, mpoint->b, 0 ) )
+ return -1;
+ }
+
+ return 0;
+} // }}}
+
+// vim600: set foldlevel=0 foldmethod=marker:
Added: hivetools/mount.h
===================================================================
--- hivetools/mount.h (rev 0)
+++ hivetools/mount.h 2007-01-09 14:48:15 UTC (rev 60)
@@ -0,0 +1,27 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2005-2006 hivetools <http://hivetools.sourceforge.net/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+#ifndef __MOUNT_H
+#define __MOUNT_H
+
+/*****************************************************************************/
+
+long hl_mount(const char *filename, const char *mpoint, int mode);
+long hl_mount_list(int argc, char **argv);
+
+/*****************************************************************************/
+
+#endif /* __MOUNT_H */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-08 05:57:17
|
Revision: 59
http://hivetools.svn.sourceforge.net/hivetools/?rev=59&view=rev
Author: jasta
Date: 2007-01-07 21:57:12 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
reintroduced wr_fprint_val (i thought it wasn't being used again, sorry)
Modified Paths:
--------------
lib/regtypes.c
Modified: lib/regtypes.c
===================================================================
--- lib/regtypes.c 2007-01-08 05:52:17 UTC (rev 58)
+++ lib/regtypes.c 2007-01-08 05:57:12 UTC (rev 59)
@@ -149,6 +149,42 @@
winhex( stream, (unsigned char *)data, 0, length, loff);
return loff;
} // }}}
+void wr_fprint_val( FILE* stream, void *data, int type, int len, int loff ) /* {{{ print a value to a stream*/
+{
+ //int i=0;
+
+ VBUF_STATIC( eevil, 100 );
+ VBUF_STATIC( buf16, 100 );
+
+ switch( type ) {
+ case REG_SZ:
+ if( 0 == len ) {
+ utf16_fprintf(stream, "\"\"");
+ break;
+ }
+
+ if( 0 == vb_utf16to8( buf16, data, len ) ) {
+ vb_escape_evil( eevil, buf16->b );
+ utf16_fprintf( stream, "\"%s\"", eevil->b );
+ } else {
+ //SZ values can contain non-utf16. If conversion fails
+ //then we dump it raw
+ print_typed_winhex( stream, type, data, len );
+ }
+ break;
+ case REG_DWORD:
+ fflush( stdout );
+ utf16_fprintf(stream, "dword:%08x",*(unsigned int *)data);
+ break;
+
+ default:
+ print_typed_winhex( stream, type, data, len );
+ break;
+ }
+
+ utf16_fprintf( stream, "%s", stupid_cr );
+}
+// }}}
void fprint_val8( FILE* stream, void *data, int type, int len, int loff ) /* {{{ print a value to a stream (UTF8)*/
{
VBUF_STATIC(vb, 10);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-08 05:52:20
|
Revision: 58
http://hivetools.svn.sourceforge.net/hivetools/?rev=58&view=rev
Author: jasta
Date: 2007-01-07 21:52:17 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
build system correctness
Modified Paths:
--------------
Makefile.am
bin/Makefile.am
configure.ac
m4/ensure_ssl.m4
m4/vl_lib_readline.m4
Modified: Makefile.am
===================================================================
--- Makefile.am 2007-01-08 05:51:57 UTC (rev 57)
+++ Makefile.am 2007-01-08 05:52:17 UTC (rev 58)
@@ -10,4 +10,4 @@
EXTRA_DIST = configure
SUBDIRS = m4 lib hivetools bin
-LOCAL_AMFLAGS = -I m4
+ACLOCAL_FLAGS = -I m4
Modified: bin/Makefile.am
===================================================================
--- bin/Makefile.am 2007-01-08 05:51:57 UTC (rev 57)
+++ bin/Makefile.am 2007-01-08 05:52:17 UTC (rev 58)
@@ -1,8 +1,8 @@
SUBDIRS=
+
LDADD = \
- $(top_builddir)/hivetools/libhivetools.a \
- $(top_builddir)/lib/libhive.la \
- $(top_builddir)/misc/libmisc.a
+ $(top_builddir)/hivetools/libhivetools.la \
+ $(top_builddir)/lib/libhive.la
bin_PROGRAMS=hiveshell cpnt regmod sam template
hiveshell_SOURCES=hiveshell.c
Modified: configure.ac
===================================================================
--- configure.ac 2007-01-08 05:51:57 UTC (rev 57)
+++ configure.ac 2007-01-08 05:52:17 UTC (rev 58)
@@ -12,10 +12,7 @@
dnl http://www.gnu.org/software/ac-archive/htmldoc/check_ssl.html
dnl
-AC_INIT([hivetools],
- [0.3],
- [Sean Loaring slo...@te...],
- [hivetools])
+AC_INIT([hivetools],[0.3],[Sean Loaring slo...@te...],[hivetools])
AM_INIT_AUTOMAKE(hivetools, 0.3)
AM_MAINTAINER_MODE
AC_CONFIG_SRCDIR([lib/libhive.c])
@@ -66,7 +63,6 @@
AC_CONFIG_FILES([
Makefile
m4/Makefile
- misc/Makefile
lib/Makefile
hivetools/Makefile
bin/Makefile
Modified: m4/ensure_ssl.m4
===================================================================
--- m4/ensure_ssl.m4 2007-01-08 05:51:57 UTC (rev 57)
+++ m4/ensure_ssl.m4 2007-01-08 05:52:17 UTC (rev 58)
@@ -27,4 +27,4 @@
HAVE_SSL=yes
fi
AC_SUBST(HAVE_SSL)
-])dnl
+])
Modified: m4/vl_lib_readline.m4
===================================================================
--- m4/vl_lib_readline.m4 2007-01-08 05:51:57 UTC (rev 57)
+++ m4/vl_lib_readline.m4 2007-01-08 05:52:17 UTC (rev 58)
@@ -43,4 +43,5 @@
AC_CHECK_HEADERS(history.h readline/history.h)
fi
fi
-])dnl
+])
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-08 05:52:02
|
Revision: 57
http://hivetools.svn.sourceforge.net/hivetools/?rev=57&view=rev
Author: jasta
Date: 2007-01-07 21:51:57 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
vb_escape_evil is apparently not local to regtypes.c
Modified Paths:
--------------
lib/regtypes.c
lib/regtypes.h
Modified: lib/regtypes.c
===================================================================
--- lib/regtypes.c 2007-01-08 04:21:54 UTC (rev 56)
+++ lib/regtypes.c 2007-01-08 05:51:57 UTC (rev 57)
@@ -38,7 +38,7 @@
static char typebuf[TYPE_BUF_LEN];
static char *get_hextype( int type );
-static void vb_escape_evil(vbuf *vb, char *string) // {{{ escape things like '\' and '"'
+void vb_escape_evil(vbuf *vb, char *string) // {{{ escape things like '\' and '"'
{
int i=0;
Modified: lib/regtypes.h
===================================================================
--- lib/regtypes.h 2007-01-08 04:21:54 UTC (rev 56)
+++ lib/regtypes.h 2007-01-08 05:51:57 UTC (rev 57)
@@ -112,6 +112,7 @@
void fprint_val( FILE* stream, void *data, int type, int len, int loff ); /* print a value to a stream*/
void fprint_val8( FILE* stream, void *data, int type, int len, int loff );
void vbprint_val8( vbuf *vb, void *data, int type, int len, int loff );
+void vb_escape_evil(vbuf *vb, char *string);
void escape_evil( char *string, int length );
char *get_wintype( int type );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-08 04:21:56
|
Revision: 56
http://hivetools.svn.sourceforge.net/hivetools/?rev=56&view=rev
Author: jasta
Date: 2007-01-07 20:21:54 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
reintroduced globals.[ch]
Modified Paths:
--------------
lib/Makefile.am
Added Paths:
-----------
lib/globals.c
lib/globals.h
Modified: lib/Makefile.am
===================================================================
--- lib/Makefile.am 2007-01-08 04:21:15 UTC (rev 55)
+++ lib/Makefile.am 2007-01-08 04:21:54 UTC (rev 56)
@@ -15,6 +15,8 @@
regtypes.c \
regtypes.h \
tools.c \
+ globals.c \
+ globals.h \
uerr.c \
winerr.c \
winerr.h \
@@ -27,6 +29,7 @@
regstructs.h \
regtypes.h \
tools.h \
+ globals.h \
uerr.h \
winerr.h \
wintypes.h
Copied: lib/globals.c (from rev 51, lib/globals.c)
===================================================================
--- lib/globals.c (rev 0)
+++ lib/globals.c 2007-01-08 04:21:54 UTC (rev 56)
@@ -0,0 +1,24 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2005-2006 hivetools <http://hivetools.sourceforge.net/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+/*****************************************************************************/
+
+#include "globals.h"
+
+/*****************************************************************************/
+
+/* Why the fuck are these here? */
+int gverbose = 0;
Copied: lib/globals.h (from rev 51, lib/globals.h)
===================================================================
--- lib/globals.h (rev 0)
+++ lib/globals.h 2007-01-08 04:21:54 UTC (rev 56)
@@ -0,0 +1,5 @@
+
+
+extern int winout;
+
+extern int gverbose;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-08 04:21:16
|
Revision: 55
http://hivetools.svn.sourceforge.net/hivetools/?rev=55&view=rev
Author: jasta
Date: 2007-01-07 20:21:15 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
removed old code
Modified Paths:
--------------
bin/hiveshell.c
Modified: bin/hiveshell.c
===================================================================
--- bin/hiveshell.c 2007-01-08 03:45:00 UTC (rev 54)
+++ bin/hiveshell.c 2007-01-08 04:21:15 UTC (rev 55)
@@ -56,14 +56,14 @@
//#define CRAP_ERROR DIE("This is a meaningless error.");
-#include "../misc/tools.h"
+#include "../lib/tools.h"
#include "../hivetools/hivetools.h"
-//#include "../libhive/ntreg.h" //TODO: get rid of this
#include "../lib/regtypes.h"
#include "../hivetools/sam.h"
#include "../hivetools/nstdreg.h"
-#include "../misc/globals.h"
+#include "../hivetools/mount.h"
#include "../lib/ntreg.h"
+#include "../lib/globals.h"
//prototypes
void find_n_change(char *username);
@@ -85,237 +85,6 @@
int done=0; //set to 1 to quit program
-/////* {{{ THIS STUFF SHOULD BE IN SAM.{HC} */
-////#define USER_NAME_PATH "\\SAM\\SAM\\Domains\\Account\\Users\\Names\\"
-//char *sam_rid2uname( int rid ) // {{{ return user name in static buffer
-//{
-// static struct varbuf *vb = NULL;
-// if( NULL == vb ) vb = vbuf_alloc( 10 );
-//
-// if( 0 != sam_get_user_name( rid, vb ) ) return NULL;
-//
-// return vb->b;
-//} // }}}
-//void print_user( FILE *fp, int rid ) // {{{ Nicely print the information for a user
-//{
-// //TODO: this should live in sam.c
-// //TODO: ugly and no ACB information
-//
-// struct uv *userv;
-// struct uf *userf;
-//
-// static struct varbuf *unbuf = NULL;
-// static struct varbuf *vb = NULL;
-// if( NULL == unbuf ) unbuf = vbuf_alloc( 10 );
-// if( NULL == vb ) vb = vbuf_alloc( 10 );
-//
-// if( 0 != sam_get_user_name( rid, unbuf ) ) {
-// //TODO: error
-// fprintf(fp, "print_user(): couldn't get user name for rid %x\n", rid );
-// return;
-// }
-// fprintf(fp, "------------------------------------------------------------------------------------------\n");
-// fprintf(fp, "RID: %x: Username: %s\n", rid, unbuf->b);
-//
-// fprintf(fp, " USER V STRUCT:\n");
-// if( NULL == ( userv = sam_get_user_V( rid, vb ) ) ) {
-// fprintf(fp, "Error getting user V struct.\n");
-// return;
-// }
-// uv_dump( fp, userv );
-//
-// fprintf(fp, " USER F STRUCT:\n");
-// if( NULL == ( userf = sam_get_user_F( rid, vb ) ) ) {
-// fprintf(fp, "Error getting user F struct.\n");
-// return;
-// }
-// dump_user_F( fp, userf );
-//} // }}}
-//void acb_print( FILE *fp, short acb ) // {{{
-//{
-// int b;
-// fprintf(fp, "Account bits: 0x%04x =\n", acb);
-//
-// for (b=0; b < 15; b++) {
-// fprintf(fp, "[%s] %-15.15s | ",
-// (acb & (1<<b)) ? "X" : " ", acb_fields[b] );
-// if (b%3 == 2) printf("\n");
-// }
-//
-//} // }}}
-//void acb_edit( struct uf *userf ) // {{{
-//{
-// char yn[10];
-// if ( userf->acb & (ACB_DISABLED|ACB_AUTOLOCK) || (userf->bad_login_count > 0 && userf->bad_login_count >= max_sam_lock) ) {
-// printf("Account is %s\n",(userf->acb & ACB_DISABLED) ? "disabled" : "probably locked out!");
-// printf("Do you wish me to reset the failed count, unset disabled and lockout,\n");
-// fmyinput("and set the \"password never expires\" option? (y/n) [n]",yn,2);
-// if (*yn == 'y') {
-// userf->acb |= ACB_PWNOEXP;
-// userf->acb &= ~ACB_DISABLED;
-// userf->acb &= ~ACB_AUTOLOCK;
-// //userf->acb = acb;
-// userf->bad_login_count = 0;
-// WARN("TODO: WRITE CHANGES TO REGISTRY");
-// //put_buf2val(hive[H_SAM], v, 0, s, REG_BINARY);
-// printf("Unlocked!\n");
-// }
-// }
-//} // }}}
-//
-//void promote_user(int rid) // {{{
-//{
-// /* Promote user into administrators group (group ID 0x220)
-// * And remove from all others...
-// * hdesc - hive
-// * rid - users rid
-// * no returns yet
-// * THIS IS VERY HACKISH YET
-// */
-// char s[200];
-// char g[200];
-// //int nk = 0;
-// rl_hkey hk;
-// long mblen = 0, cblen = 0;
-// //struct keyval *m = NULL, *c = NULL;
-// char *m, *c;
-// //struct keyval admember = { 4, 0x220 };
-// unsigned int *grps, *gcnts;
-// int count = 0;
-// int i, grp;
-// ulong size;
-//
-// if (!rid || (H_SAM < 0)) return;
-//
-// /* Get member list for user. Go for the first full SID, it's usually local computer I hope */
-// snprintf(s,180,"\\SAM\\SAM\\Domains\\Builtin\\Aliases\\Members\\S-1-5-21-\\%08X",rid);
-// /* Now, the TYPE field is the number of groups the user is member of */
-// /* Don't we just love the inconsistent use of fields!! */
-// ASSERT( rlERROR_SUCCESS == rlRegOpenKeyEx( HKEY_LOCAL_MACHINE, s, 0, 0, &hk ), "Couldn't open key." );
-//// nk = get_file_offset( hive[H_SAM], trav_path(hive[H_SAM], 0, s, 0));
-//// if (!nk) {
-//// printf("Cannot find path <%s>\n",s);
-//// return;
-//// }
-//// nk += 4;
-//// count = get_val_type(hive[H_SAM],nk,"@");
-//// if (count == -1) {
-//// printf("Cannot find value <%s\\@>\n",s);
-//// return;
-//// }
-//// printf("User is member of %d groups.\n",count);
-//
-// /* This is the data size */
-// ASSERT( rlERROR_MORE_DATA == rlRegQueryValueEx( hk, "", NULL, NULL, &size ), "Another broken error message" );
-// //size = get_val_len(hive[H_SAM],nk,"@");
-//
-// /* It should be 4 bytes for each group */
-// printf("Data size %ld bytes.\n",size);
-// if (size != count * 4) {
-// printf("DEBUG: Size is not 4 * count! May not matter anyway. Continuing..\n");
-// }
-//
-// ASSERT( 0 < get_realloc( hk, "", NULL, &m, &mblen ), "Huh?");
-// //m = get_val2buf(hive[H_SAM], NULL, nk, "@", 0);
-// /*
-// if (!m) {
-// printf("Could not get value data! Giving up.\n");
-// return;
-// }
-// */
-//
-// printf("User was member of groups: ");
-// grps = (unsigned int *)m;
-// for (i = 0; i < count; i++) {
-// grp = grps[i];
-// printf("%08x ",grp);
-// switch (grp) {
-// case 0x220: printf("=Administrators, "); break;
-// case 0x221: printf("=Users, "); break;
-// case 0x222: printf("=Guests, "); break;
-// default: printf(", "); break;
-// }
-// snprintf(g, 180, "\\SAM\\SAM\\Domains\\Builtin\\Aliases\\%08X\\C",grp);
-// ASSERT( 0 < get_realloc( HKEY_LOCAL_MACHINE, g, NULL, &c, &cblen ), "Huh?");
-//// ASSERT( rlERROR_MORE_DATA == rlRegQueryValueEx( HKEY_LOCAL_MACHINE, g, NULL, &blen ), "This is a bad error string" );
-//// c = F_MALLOC( blen );
-//// ASSERT( rlERROR_SUCCESS == rlRegQueryValueEx( HKEY_LOCAL_MACHINE, g, c, &blen ), "This is another bad error string" );
-//// c = get_val2buf(hive[H_SAM], NULL, 0, g, 0);
-// if (c) {
-// gcnts = (unsigned int *)c;
-// gcnts[0xc]--;
-// /* Decrease members counter */
-// WARN("WRITE TO HIVE");
-// //put_buf2val(hive[H_SAM], c, 0, g, 0);
-// } else {
-// printf("Group info for %x not found!\n",grp);
-// }
-//
-// }
-//
-// cblen = 0;
-// FREE( c );
-//#if 1
-// DIE("You need to replace this part.");
-// printf("\nDeleting user memberships\n");
-//
-// //del_value(hive[H_SAM], hk, "@");
-//
-// printf("Adding into only administrators:\n");
-//
-//// if (!add_value(hive[H_SAM], nk, "@", 1)) { /* Type is # of groups, here 1 */
-//// printf("Failed to add @ value to key\n");
-//// }
-//#endif
-// //put_buf2val(hive[H_SAM], &admember, nk, "@", 0);
-//
-// /* Now bumb up administrator groups count */
-// struct valh *vh;
-// if( NULL == (vh = vh_open( HKEY_LOCAL_MACHINE, "\\SAM\\SAM\\Domains\\Builtin\\Aliases\\00000220\\C"))) {
-// printf("Group info for 220 (adm) not found!");
-// return;
-// }
-// //c = get_val2buf(hive[H_SAM], NULL, 0, "\\SAM\\Domains\\Builtin\\Aliases\\00000220\\C", 0);
-// //if (!c) printf("Group info for 220 (adm) not found!\n");
-// gcnts = (unsigned int *)vh->buf;
-// gcnts[0xc]++;
-// //put_buf2val(hive[H_SAM], c, 0, "\\SAM\\Domains\\Builtin\\Aliases\\00000220\\C", 0);
-//
-// vh_close( vh );
-//
-// printf("Promotion DONE!\n");
-//
-//} // }}}
-////char *change_pw(char *buf, int rid, int vlen, int stat) // {{{}}}
-////
-//void pass_print( int rid, struct uv *userv ) // {{{ Nicely print the password situation in uv
-//{
-// int ntolen = uv_get_entry( userv, UV_NTPW )->len;
-// char omd4[32], olanman[32];
-// if ( ntolen < 16) {
-// printf("Note: NT password does not seem to be set or is invalid.\n");
-//
-// } else {
-// rid_pw_decrypt( rid, omd4, uv_get_field_ptr( userv, UV_NTPW, NULL ) );
-// if( gverbose ) {
-// printf("Crypted NT pw: ");
-// hexprnt(stdout, uv_get_field_ptr( userv, UV_NTPW, NULL ), ntolen);
-// printf("MD4 hash : "); hexprnt(stdout, omd4, ntolen);
-// }
-// }
-//
-// int lmolen = uv_get_entry( userv, UV_LMPW )->len;
-// if ( lmolen < 16) {
-// printf("Note: NT password does not seem to be set or is invalid.\n");
-// } else {
-// rid_pw_decrypt( rid, olanman, uv_get_field_ptr( userv, UV_LMPW, NULL ) );
-// if( gverbose ) {
-// printf("Crypted LM pw: ");
-// hexprnt(stdout, uv_get_field_ptr( userv, UV_LMPW, NULL ), lmolen);
-// printf("MD4 hash : "); hexprnt(stdout, olanman, ntolen);
-// }
-// }
-//} // }}}
int change_pw(int rid, int stat) // {{{ TODO: hack this up and put as much in sam.c/h as possible
{
/*
@@ -369,7 +138,6 @@
sam_set_lm_password( rid, newp );
}
-
if( gverbose ) printf("New passwords:\n");
pass_print( vb, rid, (struct uv*)uvbuf->b);
printf("%s\n", vb->b );
@@ -380,8 +148,6 @@
printf("\n");
return 0;
} // }}}
-//
-////}}}
void usage(void) // {{{
{
@@ -448,76 +214,6 @@
hl_close_all();
return 0;
-
-#if 0
- // {{{ Old
- WARN("TODO: replace the following");
- //if (dodebug) debugit(hive[0]->buf,hive[0]->size);
- if(0) DIE("Hi! I'm impossible!.");
- else {
- //check_get_samdata();
- //DIE("I commented out the above because it no longer exists.");
- if (list && !edit && !inter && !export) {
- DIE("list_users() does not exist at the moment");
- //if ( list_users(1) ) edit = 1;
- }
-
- if (edit) editor();
- else if (!export && who) { handle_syskey(); find_n_change(who); }
-
-
- if (inter) interactive();
- // if (export) doexport( regpath );
- }
-
- hl_close_all();
-
- if( gverbose ) {
- printf("\nHives that have changed:\n # Name\n");
- for (il = 0; il < no_hives; il++) {
- DIE("TODO: replace me");
- /*
- if (hive[il]->state & HMODE_DIRTY) {
- if (!logchange) printf("%2d <%s>\n",il,hive[il]->filename);
- d = 1;
- }
- */
- }
- }
- if (d) {
- /* Only prompt user if logging of changed files has not been set */
- /* Thus we assume confirmations are done externally if they ask for a list of changes */
- if (!logchange) fmyinput("Write hive files? (y/n) [n] : ",iwho,3);
- if (*iwho == 'y' || logchange) {
- if (logchange) {
- ch = fopen("/tmp/changed","w");
- }
- for (il = 0; il < no_hives; il++) {
- DIE("TODO: replace me.");
- /*
- if (hive[il]->state & HMODE_DIRTY) {
- printf("%2d <%s> - ",il,hive[il]->filename);
- if (!writeHive(hive[il])) {
- printf("OK\n");
- if (logchange) fprintf(ch,"%s ",hive[il]->filename);
- dd = 2;
- }
- }
- */
- }
- if (logchange) {
- fprintf(ch,"\n");
- fclose(ch);
- }
- } else {
- printf("Not written!\n\n");
- }
- } else {
- if( gverbose ) printf("None!\n\n");
- }
- return(dd);
- // }}}
-#endif
} // }}}
// {{{ Command Vector
struct cmds {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-08 03:45:01
|
Revision: 54
http://hivetools.svn.sourceforge.net/hivetools/?rev=54&view=rev
Author: jasta
Date: 2007-01-07 19:45:00 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
removed commented code
Modified Paths:
--------------
lib/libhive.c
Modified: lib/libhive.c
===================================================================
--- lib/libhive.c 2007-01-08 03:28:59 UTC (rev 53)
+++ lib/libhive.c 2007-01-08 03:45:00 UTC (rev 54)
@@ -772,26 +772,6 @@
return rlERROR_BROKEN_ERROR;
} // }}}
-//DWORD rlFormatMessage( DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPTSTR lpBuffer, DWORD nSize, va_list* Arguments) // {{{
-//{
-// /* Oh. My. God. WTF was the person who came up with this API
-// * function smoking? */
-//
-// /* I'm implementing this as quickly and half-assedly as possible. If
-// * you need missing features then you'll have to write them yourself */
-//
-// ASSERT( dwFlags == (rlFORMAT_MESSAGE_ALLOCATE_BUFFER | rlFORMAT_MESSAGE_FROM_SYSTEM),
-// "FormatMessage() doesn't implement whatever it is that you are trying to do." );
-//
-// ASSERT( dwMessageId < MAX_WIN_ERROR, "FormatMessage(): Got a dwMessageId I don't know about." );
-//
-// *((void**)lpBuffer) = (void*)F_MALLOC( strlen( win_errstr[dwMessageId] ) );
-//
-// strcpy( *(void**)lpBuffer, win_errstr[dwMessageId] );
-//
-// return strlen( lpBuffer ) + 1;
-//} // }}}
-
/** UNSORTED **/
long rlRegQueryMultipleValues(rl_hkey hkey, VALENTW *val_list, ulong nvals,
char *buf, ulong *totsize)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-08 03:29:00
|
Revision: 53
http://hivetools.svn.sourceforge.net/hivetools/?rev=53&view=rev
Author: jasta
Date: 2007-01-07 19:28:59 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
oops
Removed Paths:
-------------
bin/cpnt
Deleted: bin/cpnt
===================================================================
--- bin/cpnt 2007-01-08 03:28:20 UTC (rev 52)
+++ bin/cpnt 2007-01-08 03:28:59 UTC (rev 53)
@@ -1,117 +0,0 @@
-#! /bin/sh
-
-# cpnt - temporary wrapper script for .libs/cpnt
-# Generated by ltmain.sh - GNU libtool 1.5.22 Debian 1.5.22-4 (1.1220.2.365 2005/12/18 22:14:06)
-#
-# The cpnt program cannot be directly executed until all the libtool
-# libraries that it depends on are installed.
-#
-# This wrapper script should never be moved out of the build directory.
-# If it is, it will not operate correctly.
-
-# Sed substitution that helps us do robust quoting. It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed='/bin/sed -e 1s/^X//'
-sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-relink_command="(cd /home/jasta/software/hivetools-0.3/bin; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=\"/home/jasta/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games\"; export PATH; gcc -g -O2 -I/usr/include/openssl -DHAVE_SSL -o \$progdir/\$file cpnt.o -L/usr/lib ../hivetools/libhivetools.a ../lib/.libs/libhive.so ../misc/libmisc.a -lssl -lcrypto -lreadline -Wl,--rpath -Wl,/home/jasta/software/hivetools-0.3/lib/.libs -Wl,--rpath -Wl,/usr/local/lib)"
-
-# This environment variable determines our operation mode.
-if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
- # install mode needs the following variable:
- notinst_deplibs=' ../lib/libhive.la'
-else
- # When we are sourced in execute mode, $file and $echo are already set.
- if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
- echo="echo"
- file="$0"
- # Make sure echo works.
- if test "X$1" = X--no-reexec; then
- # Discard the --no-reexec flag, and continue.
- shift
- elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
- # Yippee, $echo works!
- :
- else
- # Restart under the correct shell, and then maybe $echo will work.
- exec /bin/sh "$0" --no-reexec ${1+"$@"}
- fi
- fi
-
- # Find the directory that this script lives in.
- thisdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
- test "x$thisdir" = "x$file" && thisdir=.
-
- # Follow symbolic links until we get to the real thisdir.
- file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'`
- while test -n "$file"; do
- destdir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
-
- # If there was a directory component, then change thisdir.
- if test "x$destdir" != "x$file"; then
- case "$destdir" in
- [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
- *) thisdir="$thisdir/$destdir" ;;
- esac
- fi
-
- file=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
- file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'`
- done
-
- # Try to get the absolute directory name.
- absdir=`cd "$thisdir" && pwd`
- test -n "$absdir" && thisdir="$absdir"
-
- program=lt-'cpnt'
- progdir="$thisdir/.libs"
-
- if test ! -f "$progdir/$program" || \
- { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \
- test "X$file" != "X$progdir/$program"; }; then
-
- file="$$-$program"
-
- if test ! -d "$progdir"; then
- mkdir "$progdir"
- else
- rm -f "$progdir/$file"
- fi
-
- # relink executable if necessary
- if test -n "$relink_command"; then
- if relink_command_output=`eval $relink_command 2>&1`; then :
- else
- echo "$relink_command_output" >&2
- rm -f "$progdir/$file"
- exit 1
- fi
- fi
-
- mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null ||
- { rm -f "$progdir/$program";
- mv -f "$progdir/$file" "$progdir/$program"; }
- rm -f "$progdir/$file"
- fi
-
- if test -f "$progdir/$program"; then
- if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
- # Run the actual program with our arguments.
-
- exec "$progdir/$program" ${1+"$@"}
-
- $echo "$0: cannot exec $program ${1+"$@"}"
- exit 1
- fi
- else
- # The program doesn't exist.
- $echo "$0: error: \`$progdir/$program' does not exist" 1>&2
- $echo "This script is just a wrapper for $program." 1>&2
- echo "See the libtool documentation for more information." 1>&2
- exit 1
- fi
-fi
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-08 03:28:21
|
Revision: 52
http://hivetools.svn.sourceforge.net/hivetools/?rev=52&view=rev
Author: jasta
Date: 2007-01-07 19:28:20 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
removed globals.[ch]
Removed Paths:
-------------
lib/globals.c
lib/globals.h
Deleted: lib/globals.c
===================================================================
--- lib/globals.c 2007-01-08 03:27:45 UTC (rev 51)
+++ lib/globals.c 2007-01-08 03:28:20 UTC (rev 52)
@@ -1,24 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 2005-2006 hivetools <http://hivetools.sourceforge.net/>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- */
-
-/*****************************************************************************/
-
-#include "globals.h"
-
-/*****************************************************************************/
-
-/* Why the fuck are these here? */
-int gverbose = 0;
Deleted: lib/globals.h
===================================================================
--- lib/globals.h 2007-01-08 03:27:45 UTC (rev 51)
+++ lib/globals.h 2007-01-08 03:28:20 UTC (rev 52)
@@ -1,5 +0,0 @@
-
-
-extern int winout;
-
-extern int gverbose;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-08 03:27:46
|
Revision: 51
http://hivetools.svn.sourceforge.net/hivetools/?rev=51&view=rev
Author: jasta
Date: 2007-01-07 19:27:45 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
removed misc dir (moved it to lib/ a while ago)
Removed Paths:
-------------
misc/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-08 03:26:41
|
Revision: 50
http://hivetools.svn.sourceforge.net/hivetools/?rev=50&view=rev
Author: jasta
Date: 2007-01-07 19:26:40 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
reenabled and updated the hivetools package
Modified Paths:
--------------
Makefile.am
hivetools/Makefile.am
hivetools/hivetools.c
hivetools/nstdreg.c
hivetools/sam.c
Modified: Makefile.am
===================================================================
--- Makefile.am 2007-01-08 03:25:43 UTC (rev 49)
+++ Makefile.am 2007-01-08 03:26:40 UTC (rev 50)
@@ -9,5 +9,5 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
EXTRA_DIST = configure
-SUBDIRS = m4 lib test
+SUBDIRS = m4 lib hivetools bin
LOCAL_AMFLAGS = -I m4
Modified: hivetools/Makefile.am
===================================================================
--- hivetools/Makefile.am 2007-01-08 03:25:43 UTC (rev 49)
+++ hivetools/Makefile.am 2007-01-08 03:26:40 UTC (rev 50)
@@ -1,3 +1,17 @@
SUBDIRS=
-lib_LIBRARIES=libhivetools.a
-libhivetools_a_SOURCES=hivetools.c nstdreg.c sam.c hivetools.h nstdreg.h sam.h
+
+INCLUDES = \
+ -I$(top_srcdir)/lib
+
+lib_LTLIBRARIES = \
+ libhivetools.la
+
+libhivetools_la_SOURCES = \
+ hivetools.c \
+ hivetools.h \
+ nstdreg.c \
+ nstdreg.h \
+ sam.c \
+ sam.h \
+ mount.c \
+ mount.h
Modified: hivetools/hivetools.c
===================================================================
--- hivetools/hivetools.c 2007-01-08 03:25:43 UTC (rev 49)
+++ hivetools/hivetools.c 2007-01-08 03:26:40 UTC (rev 50)
@@ -29,7 +29,6 @@
#include "hivetools.h"
#include "sam.h"
-#include "../misc/globals.h"
#include "../lib/ntreg.h" //TODO: shouldn't be here
#include <ctype.h>
Modified: hivetools/nstdreg.c
===================================================================
--- hivetools/nstdreg.c 2007-01-08 03:25:43 UTC (rev 49)
+++ hivetools/nstdreg.c 2007-01-08 03:26:40 UTC (rev 50)
@@ -26,10 +26,11 @@
}}} */
#include "../lib/libhive.h"
+#include "../lib/regtypes.h"
#include "nstdreg.h"
-#include "../misc/tools.h"
-#include "../misc/uerr.h"
-#include "errno.h"
+#include "../lib/tools.h"
+#include "../lib/uerr.h"
+#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <libgen.h>
@@ -40,7 +41,7 @@
char *ns_basename( char *p, char delim );
char *pathjoin( char *buf, int blen, char *p1, char *p2 );
-void *vb_pathjoin( vbuf *vb, char *p1, char *p2 );
+static void vb_pathjoin( vbuf *vb, char *p1, char *p2 );
char *hivenames[] = // {{{
{ "HKEY_LOCAL_MACHINE",
@@ -261,7 +262,6 @@
char *p = path;
int ttype;
VBUF_STATIC(tok,100);
- int off = 0;
int loff = -1;
int last_cur=0;
@@ -566,11 +566,8 @@
int ns_key_recursive_delete( rl_hkey hk, char *parent, char *name ) // {{{
{
int r=0;
- //int idx=0;
rl_hkey sk;
char *nbuf = NULL;
- long blen, cblen = 0;
- //char pstr[SZ_MAX];
VBUF_STATIC( bn, 100 );
VBUF_STATIC( ps, 100 );
VBUF_STATIC( regbn, 100 );
@@ -789,7 +786,9 @@
if(is_esc && '0' == c ) c = '\0';
switch( c ) {
case '\0':
- if(p=src)all_period=0;
+ if (p == src)
+ all_period = 0;
+
while(*p)p++;
break;
case '/':
@@ -854,6 +853,8 @@
result->vb_path = vbuf_alloc( strlen( path ) + 1 );
vbuf_strset( result->vb_path, path );
ns_rewinddir( result );
+
+ return result;
} // }}}
void NREGDIR_FREE( NREGDIR *dir ) // {{{
{
@@ -864,7 +865,6 @@
{
//char tok[PATH_MAX];
rl_hkey hk;
- char rlpath[PATH_MAX];
char *p = path;
int ttype;
int hiveno;
@@ -872,8 +872,6 @@
VBUF_STATIC( vb_rpath, 100 );
VBUF_STATIC( vb_tok, 100 );
- int off;
-
if( 0 != vb_process_path( vb_path, path ) ) return NULL;
// {{{ append a '/' to result->path if there isn't one already
@@ -1116,9 +1114,10 @@
int ns_set_sz( char *path, char *str ) // {{{ in: path,str=utf8 string; out: str->utf16->registry
{
VBUF_STATIC( vb, 100 );
- int nl = ( strlen( str ) + 1 )* 2;
- if( 0 != vb_utf8to16T( vb, str, strlen( str ) + 1 ) ) return -1;
+ if( 0 != vb_utf8to16T( vb, str, strlen( str ) + 1 ) )
+ return -1;
+
return ns_set_valueT( path, REG_SZ, vb->b, vb->dlen );
} // }}}
int ns_set_valueT( char *path, int type, char *value, int len ) // {{{ in: raw value data; out: ->registry
@@ -1171,10 +1170,7 @@
} // }}}
int ns_read_valueT( char *path, unsigned long *type, struct varbuf *vb ) // {{{
{
- char *dn = NULL;
- char *bn = NULL;
NREGDIR *dir = NULL;
- NREGH* rh;
rl_hkey hk;
unsigned long needed;
//VBUF_STATIC( vpath, 100 );
@@ -1340,21 +1336,18 @@
return ns_unlink( cp->b );
} // }}}
-void *vb_pathjoin( vbuf *vb, char *p1, char *p2 ) // {{{ attach p2 relative to p1
+static void vb_pathjoin( vbuf *vb, char *p1, char *p2 ) // {{{ attach p2 relative to p1
{
VBUF_STATIC( cp, 100 );
- char *result;
-
- if( path_is_absolute( p2 ) ) {
+ if (path_is_absolute( p2 )) {
vbuf_strset( cp, p2 );
- }else {
+ } else {
vbuf_strset( cp, p1 );
vbuf_strcat( cp, p2 );
}
vb_process_path( vb, cp->b );
-
} // }}}
char *pathjoinA( char *buf, int blen, char *p1, char *p2 ) // {{{ attach p2 relative to p1
{
@@ -1475,11 +1468,15 @@
return r + ns_vdirnamer( vb, p );
}
- if( p = esc_index( path, '/' ) ) { // if we are not the last element then we append
+ if((p = esc_index( path, '/' ))) { // if we are not the last element then we append
char *p2 = p;
- while( *p2 == '/' )p2++;
- if(!*p2) return 0;
+ while (*p2 == '/')
+ p2++;
+
+ if (*p2 == '\0')
+ return 0;
+
if( vb->dlen > 1 && vb->b[vb->dlen-2] != '/' )
vbuf_charcat( vb, '/' );
vbuf_strncat( vb, path, p - path );
@@ -1531,12 +1528,10 @@
}
void ns_vbasename( vbuf *vb, char *path ) // {{{
{
- VBUF_STATIC( tok, 100 );
int type;
- char *result = NULL;
char *p = path;
- int c, is_esc;
int is_set = 0;
+ VBUF_STATIC( tok, 100 );
vbuf_strset( vb, "" );
Modified: hivetools/sam.c
===================================================================
--- hivetools/sam.c 2007-01-08 03:25:43 UTC (rev 49)
+++ hivetools/sam.c 2007-01-08 03:26:40 UTC (rev 50)
@@ -35,8 +35,8 @@
#include "sam.h"
#include "hivetools.h"
#include <errno.h>
-#include "../misc/tools.h"
-#include "../misc/uerr.h"
+#include "../lib/tools.h"
+#include "../lib/uerr.h"
#include "../lib/regtypes.h"
#include "nstdreg.h"
@@ -230,7 +230,6 @@
int sam_get_user_name( struct varbuf *out, int irid ) { // {{{
VBUF_STATIC( uvbuf, 100 );
VBUF_STATIC( uname, 100 );
- int blen;
struct uv *userv;
if( NULL == ( userv = sam_get_user_V( irid, uvbuf ) ) ) return -1;
@@ -323,14 +322,12 @@
} // }}}
int sam_user_list( struct varbuf *vb ) { // {{{ populate vb with array of RIDs (dword user IDs)
int index;
- ulong type;
- rl_hkey rl;
int no_users;
int *ridlist;
VBUF_STATIC( path, 100 );
-
NREGDIR *dir = NULL;
struct ns_dirent *de;
+ ulong len;
if( 0 > ( no_users = sam_no_users() ) )
return -1;
@@ -340,14 +337,13 @@
ridlist = (int*)vb->b;
- ulong len = SZ_MAX - 1;
+ len = SZ_MAX - 1;
if( NULL == ( dir = ns_opendir( NS_USER_NAME_PATH ) ) )
return -1;
index = 0;
- while( de = ns_readdir( dir ) ) {
- int type;
+ while ((de = ns_readdir(dir))) {
if( de->type != RTYPE_KEY ) {
WARN( "Invalid type reading user rid list." );
continue;
@@ -465,56 +461,13 @@
} // }}}
int sam_uname2rid( char *uname ) // {{{
{
- int index;
- ulong type;
- char name[SZ_MAX];
- ulong len = SZ_MAX - 1;
+ int r;
VBUF_STATIC( path, 10 );
- rl_hkey rl;
- int r;
-
vbuf_printf( path, "%s/%s/\\0", NS_USER_NAME_PATH, uname );
if( 0 != ns_read_dword( path->b, &r ) ) return -1;
- return r;
-// if( NULL == ( rl = sam_get_users_hkey() ) ) return NULL;
-//
-// for( index = 0;
-// (rlERROR_SUCCESS == rlRegEnumKeyEx(rl, index, name, &len, NULL, NULL, NULL));
-// index++
-// ) {
-//
-// ulong rid;
-// ulong rid_len = sizeof( rid );
-//
-// //fprintf(stderr, "Checking: %s == %s\n", uname, name );
-//
-// if( 0 == strcmp( uname, name ) ) {
-// ASSERT( rlERROR_SUCCESS == rlRegQueryValueEx( rl, name, &type, (void*)&rid, &rid_len ) , "rlRegQueryValueEx error.");
-// ASSERT( rid_len == 4, "sam_uname2rid(): rid_len is looking strange." );
-//
-// return rid;
-// }
-//
-//
-// //fprintf(stderr, "RIDIN: %x, RID: %lx\n", irid, rid );
-//
-// /*
-// if( irid == rid ) {
-// *blen = len;
-// if( NULL == buf || blin < len ) { return -1; }
-// strncpy( buf, name, len);
-//
-// return *blen;
-// }
-//
-// */
-//
-// len = SZ_MAX - 1;
-// }
-//
-// return -1;
+ return r;
} // }}}
///*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ja...@us...> - 2007-01-08 03:25:44
|
Revision: 49
http://hivetools.svn.sourceforge.net/hivetools/?rev=49&view=rev
Author: jasta
Date: 2007-01-07 19:25:43 -0800 (Sun, 07 Jan 2007)
Log Message:
-----------
deleted unused code and voided the effect and presence of gverbose
Modified Paths:
--------------
lib/Makefile.am
lib/libhive-helper.c
lib/ntreg.c
lib/regtypes.c
lib/tools.c
Modified: lib/Makefile.am
===================================================================
--- lib/Makefile.am 2006-12-24 00:36:52 UTC (rev 48)
+++ lib/Makefile.am 2007-01-08 03:25:43 UTC (rev 49)
@@ -1,9 +1,10 @@
SUBDIRS=
+
lib_LTLIBRARIES=libhive.la
+
libhive_la_SOURCES = \
defines.c \
defines.h \
- globals.c \
libhive.c \
libhive.h \
libhive-helper.c \
Modified: lib/libhive-helper.c
===================================================================
--- lib/libhive-helper.c 2006-12-24 00:36:52 UTC (rev 48)
+++ lib/libhive-helper.c 2007-01-08 03:25:43 UTC (rev 49)
@@ -34,23 +34,6 @@
#include "ntreg.h"
-// {{{ Array of loaded hives
-//struct hive *hive[MAX_HIVES+1];
-//char *pathmap[MAX_HIVES+1];
-
-#define MAX_HIVES 10
-rl_hkey mounts[MAX_HIVES+1];
-int no_hives = 0;
-
-char *HKEY_CLASSES_ROOT_PATHS[] = {""};
-char *HKEY_CURRENT_USER_PATHS[] = {""};
-char *HKEY_LOCAL_MACHINE_PATHS[] = { "SAM", "system", "security", "software", "" };
-char *HKEY_USERS_PATHS[] = {""};
-char *HKEY_PERFORMANCE_DATA_PATHS[] = {""};
-char *HKEY_CURRENT_CONFIG_PATHS[] = {""};
-char *HKEY_DYN_DATA_PATHS[] = {""};
-// }}}
-
char *get_type_str( ulong type ) // {{{
{
return (type <= REG_MAX ? val_types[type] : "(unknown)");
Modified: lib/ntreg.c
===================================================================
--- lib/ntreg.c 2006-12-24 00:36:52 UTC (rev 48)
+++ lib/ntreg.c 2007-01-08 03:25:43 UTC (rev 49)
@@ -41,7 +41,6 @@
#include "ntreg.h"
#include "tools.h"
-#include "globals.h"
#include "uerr.h"
#include "winerr.h"
// }}}
@@ -67,7 +66,6 @@
};
// }}}
// {{{ **** Globals that should probably not exist
-int *watch;
char ddbuf[1024]; //debug crap to delete
//TODO: this should probably be in hivelib.c/h
@@ -287,7 +285,7 @@
struct ri_key *result = p;
if( result->head.id == ID_RI_KEY ) {
- if( gverbose ) parse_ri_struct ( hdesc, result );
+// if (gverbose) parse_ri_struct ( hdesc, result );
return result;
}
else {
@@ -301,7 +299,7 @@
struct li_key *result = p;
if( result->head.id == ID_LI_KEY ) {
- if( gverbose )parse_li_struct( hdesc, result );
+// if( gverbose )parse_li_struct( hdesc, result );
return result;
}
else
@@ -1195,8 +1193,6 @@
if( sz > n ) DIE("buffer is too small." );
buf[sz] = '\0';
- if( nk->len_name != sz && gverbose )
- fprintf(stderr, "nk_get_name() oddball: %d -> %d: %s\n", nk->len_name, sz, buf );
//fprintf(stderr, "nk_get_name() fixed:\n");
//hexdump( buf, 0, sz, 1 );
@@ -1217,7 +1213,7 @@
buf[sz] = '\0';
//fixname( buf, sz, n );
- if( gverbose ) fprintf(stderr, "nt_get_classname() returning \"%s\"\n", buf );
+// if( gverbose ) fprintf(stderr, "nt_get_classname() returning \"%s\"\n", buf );
return sz;
}
@@ -1329,14 +1325,9 @@
for( i=min; i<=max; i++) {
struct nk_key *subkey = lx_get_subkey( hdesc, lxkey, i );
nk_get_name( subkey, buf, SZ_MAX );
- if( gverbose ) {
- fprintf(stderr, "lf_findkey() \"%s\" == \"%s\"?\n", name, buf );
- fflush(stderr);
- }
- if( 0 == strcmp( name, buf ) ) {
- //fprintf(stderr, "lf_findkey(): success\n");
+
+ if( 0 == strcmp( name, buf ) )
return i;
- }
}
return -1;
@@ -1581,7 +1572,7 @@
{
vk_get_name( nk_get_value( hdesc, nk, i ), buf, SZ_MAX );
- if( gverbose )fprintf(stdout, "nk_find_value() \"%s\" == \"%s\"?\n", name, buf );
+// if( gverbose )fprintf(stdout, "nk_find_value() \"%s\" == \"%s\"?\n", name, buf );
if( 0 == strcmp( name, buf ) )
return i;
}
@@ -1718,12 +1709,13 @@
while( 1 ) {
int token_type = gettoken( tok, SZ_MAX, &path, '\\' );
- if( gverbose ) {
- debugbuf[0] = '\0';
- nk_get_path( hdesc, tnk, debugbuf, SZ_MAX );
- fprintf(stderr, "trav_path(): (path:%s;tok:%s) main loop @ %s\n", path, tok, debugbuf);
- }
+// if( gverbose ) {
+// debugbuf[0] = '\0';
+// nk_get_path( hdesc, tnk, debugbuf, SZ_MAX );
+// fprintf(stderr, "trav_path(): (path:%s;tok:%s) main loop @ %s\n", path, tok, debugbuf);
+// }
+
switch( token_type )
{
case TOK_DELIM:
@@ -1731,7 +1723,7 @@
tnk = hdesc->root_key;
//hb = hdesc->root_block;
- if( gverbose ) { fprintf( stderr, "trav_path(): path is absolute, using nk=%p\n", nk ); fflush( stderr ); };
+// if( gverbose ) { fprintf( stderr, "trav_path(): path is absolute, using nk=%p\n", nk ); fflush( stderr ); };
break;
case TOK_BUF_SMALL:
@@ -1780,10 +1772,10 @@
case TOK_EMPTY:
/* All done ! */
- if( gverbose ) {
- fprintf( stderr, "trav_path( %s ): returning with: \n", path);
- parse_nk_nice( hdesc, tnk );
- }
+// if( gverbose ) {
+// fprintf( stderr, "trav_path( %s ): returning with: \n", path);
+// parse_nk_nice( hdesc, tnk );
+// }
switch( type ) {
case 0:
return tnk;
@@ -1822,7 +1814,13 @@
if( i_vofs != 0 ) {
nk = check_nk_ptr( hdesc, get_ptr_off_f( hdesc, i_vofs ) );
- if( gverbose ) { fprintf( stderr, "trav_path(): path is relative=0x%p\n", nk ); fflush( stderr ); };
+
+// if( gverbose )
+// {
+// fprintf( stderr, "trav_path(): path is relative=0x%p\n", nk );
+// fflush( stderr );
+// }
+
if( NULL == ( nk =
check_nk_ptr( hdesc, get_ptr_off_f( hdesc, i_vofs ) ) ) )
fprintf( stderr, "trav_path() passed something dumpy: 0x%x\n", i_vofs );
@@ -1830,7 +1828,7 @@
else {
nk = hdesc->root_key;
- if( gverbose ) { fprintf( stderr, "trav_path(): i_vofs == 0, trying root nk=%p\n", nk ); fflush( stderr ); };
+// if( gverbose ) { fprintf( stderr, "trav_path(): i_vofs == 0, trying root nk=%p\n", nk ); fflush( stderr ); };
}
nk = gen_trav_path( hdesc, nk, path, type );
@@ -2295,7 +2293,7 @@
DIE("vk_get_name(): I don't know how to deal with type %d", vk->flag );
}
- if( gverbose ) fprintf(stderr, "vk_get_name() returning \"%s\"\n", buf );
+// if( gverbose ) fprintf(stderr, "vk_get_name() returning \"%s\"\n", buf );
return sz;
}
@@ -2306,7 +2304,7 @@
int vkofs;
int len;
- if( gverbose ) fprintf( stderr, "Moo3: 0x%x\n", vofs);
+// if( gverbose ) fprintf( stderr, "Moo3: 0x%x\n", vofs);
vkofs = get_file_offset( hdesc, trav_path(hdesc, vofs,path,1) );
if (!vkofs) return -1;
vkofs +=4;
@@ -2461,7 +2459,7 @@
{
lx_key *result = p;
- if( gverbose )fprintf(stderr, "pull_lxkey(): id: 0x%x (%s)\n", result->head.id, id_to_str( result->head.id ) );
+// if( gverbose )fprintf(stderr, "pull_lxkey(): id: 0x%x (%s)\n", result->head.id, id_to_str( result->head.id ) );
if( result->head.id == ID_LF_KEY ||
result->head.id == ID_LH_KEY ||
Modified: lib/regtypes.c
===================================================================
--- lib/regtypes.c 2006-12-24 00:36:52 UTC (rev 48)
+++ lib/regtypes.c 2007-01-08 03:25:43 UTC (rev 49)
@@ -34,7 +34,6 @@
#include "libhive.h"
#include "uerr.h"
#include "tools.h"
-#include "globals.h"
static char typebuf[TYPE_BUF_LEN];
static char *get_hextype( int type );
Modified: lib/tools.c
===================================================================
--- lib/tools.c 2006-12-24 00:36:52 UTC (rev 48)
+++ lib/tools.c 2007-01-08 03:25:43 UTC (rev 49)
@@ -27,7 +27,6 @@
#include <string.h>
#include <assert.h>
#include "defines.h"
-#include "globals.h"
#include "tools.h"
#include "uerr.h"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|