NetExec icon indicating copy to clipboard operation
NetExec copied to clipboard

Refactoring nxc path and adding support for XDG Base Directory - addressing issue #558

Open d4ytox opened this issue 9 months ago • 3 comments

Description

  • Refactoring NXC_PATH, CONFIG_PATH and TMP_PATH to be uniformly used accross NetExec - This is a pre-requisite to support XDB Base Directory.
  • Adding support for XDB Base Directory - issue #558

Type of change

Please delete options that are not relevant.

  • [x] New feature (non-breaking change which adds functionality)
  • [x] This change requires a documentation update

How Has This Been Tested?

Ran poetry run netexec and poetry run run python tests/e2e_tests.py. Have also tested by setting XDG_CONFIG_HOME on my machine.

If you are using poetry, you can easily run tests via: poetry run python tests/e2e_tests.py -t $TARGET -u $USER -p $PASSWORD There are additional options like --errors to display ALL errors (some may not be failures), --poetry (output will include the poetry run prepended), --line-num $START-$END $SINGLE for only running a subset

Checklist:

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

d4ytox avatar Apr 18 '25 13:04 d4ytox

Hey reviewers - Would be good to get a quick sanity check from someone before carrying on to the XDG BASE Directory changes. Thanks :)

d4ytox avatar Apr 18 '25 13:04 d4ytox

Thanks for the addition!

NeffIsBack avatar Apr 18 '25 23:04 NeffIsBack

Initially added XDG_DATA_HOME as well but realized that the current DATA_PATH is also used during setup so it makes the setup fail and copying the install files in XDG_DATA_HOME at the beginning of setup seem counterproductive (and not the expected use of XDG_DATA_HOME either). Ultimately I think some of the files stored in the config path could move accross to a new XDG_DATA_HOME dir - but adding XDG_CONFIG_HOME seems enough to be compliant for now. Let me know what you think

d4ytox avatar Apr 20 '25 14:04 d4ytox

A few thoughts:

  • I will move the nxc_hosted to the .nxc folder as well. I don't see a reason why it should be in a separat folder which clobbers the system even more. If there wasn't a good reason to have it somewhere else
  • I think it would be really confusing if we move the .nxc folder suddenly to a whole separat location. However, being able to move it to a new location which is reliable throughout the application is really nice! So i would suggest instead of checking for XDG_CONFIG_HOME we check for our own env var NXC_FOLDER.

Thoughts?

NeffIsBack avatar Jun 10 '25 11:06 NeffIsBack

Beautiful: image image

NeffIsBack avatar Jun 10 '25 12:06 NeffIsBack