summaryrefslogtreecommitdiffstats
path: root/sh/hivexsh.pod
blob: a31d9e0bd04bb579a7001644ee3c5a73e21d5f21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
=encoding utf8

=head1 NAME

hivexsh - Windows Registry hive shell

=head1 SYNOPSIS

 hivexsh [-options] [hivefile]

=head1 DESCRIPTION

This program provides a simple shell for navigating Windows Registry
'hive' files.  It uses the hivex library for access to these binary
files.

Firstly you will need to provide a hive file from a Windows operating
system.  The hive files are usually located in
C<C:\Windows\System32\Config> and have names like C<software>,
C<system> etc (without any file extension).  For more information
about hive files, read L<hivex(3)>.  For information about downloading
files from virtual machines, read L<virt-cat(1)> and L<guestfish(1)>.

You can provide the name of the hive file to examine on the command
line.  For example:

 hivexsh software

Or you can start C<hivexsh> without any arguments, and immediately use
the C<load> command to load a hive:

 $ hivexsh
 
 Welcome to hivexsh, the hivex interactive shell for examining
 Windows Registry binary hive files.
 
 Type: 'help' for help with commands
       'quit' to quit the shell
 
 > load software
 software\>

Navigate through the hive's keys using the C<cd> command, as if it
contained a filesystem, and use C<ls> to list the subkeys of the
current key.  Other commands are listed below.

=head1 OPTIONS

=over 4

=item B<-d>

Enable lots of debug messages.  If you find a Registry file that this
program cannot parse, please enable this option and post the complete
output I<and> the Registry hive file in your bug report.

=item B<-f> filename

Read commands from C<filename> instead of stdin.  To write a hivexsh
script, use:

 #!/usr/bin/hivexsh -f

=item B<-w>

If this option is given, then writes are allowed to the hive
(see L</commit> command below, and the discussion of
modifying hives in L<hivex(3)/WRITING TO HIVE FILES>).

B<Important Note:> Even if you specify this option, nothing is written
to a hive unless you call the L</commit> command.  If you exit the
shell without committing, all changes will be discarded.

If this option is not given, then write commands are disabled.

=back

=head1 COMMANDS

=over 4

=item B<add> name

Add a subkey named C<name> below the current node.  The name may
contain spaces and punctuation characters, and does not need to be
quoted.

The new key will have no subkeys and no values (see C<setval>).

There must be no existing subkey called C<name>, or this command will
fail.  To replace an existing subkey, delete it first like this:

 cd name
 del

=item B<cd> path

Change to the subkey C<path>.  Use Windows-style backslashes to
separate path elements, and start with a backslash in order to start
from the root of the hive.  For example:

 cd \Classes\*

moves from the root node, to the C<Classes> node, to the C<*> node.
If you were already at the root node, you could do this instead:

 cd Classes\*

or even:

 cd Classes
 cd *

Path elements (node names) are matched case insensitively, and
characters like space, C<*>, and C<?> have I<no> special significance.

C<cd ..> may be used to go to the parent directory.

C<cd> without any arguments prints the current path.

Be careful with C<cd \> since the readline library has an undocumented
behaviour where it will think the final backslash is a continuation
(it reads the next line of input and appends it).  Put a single space
after the backslash.

=item B<close> | B<unload>

Close the currently loaded hive.

If you modified the hive, all uncommitted writes are lost when you
call this command (or if the shell exits).  You have to call C<commit>
to write changes.

=item B<commit> [newfile]

Commit changes to the hive.  If the optional C<newfile> parameter is
supplied, then the hive is written to that file, else the original
file is overwritten.

Note that you have to specify the C<-w> flag, otherwise no writes are
allowed.

=item B<del>

Delete the current node and everything beneath it.  The current
directory is moved up one level (as if you did C<cd ..>) after
this command.

You cannot delete the root node.

=item B<exit> | B<quit>

Exit the shell.

=item B<load> hivefile

Load the binary hive named C<hivefile>.  The currently loaded hive, if
any, is closed.  The current directory is changed back to the root
node.

=item B<ls>

List the subkeys of the current hive Registry key.  Note this command
does not take any arguments.

=item B<lsval> [key]

List the (key, value) pairs of the current hive Registry key.  If no
argument is given then all pairs are displayed.  If C<key> is given,
then the value of the named key is displayed.  If C<@> is given, then
the value of the default key is displayed.

=item B<setval> nrvals

This command replaces all (key, value) pairs at the current node with
the values in subsequent input.  C<nrvals> is the number of values
(ie. (key, value) pairs), and any existing values at this node are
deleted.  So C<setval 0> just deletes any values at the current node.

The command reads 2 * nrvals lines of input, with each pair of
lines of input corresponding to a key and a value to add.

For example, the following setval command replaces whatever is at the
current node with two (key, value) pairs.  The default key is set to
the UTF16-LE-encoded string "abcd".  The other value is named
"ANumber" and is a little-endian DWORD 0x12345678.

 setval 2
 @
 string:abcd
 ANumber
 dword:12345678

The first line of each pair is the key (the special key C<@> means
the default key, but you can also use a blank line).

The second line of each pair is the value, which has a special format
C<type:value> with possible types summarized in the table below:

 none                 No data is stored, and the type is set to 0.
 
 string:abc           "abc" is stored as a UTF16-LE-encoded
                      string (type 1).  Note that only 7 bit
                      ASCII strings are supported as input.
 
 expandstring:...     Same as string but with type 2.
 
 dword:0x01234567     A DWORD (type 4) with the hex value
                      0x01234567.  You can also use decimal
                      or octal numbers here.
 
 qword:0x0123456789abcdef
                      A QWORD (type 11) with the hex value
                      0x0123456789abcdef.  You can also use
                      decimal or octal numbers here.
 
 hex:<type>:<hexbytes>
 hex:1:41,00,42,00,43,00,44,00,00,00
                      This is the generic way to enter any
                      value.  <type> is the integer value type.
                      <hexbytes> is a list of pairs of hex
                      digits which are treated as bytes.
                      (Any non-hex-digits here are ignored,
                      so you can separate bytes with commas
                      or spaces if you want).

=back

=head1 EXAMPLE

 $ guestfish --ro -i Windows7
 ><fs> download win:c:\windows\system32\config\software software
 ><fs> quit
 
 $ hivexsh software
 
 Welcome to hivexsh, the hivex interactive shell for examining
 Windows Registry binary hive files.
 
 Type: 'help' for help with commands
       'quit' to quit the shell
 
 software\> ls
 ATI Technologies
 Classes
 Clients
 Intel
 Microsoft
 ODBC
 Policies
 RegisteredApplications
 Sonic
 Wow6432Node
 software\> quit

=head1 SEE ALSO

L<hivex(3)>,
L<hivexget(1)>,
L<hivexml(1)>,
L<virt-win-reg(1)>,
L<guestfs(3)>,
L<http://libguestfs.org/>,
L<virt-cat(1)>,
L<virt-edit(1)>.

=head1 AUTHORS

Richard W.M. Jones (C<rjones at redhat dot com>)

=head1 COPYRIGHT

Copyright (C) 2009-2010 Red Hat Inc.

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 of the License, 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.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.