Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/new_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ body:
label: Package type
description: |
- **`ZIP_EXE`** - An executable tool distributed in a ZIP file
- **`INSTALLER_EXE`** - An installer distributed as an EXE file
- **`SINGLE_EXE`** - An executable tool (not an installer for the tool) distributed via direct/raw download
- **`SINGLE_PS1`** - A PowerShell script distributed via direct/raw download
- **`OTHER/UNKNOWN`** - A tool distributed in a different way than the ones described above. For example, an EXE or MSI installer for the tool. It is required that you provide details of how the tool is installed in the `Extra information` section. Note this type does not support automation, a PR would be appreciated!
options:
- ZIP_EXE
- INSTALLER_EXE
- SINGLE_EXE
- SINGLE_PS1
- OTHER/UNKNOWN
Expand Down Expand Up @@ -135,6 +137,12 @@ body:
label: Download SHA256 Hash
description: |
SHA256 hash of the `.zip` file downloaded from the download url introduced in the previous field. The hash is used for verification purposes. Example: `62af5cce80dbbf5cdf961ec9515549334a2112056d4168fced75c892c24baa95 `
- type: input
id: target_file
attributes:
label: Main EXE file
description: |
Main EXE file name or path under the installed tool folder. Example: `bin\x86\tool.exe` or `tool.exe`
- type: input
id: arguments
attributes:
Expand Down
1 change: 1 addition & 0 deletions categories.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ Utilities
Visual Basic
Web Application
Wordlists
VB
62 changes: 62 additions & 0 deletions scripts/utils/create_package_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,21 @@ def package_version(dependency_version):
VM-Install-From-Zip $toolName $category $zipUrl -zipSha256 $zipSha256 -consoleApp ${console_app} -innerFolder ${inner_folder} -arguments $arguments
"""

INSTALLER_EXE_TEMPLATE = r"""$ErrorActionPreference = 'Stop'
Import-Module vm.common -Force -DisableNameChecking

$toolName = '{tool_name}'
$category = VM-Get-Category($MyInvocation.MyCommand.Definition)

$exeUrl = '{target_url}'
$exeSha256 = '{target_hash}'

$toolDir = Join-Path ${{Env:RAW_TOOLS_DIR}} $toolName
$executablePath = (Join-Path $toolDir '{target_file}')
VM-Install-With-Installer $toolName $category "EXE" "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- /Dir=`"$($toolDir)`"" `
$executablePath $exeUrl -sha256 $exeSha256
"""

"""
Needs the following format strings:
tool_name="...", category="..."
Expand Down Expand Up @@ -228,6 +243,17 @@ def package_version(dependency_version):
VM-Uninstall $toolName $category
"""

UNINSTALLER_EXE_TEMPLATE = r"""$ErrorActionPreference = 'Continue'
Import-Module vm.common -Force -DisableNameChecking

$toolName = '{tool_name}'
$category = VM-Get-Category($MyInvocation.MyCommand.Definition)

VM-Uninstall-With-Uninstaller $toolName $category "EXE" "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-"

VM-Uninstall $toolName $category
"""

"""
Needs the following format strings:
tool_name="...", category="..."
Expand Down Expand Up @@ -280,6 +306,23 @@ def create_zip_exe_template(packages_path, **kwargs):
)


def create_installer_exe_template(packages_path, **kwargs):
create_template(
INSTALLER_EXE_TEMPLATE,
uninstall_template=UNINSTALLER_EXE_TEMPLATE,
packages_path=packages_path,
pkg_name=kwargs.get("pkg_name"),
version=kwargs.get("version"),
authors=kwargs.get("authors"),
description=kwargs.get("description"),
tool_name=kwargs.get("tool_name"),
category=kwargs.get("category"),
target_url=kwargs.get("target_url"),
target_hash=kwargs.get("target_hash"),
target_file=kwargs.get("target_file"),
)


def create_node_template(packages_path, **kwargs):
create_template(
NODE_TEMPLATE,
Expand Down Expand Up @@ -388,6 +431,7 @@ def create_template(
category="",
target_url="",
target_hash="",
target_file="",
shim_path="",
dependency="",
console_app="",
Expand Down Expand Up @@ -427,6 +471,7 @@ def create_template(
arguments=arguments,
target_url=target_url,
target_hash=target_hash,
target_file=target_file,
shim_path=shim_path,
console_app=console_app,
inner_folder=inner_folder,
Expand Down Expand Up @@ -476,6 +521,22 @@ def get_script_directory():
"target_hash",
],
},
"INSTALLER_EXE": {
"cb": create_installer_exe_template,
"doc": "An installer distributed as an EXE file",
"example": "<url>/tool.exe",
"arguments": [
"pkg_name",
"version",
"authors",
"description",
"tool_name",
"category",
"target_url",
"target_hash",
"target_file",
],
},
"NODE": {
"cb": create_node_template,
"doc": "An tool from the JavaScript Package Registry installed with npm",
Expand Down Expand Up @@ -627,6 +688,7 @@ def main(argv=None):
parser.add_argument("--dependency", type=str, default="", help="Metapackage dependency")
parser.add_argument("--target_url", type=str, default="", help="URL to target file (zip or executable)")
parser.add_argument("--target_hash", type=str, default="", help="SHA256 hash of target file (zip or executable)")
parser.add_argument("--target_file", type=str, default="", help="EXE name/path under the installed tool folder")
parser.add_argument("--shim_path", type=str, default="", help="Metapackage shim path")
parser.add_argument(
"--console_app",
Expand Down
Loading