Hi all,
In this post I want to introduce a Powershell script cmdlet that I have written to upload files to a McAfee Advanced Threat Defense box.
This is the first time that I write something in Powershell, I have tried to follow the specifications specially in terms of output and binding, in such a way that the files to be uploaded to the ATD box can be piped from a list, external file or another cmdlet and in the same way the cmdlet outputs information in an object format that allows to work on the results obtained from the upload operation.
Installation process:
- The Script can be downloaded from the following link:
https://github.com/built4tech/submit-atd - The current execution polity of the system where the cmdlet Script is going to be executed must allow the execution of unsigned scripts (Unresricted)
- If the current policy doesn't allow to execute unsigned scripts, you must change that policy, with the set-execution-policy cmdlet. It is important to note that this change requires administrative privileges.
- Once the policy is changed, you can import the module, and check that in the function space the new cmdlet (Submit-Atd) has been loaded.
- You can now, invoke the cmdlet. Bellow you can see some examples of how the script can be invoked and the information obtained:
sucess : True
file_size : 561659
mimeType : application/vnd.openxmlformats-officedocument.wordprocessingml.document
md5 : CBECAE24EEAAC476CA9F5828AABB0AB6
sha1 : C41C619C9355A30747DFA4F9DDF25B6367CA0CCC
file_name : source.bin
detail : Upload process sucessfull
sha256 : D66C3A184327B3E675725D1A70844B8A7653C1FD9774CC02B7C04F9FD78E909B
file_size : 561659
mimeType : application/vnd.openxmlformats-officedocument.wordprocessingml.document
md5 : CBECAE24EEAAC476CA9F5828AABB0AB6
sha1 : C41C619C9355A30747DFA4F9DDF25B6367CA0CCC
file_name : source.bin
detail : Upload process sucessfull
sha256 : D66C3A184327B3E675725D1A70844B8A7653C1FD9774CC02B7C04F9FD78E909B
2) Submit-atd -Atd_host 192.168.20.140 -Atd_user admin -Atd_pass McAfee123!
-Fullname C:\test\source.bin, C:\test\source-2.bin
sucess : True
file_size : 561659
mimeType : application/vnd.openxmlformats-officedocument.wordprocessingml.document
md5 : CBECAE24EEAAC476CA9F5828AABB0AB6
sha1 : C41C619C9355A30747DFA4F9DDF25B6367CA0CCC
file_name : source.bin
detail : Upload process sucessfull
sha256 : D66C3A184327B3E675725D1A70844B8A7653C1FD9774CC02B7C04F9FD78E909B
sucess : True
file_size : 561659
mimeType : application/vnd.openxmlformats-officedocument.wordprocessingml.document
md5 : CBECAE24EEAAC476CA9F5828AABB0AB6
sha1 : C41C619C9355A30747DFA4F9DDF25B6367CA0CCC
file_name : source-2.bin
detail : Upload process sucessfull
sha256 : D66C3A184327B3E675725D1A70844B8A7653C1FD9774CC02B7C04F9FD78E909B
3) get-content .\input.txt | Submit-atd -Atd_host 192.168.20.140 -Atd_user
admin -Atd_pass McAfee123!
Output removed for brevity
4) Get-ChildItem -Path c:\test | Select-Object -ExpandProperty Fullname | Submit-atd -Atd_host 192.168.20.140 -Atd_user admin -Atd_pass McAfee123!
Output removed for brevity
5) Get-ChildItem -Path c:\test | Select-Object Fullname | Submit-atd -Atd_host 192.168.20.140 -Atd_user admin -Atd_pass McAfee123! | select-object sucess, file_name, file_size, md5
sucess file_name file_size md5
------ --------- --------- ---
True codecs.ps1 963 8395B77C7F7ECD46E9FC19152D3E8292
True source-2.bin 561659 CBECAE24EEAAC476CA9F5828AABB0AB6
True source.bin 561659 CBECAE24EEAAC476CA9F5828AABB0AB6
6) Get-ChildItem -path c:\test | select-object @{n='Fullname'; e={$_.FullName}} | Submit-atd -Atd_host 192.168.20.140 -Atd_user admin -Atd_pass McAfee123! | select-object sucess, file_name, file_size, sha256
sucess file_name file_size sha256
------ --------- --------- ------
True codecs.ps1 963 A36E1FE536D1C6A38615D28D8A4A408480.....
True source-2.bin 561659 D66C3A184327B3E675725D1A70844B8A76......
True source.bin 561659 D66C3A184327B3E675725D1A70844B8A76......
That's all, thanks for reading
Comments
Post a Comment