manageiq-smartstate 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +4 -0
- data/.rspec_ci +4 -0
- data/.travis.yml +15 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +202 -0
- data/README.md +45 -0
- data/Rakefile +23 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/MiqContainerGroup/MiqContainerGroup.rb +31 -0
- data/lib/MiqVm/MiqLocalVm.rb +50 -0
- data/lib/MiqVm/MiqRhevmVm.rb +179 -0
- data/lib/MiqVm/MiqVm.rb +355 -0
- data/lib/MiqVm/miq_azure_vm.rb +96 -0
- data/lib/MiqVm/miq_scvmm_vm.rb +38 -0
- data/lib/MiqVm/test/camcorder_fleece_test.rb +60 -0
- data/lib/MiqVm/test/localVm.rb +45 -0
- data/lib/MiqVm/test/partitionAlignmentCheck.rb +76 -0
- data/lib/MiqVm/test/remoteVm.rb +65 -0
- data/lib/MiqVm/test/rhevmNfsTest.rb +62 -0
- data/lib/MiqVm/test/rhevmNfsTest2.rb +66 -0
- data/lib/MiqVm/test/rhevmTest.rb +70 -0
- data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackCommon.rb +107 -0
- data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackImage.rb +67 -0
- data/lib/OpenStackExtract/MiqOpenStackVm/MiqOpenStackInstance.rb +182 -0
- data/lib/Scvmm/miq_hyperv_disk.rb +273 -0
- data/lib/Scvmm/miq_scvmm_parse_powershell.rb +75 -0
- data/lib/Scvmm/miq_scvmm_vm_ssa_info.rb +135 -0
- data/lib/Scvmm/test/miq_hyperv_disk_test.rb +33 -0
- data/lib/Scvmm/test/miq_scvmm_vm_ssa_info_test.rb +41 -0
- data/lib/VmLocalDiskAccess/test/localCfg.rb +97 -0
- data/lib/VolumeManager/LVM/logical_volume.rb +75 -0
- data/lib/VolumeManager/LVM/lv_segment.rb +43 -0
- data/lib/VolumeManager/LVM/lvm2disk.rb +158 -0
- data/lib/VolumeManager/LVM/parser.rb +138 -0
- data/lib/VolumeManager/LVM/physical_volume.rb +19 -0
- data/lib/VolumeManager/LVM/scanner.rb +156 -0
- data/lib/VolumeManager/LVM/thin/btree.rb +83 -0
- data/lib/VolumeManager/LVM/thin/constants.rb +86 -0
- data/lib/VolumeManager/LVM/thin/data_map.rb +44 -0
- data/lib/VolumeManager/LVM/thin/mapping_tree.rb +19 -0
- data/lib/VolumeManager/LVM/thin/space_maps.rb +58 -0
- data/lib/VolumeManager/LVM/thin/superblock.rb +136 -0
- data/lib/VolumeManager/LVM/thin.rb +6 -0
- data/lib/VolumeManager/LVM/volume_group.rb +97 -0
- data/lib/VolumeManager/LVM.rb +8 -0
- data/lib/VolumeManager/MiqLdm.rb +546 -0
- data/lib/VolumeManager/MiqLvm.rb +17 -0
- data/lib/VolumeManager/MiqNativeVolumeManager.rb +150 -0
- data/lib/VolumeManager/MiqVolumeManager.rb +277 -0
- data/lib/VolumeManager/VolMgrPlatformSupport.rb +18 -0
- data/lib/VolumeManager/VolMgrPlatformSupportLinux.rb +77 -0
- data/lib/VolumeManager/VolMgrPlatformSupportWin.rb +17 -0
- data/lib/VolumeManager/test/blockDevTest.rb +40 -0
- data/lib/VolumeManager/test/ldm.rb +97 -0
- data/lib/blackbox/VmBlackBox.rb +103 -0
- data/lib/blackbox/xmlStorage.rb +180 -0
- data/lib/db/MiqBdb/MiqBdb.rb +309 -0
- data/lib/db/MiqBdb/MiqBdbBtree.rb +219 -0
- data/lib/db/MiqBdb/MiqBdbHash.rb +199 -0
- data/lib/db/MiqBdb/MiqBdbPage.rb +159 -0
- data/lib/db/MiqBdb/MiqBdbUtil.rb +18 -0
- data/lib/db/MiqSqlite/MiqSqlite3.rb +330 -0
- data/lib/db/MiqSqlite/MiqSqlite3Cell.rb +167 -0
- data/lib/db/MiqSqlite/MiqSqlite3Page.rb +151 -0
- data/lib/db/MiqSqlite/MiqSqlite3Table.rb +124 -0
- data/lib/db/MiqSqlite/MiqSqlite3Util.rb +32 -0
- data/lib/disk/DiskProbe.rb +68 -0
- data/lib/disk/MiqDisk.rb +317 -0
- data/lib/disk/camcorder_test.rb +90 -0
- data/lib/disk/dos_mbr.img +0 -0
- data/lib/disk/modules/AzureBlobDisk.rb +101 -0
- data/lib/disk/modules/LocalDevMod.rb +47 -0
- data/lib/disk/modules/LocalDevProbe.rb +6 -0
- data/lib/disk/modules/MSCommon.rb +352 -0
- data/lib/disk/modules/MSVSDiffDisk.rb +91 -0
- data/lib/disk/modules/MSVSDiskProbe.rb +61 -0
- data/lib/disk/modules/MSVSDynamicDisk.rb +42 -0
- data/lib/disk/modules/MSVSFixedDisk.rb +45 -0
- data/lib/disk/modules/MiqLargeFile.rb +63 -0
- data/lib/disk/modules/MiqLargeFileWin32.rb +107 -0
- data/lib/disk/modules/QcowDisk.rb +692 -0
- data/lib/disk/modules/QcowDiskProbe.rb +34 -0
- data/lib/disk/modules/RawBlockIO.rb +116 -0
- data/lib/disk/modules/RawDisk.rb +45 -0
- data/lib/disk/modules/RawDiskProbe.rb +7 -0
- data/lib/disk/modules/RhevmDescriptor.rb +167 -0
- data/lib/disk/modules/RhevmDiskProbe.rb +52 -0
- data/lib/disk/modules/VMWareCowdDisk.rb +207 -0
- data/lib/disk/modules/VMWareDescriptor.rb +214 -0
- data/lib/disk/modules/VMWareDiskProbe.rb +74 -0
- data/lib/disk/modules/VMWareSparseDisk.rb +189 -0
- data/lib/disk/modules/VhdxDisk.rb +625 -0
- data/lib/disk/modules/VhdxDiskProbe.rb +46 -0
- data/lib/disk/modules/VixDiskMod.rb +54 -0
- data/lib/disk/modules/VixDiskProbe.rb +6 -0
- data/lib/disk/modules/miq_disk_cache.rb +135 -0
- data/lib/disk/modules/miq_dummy_disk.rb +41 -0
- data/lib/disk/modules/vhdx_bat_entry.rb +10 -0
- data/lib/disk/test.rb +66 -0
- data/lib/fs/MetakitFS/MetakitFS.rb +530 -0
- data/lib/fs/MetakitFS/test/Makefile +14 -0
- data/lib/fs/MetakitFS/test/MkCollectFiles.rb +165 -0
- data/lib/fs/MetakitFS/test/MkSelectFiles.rb +30 -0
- data/lib/fs/MetakitFS/test/collect_files.yaml +70 -0
- data/lib/fs/MetakitFS/test/init.rb +3 -0
- data/lib/fs/MetakitFS/test/mk2vmdk.rb +64 -0
- data/lib/fs/MetakitFS/test/mk4test.c +92 -0
- data/lib/fs/MetakitFS/test/mkFsTest.rb +113 -0
- data/lib/fs/MetakitFS/test/proto.rb +97 -0
- data/lib/fs/MiqFS/FsProbe.rb +39 -0
- data/lib/fs/MiqFS/MiqFS.rb +515 -0
- data/lib/fs/MiqFS/modules/AUFSProbe.rb +26 -0
- data/lib/fs/MiqFS/modules/Ext3.rb +305 -0
- data/lib/fs/MiqFS/modules/Ext3Probe.rb +25 -0
- data/lib/fs/MiqFS/modules/Ext4.rb +304 -0
- data/lib/fs/MiqFS/modules/Ext4Probe.rb +25 -0
- data/lib/fs/MiqFS/modules/Fat32.rb +318 -0
- data/lib/fs/MiqFS/modules/Fat32Probe.rb +30 -0
- data/lib/fs/MiqFS/modules/HFSProbe.rb +18 -0
- data/lib/fs/MiqFS/modules/Iso9660.rb +293 -0
- data/lib/fs/MiqFS/modules/Iso9660Probe.rb +18 -0
- data/lib/fs/MiqFS/modules/LocalFS.rb +105 -0
- data/lib/fs/MiqFS/modules/NTFS.rb +287 -0
- data/lib/fs/MiqFS/modules/NTFSProbe.rb +21 -0
- data/lib/fs/MiqFS/modules/NativeFS.rb +155 -0
- data/lib/fs/MiqFS/modules/ReFSProbe.rb +17 -0
- data/lib/fs/MiqFS/modules/RealFS.rb +79 -0
- data/lib/fs/MiqFS/modules/RealFSProbe.rb +6 -0
- data/lib/fs/MiqFS/modules/Reiser4Probe.rb +18 -0
- data/lib/fs/MiqFS/modules/ReiserFS.rb +315 -0
- data/lib/fs/MiqFS/modules/ReiserFSProbe.rb +42 -0
- data/lib/fs/MiqFS/modules/UnionFSProbe.rb +18 -0
- data/lib/fs/MiqFS/modules/WebDAV.rb +127 -0
- data/lib/fs/MiqFS/modules/WebDAVFile.rb +68 -0
- data/lib/fs/MiqFS/modules/XFS.rb +300 -0
- data/lib/fs/MiqFS/modules/XFSProbe.rb +26 -0
- data/lib/fs/MiqFS/modules/ZFSProbe.rb +18 -0
- data/lib/fs/MiqFS/test.rb +59 -0
- data/lib/fs/MiqFsUtil.rb +383 -0
- data/lib/fs/MiqMountManager.rb +209 -0
- data/lib/fs/MiqNativeMountManager.rb +101 -0
- data/lib/fs/MountManagerProbe.rb +29 -0
- data/lib/fs/ReiserFS/block.rb +209 -0
- data/lib/fs/ReiserFS/directory.rb +136 -0
- data/lib/fs/ReiserFS/directory_entry.rb +140 -0
- data/lib/fs/ReiserFS/file_data.rb +111 -0
- data/lib/fs/ReiserFS/superblock.rb +140 -0
- data/lib/fs/ReiserFS/utils.rb +95 -0
- data/lib/fs/VimDatastoreFS/VimDatastoreFS.rb +192 -0
- data/lib/fs/ext3/alloc_bitmap.rb +38 -0
- data/lib/fs/ext3/block_pointers_path.rb +130 -0
- data/lib/fs/ext3/directory.rb +51 -0
- data/lib/fs/ext3/directory_entry.rb +67 -0
- data/lib/fs/ext3/ex_attrib_header.rb +14 -0
- data/lib/fs/ext3/ex_attrib_name.rb +23 -0
- data/lib/fs/ext3/file_data.rb +130 -0
- data/lib/fs/ext3/group_descriptor_entry.rb +65 -0
- data/lib/fs/ext3/group_descriptor_table.rb +54 -0
- data/lib/fs/ext3/hash_tree_entry.rb +18 -0
- data/lib/fs/ext3/hash_tree_header.rb +15 -0
- data/lib/fs/ext3/inode.rb +228 -0
- data/lib/fs/ext3/posix_acl_entry.rb +29 -0
- data/lib/fs/ext3/posix_acl_header.rb +11 -0
- data/lib/fs/ext3/superblock.rb +406 -0
- data/lib/fs/ext3/test/tc_Ext3BlockPointersPath.rb +74 -0
- data/lib/fs/ext4/alloc_bitmap.rb +38 -0
- data/lib/fs/ext4/directory.rb +87 -0
- data/lib/fs/ext4/directory_entry.rb +77 -0
- data/lib/fs/ext4/ex_attrib_header.rb +14 -0
- data/lib/fs/ext4/ex_attrib_name.rb +23 -0
- data/lib/fs/ext4/extent.rb +35 -0
- data/lib/fs/ext4/extent_header.rb +40 -0
- data/lib/fs/ext4/extent_index.rb +33 -0
- data/lib/fs/ext4/group_descriptor_entry.rb +69 -0
- data/lib/fs/ext4/group_descriptor_table.rb +54 -0
- data/lib/fs/ext4/hash_tree_entry.rb +58 -0
- data/lib/fs/ext4/hash_tree_header.rb +35 -0
- data/lib/fs/ext4/inode.rb +465 -0
- data/lib/fs/ext4/posix_acl_entry.rb +29 -0
- data/lib/fs/ext4/posix_acl_header.rb +11 -0
- data/lib/fs/ext4/superblock.rb +412 -0
- data/lib/fs/fat32/boot_sect.rb +379 -0
- data/lib/fs/fat32/directory.rb +222 -0
- data/lib/fs/fat32/directory_entry.rb +540 -0
- data/lib/fs/fat32/file_data.rb +128 -0
- data/lib/fs/iso9660/boot_sector.rb +170 -0
- data/lib/fs/iso9660/directory.rb +90 -0
- data/lib/fs/iso9660/directory_entry.rb +147 -0
- data/lib/fs/iso9660/file_data.rb +78 -0
- data/lib/fs/iso9660/rock_ridge.rb +329 -0
- data/lib/fs/iso9660/util.rb +57 -0
- data/lib/fs/modules/LinuxMount.rb +300 -0
- data/lib/fs/modules/LinuxMountProbe.rb +29 -0
- data/lib/fs/modules/WinMount.rb +97 -0
- data/lib/fs/modules/WinMountProbe.rb +24 -0
- data/lib/fs/ntfs/attrib_attribute_list.rb +131 -0
- data/lib/fs/ntfs/attrib_bitmap.rb +26 -0
- data/lib/fs/ntfs/attrib_data.rb +74 -0
- data/lib/fs/ntfs/attrib_file_name.rb +110 -0
- data/lib/fs/ntfs/attrib_header.rb +194 -0
- data/lib/fs/ntfs/attrib_index_allocation.rb +19 -0
- data/lib/fs/ntfs/attrib_index_root.rb +247 -0
- data/lib/fs/ntfs/attrib_object_id.rb +40 -0
- data/lib/fs/ntfs/attrib_standard_information.rb +107 -0
- data/lib/fs/ntfs/attrib_type.rb +49 -0
- data/lib/fs/ntfs/attrib_volume_information.rb +53 -0
- data/lib/fs/ntfs/attrib_volume_name.rb +31 -0
- data/lib/fs/ntfs/boot_sect.rb +253 -0
- data/lib/fs/ntfs/data_run.rb +358 -0
- data/lib/fs/ntfs/directory_index_node.rb +114 -0
- data/lib/fs/ntfs/index_node_header.rb +69 -0
- data/lib/fs/ntfs/index_record_header.rb +85 -0
- data/lib/fs/ntfs/mft_entry.rb +288 -0
- data/lib/fs/ntfs/utils.rb +43 -0
- data/lib/fs/test/camcorder_fs_test.rb +108 -0
- data/lib/fs/test/collect_files_direct.yaml +22 -0
- data/lib/fs/test/collect_files_in.yaml +24 -0
- data/lib/fs/test/collect_files_in_nc.yaml +22 -0
- data/lib/fs/test/collect_files_out.yaml +6 -0
- data/lib/fs/test/collect_files_rm.yaml +6 -0
- data/lib/fs/test/copyTest.rb +126 -0
- data/lib/fs/test/fsTest.rb +87 -0
- data/lib/fs/test/updateTest.rb +184 -0
- data/lib/fs/xfs/allocation_group.rb +160 -0
- data/lib/fs/xfs/bmap_btree_block.rb +125 -0
- data/lib/fs/xfs/bmap_btree_record.rb +80 -0
- data/lib/fs/xfs/bmap_btree_root_node.rb +72 -0
- data/lib/fs/xfs/directory.rb +133 -0
- data/lib/fs/xfs/directory2_data_header.rb +27 -0
- data/lib/fs/xfs/directory3_data_header.rb +34 -0
- data/lib/fs/xfs/directory_block_tail.rb +22 -0
- data/lib/fs/xfs/directory_data_header.rb +46 -0
- data/lib/fs/xfs/directory_entry.rb +106 -0
- data/lib/fs/xfs/inode.rb +532 -0
- data/lib/fs/xfs/inode_map.rb +100 -0
- data/lib/fs/xfs/short_form_directory_entry.rb +91 -0
- data/lib/fs/xfs/short_form_header.rb +44 -0
- data/lib/fs/xfs/superblock.rb +556 -0
- data/lib/lib/tasks/azure.rake +52 -0
- data/lib/manageiq/smartstate/version.rb +5 -0
- data/lib/manageiq/smartstate.rb +7 -0
- data/lib/manageiq-smartstate.rb +1 -0
- data/lib/metadata/MIQExtract/MIQExtract.rb +297 -0
- data/lib/metadata/MIQExtract/test/extractTest.rb +41 -0
- data/lib/metadata/MIQExtract/test/full_extract_test.rb +68 -0
- data/lib/metadata/ScanProfile/HostScanItem.rb +4 -0
- data/lib/metadata/ScanProfile/HostScanProfile.rb +4 -0
- data/lib/metadata/ScanProfile/HostScanProfiles.rb +41 -0
- data/lib/metadata/ScanProfile/ScanItemBase.rb +63 -0
- data/lib/metadata/ScanProfile/ScanProfileBase.rb +51 -0
- data/lib/metadata/ScanProfile/ScanProfilesBase.rb +60 -0
- data/lib/metadata/ScanProfile/VmScanItem.rb +4 -0
- data/lib/metadata/ScanProfile/VmScanProfile.rb +4 -0
- data/lib/metadata/ScanProfile/VmScanProfiles.rb +38 -0
- data/lib/metadata/ScanProfile/modules/HostScanItemFile.rb +51 -0
- data/lib/metadata/ScanProfile/modules/HostScanItemNteventlog.rb +84 -0
- data/lib/metadata/ScanProfile/modules/VmScanItemFile.rb +39 -0
- data/lib/metadata/ScanProfile/modules/VmScanItemNteventlog.rb +34 -0
- data/lib/metadata/ScanProfile/modules/VmScanItemRegistry.rb +64 -0
- data/lib/metadata/VMMount/VMMount.rb +81 -0
- data/lib/metadata/VMMount/VMPlatformMount.rb +18 -0
- data/lib/metadata/VMMount/VMPlatformMountLinux.rb +75 -0
- data/lib/metadata/VMMount/VMPlatformMountWin.rb +13 -0
- data/lib/metadata/VmConfig/GetNativeCfg.rb +45 -0
- data/lib/metadata/VmConfig/VmConfig.rb +947 -0
- data/lib/metadata/VmConfig/cfgConfig.rb +45 -0
- data/lib/metadata/VmConfig/ovfConfig.rb +99 -0
- data/lib/metadata/VmConfig/test/GetVMwareCfgTest.rb +40 -0
- data/lib/metadata/VmConfig/vmcConfig.rb +116 -0
- data/lib/metadata/VmConfig/vmtxConfig.rb +4 -0
- data/lib/metadata/VmConfig/vmxConfig.rb +162 -0
- data/lib/metadata/VmConfig/xmlConfig.rb +79 -0
- data/lib/metadata/VmConfig/xmlMsHyperVConfig.rb +41 -0
- data/lib/metadata/linux/InitProcHash.rb +632 -0
- data/lib/metadata/linux/LinuxInitProcs.rb +142 -0
- data/lib/metadata/linux/LinuxOSInfo.rb +237 -0
- data/lib/metadata/linux/LinuxPackages.rb +209 -0
- data/lib/metadata/linux/LinuxSystemd.rb +130 -0
- data/lib/metadata/linux/LinuxUsers.rb +289 -0
- data/lib/metadata/linux/LinuxUtils.rb +197 -0
- data/lib/metadata/linux/MiqConaryPackages.rb +41 -0
- data/lib/metadata/linux/MiqRpmPackages.rb +160 -0
- data/lib/metadata/linux/test/Name +0 -0
- data/lib/metadata/linux/test/Packages +0 -0
- data/lib/metadata/linux/test/rpoTest.rb +5 -0
- data/lib/metadata/linux/test/tc_LinuxUtils.rb +4157 -0
- data/lib/metadata/util/event_log_filter.rb +61 -0
- data/lib/metadata/util/md5deep.rb +280 -0
- data/lib/metadata/util/win32/Win32Accounts.rb +764 -0
- data/lib/metadata/util/win32/Win32EventLog.rb +743 -0
- data/lib/metadata/util/win32/Win32Services.rb +86 -0
- data/lib/metadata/util/win32/Win32Software.rb +326 -0
- data/lib/metadata/util/win32/Win32System.rb +333 -0
- data/lib/metadata/util/win32/boot_info_win.rb +59 -0
- data/lib/metadata/util/win32/fleece_hives.rb +220 -0
- data/lib/metadata/util/win32/ms-registry.rb +650 -0
- data/lib/metadata/util/win32/peheader.rb +868 -0
- data/lib/metadata/util/win32/remote-registry.rb +142 -0
- data/lib/metadata/util/win32/system_path_win.rb +103 -0
- data/lib/metadata/util/win32/versioninfo.rb +17 -0
- data/manageiq-smartstate.gemspec +35 -0
- metadata +486 -0
@@ -0,0 +1,333 @@
|
|
1
|
+
require 'util/xml/xml_utils'
|
2
|
+
require 'util/miq-xml'
|
3
|
+
require 'util/miq-logger'
|
4
|
+
|
5
|
+
module MiqWin32
|
6
|
+
class System
|
7
|
+
attr_reader :os, :account_policy, :networks
|
8
|
+
|
9
|
+
OS_MAPPING = [
|
10
|
+
'ProductName', :product_name,
|
11
|
+
'CurrentVersion', :version,
|
12
|
+
'CurrentBuildNumber', :build,
|
13
|
+
'SystemRoot', :system_root,
|
14
|
+
'CSDVersion', :service_pack,
|
15
|
+
'ProductId', :productid,
|
16
|
+
'DigitalProductId', :product_key,
|
17
|
+
'Vendor', :distribution,
|
18
|
+
'EditionID', :edition_id,
|
19
|
+
]
|
20
|
+
|
21
|
+
COMPUTER_NAME_MAPPING = [
|
22
|
+
'ComputerName', :machine_name,
|
23
|
+
]
|
24
|
+
|
25
|
+
PRODUCT_OPTIONS_MAPPING = [
|
26
|
+
'ProductType', :product_type,
|
27
|
+
'ProductSuite', :product_suite,
|
28
|
+
]
|
29
|
+
|
30
|
+
ENVIRONMENT_MAPPING = [
|
31
|
+
'PROCESSOR_ARCHITECTURE', :architecture
|
32
|
+
]
|
33
|
+
|
34
|
+
TCPIP_MAPPING = [
|
35
|
+
"Hostname", :hostname,
|
36
|
+
]
|
37
|
+
|
38
|
+
NETWORK_CARDS_MAPPING = [
|
39
|
+
"ServiceName", :guid,
|
40
|
+
"Description", :description,
|
41
|
+
]
|
42
|
+
|
43
|
+
DHCP_MAPPING = [
|
44
|
+
"EnableDHCP", :dhcp_enabled,
|
45
|
+
"DhcpIPAddress", :ipaddress,
|
46
|
+
"DhcpSubnetMask", :subnet_mask,
|
47
|
+
"LeaseObtainedTime", :lease_obtained,
|
48
|
+
"LeaseTerminatesTime", :lease_expires,
|
49
|
+
"DhcpDefaultGateway", :default_gateway,
|
50
|
+
"DhcpServer", :dhcp_server,
|
51
|
+
"DhcpNameServer", :dns_server,
|
52
|
+
"DhcpDomain", :domain,
|
53
|
+
]
|
54
|
+
|
55
|
+
STATIC_MAPPING = [
|
56
|
+
"EnableDHCP", :dhcp_enabled,
|
57
|
+
"IPAddress", :ipaddress,
|
58
|
+
"SubnetMask", :subnet_mask,
|
59
|
+
"DefaultGateway", :default_gateway,
|
60
|
+
"NameServer", :dns_server,
|
61
|
+
"Domain", :domain,
|
62
|
+
]
|
63
|
+
|
64
|
+
# Software registry value filters
|
65
|
+
OS_MAPPING_VALUES, NETWORK_CARDS_VALUES = [], []
|
66
|
+
(0...OS_MAPPING.length).step(2) { |i| OS_MAPPING_VALUES << OS_MAPPING[i] }
|
67
|
+
(0...NETWORK_CARDS_MAPPING.length).step(2) { |i| NETWORK_CARDS_VALUES << NETWORK_CARDS_MAPPING[i] }
|
68
|
+
|
69
|
+
# System registry value filters
|
70
|
+
PRODUCT_OPTIONS_VALUES, ENVIRONMENT_VALUES, COMPUTER_NAME_VALUES, TCPIP_VALUES = [], [], [], []
|
71
|
+
(0...PRODUCT_OPTIONS_MAPPING.length).step(2) { |i| PRODUCT_OPTIONS_VALUES << PRODUCT_OPTIONS_MAPPING[i] }
|
72
|
+
(0...ENVIRONMENT_MAPPING.length).step(2) { |i| ENVIRONMENT_VALUES << ENVIRONMENT_MAPPING[i] }
|
73
|
+
(0...COMPUTER_NAME_MAPPING.length).step(2) { |i| COMPUTER_NAME_VALUES << COMPUTER_NAME_MAPPING[i] }
|
74
|
+
(0...TCPIP_MAPPING.length).step(2) { |i| TCPIP_VALUES << TCPIP_MAPPING[i] }
|
75
|
+
(0...DHCP_MAPPING.length).step(2) { |i| TCPIP_VALUES << DHCP_MAPPING[i] }
|
76
|
+
(0...STATIC_MAPPING.length).step(2) { |i| TCPIP_VALUES << STATIC_MAPPING[i] }
|
77
|
+
|
78
|
+
def initialize(_c, fs)
|
79
|
+
@networks = []
|
80
|
+
|
81
|
+
regHnd = RemoteRegistry.new(fs, true)
|
82
|
+
software_doc = regHnd.loadHive("software", [
|
83
|
+
{:key => "Microsoft/Windows NT/CurrentVersion", :depth => 1, :value => OS_MAPPING_VALUES},
|
84
|
+
{:key => "Microsoft/Windows NT/CurrentVersion/NetworkCards", :depth => 0, :value => NETWORK_CARDS_VALUES}
|
85
|
+
])
|
86
|
+
|
87
|
+
regHnd.close
|
88
|
+
|
89
|
+
regHnd = RemoteRegistry.new(fs, true)
|
90
|
+
sys_doc = regHnd.loadHive("system", [
|
91
|
+
{:key => 'CurrentControlSet/Control/ComputerName/ComputerName', :value => COMPUTER_NAME_VALUES},
|
92
|
+
{:key => 'CurrentControlSet/Control/Session Manager/Environment', :value => ENVIRONMENT_VALUES},
|
93
|
+
{:key => 'CurrentControlSet/Control/ProductOptions', :value => PRODUCT_OPTIONS_VALUES},
|
94
|
+
{:key => 'CurrentControlSet/Services/Tcpip/Parameters', :value => TCPIP_VALUES},
|
95
|
+
])
|
96
|
+
regHnd.close
|
97
|
+
|
98
|
+
# Get the OS information
|
99
|
+
attrs = {:type => "windows"}
|
100
|
+
|
101
|
+
reg_node = MIQRexml.findRegElement("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", software_doc.root)
|
102
|
+
attrs.merge!(XmlFind.decode(reg_node, OS_MAPPING)) if reg_node
|
103
|
+
|
104
|
+
reg_node = MIQRexml.findRegElement("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ComputerName", sys_doc.root)
|
105
|
+
attrs.merge!(XmlFind.decode(reg_node, COMPUTER_NAME_MAPPING)) if reg_node
|
106
|
+
|
107
|
+
reg_node = MIQRexml.findRegElement("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ProductOptions", sys_doc.root)
|
108
|
+
attrs.merge!(XmlFind.decode(reg_node, PRODUCT_OPTIONS_MAPPING)) if reg_node
|
109
|
+
|
110
|
+
reg_node = MIQRexml.findRegElement("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", sys_doc.root)
|
111
|
+
attrs.merge!(XmlFind.decode(reg_node, ENVIRONMENT_MAPPING)) if reg_node
|
112
|
+
|
113
|
+
attrs[:product_key] = MiqWin32::Software.DecodeProductKey(attrs[:product_key]) if attrs[:product_key]
|
114
|
+
|
115
|
+
attrs[:architecture] = architecture_to_string(attrs[:architecture])
|
116
|
+
|
117
|
+
# Parse product edition and append to product_name if needed.
|
118
|
+
os_product_suite(attrs)
|
119
|
+
|
120
|
+
@os = attrs
|
121
|
+
|
122
|
+
# Get the network card information
|
123
|
+
|
124
|
+
# Hold onto the parameters common to all network cards
|
125
|
+
reg_tcpip = MIQRexml.findRegElement("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", sys_doc.root)
|
126
|
+
if reg_tcpip
|
127
|
+
tcpip_params = XmlFind.decode(reg_tcpip, TCPIP_MAPPING)
|
128
|
+
tcpip_params[:domain] = XmlFind.findNamedElement_hash("Domain", reg_tcpip)
|
129
|
+
tcpip_params[:domain] = XmlFind.findNamedElement_hash("DhcpDomain", reg_tcpip) if tcpip_params[:domain].blank?
|
130
|
+
tcpip_params[:domain] = nil if tcpip_params[:domain].blank?
|
131
|
+
|
132
|
+
# Find each netword card, and get it's individual parameters
|
133
|
+
reg_networkCards = MIQRexml.findRegElement("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards", software_doc.root)
|
134
|
+
if reg_networkCards.kind_of?(Hash)
|
135
|
+
reg_networkCards.each_element do |networkCard|
|
136
|
+
attrs = XmlFind.decode(networkCard, NETWORK_CARDS_MAPPING)
|
137
|
+
|
138
|
+
params = XmlFind.findElement("Interfaces/#{attrs[:guid]}", reg_tcpip)
|
139
|
+
next if params.nil?
|
140
|
+
|
141
|
+
# Add the common parameters
|
142
|
+
attrs.merge!(tcpip_params)
|
143
|
+
|
144
|
+
# Blank out fields that are not shared between network types
|
145
|
+
attrs[:lease_obtained] = attrs[:lease_expires] = attrs[:dhcp_server] = nil
|
146
|
+
|
147
|
+
# Get the rest of the parameters based on whether this network is DHCP enabled
|
148
|
+
dhcp = XmlFind.findNamedElement_hash("EnableDHCP", params)
|
149
|
+
attrs.merge!(XmlFind.decode(params, dhcp.to_i == 1 ? DHCP_MAPPING : STATIC_MAPPING))
|
150
|
+
|
151
|
+
# Remove the extra curly braces from the guid
|
152
|
+
attrs[:guid] = attrs[:guid][1..-2] unless attrs[:guid].nil?
|
153
|
+
|
154
|
+
# Clean the lease times and check they are in a reasonable range
|
155
|
+
[:lease_obtained, :lease_expires].each do |t|
|
156
|
+
attrs[t] = Time.at(attrs[t].to_i).getutc.iso8601 if attrs[t] && attrs[t].to_i >= 0 && attrs[t].to_i < 0x80000000
|
157
|
+
end
|
158
|
+
@networks << attrs
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# Extracted data also built into a human-readable format if uncommented
|
164
|
+
# @debug_str = ''
|
165
|
+
|
166
|
+
# Force memory cleanup
|
167
|
+
software_doc = nil; sys_doc = nil; GC.start
|
168
|
+
|
169
|
+
regHnd = RemoteRegistry.new(fs, true)
|
170
|
+
sam_doc = regHnd.loadHive("sam", [{:key => "SAM/Domains/Account", :depth => 1, :value => ['F']}])
|
171
|
+
regHnd.close
|
172
|
+
|
173
|
+
# Extract the local account policy from the registry
|
174
|
+
@debug_str += "Account Policy:\n" if @debug_str
|
175
|
+
reg_node = MIQRexml.findRegElement("HKEY_LOCAL_MACHINE\\SAM\\SAM\\Domains\\Account", sam_doc.root)
|
176
|
+
if reg_node
|
177
|
+
reg_node.each_element(:value) do |e|
|
178
|
+
acct_policy_f = process_acct_policy_f(e.text) if e.attributes[:name] == "F"
|
179
|
+
|
180
|
+
unless acct_policy_f.nil?
|
181
|
+
# Remove unused elements
|
182
|
+
acct_policy_f.delete(:auto_increment)
|
183
|
+
acct_policy_f.delete(:next_rid)
|
184
|
+
acct_policy_f.delete(:pw_encrypt_pw_complex)
|
185
|
+
acct_policy_f.delete(:syskey)
|
186
|
+
|
187
|
+
@account_policy = acct_policy_f
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
# Dump the debug string to a file if we are collecting that data
|
193
|
+
# File.open('C:/Temp/reg_extract_full_system.txt', 'w') { |f| f.write(@debug_str) } if @debug_str
|
194
|
+
if $log
|
195
|
+
os_dup = @os.dup
|
196
|
+
[:productid, :product_key].each { |k| os_dup.delete(k) }
|
197
|
+
$log.info "VM OS information: [#{os_dup.inspect}]"
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def to_xml(doc = nil)
|
202
|
+
doc = MiqXml.createDoc(nil) unless doc
|
203
|
+
osToXml(doc)
|
204
|
+
accountPolicyToXml(doc)
|
205
|
+
networksToXml(doc)
|
206
|
+
doc
|
207
|
+
end
|
208
|
+
|
209
|
+
def osToXml(doc = nil)
|
210
|
+
doc = MiqXml.createDoc(nil) unless doc
|
211
|
+
doc.add_element(:os, @os) unless @os.empty?
|
212
|
+
doc
|
213
|
+
end
|
214
|
+
|
215
|
+
def accountPolicyToXml(doc = nil)
|
216
|
+
doc = MiqXml.createDoc(nil) unless doc
|
217
|
+
doc.add_element(:account_policy, @account_policy) unless @account_policy.blank?
|
218
|
+
doc
|
219
|
+
end
|
220
|
+
|
221
|
+
def networksToXml(doc = nil)
|
222
|
+
doc = MiqXml.createDoc(nil) unless doc
|
223
|
+
unless @networks.empty?
|
224
|
+
node = doc.add_element(:networks)
|
225
|
+
@networks.each { |n| node.add_element(:network, n) }
|
226
|
+
end
|
227
|
+
doc
|
228
|
+
end
|
229
|
+
|
230
|
+
def architecture_to_string(architecture)
|
231
|
+
case architecture
|
232
|
+
when "x86" then 32
|
233
|
+
when "AMD64" then 64
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
# Parse product edition and append to product_name if needed.
|
238
|
+
def os_product_suite(hash)
|
239
|
+
eid = hash.delete(:edition_id)
|
240
|
+
ps = hash.delete(:product_suite)
|
241
|
+
|
242
|
+
# If edition_id is populated then the edition will already be part of the product_name string
|
243
|
+
if eid.nil? && !hash[:product_name].nil?
|
244
|
+
ps = ps.to_s.split("\n")
|
245
|
+
if ps.length > 1 && !hash[:product_name].include?(ps.first)
|
246
|
+
hash[:product_name] = "#{hash[:product_name].strip} #{ps.first} Edition"
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
# Definition derived from http://www.beginningtoseethelight.org/ntsecurity/#BB4F910C0FFA1E43
|
252
|
+
# \HKEY_LOCAL_MACHINE\SAM\SAM\Domains\Account\F
|
253
|
+
SAM_STRUCT_ACCT_POLICY = BinaryStruct.new([
|
254
|
+
'a16', nil, # UNKNOWN
|
255
|
+
'Q', :auto_increment, # Auto-increment
|
256
|
+
'Q', :max_pw_age, # Maximum password age (>=0 & <=999) days - minus from qword:ff + 1 = seconds x 10 million
|
257
|
+
'Q', :min_pw_age, # Minimum password age (>=0 & <=999) days - minus from qword:ff + 1 = seconds x 10 million
|
258
|
+
'a8', nil, # UNKNOWN
|
259
|
+
'Q', :lockout_duration, # Account lockout duration (>=0 & <=99,999) minutes - minus from qword:ff + 1 = seconds x 10 million
|
260
|
+
'Q', :reset_lockout_counter, # Reset account lockout counter after (>=1 & <=99,999) minutes - minus from qword:ff + 1 = seconds x 10 million
|
261
|
+
'a8', nil, # UNKNOWN
|
262
|
+
'I', :next_rid, # Next created users RID
|
263
|
+
'C', :pw_encrypt_pw_complex, # High nibble
|
264
|
+
# Store password using reversible encryption for all users in the domain (enabled=1/disabled=0)
|
265
|
+
# Low nibble
|
266
|
+
# Password must meet complexity requirements (enabled=1/disabled=0)
|
267
|
+
'a3', nil, # UNKNOWN
|
268
|
+
'C', :min_pw_len, # Minimum password length (>=0 & <=14) characters
|
269
|
+
'a1', nil, # UNKNOWN
|
270
|
+
'C', :pw_hist, # Enforce password history (>=0 & <=24) passwords remembered
|
271
|
+
'a1', nil, # UNKNOWN
|
272
|
+
'S', :lockout_threshold, # Account lockout threshold (>=0 & <=999) attempts
|
273
|
+
'a26', nil, # UNKNOWN
|
274
|
+
'a48', :syskey, # Part of syskey
|
275
|
+
'a8', nil, # UNKNOWN
|
276
|
+
])
|
277
|
+
|
278
|
+
def process_acct_policy_f(data)
|
279
|
+
bin = MSRegHive.regBinaryToRawBinary(data)
|
280
|
+
f = SAM_STRUCT_ACCT_POLICY.decode(bin)
|
281
|
+
|
282
|
+
@debug_str += " auto_increment - %s\n" % f[:auto_increment] if @debug_str
|
283
|
+
|
284
|
+
@debug_str += " max_pw_age - %s - " % f[:max_pw_age] if @debug_str
|
285
|
+
f[:max_pw_age] = process_acct_policy_f_date(f[:max_pw_age]) / 86400
|
286
|
+
@debug_str += "%s days\n" % f[:max_pw_age] if @debug_str
|
287
|
+
|
288
|
+
@debug_str += " min_pw_age - %s - " % f[:min_pw_age] if @debug_str
|
289
|
+
f[:min_pw_age] = process_acct_policy_f_date(f[:min_pw_age]) / 86400
|
290
|
+
@debug_str += "%s days\n" % f[:min_pw_age] if @debug_str
|
291
|
+
|
292
|
+
@debug_str += " lockout_duration - %s - " % f[:lockout_duration] if @debug_str
|
293
|
+
f[:lockout_duration] = process_acct_policy_f_date(f[:lockout_duration]) / 60
|
294
|
+
@debug_str += "%s minutes\n" % f[:lockout_duration] if @debug_str
|
295
|
+
|
296
|
+
@debug_str += " reset_lockout_counter - %s - " % f[:reset_lockout_counter] if @debug_str
|
297
|
+
f[:reset_lockout_counter] = process_acct_policy_f_date(f[:reset_lockout_counter]) / 60
|
298
|
+
@debug_str += "%s minutes\n" % f[:reset_lockout_counter] if @debug_str
|
299
|
+
|
300
|
+
@debug_str += " next_rid - %s\n" % f[:next_rid] if @debug_str
|
301
|
+
|
302
|
+
@debug_str += " pw_encrypt_pw_complex - 0x%02x\n" % f[:pw_encrypt_pw_complex] if @debug_str
|
303
|
+
f[:pw_encrypt], f[:pw_complex] = process_acct_policy_f_pw_encrypt_pw_complex(f[:pw_encrypt_pw_complex])
|
304
|
+
@debug_str += " pw_encrypt - %s\n" % f[:pw_encrypt] if @debug_str
|
305
|
+
@debug_str += " pw_complex - %s\n" % f[:pw_complex] if @debug_str
|
306
|
+
|
307
|
+
if @debug_str
|
308
|
+
@debug_str += " min_pw_len - %s characters\n" % f[:min_pw_len]
|
309
|
+
@debug_str += " pw_hist - %s passwords remembered\n" % f[:pw_hist]
|
310
|
+
@debug_str += " lockout_threshold - %s attempts\n" % f[:lockout_threshold]
|
311
|
+
@debug_str += " syskey - %s\n" % Accounts.rawBinaryToRegBinary(f[:syskey])
|
312
|
+
end
|
313
|
+
|
314
|
+
f
|
315
|
+
end
|
316
|
+
|
317
|
+
def process_acct_policy_f_date(data)
|
318
|
+
return 0 if data == 0 || data == 0x8000000000000000
|
319
|
+
# minus from qword:ff + 1 = seconds x 10 million
|
320
|
+
(0x10000000000000000 - data) / 10000000
|
321
|
+
end
|
322
|
+
|
323
|
+
def process_acct_policy_f_pw_encrypt_pw_complex(data)
|
324
|
+
pw_encrypt = data >> 4
|
325
|
+
pw_encrypt = (pw_encrypt == 1)
|
326
|
+
|
327
|
+
pw_complex = data & 0x0F
|
328
|
+
pw_complex = (pw_complex == 1)
|
329
|
+
|
330
|
+
return pw_encrypt, pw_complex
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'metadata/util/win32/remote-registry'
|
2
|
+
|
3
|
+
module Win32
|
4
|
+
class SystemPath
|
5
|
+
def self.driveAssignment(fs)
|
6
|
+
log_header = "MIQ(SystemPath.driveAssignment)"
|
7
|
+
drives = []
|
8
|
+
regHnd = RemoteRegistry.new(fs, true)
|
9
|
+
xml = regHnd.loadHive("system", ["MountedDevices"])
|
10
|
+
|
11
|
+
# Find the MountedDevices node
|
12
|
+
node = nil
|
13
|
+
xml.elements.each { |e| node = e if e.name == :key && e.attributes[:keyname] == 'MountedDevices' }
|
14
|
+
|
15
|
+
unless node.nil?
|
16
|
+
node.each_element do |e|
|
17
|
+
if e.attributes[:name].include?("DosDevices") && e.text.length <= 36
|
18
|
+
data = e.text.split(",")
|
19
|
+
|
20
|
+
# The partition signature is derived from the DiskID and the partition's starting
|
21
|
+
# sector number. The DiskID (sometimes called the "NT serial number") is a group of
|
22
|
+
# four bytes in the master boot sector (LBA 0) at location 01B8h. Each partition's
|
23
|
+
# starting sector number is doubled and combined with the DiskID to form a unique
|
24
|
+
# signature for that partition. For example, consider a disk with the serial number
|
25
|
+
# 3D173D16h (hexadecimal) and a partition starting at LBA 44933868 (decimal). Double
|
26
|
+
# the sector number (89867736) and convert to hexadecimal (055B45D8h). If this partition
|
27
|
+
# were designated E:, the corresponding registry values would be:
|
28
|
+
#
|
29
|
+
# [HKEY_LOCAL_MACHINE\System\MountedDevices]
|
30
|
+
# \??\Volume{...} = 16 3d 17 3d 00 d8 45 5b 05 00 00 00
|
31
|
+
# \DosDevices\E: = 16 3d 17 3d 00 d8 45 5b 05 00 00 00
|
32
|
+
|
33
|
+
drives << {:device => e.attributes[:name],
|
34
|
+
:name => e.attributes[:name].split("\\")[-1],
|
35
|
+
:raw_data => e.text,
|
36
|
+
:serial_num => "0x#{data[3]}#{data[2]}#{data[1]}#{data[0]}".to_i(16),
|
37
|
+
:starting_sector => "0x#{data[8]}#{data[7]}#{data[6]}#{data[5]}".to_i(16) / 2}
|
38
|
+
elsif e.attributes[:name].include?("DosDevices") && e.text.length <= 100
|
39
|
+
$log.warn "#{log_header} Skipping disk #{e.attributes[:name]} - (#{e.text.length})#{e.text}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# If we do not find this key we cannot map disks with the proper drive letter.
|
45
|
+
# This is a good sign that the OS is in a sysprep state and not fully installed.
|
46
|
+
if drives.empty?
|
47
|
+
$log.warn "#{log_header} The registry does not contain a mounted device list. [Possible cause: The OS is in a pre-installed state.]"
|
48
|
+
xml.to_xml.write(xml_str = '', 0)
|
49
|
+
$log.warn "#{log_header} HKLM\\SYSTEM\\MountedDevices - START\n#{xml_str}"
|
50
|
+
$log.warn "#{log_header} HKLM\\SYSTEM\\MountedDevices - END"
|
51
|
+
|
52
|
+
os_install_loc = Win32::SystemPath.systemIdentifier(fs, :debug => true)
|
53
|
+
$log.warn "#{log_header} System Install location: <#{os_install_loc.inspect}>"
|
54
|
+
end
|
55
|
+
|
56
|
+
drives
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,220 @@
|
|
1
|
+
require 'util/miq-xml'
|
2
|
+
require 'digest/md5'
|
3
|
+
require 'metadata/util/win32/remote-registry'
|
4
|
+
require 'enumerator'
|
5
|
+
require 'util/miq-encode'
|
6
|
+
|
7
|
+
class FleeceHives
|
8
|
+
def self.collect_hive_data(xmlNode, hiveName, regHnd, xmlCol, fs)
|
9
|
+
# SAM hive
|
10
|
+
if hiveName.downcase == "sam"
|
11
|
+
scanFor = [
|
12
|
+
["SAM", "HKEY_LOCAL_MACHINE\\SAM\\SAM"],
|
13
|
+
]
|
14
|
+
# SYSTEM hive
|
15
|
+
elsif hiveName.downcase == "system"
|
16
|
+
# Preprocess some keys by making copies of them so they are not lost during processServices
|
17
|
+
scanFor = [
|
18
|
+
# The following are used for system category
|
19
|
+
["system/network", "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"],
|
20
|
+
]
|
21
|
+
scanFor.each { |i| addElement(xmlNode.root, i[0], i[1], xmlCol, true) }
|
22
|
+
|
23
|
+
processServices(xmlNode, hiveName, regHnd, xmlCol)
|
24
|
+
|
25
|
+
scanFor = [
|
26
|
+
["system/os", "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ComputerName"],
|
27
|
+
["system/os", "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"],
|
28
|
+
["system/os", "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ProductOptions"],
|
29
|
+
]
|
30
|
+
# SOFTWARE hive
|
31
|
+
elsif hiveName.downcase == "software"
|
32
|
+
scanFor = [
|
33
|
+
# The following are used for the system category
|
34
|
+
["system/network", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards"],
|
35
|
+
|
36
|
+
# The following are used for the software category
|
37
|
+
["software", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Hotfix"],
|
38
|
+
# ["software", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\Installer\\Products"],
|
39
|
+
["software", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData"],
|
40
|
+
["software", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"],
|
41
|
+
["software", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths"],
|
42
|
+
# ["software", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"],
|
43
|
+
# ["software", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce"],
|
44
|
+
# ["software", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx"],
|
45
|
+
]
|
46
|
+
|
47
|
+
# The following are for the system/os category, but I can't remove it for
|
48
|
+
# software because it screws up the product keys, due to the way product
|
49
|
+
# keys are precollected from this key
|
50
|
+
eNode = MIQRexml.findElement("system/os", xmlCol.root)
|
51
|
+
eNode = eNode.add_element("key", "keyname" => "CurrentVersion", "fqname" => "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion")
|
52
|
+
currentOS_ele = regHnd.open(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion")
|
53
|
+
currentOS_ele.each_element_with_attribute('name') { |e| eNode << e } unless currentOS_ele.nil?
|
54
|
+
end
|
55
|
+
|
56
|
+
scanFor.each { |i| addElement(xmlNode.root, i[0], i[1], xmlCol) } unless scanFor.nil?
|
57
|
+
|
58
|
+
case hiveName.downcase
|
59
|
+
when "software"
|
60
|
+
begin
|
61
|
+
postProcessApps(xmlCol, fs)
|
62
|
+
rescue Exception => err
|
63
|
+
$log.warn "Exception during Post-process Applications: [#{err}]"
|
64
|
+
end
|
65
|
+
begin
|
66
|
+
collectProductKeys(xmlNode.root, xmlCol, regHnd)
|
67
|
+
rescue => err
|
68
|
+
$log.warn "Exception during Collect Product Keys: [#{err}]"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.scanRegistry(_c, fs, hives = ["sam", nil, "security", nil, "default", nil, "system", nil, "software", nil])
|
74
|
+
xmlCol = MiqXml.createDoc("<miq/>")
|
75
|
+
|
76
|
+
hives.each_slice(2) do |hive, filter|
|
77
|
+
regHnd = RemoteRegistry.new(fs)
|
78
|
+
|
79
|
+
$log.debug "Loading registry hive [#{hive}]..."
|
80
|
+
xml = regHnd.loadHive(hive, filter)
|
81
|
+
$log.debug "Loading registry hive complete."
|
82
|
+
|
83
|
+
# File.open("C:/temp/reg_extract_full_#{c}.xml","w"){|f| xml.write(f,0)}
|
84
|
+
|
85
|
+
# Scrap details from this hive
|
86
|
+
$log.debug "Fleecing registry data."
|
87
|
+
FleeceHives.collect_hive_data(xml, hive, regHnd, xmlCol, fs)
|
88
|
+
$log.debug "Fleecing complete."
|
89
|
+
end
|
90
|
+
|
91
|
+
# File.open("C:/temp/reg_extract_#{c}.xml","w"){|f| xmlCol.write(f,0)}
|
92
|
+
xmlCol
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.DecodeProductKey(product_key)
|
96
|
+
return if product_key.blank? || product_key.length < 67
|
97
|
+
y = []; product_key.split(",")[52..67].each { |b| y << b.hex }
|
98
|
+
return MIQEncode.base24Decode(y)
|
99
|
+
rescue => err
|
100
|
+
$log.error "MIQ(OS-DecodeProductKey): [#{err}]"
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.collectProductKeys(_xml, xmlCol, regHnd)
|
104
|
+
prodKeys = MIQRexml.findElement("software/productkeys", xmlCol.root)
|
105
|
+
regHnd.digitalProductKeys.each do |e|
|
106
|
+
if e.parent && e.parent.attributes['fqname'] && e.parent.attributes['fqname'].downcase != 'software\\microsoft\\windows nt\\currentversion'
|
107
|
+
pk = productKeys(e)
|
108
|
+
prodKeys << pk if pk
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.productKeys(xmlNode)
|
114
|
+
p = xmlNode.parent
|
115
|
+
|
116
|
+
newEle = xmlNode.get_path
|
117
|
+
t = nil
|
118
|
+
newEle.each_recursive { |e1| t = e1 }
|
119
|
+
|
120
|
+
p.each_element do|e|
|
121
|
+
if e.attributes['name'] && e.attributes['name'].downcase.include?("product")
|
122
|
+
x = e.shallow_copy
|
123
|
+
x.text = e.text
|
124
|
+
t << x
|
125
|
+
end
|
126
|
+
end
|
127
|
+
ret = nil
|
128
|
+
begin
|
129
|
+
ret = newEle.find_first("//*/key[@keyname=\"Microsoft\"]")
|
130
|
+
ret = ret.elements[1] if ret
|
131
|
+
rescue => e
|
132
|
+
end
|
133
|
+
ret
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.postProcessApps(xmlCol, fs)
|
137
|
+
appPath = MIQRexml.findRegElement("software/App Paths", xmlCol.root)
|
138
|
+
return if appPath.nil?
|
139
|
+
# The icon sections below will need to be uncommented when we are ready to start
|
140
|
+
# implementing application image uploading.
|
141
|
+
# iconNode = MIQRexml.findElement("Applications/images", xmlCol.root)
|
142
|
+
appPath.each_element do|e|
|
143
|
+
e.each_element_with_attribute('name', '(Default)', max = 1) do|e1|
|
144
|
+
begin
|
145
|
+
fileName = e1.text
|
146
|
+
fileName.tr!("\\", "/")
|
147
|
+
fileName = fileName[1..-2] if fileName[0, 1] == "\"" && fileName[-1, 1] == "\""
|
148
|
+
|
149
|
+
# $log.warn "Processing App - [#{fileName}]"
|
150
|
+
fh = fs.fileOpen(fileName)
|
151
|
+
vi = File.getVersionInfo(fh)
|
152
|
+
# Access application icons
|
153
|
+
# peData = PEheader.new(fh)
|
154
|
+
fh.close
|
155
|
+
# $log.warn "Processing App - [#{fileName}] - VI length:[#{vi.length}]"
|
156
|
+
if vi.length > 0
|
157
|
+
e2 = e.add_element('versioninfo')
|
158
|
+
vi.each_pair { |k, v| e2.add_element("value", "name" => k).add_text(v.to_s) }
|
159
|
+
end
|
160
|
+
|
161
|
+
# if peData.icons.length > 0
|
162
|
+
# ie = e1.add_element("image",{"file"=>fileName, "count"=>peData.icons.length.to_s, "md5"=>Digest::MD5.hexdigest(peData.icons[0])})
|
163
|
+
# addIconData(ie, peData, iconNode)
|
164
|
+
# end
|
165
|
+
rescue Exception => e
|
166
|
+
# $log.warn "postProcessApps - [#{fileName}] - error [#{e.to_s}]"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def self.addIconData(icon_element, peData, iconNode)
|
173
|
+
$log.debug "Adding application image: [#{icon_element}]"
|
174
|
+
# Copy this element into another branch of the xml to store icon binary data
|
175
|
+
newEle = iconNode.add_element(icon_element.name, icon_element.attributes)
|
176
|
+
# Encode binary icon data as an element
|
177
|
+
newEle.add_element("binary", {"type" => "icon"}).add_text(MIQEncode.encode(peData.icons[0]))
|
178
|
+
end
|
179
|
+
|
180
|
+
def self.processServices(xmlNode, _hiveName, _regHnd, xmlCol)
|
181
|
+
eServices = MIQRexml.findElement("services", xmlCol.root)
|
182
|
+
|
183
|
+
eSvcList = MIQRexml.findRegElement("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services", xmlNode.root)
|
184
|
+
if eSvcList
|
185
|
+
eSvcList.each_element do |e|
|
186
|
+
next if e.name != "key"
|
187
|
+
|
188
|
+
# Remove child elements's that have children. This data is not being processed on the server
|
189
|
+
# and adds a lot of extract size to the xml and time for tagging.
|
190
|
+
e.each_element { |e1| e1.remove! if e1.name == 'key' }
|
191
|
+
|
192
|
+
# Create one element referring to the type by name
|
193
|
+
serviceType = MIQRexml.getChildAttrib(e, "Type", 1).to_i
|
194
|
+
e2 = e.add_element("value", "name" => "TypeName", "type" => "REG_SZ")
|
195
|
+
e2.text = if (serviceType & 0x00000001) > 0
|
196
|
+
"kernel"
|
197
|
+
elsif (serviceType & 0x00000002) > 0
|
198
|
+
"filesystem"
|
199
|
+
elsif ((serviceType & 0x00000010) > 0) || ((serviceType & 0x00000020) > 0)
|
200
|
+
"win32_service"
|
201
|
+
else
|
202
|
+
"misc"
|
203
|
+
end
|
204
|
+
|
205
|
+
eServices << e
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def self.addElement(xmlNode, nodeName, regPath, xmlCol, makeCopy = false)
|
211
|
+
eNode = MIQRexml.findElement(nodeName, xmlCol.root)
|
212
|
+
eNew = MIQRexml.findRegElement(regPath, xmlNode)
|
213
|
+
|
214
|
+
if makeCopy
|
215
|
+
eNode << MiqXml.createDoc(eNew.to_s).root if eNew
|
216
|
+
else
|
217
|
+
eNode << eNew if eNew
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|