Skip to content

Commit 292831f

Browse files
committed
Version 1.0.0.18
Added new optional parameter /OutputName to override the original filename.
1 parent ce861eb commit 292831f

5 files changed

Lines changed: 52 additions & 14 deletions

File tree

RawCopy.au3

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#AutoIt3Wrapper_Change2CUI=y
66
#AutoIt3Wrapper_Res_Comment=Raw file copy
77
#AutoIt3Wrapper_Res_Description=Copy files from NTFS volumes by using low level disk access
8-
#AutoIt3Wrapper_Res_Fileversion=1.0.0.17
8+
#AutoIt3Wrapper_Res_Fileversion=1.0.0.18
99
#AutoIt3Wrapper_Res_LegalCopyright=Joakim Schicht
1010
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
1111
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
@@ -24,7 +24,7 @@ Global $IsolatedAttributeList, $AttribListNonResident=0,$IsCompressed,$IsSparse,
2424
Global $RUN_VCN[1],$RUN_Clusters[1],$MFT_RUN_Clusters[1],$MFT_RUN_VCN[1],$DataQ[1],$AttribX[1],$AttribXType[1],$AttribXCounter[1],$AttribXStreamName[1],$sBuffer,$AttrQ[1]
2525
Global $IndxEntryNumberArr[1],$IndxMFTReferenceArr[1],$IndxMFTRefSeqNoArr[1],$IndxIndexFlagsArr[1],$IndxMFTReferenceOfParentArr[1],$IndxMFTParentRefSeqNoArr[1],$IndxCTimeArr[1],$IndxATimeArr[1],$IndxMTimeArr[1],$IndxRTimeArr[1],$IndxAllocSizeArr[1],$IndxRealSizeArr[1],$IndxFileFlagsArr[1],$IndxFileNameArr[1],$IndxSubNodeVCNArr[1],$IndxNameSpaceArr[1]
2626
Global $IRArr[12][2],$IndxArr[20][2]
27-
Global $VolumesArray[1][3],$DetailMode=1, $WriteFSInfo=0
27+
Global $VolumesArray[1][3],$DetailMode=1, $WriteFSInfo=0, $OutputName
2828
Global $DateTimeFormat = 6 ; YYYY-MM-DD HH:MM:SS:MSMSMS:NSNSNSNS = 2007-08-18 08:15:37:733:1234
2929
Global $tDelta = _WinTime_GetUTCToLocalFileTimeDelta()
3030
Global Const $RecordSignature = '46494C45' ; FILE signature
@@ -60,7 +60,7 @@ $VolumesArray[0][0] = "Type"
6060
$VolumesArray[0][1] = "ByteOffset"
6161
$VolumesArray[0][2] = "Sectors"
6262

63-
ConsoleWrite("RawCopy v1.0.0.17" & @CRLF & @CRLF)
63+
ConsoleWrite("RawCopy v1.0.0.18" & @CRLF & @CRLF)
6464
_GetInputParams()
6565
;_ArrayDisplay($VolumesArray,"$VolumesArray")
6666
$ParentDir = _GenDirArray($TargetFileName)
@@ -176,6 +176,9 @@ Exit
176176

177177
Func _MainExtract()
178178
Local $LocalCoreFilename
179+
If $OutputName <> "" Then
180+
$FN_FileName = $OutputName
181+
EndIf
179182
For $i = 1 To UBound($DataQ) - 1
180183
_DecodeDataQEntry($DataQ[$i])
181184
$AttributeOutFileName = $OutPutPath & "\" & $ADS_Name
@@ -2448,7 +2451,7 @@ Func _GenRefArray()
24482451
EndFunc
24492452

24502453
Func _GetInputParams()
2451-
Local $TmpAllAttr, $TmpOutPath, $TmpImageFile, $TmpFileNamePath, $TmpImageVolume, $TmpRawDirMode, $TmpWriteFSInfo, $str1,$str2,$pos,$matchstr
2454+
Local $TmpAllAttr, $TmpOutPath, $TmpImageFile, $TmpFileNamePath, $TmpImageVolume, $TmpRawDirMode, $TmpWriteFSInfo, $str1,$str2,$pos,$matchstr,$TmpOutName
24522455
For $i = 1 To $cmdline[0]
24532456
;ConsoleWrite("Param " & $i & ": " & $cmdline[$i] & @CRLF)
24542457
If StringLeft($cmdline[$i],14) = "/FileNamePath:" Then $TmpFileNamePath = StringMid($cmdline[$i],15)
@@ -2458,6 +2461,7 @@ Func _GetInputParams()
24582461
If StringLeft($cmdline[$i],13) = "/ImageVolume:" Then $TmpImageVolume = StringMid($cmdline[$i],14)
24592462
If StringLeft($cmdline[$i],12) = "/RawDirMode:" Then $TmpRawDirMode = StringMid($cmdline[$i],13)
24602463
If StringLeft($cmdline[$i],13) = "/WriteFSInfo:" Then $TmpWriteFSInfo = StringMid($cmdline[$i],14)
2464+
If StringLeft($cmdline[$i],12) = "/OutputName:" Then $TmpOutName = StringMid($cmdline[$i],13)
24612465
Next
24622466
If $cmdline[0] = 0 Then
24632467
_PrintHelp()
@@ -2472,6 +2476,14 @@ Func _GetInputParams()
24722476
EndIf
24732477
EndIf
24742478

