@@ -44,49 +44,29 @@ def prefetch_key_value()
44
44
reg_key . close
45
45
end
46
46
47
- def timezone_key_value ( sysnfo )
48
-
49
- if sysnfo =~/(Windows 7)/
50
- reg_key = session . sys . registry . open_key ( HKEY_LOCAL_MACHINE , "SYSTEM\\ CurrentControlSet\\ Control\\ TimeZoneInformation" , KEY_READ )
51
- key_value = reg_key . query_value ( "TimeZoneKeyName" ) . data
52
- if key_value . empty? or key_value . nil?
53
- print_line ( "Couldn't find key/value for timezone from registry." )
54
- else
55
- print_good ( "Remote: Timezone is %s" % key_value )
56
- end
57
-
58
- elsif sysnfo =~/(Windows XP)/
59
- reg_key = session . sys . registry . open_key ( HKEY_LOCAL_MACHINE , "SYSTEM\\ CurrentControlSet\\ Control\\ TimeZoneInformation" , KEY_READ )
60
- key_value = reg_key . query_value ( "StandardName" ) . data
61
- if key_value . empty? or key_value . nil?
47
+ def timezone_key_values ( key_value )
48
+ # Looks for timezone from registry
49
+ timezone_key = session . sys . registry . open_key ( HKEY_LOCAL_MACHINE , "SYSTEM\\ CurrentControlSet\\ Control\\ TimeZoneInformation" , KEY_READ )
50
+ if timezone_key . nil?
62
51
print_line ( "Couldn't find key/value for timezone from registry." )
63
52
else
64
- print_good ( "Remote: Timezone is %s" % key_value )
65
- end
66
- else
67
- print_error ( "Unknown system. Can't find timezone value from registry." )
68
- end
69
- reg_key . close
70
- end
71
-
72
-
73
- def timezone_bias ( )
74
- # Looks for the timezone difference in minutes from registry
75
- reg_key = session . sys . registry . open_key ( HKEY_LOCAL_MACHINE , "SYSTEM\\ CurrentControlSet\\ Control\\ TimeZoneInformation" , KEY_READ )
76
- key_value = reg_key . query_value ( "Bias" ) . data
77
- if key_value . nil?
78
- print_error ( "Couldn't find bias from registry" )
79
- else
80
- if key_value < 0xfff
81
- bias = key_value
82
- print_good ( "Remote: localtime bias to UTC: -%s minutes." % bias )
83
- else
84
- offset = 0xffffffff
85
- bias = offset - key_value
86
- print_good ( "Remote: localtime bias to UTC: +%s minutes." % bias )
53
+ timezone = timezone_key . query_value ( key_value ) . data
54
+ tzbias = timezone_key . query_value ( "Bias" ) . data
55
+ if timezone . nil? or tzbias . nil?
56
+ print_error ( "Couldn't find timezone information from registry." )
57
+ else
58
+ print_good ( "Remote: Timezone is %s." % timezone )
59
+ if tzbias < 0xfff
60
+ bias = tzbias
61
+ print_good ( "Remote: Localtime bias to UTC: -%s minutes." % bias )
62
+ else
63
+ offset = 0xffffffff
64
+ bias = offset - tzbias
65
+ print_good ( "Remote: Localtime bias to UTC: +%s minutes." % bias )
66
+ end
67
+ end
87
68
end
88
- end
89
- reg_key . close
69
+ timezone_key . close
90
70
end
91
71
92
72
@@ -113,19 +93,19 @@ def gather_prefetch_info(name_offset, hash_offset, lastrun_offset, runcount_offs
113
93
prun = count [ 'lpBuffer' ] . unpack ( 'L*' ) [ 0 ]
114
94
115
95
# Finds the hash.
116
- client . railgun . kernel32 . SetFilePointer ( handle , hash_offset , 0 , 0 )
96
+ client . railgun . kernel32 . SetFilePointer ( handle , hash_offset , 0 , nil )
117
97
hh = client . railgun . kernel32 . ReadFile ( handle , 4 , 4 , 4 , nil )
118
98
phash = hh [ 'lpBuffer' ] . unpack ( 'h*' ) [ 0 ] . reverse
119
99
120
100
# Finds the LastModified timestamp (MACE)
121
101
lm = client . priv . fs . get_file_mace ( filename )
122
- lmod = lm [ 'Modified' ] . utc . to_s
102
+ lmod = lm [ 'Modified' ] . utc
123
103
124
104
# Finds the Creation timestamp (MACE)
125
105
cr = client . priv . fs . get_file_mace ( filename )
126
- creat = cr [ 'Created' ] . utc . to_s
106
+ creat = cr [ 'Created' ] . utc
127
107
128
- # Prints the results and closes the file handle
108
+ # Saves the results to the table and closes the file handle
129
109
if name . nil? or count . nil? or hh . nil? or lm . nil? or cr . nil?
130
110
print_error ( "Could not access file: %s." % filename )
131
111
else
@@ -136,7 +116,6 @@ def gather_prefetch_info(name_offset, hash_offset, lastrun_offset, runcount_offs
136
116
end
137
117
138
118
139
-
140
119
def run
141
120
142
121
print_status ( "Prefetch Gathering started." )
@@ -157,19 +136,26 @@ def run
157
136
158
137
sysnfo = client . sys . config . sysinfo [ 'OS' ]
159
138
160
- if sysnfo =~/(Windows XP)/ # Offsets for WinXP
139
+ if sysnfo =~/(Windows XP)/
140
+ # Offsets for WinXP
161
141
print_good ( "Detected Windows XP (max 128 entries)" )
162
142
name_offset = 0x10
163
143
hash_offset = 0x4C
164
144
lastrun_offset = 0x78
165
145
runcount_offset = 0x90
146
+ # Registry key for timezone
147
+ key_value = "StandardName"
166
148
167
- elsif sysnfo =~/(Windows 7)/ # Offsets for Win7
149
+ elsif sysnfo =~/(Windows 7)/
150
+ # Offsets for Win7
168
151
print_good ( "Detected Windows 7 (max 128 entries)" )
169
152
name_offset = 0x10
170
153
hash_offset = 0x4C
171
154
lastrun_offset = 0x80
172
155
runcount_offset = 0x98
156
+ # Registry key for timezone
157
+ key_value = "TimeZoneKeyName"
158
+
173
159
else
174
160
print_error ( "No offsets for the target Windows version. Currently works only on WinXP and Win7." )
175
161
return nil
@@ -191,10 +177,9 @@ def run
191
177
192
178
prefetch_key_value
193
179
194
- print_status ( "Searching for TimeZone Registry Values." )
180
+ print_status ( "\n Searching for TimeZone Registry Values." )
195
181
196
- timezone_key_value ( sysnfo )
197
- timezone_bias
182
+ timezone_key_values ( key_value )
198
183
199
184
print_good ( "Current UTC Time: %s" % Time . now . utc )
200
185
@@ -216,6 +201,7 @@ def run
216
201
end
217
202
end
218
203
204
+ # Stores and prints out results
219
205
results = table . to_s
220
206
loot = store_loot ( "prefetch_info" , "text/plain" , session , results , nil , "Prefetch Information" )
221
207
print_line ( "\n " + results + "\n " )
0 commit comments