BlackArch / blackarch

An ArchLinux based distribution for penetration testers and security researchers.
https://www.blackarch.org
Other
2.78k stars 554 forks source link

peotry package software may spit out this error message : [Errno 13] Permission denied: '/usr/share/netexec/virtualenvs/envs.toml' but has no incidence on tool functionality #4069

Open AkechiShiro opened 7 months ago

AkechiShiro commented 7 months ago

I did not find any existing functionality not working as intended, I'm reporting this bug just for documentation purpose and if someone wants to further investigate a possible fix in the future.


Bug description

netexec run as user after installation cannot read envs.toml in virtualenvs, I don't think this is as intended, or are we supposed to run netexec as root ?

Steps to reproduce

Actual result: Describe here what happens after you run the steps above (i.e. the buggy behaviour) The tool works fine but fails to read this configuration file :

Expected result: Describe here what should happen after you run the steps above (i.e. what would be the correct behaviour) I believe that the tool should have the permission to read this file inside the virtualenvs folder, however I'm not sure about the use case for this file, it seems related to the poetry virtual environment.

Screenshots

Info for developers

GNU/Linux distribution: ArchLinux with BlackArch repositories added. Tool version: v1.1.0.r70.g9df72e2f-1

Link to debug log

[Errno 13] Permission denied: '/usr/share/netexec/virtualenvs/envs.toml'
[*] First time use detected
[*] Creating home directory structure
[*] Creating missing folder logs
[*] Creating missing folder modules
[*] Creating missing folder protocols
[*] Creating missing folder workspaces
[*] Creating missing folder obfuscated_scripts
[*] Creating missing folder screenshots
[*] Copying default configuration file
usage: netexec [-h] [-t THREADS] [--timeout TIMEOUT] [--jitter INTERVAL] [--no-progress] [--verbose] [--debug] [--version]
               {ftp,ldap,mssql,rdp,smb,ssh,vnc,winrm,wmi} ...
noraj commented 7 months ago

I believe that the tool should have the permission to read this file inside the virtualenvs folder

I don't believe this is a read issue. In fact /usr/share/netexec/virtualenvs/envs.toml doesn't exist. On the contrary, I think nxc is trying to create but can't as it's a root / write-protected folder.

➜ ls -lh /usr/share/netexec/virtualenvs/envs.toml                                                                                                                                                                    
ls: cannot access '/usr/share/netexec/virtualenvs/envs.toml': No such file or directory 

Once you executed the tool a root with sudo once, the file is created. You still have the issue after that, but you don't have the issue as long as you run it as root.

➜ sudo nxc…
Using virtualenv: /usr/share/netexec/virtualenvs/netexec-PWU1S8Zj-py3.11   
…

➜ nxc…
[Errno 13] Permission denied: '/usr/share/netexec/virtualenvs/envs.toml'

nxc is able to read it as everyone, but it's writing that is required at each execution.

➜ ls -ls /usr/share/netexec/virtualenvs/envs.toml
4 -rw-r--r-- 1 root root 51 janv. 26 09:21 /usr/share/netexec/virtualenvs/envs.toml

It's not an issue of nxc but rather of the poetry virtualenv.

There is maybe an option to circumvent that with poetry so if you find how, let me know.

AkechiShiro commented 7 months ago

Thanks, I'll try to have a look at poetry and let you know if I find anything, you are correct the file does not exists.

I do agree with you this is an issue with peotry and not netexec.