2479+
If StringLen($TmpOutName) > 0 Then
2480+
$OutPutName = $TmpOutName
2481+
If StringInStr($OutPutName, "\") Then
2482+
$OutPutName = _GetFilenameFromPath($OutPutName)
2483+
EndIf
2484+
$OutPutName = _FixWindowsFilename($OutPutName)
2485+
EndIf
2486+
24752487
If StringLen($TmpAllAttr) > 0 Then
24762488
If $TmpAllAttr=1 Then
24772489
$DoExtractMeta = 1
@@ -2693,17 +2705,17 @@ EndFunc
26932705

26942706
Func _PrintHelp()
26952707
ConsoleWrite("Syntax:" & @CRLF)
2696-
ConsoleWrite("RawCopy /ImageFile:FullPath\ImageFilename /ImageVolume:[1,2...n] /FileNamePath:FullPath\Filename /OutputPath:FullPath /AllAttr:[0|1] /RawDirMode:[0|1|2] /WriteFSInfo:[0|1]" & @CRLF)
2708+
ConsoleWrite("RawCopy /ImageFile:FullPath\ImageFilename /ImageVolume:[1,2...n] /FileNamePath:FullPath\Filename /OutputPath:FullPath /OutputName:FileName /AllAttr:[0|1] /RawDirMode:[0|1|2] /WriteFSInfo:[0|1]" & @CRLF)
26972709
ConsoleWrite("Examples:" & @CRLF)
2698-
ConsoleWrite("RawCopy /FileNamePath:c:\pagefile.sys /OutputPath:e:\temp" & @CRLF)
2710+
ConsoleWrite("RawCopy /FileNamePath:c:\hiberfil.sys /OutputPath:e:\temp /OutputName:hiberfil_c.sys" & @CRLF)
26992711
ConsoleWrite("RawCopy /FileNamePath:c:\pagefile.sys /OutputPath:e:\temp /AllAttr:1" & @CRLF)
2700-
ConsoleWrite("RawCopy /FileNamePath:c:0 /OutputPath:e:\temp" & @CRLF)
2712+
ConsoleWrite("RawCopy /FileNamePath:c:0 /OutputPath:e:\temp /OutputName:MFT_C" & @CRLF)
27012713
ConsoleWrite("RawCopy /ImageFile:e:\temp\diskimage.dd /ImageVolume:2 /FileNamePath:c:2 /OutputPath:e:\out" & @CRLF)
27022714
ConsoleWrite("RawCopy /ImageFile:e:\temp\partimage.dd /ImageVolume:1 /FileNamePath:c:\file.ext /OutputPath:e:\out" & @CRLF)
27032715
ConsoleWrite("RawCopy /FileNamePath:c:\$Extend /RawDirMode:1" & @CRLF)
27042716
ConsoleWrite('RawCopy /ImageFile:e:\temp\diskimage.dd /ImageVolume:2 /FileNamePath:"c:\system volume information" /RawDirMode:2 /WriteFSInfo:1' & @CRLF)
27052717
ConsoleWrite("RawCopy /FileNamePath:\\.\HarddiskVolumeShadowCopy1:x:\ /RawDirMode:1" & @CRLF)
2706-
ConsoleWrite("RawCopy /FileNamePath:\\.\Harddisk0Partition2:0 /OutputPath:e:\out" & @CRLF)
2718+
ConsoleWrite("RawCopy /FileNamePath:\\.\Harddisk0Partition2:0 /OutputPath:e:\out /OutputName:MFT_Hd0Part2" & @CRLF)
27072719
ConsoleWrite("RawCopy /FileNamePath:\\.\PhysicalDrive0:0 /ImageVolume:2 /OutputPath:e:\out" & @CRLF)
27082720
EndFunc
27092721

@@ -3003,4 +3015,24 @@ Func _AlignString($input,$length)
30033015
$input = " "&$input
30043016
WEnd
30053017
Return $input
3018+
EndFunc
3019+
3020+
Func _GetFilenameFromPath($FileNamePath)
3021+
$stringlength = StringLen($FileNamePath)
3022+
If $stringlength = 0 Then Return SetError(1,0,0)
3023+
$TmpOffset = StringInStr($FileNamePath, "\", 1, -1)
3024+
If $TmpOffset = 0 Then Return $FileNamePath
3025+
Return StringMid($FileNamePath,$TmpOffset+1)
3026+
EndFunc
3027+
3028+
Func _FixWindowsFilename($input)
3029+
$input = StringReplace($input, "/", "")
3030+
$input = StringReplace($input, "\", "")
3031+
$input = StringReplace($input, ":", "")
3032+
$input = StringReplace($input, "*", "")
3033+
$input = StringReplace($input, "?", "")
3034+
$input = StringReplace($input, '"', "")
3035+
$input = StringReplace($input, "<", "")
3036+
$input = StringReplace($input, ">", "")
3037+
Return $input
30063038
EndFunc

RawCopy.exe

0 Bytes
Binary file not shown.

RawCopy64.exe

512 Bytes
Binary file not shown.

changelog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
RawCopy Changelog
22

3+
v1.0.0.18: Added new optional parameter /OutputName to override the original filename.
4+
35
v1.0.0.17: Optimization of code parsing directories ($I30). Thanks to natocccp.
46

57
v1.0.0.16: Changed calculation of MFT_Record_Size to accomodate for a rare bug seen in certain Windows 7 x64 vm's.

readme.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ The volume number to extract from. If volume is not NTFS nothing will be extract
1313
The full path and filename of file to extract. Can also be in the form of Volume:MftRef. Mandatory.
1414
/OutputPath:
1515
The output path to extract file to. Optional. If omitted, then extract path defaults to program directory.
16+
/OutputName:
17+
The output filename. Optional. If omitted, then filename be that of the original filename. Only used to override the original filename.
1618
/AllAttr:
1719
Boolean flag to trigger extraction of all attributes. Optional. Defaults to 0.
1820
/RawDirMode:
@@ -30,19 +32,21 @@ For image files the volume letter in the /FileNamePath: parameter is ignored.
3032

3133
When specifying device paths in /FileNamePath it is possible to access attached devices that does not have any volumes mounted. Examples are HarddiskVolume1, Harddisk0Partition2, HarddiskVolumeShadowCopy1, PhysicalDrive1.
3234

35+
In order to extract files from a shadow copy within an image file, you will have to mount the image file beforehand so that Windows will present a symbolic link to the shadow copy such as \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy60. It is recommended to mount the image with a tool such as Arsenal Image Mounter (which is free).
36+
3337
The /WriteFSInfo: parameter can be useful when scripting since SectorsPerCluster and MFTRecordSize is used with LogFileParser and Mft2Csv.
3438

3539

3640
Sample usage
3741

38-
Example for copying the pagefile off a running system
39-
RawCopy.exe /FileNamePath:C:\pagefile.sys /OutputPath:E:\output
42+
Example for copying the hibernation file off a running system and save it to E:\output\hiberfil_c.sys
43+
RawCopy.exe /FileNamePath:C:\hiberfil.sys /OutputPath:E:\output /OutputName:hiberfil_c.sys
4044

4145
Example for copying the SYSTEM hive off a running system
4246
RawCopy.exe /FileNamePath:C:\WINDOWS\system32\config\SYSTEM /OutputPath:E:\output
4347

44-
Example for extracting the $MFT by specifying its index number, into to the program directory.
45-
RawCopy.exe /FileNamePath:C:0
48+
Example for extracting the $MFT by specifying its index number, into to the program directory and override the default output filename to MFT_C.bin.
49+
RawCopy.exe /FileNamePath:C:0 /OutputName:MFT_C.bin
4650

4751
Example for extracting MFT reference number 30224 and all attributes including $DATA, and dumping it into C:\tmp:
4852
RawCopy.exe /FileNamePath:C:30224 /OutputPath:C:\tmp /AllAttr:1
@@ -65,5 +69,5 @@ RawCopy.exe /FileNamePath:\\.\HarddiskVolumeShadowCopy1:x:\ /RawDirMode:1
6569
Example for extracting $MFT from partition 2 on harddisk 1 and dumping it into e:\out:
6670
RawCopy.exe /FileNamePath:\\.\Harddisk0Partition2:0 /OutputPath:e:\out
6771

68-
Example for extracting $MFT from second volume on PhysicalDrive0:
69-
RawCopy.exe /FileNamePath:\\.\PhysicalDrive0:0 /ImageVolume:2 /OutputPath:e:\out
72+
Example for extracting $MFT from second volume on PhysicalDrive0, and save it as E:\out\MFT_Pd0Vol2.bin:
73+
RawCopy.exe /FileNamePath:\\.\PhysicalDrive0:0 /ImageVolume:2 /OutputPath:e:\out /OutputName:MFT_Pd0Vol2.bin

0 commit comments

Comments
 (0)