Skip to content

Commit

Permalink
Merge branch 'feature/check-perm' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
SkypLabs committed Mar 19, 2023
2 parents 119401d + 000f131 commit ecbeb0b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/probequest/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

from . import __version__ as VERSION
from .config import Config
from .exceptions import InterfaceDoesNotExistException
from .exceptions import DependencyNotPresentException
from .exceptions import (DependencyNotPresentException,
InterfaceDoesNotExistException)
from .exporters.csv import ProbeRequestCSVExporter
from .probe_request_filter import ProbeRequestFilter
from .probe_request_parser import ProbeRequestParser
Expand Down Expand Up @@ -155,6 +155,19 @@ def build_cluster(config):
return engine


def check_permissions() -> bool:
"""
Check the user permissions to ensure the network trafic can be captured.
For now, this function only checks if the current user is root.
"""

if geteuid() == 0:
return True

return False


def main():
"""
Entry point of the command-line tool.
Expand Down Expand Up @@ -210,9 +223,9 @@ def main():
logger.debug("Memory handler closed")

# -------------------------------------------------- #
# Checking privileges
# Check permissions
# -------------------------------------------------- #
if not geteuid() == 0:
if not config.fake and not check_permissions():
logger.critical("User needs to be root to sniff the traffic")
sys_exit("[!] You must be root")

Expand Down
2 changes: 2 additions & 0 deletions src/probequest/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class Config:
Configuration object.
"""

# pylint: disable=too-many-instance-attributes

_interface = None

essid_filters = None
Expand Down

0 comments on commit ecbeb0b

Please sign in to comment.