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

still recognice issue with os.geteuid() in Windows 10 21H1 #56

Closed
MrEnergy64 opened this issue Aug 14, 2021 · 5 comments
Closed

still recognice issue with os.geteuid() in Windows 10 21H1 #56

MrEnergy64 opened this issue Aug 14, 2021 · 5 comments

Comments

@MrEnergy64
Copy link
Contributor

MrEnergy64 commented Aug 14, 2021

We still identify the issue that your python3-nmap is using "os.geteuid()" which is not exist in Windows 10 (21H1) anymore:

File "C:\Users\mrene\Documents\PYTHON\ncurses-IPventur.py", line 389, in scannen
results = nmap.nmap_os_detection(f'{ip}')
File "C:\Users\mrene\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nmap3\utils.py", line 74, in wrapper
if(os.geteuid() == 0):
AttributeError: module 'os' has no attribute 'geteuid'

Therefore actual you cannot do these scans under Windows 10:

nmap_detect_firewall
nmap_os_detection
nmap_stealth_scan
nmap.nmap_os_detection

In our python3-nmap front ncurses-IPventur we use this workaround with win32api.GetConsoleTitle(). Or do you have another solution instead of os.getuid? python-nmap3 version is: 1.4.9

os_version = platform.system()
if os_version == "Windows":
ScreenDel = "cls"
import win32api
check = win32api.GetConsoleTitle()
cmd = "where" if platform.system() == "Windows" else "which"
if "Administrator" in check:
User = "Administrator"
return os_version, User, ScreenDel, cmd
else:
User = "Normal User - limited scan"
return os_version, User, ScreenDel, cmd
else:
ScreenDel = "clear"
cmd = "where" if platform.system() == "Windows" else "which"
if os.geteuid()==0:
User = "Root User"
return os_version, User, ScreenDel, cmd
else:
User = "Normal User - limited scan"
return os_version, User, ScreenDel, cmd

@latest-release
Copy link
Contributor

This issue was solved, please install the github version.

@MrEnergy64
Copy link
Contributor Author

MrEnergy64 commented Aug 14, 2021

OK, so the normal install-able version is not the github version? OK, let me try first. Then I need to update the README.md as well.
Ah, stop, I used the github version:

python3-nmap:

$ git clone https://github.com/wangoloj/python3-nmap.git

$ pip3 install -r requirements.txt

So, I guess git clone https://github.com/wangoloj/python3-nmap.git is not https://github.com/nmmapper/python3-nmap.

I will check it now....

OK, when I check the version, it is still python-nmap3 version is: 1.4.9

udp scan is still not working (user is administrator):
File "C:\Users\mrene\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nmap3\nmap3.py", line 88, in default_command_privileged
return self.default_command()
File "C:\Users\mrene\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nmap3\nmap3.py", line 77, in default_command
return self.default_command_privileged()
RecursionError: maximum recursion depth exceeded

tcp-scan is working now....
but fw scan has a new issue:

File "C:\Users\mrene\Documents\PYTHON\ncurses-IPventur.py", line 418, in scannen
results = nmap.nmap_os_detection(f'{ip}')
File "C:\Users\mrene\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nmap3\utils.py", line 80, in wrapper
if(is_root_or_admin):
UnboundLocalError: local variable 'is_root_or_admin' referenced before assignment

portscan is working (as administrator)....

stealth-scan same issue like fw scan (user is still admin):

File "C:\Users\mrene\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\nmap3\utils.py", line 80, in wrapper
if(is_root_or_admin):
UnboundLocalError: local variable 'is_root_or_admin' referenced before assignment

arp-scan is working (as Admin)....
and nmap_version_scan seems to be OK as well.

I did the scan test always as Administrator:

image

I will do test now with admin and none admin rights, just for Win10....

@nmmapper
Copy link
Owner

Alright I see a typo. change is_admin to is_root_or_admin Will fix and commit. If you can do it before me and make a pull request

try:
            is_root_or_admin = (os.getuid() == 0)
        except AttributeError as e:
            is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0
            
        if(is_root_or_admin):
            return func(*args, **kwargs)

@MrEnergy64
Copy link
Contributor Author

MrEnergy64 commented Aug 15, 2021 via email

@MrEnergy64
Copy link
Contributor Author

did pull request for utils.py

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

3 participants