@@ -1813,6 +1813,21 @@ def acquire_target_targetd(target: Target, args: argparse.Namespace, output_ts:
1813
1813
return files
1814
1814
1815
1815
1816
+ def _add_modules_for_profile (choice : str , operating_system : str , profile : dict , msg : str ):
1817
+ modules_selected = dict ()
1818
+
1819
+ if choice and choice != "none" :
1820
+ profile_dict = profile [choice ]
1821
+ if operating_system not in profile_dict :
1822
+ log .error (msg , operating_system , choice )
1823
+ return {}
1824
+
1825
+ for mod in profile_dict [operating_system ]:
1826
+ modules_selected [mod .__modname__ ] = mod
1827
+
1828
+ return modules_selected
1829
+
1830
+
1816
1831
def acquire_target_regular (target : Target , args : argparse .Namespace , output_ts : Optional [str ] = None ) -> list [str ]:
1817
1832
files = []
1818
1833
output_ts = output_ts or get_utc_now_str ()
@@ -1880,13 +1895,18 @@ def acquire_target_regular(target: Target, args: argparse.Namespace, output_ts:
1880
1895
profile = "default"
1881
1896
log .info ("" )
1882
1897
1883
- if profile and profile != "none" :
1884
- if target .os not in PROFILES [profile ]:
1885
- log .error ("No collection set for OS %s with profile %s" , target .os , profile )
1886
- return files
1898
+ profile_modules = _add_modules_for_profile (
1899
+ profile , target .os , PROFILES , "No collection set for OS %s with profile %s"
1900
+ )
1901
+ volatile_modules = _add_modules_for_profile (
1902
+ args .volatile , target .os , VOLATILE , "No collection set for OS %s with volatile profile %s"
1903
+ )
1887
1904
1888
- for mod in PROFILES [profile ][target .os ]:
1889
- modules_selected [mod .__modname__ ] = mod
1905
+ modules_selected .update (profile_modules )
1906
+ modules_selected .update (volatile_modules )
1907
+
1908
+ if not (profile_modules or volatile_modules ):
1909
+ return files
1890
1910
1891
1911
log .info ("Modules selected: %s" , ", " .join (sorted (modules_selected )))
1892
1912
@@ -2144,8 +2164,35 @@ class OSXProfile:
2144
2164
}
2145
2165
2146
2166
2167
+ class VolatileProfile :
2168
+ DEFAULT = [
2169
+ Netstat ,
2170
+ WinProcesses ,
2171
+ WinProcEnv ,
2172
+ WinArpCache ,
2173
+ WinRDPSessions ,
2174
+ WinDnsClientCache ,
2175
+ ]
2176
+ EXTENSIVE = [
2177
+ Proc ,
2178
+ Sys ,
2179
+ ]
2180
+
2181
+
2182
+ VOLATILE = {
2183
+ "default" : {"windows" : VolatileProfile .DEFAULT },
2184
+ "extensive" : {
2185
+ "windows" : VolatileProfile .DEFAULT ,
2186
+ "linux" : VolatileProfile .EXTENSIVE ,
2187
+ "bsd" : VolatileProfile .EXTENSIVE ,
2188
+ "esxi" : VolatileProfile .EXTENSIVE ,
2189
+ },
2190
+ "none" : None ,
2191
+ }
2192
+
2193
+
2147
2194
def main () -> None :
2148
- parser = create_argument_parser (PROFILES , MODULES )
2195
+ parser = create_argument_parser (PROFILES , VOLATILE , MODULES )
2149
2196
args = parse_acquire_args (parser , config = CONFIG )
2150
2197
2151
2198
try :
0 commit comments