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

sudo command is not executed #100

Open
Luciogi opened this issue Aug 5, 2024 · 3 comments
Open

sudo command is not executed #100

Luciogi opened this issue Aug 5, 2024 · 3 comments

Comments

@Luciogi
Copy link

Luciogi commented Aug 5, 2024

    @user_is_root
    def nmap_os_detection(self, target, arg="-O", args=None):  # requires root
        """
        nmap -oX - nmmapper.com -O
        NOTE: Requires root
        """
        xml_root = self.scan_command(target=target, arg=arg, args=args)
        results = self.parser.os_identifier_parser(xml_root)
        return results

@user_is_root exits control before scan_command(...) is executed (which run sudo nmap ...)

And

return self.default_args.format(nmap=self.nmaptool, outarg="-oX")

should be as

return self.default_args.format(nmap="sudo "+self.nmaptool, outarg="-oX")
@nmmapper
Copy link
Owner

nmmapper commented Aug 5, 2024

Good suggestion, though i don't think it's a good idea to hard code sudo command like that. Any other solution is welcome

@Luciogi
Copy link
Author

Luciogi commented Aug 5, 2024

We can make Variable PRIVILEGE_CMD="sudo".
There are other alternatives for sudo like doas
to handle that we can make condition as in pseudo code

if ( PRIVILEGE_CMD is empty):
    PRIVILEGE_CMD="sudo"
else:
    PRIVILEGE_CMD=readFromEnvironment()

I have not searched how can be this useful for gui apps with polkit to get root privileges

@nmmapper
Copy link
Owner

nmmapper commented Aug 8, 2024

The library was designed to be a little easier to use, if possible the decorate user_is_root returns Json, is there a way you can use the returned json to determine how to use sudo?

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

No branches or pull requests

2 participants