forked from kevoreilly/CAPEv2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix exit parent and LNK package from cmd to powershell (kevoreilly#2256)
* prevent analysis end with blocking shell * some LNK do not run when detonated by cmd. * Update lnk.py * fix test * fix lint
- Loading branch information
Showing
3 changed files
with
12 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (C) 2010-2015 Cuckoo Foundation, Optiv, Inc. ([email protected]) | ||
# Copyright (C) 2010-2015 Cuckoo Foundation. | ||
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org | ||
# See the file 'docs/LICENSE' for copying permission. | ||
|
||
|
@@ -7,23 +7,18 @@ | |
|
||
|
||
class LNK(Package): | ||
"""LNK analysis package.""" | ||
"""Windows LNK analysis package via powershell.""" | ||
|
||
PATHS = [ | ||
("SystemRoot", "system32", "cmd.exe"), | ||
# PS <= 5 | ||
("SystemRoot", "sysnative", "WindowsPowerShell", "v*.0", "powershell.exe"), | ||
("SystemRoot", "system32", "WindowsPowerShell", "v*.0", "powershell.exe"), | ||
] | ||
summary = "Executes a .lnk file using cmd.exe." | ||
description = """Uses cmd.exe with the "/wait" option to run a .lnk file. | ||
For context behind this command: | ||
/C Carries out the command specified by string and then terminates | ||
START Starts a separate window to run a specified program or command. | ||
/WAIT Start application and wait for it to terminate. | ||
"" The name of the separate window | ||
"path" The path of the uploaded sample | ||
The .lnk extension will be added automatically.""" | ||
summary = "Executes a sample file with powershell." | ||
description = "Uses 'powershell Start-Process -FilePath <sample>' to run a .lnk file." | ||
|
||
def start(self, path): | ||
powershell = self.get_path_glob("PowerShell") | ||
path = check_file_extension(path, ".lnk") | ||
cmd_path = self.get_path("cmd.exe") | ||
cmd_args = f'/c start /wait "" "{path}"' | ||
return self.execute(cmd_path, cmd_args, path) | ||
args = f'Start-Process -FilePath "{path}"' | ||
return self.execute(powershell, args, path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters