pax_global_header00006660000000000000000000000064146453474760014536gustar00rootroot0000000000000052 comment=68c148281a2d4b4fa7d70d6d447b2a8932b1dbee getmac-0.9.5/000077500000000000000000000000001464534747600130115ustar00rootroot00000000000000getmac-0.9.5/.coveragerc000066400000000000000000000002541464534747600151330ustar00rootroot00000000000000# Temporary hack until we remove shutilwhich with removal of Python 2 # TODO: move relative_files into tox.ini [run] relative_files = True omit = getmac/shutilwhich.py getmac-0.9.5/.editorconfig000066400000000000000000000012421464534747600154650ustar00rootroot00000000000000# https://editorconfig.org/ root = true [*] indent_style = space indent_size = 4 end_of_line = lf charset = utf-8 # Docstrings and comments use max_line_length = 79 [*.py] max_line_length = 99 insert_final_newline = true trim_trailing_whitespace = true # Use 2 spaces for the HTML files [*.{yml,yaml}] indent_size = 2 # The JSON files contain newlines inconsistently [*.json] indent_size = 2 insert_final_newline = unset # Makefiles always use tabs for indentation [Makefile] indent_style = tab [*.ps1] end_of_line = crlf [Vagrantfile] indent_size = 2 # Ignore formatting for samples [**/tests/samples/**] indent_style = unset indent_size = unset end_of_line = unsetgetmac-0.9.5/.gitattributes000066400000000000000000000022711464534747600157060ustar00rootroot00000000000000# Source: https://github.com/alexkaratarakis/gitattributes * text=auto *.py text eol=lf *.md text eol=lf # Samples tests/samples/**/*.out text eol=lf tests/samples/*.out text eol=lf tests/samples/windows*/*.out text eol=crlf # Windows *.ps1 text eol=crlf *.bat text eol=crlf # POSIX *.sh text eol=lf *.bash text eol=lf *.1 text eol=lf packaging/*.spec text eol=lf Makefile text eol=lf # Documents *.doc diff=astextplain *.DOC diff=astextplain *.docx diff=astextplain *.DOCX diff=astextplain *.dot diff=astextplain *.DOT diff=astextplain *.pdf diff=astextplain *.PDF diff=astextplain *.rtf diff=astextplain *.RTF diff=astextplain *.adoc text *.textile text *.mustache text *.csv text *.tab text *.tsv text *.sql text # Graphics *.png binary *.jpg binary *.jpeg binary *.gif binary *.tif binary *.tiff binary *.ico binary # SVG treated as an asset (binary) by default. If you want to treat it as text, # comment-out the following line and uncomment the line after. *.svg binary #*.svg text *.eps binary getmac-0.9.5/.github/000077500000000000000000000000001464534747600143515ustar00rootroot00000000000000getmac-0.9.5/.github/ISSUE_TEMPLATE/000077500000000000000000000000001464534747600165345ustar00rootroot00000000000000getmac-0.9.5/.github/ISSUE_TEMPLATE/bug_report.md000066400000000000000000000011571464534747600212320ustar00rootroot00000000000000--- name: Bug report about: Report errors, bugs, or anything else that isn't working as expected. --- **Describe the bug** A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior [if applicable]. **Expected behavior** A clear and concise description of what you expected to happen. **System info** (please complete the following information): - OS name (e.g. Windows 10 x64): - OS Version (e.g. 1804 build 17134): - Python version (e.g. CPython 3.6.5 x64): - getmac version (e.g. getmac 0.8.3): **Additional context** Add any other context about the problem here. getmac-0.9.5/.github/ISSUE_TEMPLATE/config.yml000066400000000000000000000002721464534747600205250ustar00rootroot00000000000000blank_issues_allowed: true contact_links: - name: Have a general question or comment? url: "https://github.com/GhostofGoes/getmac/discussions" about: Open a discussion thread! getmac-0.9.5/.github/pull_request_template.md000066400000000000000000000014141464534747600213120ustar00rootroot00000000000000### All Submissions: - [ ] Have you followed the guidelines in our Contributing document? - [ ] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change? - [ ] Have you added an explanation of what your changes do and why you'd like us to include them? ### Code changes: - [ ] Did you format your code with Black? - `black getmac tests` - [ ] Are the linting checks passing? - `tox -e check` - [ ] Do all tests pass locally? - `tox` - [ ] Have you updated the [CHANGELOG](CHANGELOG.md) with a summary of your change? - [ ] Did you add your name to the contributors list in the [README](README.md)? ### Summary of changes: - getmac-0.9.5/.github/workflows/000077500000000000000000000000001464534747600164065ustar00rootroot00000000000000getmac-0.9.5/.github/workflows/ci.yml000066400000000000000000000113711464534747600175270ustar00rootroot00000000000000name: CI on: - release - push - pull_request jobs: lint: name: Run lint checks runs-on: ubuntu-20.04 # Workaround to disable pip upgrade warnings until fixed in setup-python # See: https://github.com/actions/setup-python/issues/532 env: PIP_DISABLE_PIP_VERSION_CHECK: 1 steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: "3.8" - name: Install tox run: python -m pip install tox - name: Run lint checks run: tox -e check test: name: Run tests runs-on: ${{ matrix.platform }} # Workaround to disable pip upgrade warnings until fixed in setup-python # See: https://github.com/actions/setup-python/issues/532 env: PIP_DISABLE_PIP_VERSION_CHECK: 1 strategy: fail-fast: false # Versions available: # pypy: https://downloads.python.org/pypy/versions.json # Python: https://github.com/actions/python-versions/blob/main/versions-manifest.json # Additional info: https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md # OS images: https://github.com/actions/runner-images matrix: python-version: - "3.7" - "3.8" - "3.9" - "pypy-3.7" - "pypy-3.8" - "pypy-3.9" architecture: - x86 - x64 platform: - ubuntu-20.04 - windows-latest # Fix tests failing on MacOS 14+ due to ARM architecture # https://github.com/actions/setup-python/issues/825 # TODO: update tests to use ARM MacOS with 14+, add # architecture to the list of architectures above. - macos-13 exclude: - platform: ubuntu-20.04 architecture: x86 - platform: macos-13 architecture: x86 - platform: macos-13 python-version: "pypy-3.7" - platform: macos-13 python-version: "pypy-3.8" steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} architecture: ${{ matrix.architecture }} - name: Display platform and environment information run: | python --version python -c "import sys; print('sys.version: %s' % str(sys.version))" python -c "import sys; print('sys.platform: %s' % str(sys.platform))" python -c "import os; print('os.name: %s' % str(os.name))" python -c "import platform; print('platform.uname(): %s' % str(platform.uname()))" - name: Install dependencies run: python -m pip install tox coveralls tox-gh-actions # TODO: fix benchmark results (maybe a separate Job?) - name: Run tests run: tox - uses: codecov/codecov-action@v3 with: # codecov is annoying. Not sure why I'm still using it, # may need to look at something that has less heisenbugs. # https://community.codecov.com/t/ci-failure-due-to-too-many-uploads-to-this-commit/2587/12 fail_ci_if_error: false - name: Coveralls if: ${{ matrix.platform == 'ubuntu-20.04' && github.event_name != 'pull_request' }} uses: AndreMiras/coveralls-python-action@develop with: parallel: true flag-name: ${{ matrix.python-version }}-${{ matrix.platform }} coveralls_finish: needs: test runs-on: ubuntu-20.04 steps: - name: Coveralls Finished if: ${{ github.event_name != 'pull_request' }} uses: AndreMiras/coveralls-python-action@develop with: parallel-finished: true # TODO: publish # TODO: need to do this for both "getmac" and "get-mac" packages # TODO: don't publish pre-releases OR publish them as pre-releases to PyPI # https://github.com/marketplace/actions/upload-a-build-artifact # name: "Build and publish a release" # on: # release: # types: [released] # jobs: # publish: # name: "📦 Publish Python distributions" # runs-on: "ubuntu-20.04" # strategy: # matrix: # python-version: # - "3.8" # steps: # - uses: actions/checkout@v3 # - name: "🐍 Set up Python ${{ matrix.python-version }}" # uses: actions/setup-python@v4 # with: # python-version: "${{ matrix.python-version }}" # - name: "🐍 Install wheel" # run: "python -m pip install wheel --user" # - name: "🐍 Build a binary wheel and a source tarball" # run: "python setup.py sdist bdist_wheel" # - name: "📦 Publish distribution to PyPI" # uses: "pypa/gh-action-pypi-publish@master" # if: "startsWith(github.ref, 'refs/tags')" # with: # password: "${{ secrets.pypi_password }}" getmac-0.9.5/.github/workflows/codeql-analysis.yml000066400000000000000000000044351464534747600222270ustar00rootroot00000000000000# For most projects, this workflow file will not need changing; you simply need # to commit it to your repository. # # You may wish to alter this file to override the set of languages analyzed, # or to provide custom queries or build logic. # # ******** NOTE ******** # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # name: "CodeQL" on: push: branches: [ main ] pull_request: # The branches below must be a subset of the branches above branches: [ main ] schedule: - cron: '19 17 * * 0' jobs: analyze: name: Analyze runs-on: ubuntu-20.04 permissions: actions: read contents: read security-events: write strategy: fail-fast: false matrix: language: [ 'python' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://git.io/codeql-language-support steps: - name: Checkout repository uses: actions/checkout@v2 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v2 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines # and modify them (or add more) to build your code if your project # uses a compiled language #- run: | # make bootstrap # make release - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 getmac-0.9.5/.gitignore000066400000000000000000000024131464534747600150010ustar00rootroot00000000000000.idea/ .vscode/ .vagrant/ .pytest_cache # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python env/ build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ *.egg-info/ .installed.cfg *.egg deb_dist/ # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest #*.spec as rpm wants .spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover .hypothesis/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # pyenv .python-version # celery beat schedule file celerybeat-schedule # SageMath parsed files *.sage.py # dotenv .env # virtualenv .venv venv/ ENV/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ /docs/man/.doctrees/ # Profiling output from cProfile *.prof getmac-0.9.5/CHANGELOG.md000066400000000000000000000427341464534747600146340ustar00rootroot00000000000000# Changelog **NOTE**: if any changes significantly impact your project or use case, please open an issue on [GitHub](https://github.com/GhostofGoes/getmac/issues) or email me (see git commit author info for address). **Announcement**: Compatibility with Python versions older than 3.7 (2.7, 3.4, 3.5, and 3.6) is deprecated and will be removed in getmac 1.0.0. If you are stuck on an unsupported Python, consider loosely pinning the version of this package in your dependency list, e.g. `getmac<1.0.0` or `getmac~=0.9.0`. ## 0.9.5 (07/15/2024) ### Changed * Fixed macOS arp when MAC has one character sections in specific cases (Fixes issue #92) ## 0.9.4 (06/01/2023) ### Added * Support BusyBox's ``arping`` ### Changed * Improve how ARP is handled. If ``ArpFile`` method succeeds, use it instead of ``ArpingHost`` (this should fix [#86](https://github.com/GhostofGoes/getmac/issues/86), for realsies this time). * Speed up the first call to ``ArpingHost`` * Fix FORCE_METHOD not being respected for IPv4 macs ## 0.9.3 (03/16/2023) ### Changed * Fix `ArpFile` method being used for IPv6 (`/proc/net/arp`, and ARP in general, is IPv4-only) ## 0.9.2 (02/03/2023) ### Changed * Fix flakiness with UuidArpGetNode on MacOS by making it the last method attempted (Fixes issue [#82](https://github.com/GhostofGoes/getmac/issues/82)) ## 0.9.1 (01/24/2023) ### Changed * Deprecate Python 3.6 support (support will be removed in getmac 1.0.0) ### Dev * Fix links in README and PyPI metadata to use "main" instead of "master" for primary branch * Remove "Documentation" link from PyPI (the ReadTheDocs site is broken and hasn't been updated since 0.5.0) * Add PyPI classifiers for 3.10 and 3.11 * Some cleanup of CHANGELOG ## 0.9.0 (01/23/2023) This release is a *complete rewrite of getmac from the ground up*. The public API of `getmac` is **unchanged** as part of this rewrite. `get_mac_address()` is still the primary way of getting a MAC address, it's just the "under the hood" internals that have changed completely. It's passing tests and seems to be operable. However, with a change this large there are inevitably issues that the tests or I don't catch, so I'm doing a series of pre-releases until I'm 99% confident in it's stability. Refer to `docs/rewrite.md` for a in-depth explanation of the rewrite changes. The new system has a number of benefits - Reduction of false-positives and false-negatives by improving method selection accuracy (platform, validity, etc.) - *Significantly* faster overall - "Misses" have the same performance as "Hits" - Easier to test, since each method can be tested directly via it's class - Easier to type annotate and analyze with mypy - Easier to read, improving reviewability and ease of contributing for newcomers - Extensible! Custom methods can be defined and added at runtime (which is perfect if you have some particular edge case but aren't able to open-source it). ### Added * Fully support Python 3.9 (automated tests in CI) * Tentatively support Python 3.10 and 3.11 (unable to test due to the need to be able to still test 2.7) * Added default interface detection for MacOS (command: `route get default`) * Added initial support for Solaris/SunOS. There were a few existing methods that worked as-is, so just added indicators that those methods support `sunos` (Which applies to any system where `platform.system() == SunOS`). * `arping` (POSIX) or `SendARP` (Windows) will now *always* be used instead of sending a UDP packet when looking for the MAC of a IPv4 host, if they're available and operable (otherwise, UDP + ARP table check will be used like before). * The amount of time taken to get a result (in seconds) will now be recorded and logged if debugging is enabled (`DEBUG>=1` or `-d`) * Added command line argument to override the UDP port for network requests: `--override-port` (this was already possible in Python via `getmac.getmac.PORT`, but wasn't configurable via the CLI. Now it is!). * Added ability to override the detected platform via `--override-platform` argument (CLI) or `getmac.getmac.OVERRIDE_PLATFORM` variable (Python). This will force methods for that platform to be used, regardless of the actual platform. Here's an example forcing `linux` to be used as the platform: `getmac -i eth0 --override-platform linux`. In version 1.0.0, this feature will added as an argument to `get_mac_address()`. * Added ability to force a specific method to be used via `--force-method` argument (CLI) or `getmac.getmac.FORCE_METHOD` variable (Python). This is useful for troubleshooting issues, general debugging, and testing changes. Example: `getmac -v -dddd --ip 192.168.0.1 --force-method ctypeshost` ### Changed * **Complete rewrite of `getmac` from the ground up. Refer to `docs/rewrite.md` for a in-depth explanation of the rewrite changes** * Fixed a failure to look up a hostname now returns `None`, as expected, instead of raising an exception (`socket.gaierror`). * Fixed numerous false-negative and false-positive bugs * Improved overall performance * Performance for cases where no MAC is found is now the same as cases where a MAC is found (speed of "misses" now equals that of "hits") * Improved the reliability and performance of many methods * Fixed `netstat` on older Linux distros (such as Ubuntu 12.04) * Overhauled `ifconfig` parsing. It should now be far more reliable and accurate across all platforms. * Improved Android support. Note that newer devices are locked down and the amount of information that's obtainable by an unprivileged process is quite limited (Android 7/9 and newer, not sure exactly when they changed this, I'm not an Android guy). That being said, the normal Linux methods should work fine, provided you have the proper permissions (usually, `root`). * Fixed bug with `/proc/net/route` parsing (this affected Android and potentially other platforms) * Improve default interface detection for FreeBSD (command: `route get default`) ### Removed * Removed man pages from distribution (`getmac.1`/`getmac2.1`). They were severely out of date and unused. May re-add at a later date. ### Dev * Migrate CI to GitHub Actions, remove TravisCI and Appveyor * Add flake8 plugins: `flake8-pytest-style` and `flake8-annotations` * Add additional samples and tests for WSL1 (with the Ubuntu 18.04 distro) * Add additional samples for Windows 10 * Add additional samples for MacOS * Add samples and tests for Ubuntu 12.04 * Add samples for NetBSD 8 (support coming in a future release) * Add samples for Solaris 10 (support TBD) * Add samples for several versions of Android * Add new tests * Improve existing tests * Consolidate everything related to RPM packaging to `packaging/rpm/`. This stuff hasn't been updated since 0.6.0, may remove in the future and leave distro packaging to distro maintainers. ## 0.8.3 (12/10/2021) ### Changed * Added support for Thomas Habets' version of `arping` in addition to the existing iputils one (contributed by Ville Skyttä (@scop) in [#52](https://github.com/GhostofGoes/getmac/pull/52) and [#54](https://github.com/GhostofGoes/getmac/pull/54)) * Added support for docker in network bridge mode (contributed by Tomasz Duda (@tomaszduda23) in [#57](https://github.com/GhostofGoes/getmac/pull/57)) * Add CHANGELOG URL to PyPI metadata (contributed by Ville Skyttä (@scop) in [#58](https://github.com/GhostofGoes/getmac/pull/58)) * Fixed code quality test suite errors (includes changes by Daniel Flanagan (@FlantasticDan) in [#67](https://github.com/GhostofGoes/getmac/pull/67)) * Improved Android support (contributed by @emadmahdi in [#71](https://github.com/GhostofGoes/getmac/pull/71)) * Minor code quality fixes (2 years of neglecting master branch) * Add [Code of Conduct](https://github.com/GhostofGoes/getmac/blob/main/CODE_OF_CONDUCT.md) for project contributors * Add [SECURITY.md](https://github.com/GhostofGoes/getmac/blob/main/SECURITY.md) for reporting security issues (e.g. vulnerabilities) * Deprecate Python 3.4 and 3.5 * Issue deprecation message as a warning in addition to a log message ## 0.8.2 (12/07/2019) ### Changed * Added warning about Python 2 compatibility being dropped in 1.0.0 * Officially support Python 3.8 * Documented a known issue with looking up IP of a local interface on Linux/WSL (See the "Known Issues" section in the README) * Added remote host lookup using `arping` as last resort ### Dev * Standardized formatting on [Black](https://github.com/psf/black) * Lint additions: `vulture`, several Flake8 plugins * Pinned test dependencies (pytest 5 dropped Python 2 support) * Various quality-of-life improvements for contributors/developers ## 0.8.1 (05/14/2019) ### Changed * Fixed sockets being opened and not closed when `ip` or `ip6` were used, which could lead to a `ResourceWarning` (GH-42) ## 0.8.0 (04/09/2019) ### Added * OpenBSD support * FreeBSD support * Python logging is now used instead of `print` (logger: `getmac`) * Include tests in the source distribution * (CLI) Added aliases for `--no-network-requests`: `-N` and `--no-net` * (CLI) New argument: `-v`/`--verbose` ### Changed * Errors are now logged instead of raising a `RuntimeWarning` * Improved Ubuntu support * Performance improvements ### Development * Significant increase in overall test coverage * Fixed and migrated the sample tests to `pytest` * Added tests for the CLI ## 0.7.0 (01/27/2019) ### Added * Type annotations (PEP 484) ### Removed * Dropped support for Python 2.6 * Removed the usage of third-party packages (`netifaces`, `psutil`, `scapy`, and `arpreq`). This should improve the performance of lookups of non-existent interfaces or hosts, since this feature was punishing that path without providing much value. If you want to use these packages directly, I have a guide on how to do so on a [GitHub Gist](https://gist.github.com/GhostofGoes/0a8e82930e75afcefbd879a825ba4c26). ### Changed * Significantly improved the performance of the common cases on Linux for interfaces and remote hosts * Improved POSIX interface performance. Commands specific to OSX will be run only on that platform, and vice-versa. * Significantly improved the speed and accuracy of determining the default interface on Linux * Python 2 will install an executor named getmac2 and Python 3 an executor named getmac so they do not conflict when both RPMs are installed on the same system (Credit: @hargoniX) * The `warnings` module will only be imported if a error/warning occurs (improve compatibility with some freezers, notably PyInstaller) * Improved system platform detection * Various other minor performance improvements ### Development * Added unit tests for the samples (Credit: @Frizz925) * Scripts for building RPMs in the /scripts directory (Credit: @hargoniX) * Improved code quality and health checks * Include the CHANGELOG on the PyPI project page * Using `pytest` for all tests now instead of `unittest` ### Documentation * Added instructions on how to build a Debian package (Credit: @kofrezo) ## 0.6.0 (10/06/2018) ### Added * Windows default interface detection if `network_request` is enabled (Credit: @cyberhobbes) * Docker container (Credit: @Komish) ### Changed * Changed project name to `getmac`. This applies to the command line tool, GitHub, and the documentation. * Use proper Python 2-compatible print functions (Credit: @martmists) ### Removed * Support for Python 2.5. It is not feasible to test, and potentially breaks some useful language features, such as `__future__` * Variables PORT and DEBUG from top-level package imports, since changing them would have no actual effect on execution. Instead, use `getmac.getmac.DEBUG`. ### Dev * Added example videos demonstrating usage (Credit: @fortunate-man) * Added contribution guide * Added documentation on ReadTheDocs * Added a manpage ## 0.5.0 (09/24/2018) ### Added * Full support for Windows Subsystem for Linux (WSL). This is working for all features, including default interface selection! The only edge case is lookup of remote host IP addresses that are actually local interfaces will not resolve to a MAC (which should be ff-ff-ff-ff-ff-ff). ### Changed * Require `argparse` if Python version is 2.6 or older ### Dev * Updated tox tests: added Jython and IronPython, removed 2.6 ## 0.4.0 (09/21/2018) ### Added * New methods for remote host MACs * Windows: `arp` * POSIX: `arpreq` package * New methods for interface MACs * Windows: `wmic nic` * DEBUG levels: DEBUG value is now an integer, and increasing it will increase the amount and verbosity of output. On the CLI, it can be configured by increasing the amount of characters for the debug argument, e.g. '-dd' for DEBUG level 2. * Jython support (Note: on Windows Jython currently only works with interfaces) * IronPython support ### Changed * **Significant** performance improvement for remote hosts. Previously, the average for `get_mac_address(ip='10.0.0.100')` was 1.71 seconds. Now, the average is `12.7 miliseconds`, with the special case of a unpopulated arp table being only slightly higher. This was brought about by changes in how the arp table is populated. The original method was to use the host's `ping` command to send an ICMP packet to the host. This took time, which heavily delayed the ability to actually get an address. The solution is to instead simply send a empty UDP packet to a high port. The port this packet is sent to can be configured using the module variable `getmac.PORT`. * "Fixed" resolution of localhost/127.0.0.1 by hardcoding the response. This should resolve a lot of problematic edge cases. I'm ok with this for now since I don't know of a case when it isn't all zeroes. * Greatly increased the reliability of getting host and interface MACs on Windows * Improved debugging output * Tightened up the size of `getmac.py` * Various minor stability and performance improvements * Add LICENSE to PyPI package ### Removed * Support for Python 3.2 and 3.3. The total downloads from PyPI with those versions in August was ~53k and ~407K, respectfully. The majority of those are likely from automated testing (e.g. TravisCI) and not actual users. Therefore, I've decided to drop support to simplify development, especially since before 3.4 the 3.x series was still very much a "work in progress". ### Dev * Added automated tests for Windows using Appveyor * Tox runner for tests * Added github.io page * Improved TravisCI testing ## 0.3.0 (08/30/2018) ### Added * Attempt to use Python modules if they're installed. This is useful for larger projects that already have them installed as dependencies, as they provide a more reliable means of getting information. * `psutil`: Interface MACs on all platforms * `scapy`: Interface MACs and Remote MACs on all platforms * `netifaces`: Interface MACs on Non-Windows platforms * New methods for remote MACs * POSIX: `ip neighbor show`, Abuse of `uuid._arp_getnode()` * New methods for Interface MACs * POSIX: `lanscan -ai` (HP-UX) ### Changed * Certain critical failures that should never happen will now warn instead of failing silently. * Added a sanity check to the `ip6` argument (IPv6 addresses) * Improved performance in some areas * Improved debugging output ### Fixed * Major Bugfix: search of `proc/net/arp` would return shorter addresses in the same subnet if they came earlier in the sequence. Example: a search for `192.168.16.2` on Linux would instead return the MAC address of `192.168.16.254` with no errors or warning whatsoever. * Significantly improved default interface detection. Default interfaces are now properly detected on Linux and most other POSIX platforms with `ip` or `route` commands available, or the `netifaces` Python module. ### Dev * Makefile * Vagrantfile to spin up testing VMs for various platforms using [Vagrant](https://www.vagrantup.com/docs/) * Added more samples of command output on platforms (Ubuntu 18.04 LTS) ## 0.2.4 (08/26/2018) ### Fixed * Fixed identification of remote host on OSX * Resolved hangs and noticeable lag that occurred when "network_request" was True (the default) ## 0.2.3 (08/07/2018) ### Fixed * Remote host for Python 3 on Windows ## 0.2.2 ### Added * Short versions of CLI arguments (e.g. "-i" for "--interface") ### Changed * Improved usage of "ping" across platforms and IP versions * Various minor tweaks for performance * Improved Windows detection ### Fixed * Use of ping command with hostname ### Dev: * Improvements to internal code ## 0.2.1 Nothing changed. PyPI just won't let me push changes without a new version. ## 0.2.0 (04/15/2018) ### Added * Checks for default interface on Linux systems * New methods of hunting for addresses on Windows, Mac OS X, and Linux ### Changed * CLI will output nothing if it failed, instead of "None" * CLI will return with 1 on failure, 0 on success * No CLI arguments now implies the default host network interface * Added an argumnent for debugging: `--debug` * Removed `-d` option from `--no-network-requests` ### Fixed * Interfaces on Windows and Linux (including Bash for Windows) * Many bugs ### Removed * Support for Python 2.6 on the CLI ### Dev * Overhaul of internals ## 0.1.0 (04/15/2018): ### Added * Addition of a terminal command: `get-mac` * Ability to run as a module from the command line: `python -m getmac` ### Changed * `arp_request` argument was renamed to `network_request` * Updated docstring * Slight reduction in the size of getmac.py ### Dev * Overhauled the README * Moved tests into their own folder * Added Python 3.7 to list of supported snakes ## 0.0.4 (11/12/2017): * Python 2.6 compatibility ## 0.0.3 (11/11/2017): * Fixed some addresses returning without colons * Added more rigorous checks on addresses before returning them ## 0.0.2 (11/11/2017): * Remove print statements and other debugging output ## 0.0.1 (10/23/2017): * Initial pre-alpha getmac-0.9.5/CODE_OF_CONDUCT.md000066400000000000000000000121471464534747600156150ustar00rootroot00000000000000# Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience * Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: * The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or email address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at ghostofgoes@gmail.com. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning **Community Impact**: A violation through a single incident or series of actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. getmac-0.9.5/CONTRIBUTING.md000066400000000000000000000114541464534747600152470ustar00rootroot00000000000000# Contributing to getmac Thanks for taking an interest in this awesome little project. We love to bring new members into the community, and can always use the help. ## Resources * Task tracking and Bug reports: [GitHub](https://github.com/GhostofGoes/getmac/issues) * Discussion: the [Python Discord server](https://discord.gg/python) # Code requirements * Must work under all supported Python versions (2.7 and 3.4+) * Must work on all supported platforms (if applicable) * Try to match the general code style (loosely PEP8) * Be respectful. Memes, references, and jokes are ok. Explicit language (cursing/swearing), NSFW text/content, or racism are NOT ok. ## Checklist before submitting a pull request * [ ] Code is formatted using `black` (`black getmac tests`) * [ ] All tests run and pass locally * [ ] `tox` * [ ] `tox -e check` * [ ] Update the [CHANGELOG](CHANGELOG.md) (For non-trivial changes, e.g. changing functionality or adding tests) * [ ] Add your name to the contributors list in the [README](README.md) ## Checklist before a Pull Request will be merged * [ ] *All* tests pass in GitHub Actions * [ ] Code has been reviewed by at least one maintainer # Where to contribute ## Good for beginners * Sample collection (see section below) * Platform testing (see section below) * Bug reports! * Documentation (including fixes for grammar and spelling) * Improving and adding tests for existing samples ## Main areas of focus * Writing parsers for new commands (Example: `netsh int ipv6`) * Addressing missing functionality (Example: default interface detection for IPv6 on Windows) * Adding new features (Example: ability to find MAC by interface index integer) * Adding tests for internal methods and mocking where necessary ## Platform testing Help is dearly needed on testing and rooting out differences in various platforms and configurations. At a basic level, this involves just running the tests on any platforms you use. Open issues for any bugs or quirks you discover, or if you're feeling adventurous, fix it yourself! Any platform is fair game! The following are some highlights or platforms of special interest: * MacOS/OSX (This requires owning a Mac, and is the area most sorely in need of testing) * Legacy Windows desktop (7 and 8) * Windows Server * Arch Linux * BSD ## Sample collection Examples of output of various commands is an easy way contribute that is still incredibly helpful. 1. Run the command 2. Copy/paste the output (or redirect output of command, `tee` is helpful here) into an appropriately named `.out` file in `samples/` 3. That's it! # Getting started 1. Create your own fork of the code through GitHub web interface ([Here's a Guide](https://gist.github.com/Chaser324/ce0505fbed06b947d962)) 2. Clone the fork to your computer. This can be done using the [GitHub desktop](https://desktop.github.com/) GUI , `git clone `, or the Git tools in your favorite editor or IDE. 3. Create and checkout a new branch in the fork with either your username (e.g. "ghostofgoes"), or the name of the feature or issue you're working on (e.g. "openbsd-support"). Again, this can be done using the GUI, your favorite editor, or `git checkout -b origin/`. 4. Install the developer tools and getmac as an "editable" package: ```bash python -m pip install --user -U tox python -m pip install -e . ``` 5. Setup and run the tests: ```bash # Run code quality checks tox -e check # Run the tests tox ``` 6. Write some code! Git commit messages should information about what changed, and if it's relevant, the rationale (thinking) for the change. 7. Follow the checklist in the pull request template 8. Submit a pull request! # Bug reports Filing a bug report: 1. Answer these questions: * [ ] What version of `getmac` are you using? (`getmac --version`) * [ ] What operating system and processor architecture are you using? * [ ] What version of Python are you using? * [ ] What did you do? * [ ] What did you expect to see? * [ ] What did you see instead? 2. Put any excessive output into a [GitHub Gist](https://gist.github.com/) and include a link in the issue. 3. Tag the issue with "Bug" **NOTE**: If the issue is a potential security vulnerability, do *NOT* open an issue! Instead, email: ghostofgoes(at)gmail(dot)com # Features and ideas Ideas for features or other things are welcomed. Open an issue on GitHub detailing the idea, and tag it appropriately (e.g. "Feature" for a new feature). # Resources ## Regex resources (regular expressions) - https://pythex.org/ - https://regex101.com/ - [Python's `re` documentation](https://docs.python.org/3/library/re.html) - [Python's guide to regex](https://docs.python.org/3/howto/regex.html) (this is actually really helpful) - https://ultrapico.com/Expresso.htm (I haven't used this but it looks useful) getmac-0.9.5/LICENSE000066400000000000000000000020611464534747600140150ustar00rootroot00000000000000MIT License Copyright (c) 2019 Christopher Goes Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. getmac-0.9.5/MANIFEST.in000066400000000000000000000006631464534747600145540ustar00rootroot00000000000000include LICENSE README.md CHANGELOG.md CONTRIBUTING.md graft getmac graft tests prune docs prune .github prune packaging prune scripts global-exclude *.py[cod] __pycache__ *.so *.class exclude *-getmac.spec *.yml exclude tox.ini Dockerfile Vagrantfile .editorconfig .coveragerc exclude conf.py index.md make.bat Makefile rewrite.md releasing.md exclude style-requirements.txt requirements.txt TODO.md CODE_OF_CONDUCT.md SECURITY.md getmac-0.9.5/README.md000066400000000000000000000363301464534747600142750ustar00rootroot00000000000000 [![Latest version on PyPI](https://badge.fury.io/py/getmac.svg)](https://pypi.org/project/getmac/) [![Coverage Status](https://coveralls.io/repos/github/GhostofGoes/getmac/badge.svg?branch=main)](https://coveralls.io/github/GhostofGoes/getmac?branch=main) [![GitHub Actions Pipeline Status](https://github.com/ghostofgoes/getmac/actions/workflows/ci.yml/badge.svg)](https://github.com/GhostofGoes/getmac/actions) [![Weekly PyPI downloads](https://pepy.tech/badge/getmac/week)](https://pepy.tech/project/getmac) [![PyPI downloads](https://pepy.tech/badge/getmac)](https://pepy.tech/project/getmac) [![PyPI downloadss of the old name](https://pepy.tech/badge/get-mac)](https://pepy.tech/project/get-mac) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) Pure-Python package to get the MAC address of network interfaces and hosts on the local network. It provides a platform-independent interface to get the MAC addresses of: - System network interfaces (by interface name) - Remote hosts on the local network (by IPv4/IPv6 address or hostname) It provides one function: `get_mac_address()` [![asciicast](https://asciinema.org/a/rk6dUACUcZY18taCuIBE5Ssus.png)](https://asciinema.org/a/rk6dUACUcZY18taCuIBE5Ssus) [![asciicast](https://asciinema.org/a/n3insrxfyECch6wxtJEl3LHfv.png)](https://asciinema.org/a/n3insrxfyECch6wxtJEl3LHfv) ## Should you use this package? If you only need the addresses of network interfaces, have a limited set of platforms to support, and are able to handle C-extension modules, then you should instead check out the excellent [netifaces](https://pypi.org/project/netifaces/) package by Alastair Houghton ([@al45tair](https://github.com/al45tair)). It's significantly faster (thanks to it being C-code) and has been around a long time and seen widespread usage. However, unfortunately it is no longer maintained as of [May 2021](https://github.com/al45tair/netifaces/commit/ec55b59e27542776f55e0f9e3213a75bf8e0f367), so it may not be a great choice for new projects. Another great option that fits these requirements is the well-known and battle-hardened [psutil](https://github.com/giampaolo/psutil) package by Giampaolo Rodola. If the only system you need to run on is Linux, you can run as root, and C-extensions modules are fine, then you should instead check out the [arpreq](https://pypi.org/project/arpreq/) package by Sebastian Schrader. In some cases it can be significantly faster. If you want to use `psutil`, `scapy`, or `netifaces`, I have examples of how to do so in a [GitHub Gist](https://gist.github.com/GhostofGoes/0a8e82930e75afcefbd879a825ba4c26). ## Installation Stable release from PyPI ```bash pip install getmac ``` Latest development version ```bash pip install https://github.com/ghostofgoes/getmac/archive/main.tar.gz ``` ## Python examples ```python from getmac import get_mac_address eth_mac = get_mac_address(interface="eth0") win_mac = get_mac_address(interface="Ethernet 3") ip_mac = get_mac_address(ip="192.168.0.1") ip6_mac = get_mac_address(ip6="::1") host_mac = get_mac_address(hostname="localhost") updated_mac = get_mac_address(ip="10.0.0.1", network_request=True) # Enable debugging from getmac import getmac getmac.DEBUG = 2 # DEBUG level 2 print(getmac.get_mac_address(interface="Ethernet 3")) # Change the UDP port used for updating the ARP table (UDP packet) from getmac import getmac getmac.PORT = 44444 # Default is 55555 print(getmac.get_mac_address(ip="192.168.0.1", network_request=True)) ``` ## Terminal examples **Python 2 users**: use `getmac2` or `python -m getmac` instead of `getmac`. ```bash getmac --help getmac --version # Invoking with no arguments will return MAC of the default interface getmac # Usage as a module python3 -m getmac # Interface names, IPv4/IPv6 addresses, or Hostnames can be specified getmac --interface ens33 getmac --ip 192.168.0.1 getmac --ip6 ::1 getmac --hostname home.router # Running as a Python module with shorthands for the arguments python -m getmac -i 'Ethernet 4' python -m getmac -4 192.168.0.1 python -m getmac -6 ::1 python -m getmac -n home.router # Getting the MAC address of a remote host requires the ARP table to be populated. # By default, getmac will populate the table by sending a UDP packet to a high port on the host (defaults to 55555). # This can be disabled with --no-network-request, as shown here: getmac --no-network-request --ip 192.168.0.1 python -m getmac --no-network-request -n home.router # Enable output messages getmac --verbose # Debug levels can be specified with '-d' getmac -v --debug python -m getmac -v -d -i enp11s4 python -m getmac -v -dd -n home.router # Change the UDP port used for populating the ARP table when getting the MAC of a remote host getmac --ip 192.168.0.1 --override-port 9001 # The platform detected by getmac can be overridden via '--override-platform'. # This is useful when debugging issues or if you know a method # for a different platform works on the current platform. # Any values returned by platform.system() are valid. getmac -i eth0 --override-platform linux getmac --ip 192.168.0.1 --override-platform windows # Force a specific method to be used, regardless of the consequences or if it even works getmac -v -dddd --ip 192.168.0.1 --force-method ctypeshost ``` ## Function: get_mac_address() - `interface`: Name of a network interface on the system - `ip`: IPv4 address of a remote host - `ip6`: IPv6 address of a remote host - `hostname`: Hostname of a remote host - `network_request`: If an network request should be made to update and populate the ARP/NDP table of remote hosts used to lookup MACs in most circumstances. Disable this if you want to just use what's already in the table, or if you have requirements to prevent network traffic. The network request is a empty UDP packet sent to a high port, `55555` by default. This can be changed by setting `getmac.PORT` to the desired integer value. Additionally, on Windows, this will send a UDP packet to `1.1.1.1:53` to attempt to determine the default interface (Note: the IP is [CloudFlare's DNS server](https://www.cloudflare.com/learning/dns/what-is-1.1.1.1/)). ## Configuration - `logging.getLogger("getmac")`: Runtime messages and errors are recorded to the `getmac` logger using Python's [logging](https://docs.python.org/3/library/logging.html) module. They can be configured by using [logging.basicConfig()](https://docs.python.org/3/library/logging.html#logging.basicConfig) or adding handlers to the `"getmac"` logger. - `getmac.getmac.DEBUG`: integer value that controls debugging output. The higher the value, the more output you get. - `getmac.getmac.PORT`: UDP port used to populate the ARP/NDP table (see the documentation of the `network_request` argument in `get_mac_address()` for details) - `getmac.getmac.OVERRIDE_PLATFORM`: Override the platform detection with the given value (e.g. `"linux"`, `"windows"`, `"freebsd"`, etc.'). Any values returned by `platform.system()` are valid. - `getmac.getmac.FORCE_METHOD`: Force a specific method to be used, e.g. 'IpNeighborShow'. This will be used regardless of it's method type or platform compatibility, and `Method.test()` will NOT be checked! The list of available methods is in `getmac.getmac.METHODS`. ## Features - Pure-Python (no compiled C-extensions required!) - Python 2.7 and 3.4+ - Lightweight, with no dependencies and a small package size - Can be dropped into a project as a standalone .py file - Supports most interpreters: CPython, pypy, pypy3, IronPython 2.7, and Jython 2.7 - Provides a simple command line tool (when installed as a package) - MIT licensed! ## Legacy Python versions If you are running a old Python (2.6/3.3 and older) or interpreter, then you can install an older version of `getmac` that supported that version. The wheels are available in the [GitHub releases](https://github.com/GhostofGoes/getmac/releases), or from PyPI with a current version of `pip` and some special arguments. - Python 2.5: get-mac 0.5.0 - Python 2.6: getmac 0.6.0 - Python 3.2: get-mac 0.3.0 - Python 3.3: get-mac 0.3.0 NOTE: these versions do not have many of the performance improvements, platform support, and bug fixes that came with later releases. They generally work, just not as well. However, if you're using such an old Python, you probably don't care about all that :) ## Notes - Python 3.10 and 3.11 should work, but are not automatically tested at the moment due to having to support 2.7 - If none of the arguments are selected, the default network interface for the system will be used. If the default network interface cannot be determined, then it will attempt to fallback to typical defaults for the platform (`Ethernet` on Windows, `em0` on BSD, `en0` on OSX/Darwin, and `eth0` otherwise). If that fails, then it will fallback to `lo` on POSIX systems. - "Remote hosts" refer to hosts in your local layer 2 network, also commonly referred to as a "broadcast domain", "LAN", or "VLAN". As far as I know, there is not a reliable method to get a MAC address for a remote host external to the LAN. If you know any methods otherwise, please [open a GitHub issue](https://github.com/GhostofGoes/getmac/issues) or shoot me an email, I'd love to be wrong about this. - The first four arguments are mutually exclusive. `network_request` does not have any functionality when the `interface` argument is specified, and can be safely set if using in a script. - The physical transport is assumed to be Ethernet (802.3). Others, such as Wi-Fi (802.11), are currently not tested or considered. I plan to address this in the future, and am definitely open to pull requests or issues related to this, including error reports. - **Exceptions will be handled silently and returned as a None.** If you run into problems, you can set `DEBUG` to true and get more information about what's happening. If you're still having issues, please create an [issue on GitHub](https://github.com/GhostofGoes/getmac/issues) and include the output with `DEBUG` enabled. ## Commands and techniques by platform - Windows - Commands: `getmac.exe`, `ipconfig.exe`, `arp.exe`, `wmic.exe` - Libraries: `uuid`, `ctypes`, `socket` - Linux/Unix - Commands: `arp`, `ip`, `ifconfig`, `netstat`, `ip link`, `lanscan` - Libraries: `uuid`, `fcntl`, `socket` - Files: `/sys/class/net/{iface}/address`, `/proc/net/arp` - Default interfaces: `/proc/net/route`, `route`, `ip route list` - Mac OSX (Darwin) - `networksetup` - Same commands as Linux - WSL - Windows commands are used for remote hosts - Unix commands are used for interfaces - OpenBSD - Commands: `ifconfig`, `arp` - Default interfaces: `route` - FreeBSD - Commands: `ifconfig`, `arp` - Default interfaces: `netstat` - Android - Commands: `ip link` ## Platforms currently supported All or almost all features should work on "supported" platforms. While other versions of the same family or distro may work, they are untested and may have bugs or missing features. - Windows - Desktop: 7, 8, 8.1, 10, 11 (thanks @StevenLooman for testing Windows 11!) - Server: TBD - Partially supported (untested): 2000, XP, Vista - Linux distros - CentOS/RHEL 6+ - Ubuntu 16.04+ (15.10 and older should work, but are untested) - Fedora (24+) - Mac OSX (Darwin) - The latest two versions probably (TBD) - Android (6+) - Windows Subsystem for Linux (WSL) - FreeBSD (11+) - OpenBSD - Docker ## Docker Add `-v /proc/1/net/arp:/host/arp -e ARP_PATH=/host/arp` to access arp table of host inside container in bridge network mode. ```bash docker build -f packaging/Dockerfile -t getmac . docker run -it getmac:latest --help docker run -it getmac:latest --version docker run -it getmac:latest -n localhost docker run --rm -it -v /proc/1/net/arp:/host/arp -e ARP_PATH=/host/arp getmac:latest -n 192.168.0.1 ``` ## Caveats - Depending on the platform, there could be a performance detriment, due to heavy usage of regular expressions. - Platform test coverage is imperfect. If you're having issues, then you might be using a platform I haven't been able to test. Keep calm, open a GitHub issue, and I'd be more than happy to help. ## Known Issues - Linux, WSL: Getting the mac of a local interface IP does not currently work (`getmac --ip 10.0.0.4` will fail if `10.0.0.4` is the IP address of a local interface). This issue may be present on other POSIX systems as well. - Hostnames for IPv6 devices are not yet supported. - Windows: the "default" (used when no arguments set or specified) of selecting the default route interface only works effectively if `network_request` is enabled. If not, `Ethernet` is used as the default. - IPv6 support is good but lags behind IPv4 in some places and isn't as well-tested across the supported platform set. ## Background and history The Python standard library has a robust set of networking functionality, such as `urllib`, `ipaddress`, `ftplib`, `telnetlib`, `ssl`, and more. Imagine my surprise, then, when I discovered there was not a way to get a seemingly simple piece of information: a MAC address. This package was born out of a need to get the MAC address of hosts on the network without needing admin permissions, and a cross-platform way get the addresses of local interfaces. In Fall 2018 the package name changed to `getmac` from `get-mac`. This affected the package name, the CLI script, and some of the documentation. There were no changes to the core library code. While both package names will updated on PyPI, the use of `getmac` is preferred. In Summer 2020, the code was significantly refactored, moving to a class-based structure and significantly improving performance and accuracy. See [docs/rewrite.md](docs/rewrite.md) for details. ## Contributing Contributors are more than welcome! See the [contribution guide](CONTRIBUTING.md) to get started, and checkout the [todo list](TODO.md) for a full list of tasks and bugs. Before submitting a PR, please make sure you've completed the [pull request checklist](CONTRIBUTING.md#Code_requirements)! The [Python Discord server](https://discord.gg/python) is a good place to ask questions or discuss the project (Handle: @KnownError#0001). ### Contributors - Christopher Goes (@ghostofgoes) - Author and maintainer - Calvin Tran (@cyberhobbes) - Windows interface detection improvements - Daniel Flanagan (@FlantasticDan) - Code cleanup - @emadmahdi - Android fixes - Izra Faturrahman (@Frizz925) - Unit tests using the platform samples - Jose Gonzalez (@Komish) - Docker container and Docker testing - @fortunate-man - Awesome usage videos - @martmists - legacy Python compatibility improvements - @hargoniX - scripts and specfiles for RPM packaging - Ville Skyttä (@scop) - arping lookup support - Tomasz Duda (@tomaszduda23) - support for docker in network bridge mode - Steven Looman (@StevenLooman) - Windows 11 testing - Reimund Renner (@raymanP) - macOS fixes ## Sources Many of the methods used to acquire an address and the core logic framework are attributed to the CPython project's UUID implementation. - https://github.com/python/cpython/blob/master/Lib/uuid.py - https://github.com/python/cpython/blob/2.7/Lib/uuid.py ### Other notable sources - [_unix_fcntl_by_interface](https://stackoverflow.com/a/4789267/2214380) - [_windows_get_remote_mac_ctypes](goo.gl/ymhZ9p) - [String joining](https://stackoverflow.com/a/3258612/2214380) ## License MIT. Feel free to copy, modify, and use to your heart's content. Enjoy :) getmac-0.9.5/SECURITY.md000066400000000000000000000014541464534747600146060ustar00rootroot00000000000000# Security Policy ## Supported Versions | Version | Supported | | ---------- | ------------------ | | 0.8.x | :white_check_mark: | | <= 0.7.x | :x: | ## Reporting a Vulnerability or other security issue If the security issue is a general weakness or poor practice that is *not directly exploitable*, please open a [Issue on GitHub](https://github.com/GhostofGoes/getmac/issues) and add the `security` label. If the security issue is a vulnerability that can *potentially be exploited or has a exploit developed/proven*, please email ghostofgoes(at)gmail.com. Please include in the email a description of the vulnerability, any proof of concept code/exploit code, and any other information that you believe may be relevant. PGP signed message is preferred but not required. getmac-0.9.5/Vagrantfile000066400000000000000000000154501464534747600152030ustar00rootroot00000000000000# -*- mode: ruby -*- # vi: set ft=ruby : # Vagrant Documentation: https://docs.vagrantup.com/v2/ # More boxes at: https://app.vagrantup.com # Prerequisites: latest versions of Vagrant and VirtualBox # If you're on Linux, do NOT use apt/yum to install, they are severely outdated. # Instead, download the .deb from https://www.vagrantup.com/downloads.html, # and install using "sudo apt install ./.deb". # Usage: Navigate to the folder containing this file in your CLI (Windows CMD, Linux BASH) # Create VM: "vagrant up [name]" # Destroy VM: "vagrant destroy [name]" # Power down VM: "vagrant halt [name]" # Power on VM: "vagrant up [name]" # VM Command line: "vagrant ssh [name]" # Provision: "vagrant provision [name]" # Example: "vagrant up centos" creates a CentOS 7 dev/test machine # Available VMs: # osx # ubuntu12, ubuntu18, centos7 # openbsd, freebsd, netbsd # opensuse, solaris # winserver, win7, win10, win11 # NOTE: files from this directory are mounted to "/vagrant" in the VM # This only works if guest additions are installed and the proper version. # Potential workaround: vagrant plugin install vagrant-vbguest # NOTE: for Android, use the official emulators included with Android Studio # wget --no-check-certificate https://github.com/GhostofGoes/getmac/archive/refs/heads/refactor.tar.gz # tar -xzvf refactor.tar.gz Vagrant.configure(2) do |config| # MacOS (not sure if this works) config.vm.define "osx" do |osx| osx.vm.box = "jhcook/macos-sierra" #osx.vm.box = "adasilva/Mojave" osx.vm.host_name = "getmac-osx" osx.vm.boot_timeout = 1440 osx.vm.provider "virtualbox" do |vb| vb.gui = false vb.memory = "4096" vb.name = "getmac-osx-mojave" # Fix errors (source: https://github.com/mbigras/macos-vagrant) vb.customize ["modifyvm", :id, "--usb", "on"] vb.customize ["modifyvm", :id, "--usbehci", "off"] end osx.vbguest.auto_update = false end # Ubuntu 12.04 LTS config.vm.define "ubuntu12" do |ubuntu12| ubuntu12.vm.box = "hashicorp/precise32" ubuntu12.vm.host_name = "getmac-ubuntu12" ubuntu12.vm.boot_timeout = 1440 ubuntu12.vm.provider "virtualbox" do |vb| vb.gui = false vb.memory = "2048" vb.name = "getmac-Ubuntu-1204" end ubuntu12.vbguest.auto_update = false end # Ubuntu 18.04 LTS config.vm.define "ubuntu18" do |ubuntu18| ubuntu18.vm.box = "generic/ubuntu1804" ubuntu18.vm.host_name = "getmac-ubuntu18" ubuntu18.vm.boot_timeout = 1440 ubuntu18.vm.provider "virtualbox" do |vb| vb.gui = false vb.memory = "2048" vb.name = "getmac-Ubuntu-1804" end ubuntu18.vm.provision "shell", path: "scripts/ubuntu-provision.sh", privileged: false end # CentOS 7 config.vm.define "centos7" do |centos7| centos7.vm.box = "centos/7" centos7.vm.host_name = "getmac-centos7" centos7.vm.boot_timeout = 1440 centos7.vm.provider "virtualbox" do |vb| vb.gui = false vb.memory = "1024" vb.name = "getmac-CentOS-7" end centos7.vbguest.auto_update = false centos7.vm.provision "shell", path: "scripts/centos-provision.sh", privileged: false end # OpenBSD 6 config.vm.define "openbsd" do |openbsd| openbsd.vm.box = "generic/openbsd6" openbsd.vm.host_name = "getmac-openbsd" openbsd.vm.boot_timeout = 1440 openbsd.vm.provider "virtualbox" do |vb| vb.gui = false vb.memory = "1024" vb.name = "getmac-OpenBSD-6" end openbsd.vbguest.auto_update = false openbsd.vm.provision "shell", path: "scripts/openbsd-provision.sh", privileged: false end # NetBSD 8 config.vm.define "netbsd" do |netbsd| netbsd.vm.box = "generic/netbsd8" netbsd.vm.host_name = "getmac-netbsd" netbsd.vm.boot_timeout = 1440 netbsd.vm.provider "virtualbox" do |vb| vb.gui = false vb.memory = "1024" vb.name = "getmac-NetBSD-8" end netbsd.vbguest.auto_update = false # To test code: # wget --no-check-certificate https://github.com/ghostofgoes/getmac/archive/refactor.zip # sudo pkgin install python37 # # NOTE: this requires SMB, since no guest extensions # netbsd.vm.synced_folder ".", "/home/vagrant/getmac" end # FreeBSD 11 (version currently used by PFSense) config.vm.define "freebsd" do |freebsd| freebsd.vm.box = "generic/freebsd11" freebsd.vm.host_name = "getmac-freebsd" freebsd.vm.boot_timeout = 1440 freebsd.vm.provider "virtualbox" do |vb| vb.gui = false vb.memory = "1024" vb.name = "getmac-FreeBSD-12" end freebsd.vbguest.auto_update = false end # OpenSUSE 42 config.vm.define "opensuse" do |opensuse| opensuse.vm.box = "generic/opensuse42" opensuse.vm.host_name = "getmac-opensuse" opensuse.vm.boot_timeout = 1440 opensuse.vm.provider "virtualbox" do |vb| vb.gui = false vb.memory = "1024" vb.name = "getmac-OpenSUSE-42" end opensuse.vbguest.auto_update = false end # Solaris 10 # NOTE: this box appears to have working guest extensions so the # local directory (and code) will be available in the VM at "/vagrant" config.vm.define "solaris" do |solaris| solaris.vm.box = "tnarik/solaris10-minimal" solaris.vm.host_name = "getmac-solaris" solaris.vm.boot_timeout = 1440 solaris.vm.provider "virtualbox" do |vb| vb.gui = false vb.memory = "1024" vb.name = "getmac-Solaris-10" end solaris.vbguest.auto_update = false solaris.vm.provision "shell", path: "scripts/solaris-provision.sh", privileged: false end # Windows Server 2012 R2 config.vm.define "winserver" do |winserver| winserver.vm.box = "opentable/win-2012r2-standard-amd64-nocm" winserver.vm.host_name = "getmac-winserver" winserver.vm.boot_timeout = 1440 winserver.vm.provider "virtualbox" do |vb| vb.gui = true vb.memory = "2048" vb.name = "getmac-Windows-Server-2012R2" end end # Windows 7 config.vm.define "win7" do |win7| win7.vm.box = "datacastle/windows7" win7.vm.host_name = "getmac-win7" win7.vm.boot_timeout = 1440 win7.vm.provider "virtualbox" do |vb| vb.gui = true vb.memory = "2048" vb.name = "getmac-Windows-7" end end # Windows 10 config.vm.define "win10" do |win10| win10.vm.box = "Microsoft/EdgeOnWindows10" win10.vm.host_name = "getmac-win10" win10.vm.boot_timeout = 1440 win10.vm.provider "virtualbox" do |vb| vb.gui = true vb.memory = "2048" vb.name = "getmac-Windows-10" end end # Windows 11 config.vm.define "win11" do |win11| win11.vm.box = "gusztavvargadr/windows-11" win11.vm.host_name = "getmac-win11" win11.vm.boot_timeout = 1440 win11.vm.provider "virtualbox" do |vb| vb.gui = true vb.memory = "2048" vb.name = "getmac-Windows-11" end end end getmac-0.9.5/docs/000077500000000000000000000000001464534747600137415ustar00rootroot00000000000000getmac-0.9.5/docs/Makefile000066400000000000000000000013721464534747600154040ustar00rootroot00000000000000# Minimal makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build SOURCEDIR = . BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) .PHONY: help Makefile man clean # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) # Generate Unix manual page man: mkdir -p ./_build/man $(SPHINXBUILD) -b man . ./_build/man mv ./_build/man/getmac.1 . rm -Rf ./_build/man clean: rm -rf ./_build/* getmac-0.9.5/docs/TODO.md000066400000000000000000000256411464534747600150400ustar00rootroot00000000000000# 1.0.0 release - [x] rename "master" branch to "main" - [x] Create 0.9.0 branch from master/main so we can submit patch releases if needed - [ ] Add guide on using the modules API, e.g. registering a new method in `getmac.getmac.METHODS`, etc. - [ ] Switch to Poetry for project management - [ ] Also, add `isort` - [ ] Support Python 3.10 - [ ] Update pytest (pytest 4, which we were using to support python 2.7, doesn't work with python 3.10) - [ ] add tests + setup.py classifier - [ ] **API changes** (technically speaking) - Add argument to `get_mac_address()` to force the platform used (e.g. `platform_override="linux"`) - Also add CLI argument to configure this - Add argument to `get_mac_address()` to force a specific method to be used - Passing a string with the name of a method class (e.g. `"ArpFile"`), this will be dynamically looked up from the list of available methods. This will NOT check if the method works by default! - Passing a subclass of `getmac.Method` - Passing an instance of a subclass of `getmac.Method` - Add a CLI argument to reference class by name - Add ability to exclude methods. Just remove them from METHODS list so they never get used. Useful for testing specific methods or working around buggy methods. - Document these features in the README/docs, including the CLI arguments - [ ] **Consolidate `ip6` argument into `ip` argument.**. Parse based on `::` character vs `.` character if `str` or via `.version == 4`/`.version == 6` for `ipaddress` objects. - Combine `--ip` and `--ip6` CLI arguments into `--ip` - [ ] Support `ipaddress` objects, `IPv4Address` and `IPv6Address` - [ ] Move method classes into a separate file - [ ] Add new method: `get_default_interface()`. This leverages the default interface detection methods to expose a helpful public API. - [ ] Split utils into a separate file - [ ] move more logic out of `get_mac_address()` into individual methods: - [ ] interface - [ ] remote host - [ ] return data cleanup and validation - [ ] Raise exceptions on critical failures (stuff that were warnings in 0.9.0), all calls to `_warn_critical()`. - [ ] Remove all Python "Scripts" from the path, so they don't interfere with the commands we actually want (e.g. "ping"). Document this behavior! - [ ] Documentation - [ ] Single page on RTD/publish with GitHub actions built with Sphinx and Furo - [ ] Update docs/usage examples for `get_mac_address()` - [ ] Document possible values for `PLATFORM` variable - [ ] Document Method (and subclass) attributes (use Sphinx "#:" comments) - [ ] Re-add Man pages (and auto-build them in CI and include in releases and the distributions) - [ ] Document `get_by_method()` - [ ] Document `initialize_method_cache()` - [ ] Auto-generated API docs - [ ] Add docstrings to all util methods - Furo, sphinx-autodoc-typehints, sphinx-argparse-cli, sphinx-automodapi, sphinx-copybutton, recommonmark - [ ] Support IPv6 hosts: https://www.practicalcodeuse.com/how-to-arp-a-in-ipv6 - [ ] >90% test coverage - refactor tests to use the new system and structure - directly test methods via a `Method.parse()` function - add `Method.parse()` that handles the parsing of command output. this would make it *much* easier to test methods - [ ] implement proper default interface detection on Windows - [ ] Method-specific loggers? dynamically set logger name based on subclass name, so we don't have to manually set it in the string - [ ] address all TODOs in the code - [ ] FreeBSD default interface: `route get default` - [ ] Support NetBSD - platform: `netbsd` - default interface: `wm0` - ip: "route -nq show", "netstat -r", arp -a - default interface via `route get default`? - [ ] Support Solaris - platform: `sunos` - default interface; `e1000g0` (NOTE: likely because this is in Vagrant VM) - `ifconfig` with no arguments DOES NOT work, need `ifconfig -a` - `netstat` doesn't work with `-e`, but does work with no arguments, `-a` and `-i`. `-n` prevents hostnames from resolving, which is faster. `-i` gives the shortest output (and is fastest), but doesn't give us a MAC address. Providing the interface as an argument also doesn't work to get a MAC (`netstat -a -I e1000g0`). - default interface via `route get default`? - no `ip` command - [ ] Cleanup `ifconfig` methods - [ ] Split `IfconfigOther` into IfconfigWithArg/IfconfigNoArg - [ ] Combine `IfconfigEther` into other Ifconfig methods - [ ] Improve unit test coverage and platform markers - [ ] `IpLinkIface`: improve regex to not need extra portion for no arg - [ ] New method for "ip addr"? (this would be useful for CentOS and others as a fallback) - [ ] Add new regexes to `IpLinkIface` and improve it's parsing so it's more robust, especially on Android - [ ] Improve CLI tests to ensure output is what's expected (e.g. ensure `--override-port` logs a warning and the value actually gets overridden) - [ ] Support IPv6 remote hosts on windows, and IPv4+IPv6 remote hosts on WSL (see "Platform support" section in this document) - [ ] finer-grained platform support identification for methods by versions/releases, e.g. Windows 7 vs 10, Ubuntu 12 vs 20 - [ ] CLI: put "override" and other debugging-related arguments into a separate argparse argument group - [ ] Refactor to build a local state of the interfaces on the system, and use that as fallback for default lookup of interface with no name. Could also include MACs for faster lookup of future interface queries. Similar to how `netifaces` works, with a dict with interface infos. Properly address https://github.com/GhostofGoes/getmac/issues/78 ## Py3-related stuff for 1.0.0 - [ ] Drop support for python 2.7, 3.4, and 3.5 - [ ] BUMP TEST DEPENDENCIES AND PYTEST VERSION TO MODERN TIMES (especially pytest...) - [ ] Use Enums for platforms and method types instead of strings? - [ ] cache package imports done during test for use during `get()`, reuse - [ ] rewrite strings to f-strings - [ ] Use `pyproject.toml` instead of `setup.py` - https://packaging.python.org/tutorials/packaging-projects/ - Move configurations for tools out of `tox.ini` and into `pyproject.toml` - Add codespell configuration, remove CLI arguments - Add linting of pyproject.toml, remove checking of setup.py - [ ] update classifiers in setup.py - [ ] add inline type annotations for method arguments. remove types from docstrings? - [ ] Remove `shutilwhich.py` and `.coveragerc` # Etc - [ ] Refactor the default interface code. Combine the functions into one, move the default fallback logic into the function. - TODO: MAC -> IP. "to_find='mac'"? (create GitHub issue?) # Bugs or potential issues - [ ] Fix lookup of a IPv4 address of a local interface on Linux - [ ] Unicode handling. UNICODE option needed for non-english locales? (Is LC_ALL working?) - [ ] Are there ever cases where loopback != `FF:FF:FF:FF:FF:FF`? - [ ] Remote host that is actually an interface should resolve to localhost MAC - [ ] Reduce the cost of failures. Currently, failures are penalized with a slow run since it tries every method before failing. - [ ] Detect if an interface exists before trying to find it's MAC. - [ ] **Security**. Spend some quality time ensuring our sources of input (the arguments to `get_mac_address()`) don't result in unexpected code execution. A lot of stuff is running system commands, so we should focus the most effort on the `subprocess.Popen()` calls. # Platform support ## Windows ### Remote hosts do this next, i guess, to get ipv6 working on windows + WSL also, on WSL, do netsh.exe instead of netsh https://www.prodjim.com/how-to-arp-a-in-ipv6 - [ ] IPv6: `netsh int ipv6 show neigh` - [ ] IPv4: `netsh int ipv4 show neigh` ### Interface MACs - [ ] `netsh int ipv6` - [ ] win32 API (`ctypes`) ### Default Interfaces This is going to be a bit more complicated since the highest metric routes are going to be IP addresses and not interfaces. We'll have to resolve those to an interface, then select that interface as the default route. - [ ] IPv4: `netsh interface ipv4 show route` - [ ] IPv6: `netsh interface ipv6 show route` - [ ] `ipconfig` - [ ] IPv4: `route print -4` - [ ] IPv6: `route print -6` - [ ] Windows API ## POSIX - [ ] `arping` (command): investigate for remote macs - [ ] `fcntl` (library): IPv6? - [ ] `ip addr` (command) - [ ] `ip -6 neigh` (command) ## OSX (Darwin) - [ ] Determine best remote host detection methods, split off not-applicable commands. - [ ] Darwin hostnames? Does it have arp file? (Do less work) - [ ] Mac: `ndp -a` to get IPv6 network neighbors (NDP table) ## Performance - [ ] Profiling: CPU usage, memory usage, run time/load time ## Misc. - [ ] Add ability to match user-provided arguments case-insensitively - [ ] Add ability to get the mac address of a Python socket's interface (`socket.socket`) - [ ] Test against non-ethernet interfaces (WiFi, LTE, etc.) - [ ] Create a script to collect samples for all relevant commands on a platform and save output into the appropriately named sub-directory in `samples/`. # Post-1.0.0 - [ ] Add typing stubs to [typeshed](https://github.com/python/typeshed) once getmac 1.0.0 is released ([guide](https://github.com/python/typeshed/blob/master/CONTRIBUTING.md)) - [ ] Use `__import__()` or `importlib`? - [ ] Parameterize regexes? (is this any faster?) - [ ] Write a short guide on how to add and test a new method - [ ] Automatically publish to PyPI when publishing a release on GitHub - [ ] Add support for Unix and Windows interface indices as a separate argument to `get_mac_address`. On Windows, we could use `wmic`, while on Unix and Python 3 we can use `socket.if_indextoname()`. - [ ] API to add/remove methods at runtime (including new, custom methods) - [ ] Reduce duplication, for example "if not arg: return None" - [ ] Cache method checks (maybe move this to 1.1.0 release?) Save a string with the names of methods. Save to: file (location configurable via environment variable or option). Read from: file, environment variable, file pointed to by environment variable. Add a flag to control this behavior and location of the cache. Document the behavior. - [ ] Add a "net_ok" argument, check network_request attribute on method in CACHE, if not then keep checking for method in FALLBACK_CACHE that has network_request. - [ ] Add ability to specify what methods to use via function argument and CLI argument - [ ] Function arguments - [ ] Add ability to force platform name (e.g. `linux`) via function argument and CLI argument ``` methods=None type: Optional[List[Union[str, Method, Type[Method]]]] methods (list): Optional list of methods to use for MAC address lookup. This will override the default methods that are auto-determined based on platform inspection and testing, and will be used regardless of whether they work or not. These can be names of method classes as strings (``"ArpFile"``), ``Method`` subclasses (``ArpFile``), or instances of ``Method`` subclasses (``ArpFile()``). ``` getmac-0.9.5/docs/android.md000066400000000000000000000054421464534747600157100ustar00rootroot00000000000000 ## Setup 1. Install Android Studio 1. Install a emulator using Android SDK manager 1. Add 3 paths to the PATH environment variable: https://medium.com/@vsburnett/how-to-set-up-an-android-emulator-in-windows-10-e0a3284b5f94 ``` C:\Users\\AppData\Local\Android\Sdk\platform-tools C:\Users\\AppData\Local\Android\Sdk\emulator C:\Users\\AppData\Local\Android\Sdk\tools\bin ``` ## Resources - https://developer.android.com/studio/run/emulator-commandline - https://developer.android.com/studio/run/managing-avds - https://developer.android.com/studio/command-line/adb ## Running Emulator Create a AVD via Android Studio user interface under Tools -> AVD Manager. Then click the green play button next to the device to start. Alternate method via CLI: ```powershell emulator -list-avds emulator -avd Nexus_4_API_23 -netdelay none -netspeed full ``` ### Connect to the emulated device ```powershell adb devices adb shell ``` how do we add wifi? "When using an AVD with API level 25 or higher, the emulator provides a simulated Wi-Fi access point ("AndroidWifi"), and Android automatically connects to it." https://developer.android.com/studio/run/emulator.html#wifi ## Identifying Android in Python ```python is_android = hasattr(sys, 'getandroidapilevel') is_android = 'ANDROID_STORAGE' in environ # Maybe? https://github.com/damonkohler/sl4a is_android = 'AP_HANDSHAKE' in environ or "AP_HOST" in environ ``` ## Scratchpad Apparently some interfaces are limited on API 28 ```bash generic_x86_arm:/ $ cat /sys/class/net/wlan0/address cat: /sys/class/net/wlan0/address: Permission denied generic_x86_arm:/ $ ip link show wlan0 request send failed: Permission denied 1|generic_x86_arm:/ $ ip link show radio0 request send failed: Permission denied 1|generic_x86_arm:/ $ ip link show radio0@if10 request send failed: Permission denied generic_x86_arm:/ $ ip route list 0/0 generic_x86_arm:/ $ generic_x86_arm:/ $ route -n /system/bin/sh: route: not found 127|generic_x86_arm:/ $ route /system/bin/sh: route: not found 127|generic_x86_arm:/ $ generic_x86_arm:/ $ arp /system/bin/sh: arp: not found 127|generic_x86_arm:/ $ arp -a /system/bin/sh: arp: not found ``` If android stuff ever breaks, these may be useful (the updated methods should work but something could've slipped through the cracks, so documenting here for my own sanity). ```python (r"state UP.*\n.*ether " + MAC_RE_COLON, 0, "ip", ["link","addr"]), (r"wlan.*\n.*ether " + MAC_RE_COLON, 0, "ip", ["link","addr"]), (r"ether " + MAC_RE_COLON, 0, "ip", ["link","addr"]), _regexes = ( r".*\n.*link/ether " + MAC_RE_COLON, # Android 6.0.1+ (and likely other platforms as well) r"state UP.*\n.*ether " + MAC_RE_COLON, r"wlan.*\n.*ether " + MAC_RE_COLON, r"ether " + MAC_RE_COLON, ) # type: Tuple[str, str, str, str] ``` getmac-0.9.5/docs/conf.py000066400000000000000000000076511464534747600152510ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. import os import sys from datetime import datetime DOCDIR = os.path.pardir(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(os.path.pardir(DOCDIR), 'getmac')) from recommonmark.transform import AutoStructify # noqa: E402 import getmac # noqa: E402 # -- Project information ----------------------------------------------------- project = 'getmac' copyright = '2017 - %i, Christopher Goes' % datetime.today().year author = 'Christopher Goes' version = getmac.__version__ release = getmac.__version__ # -- General configuration --------------------------------------------------- # TODO: sphinx-copybutton # TODO: sphinx-tabs (or another extension) to provide tabbed command # examples for different platforms (e.g. for developer docs and CLI usage) # TODO(python3): sphinx-autodoc-typehints extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.viewcode', ] # TODO: setup ReadTheDocs # TODO: convert docs to RST format source_parsers = { '.md': 'recommonmark.parser.CommonMarkParser', } # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix(es) of source filenames. source_suffix = ['.md'] # , '.rst' # The master toctree document. master_doc = 'index' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. exclude_patterns = [] # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # None # -- Options for HTML output ------------------------------------------------- # TODO: furo theme? (like the pip documentation) html_theme = 'sphinx_rtd_theme' # html_theme_options = {} # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = [] # '_static' # Custom sidebar templates, must be a dictionary that maps document names # to template names. # # The default sidebars (for documents that don't match any pattern) are # defined by theme itself. Builtin themes are using these templates by # default: ``['localtoc.html', 'relations.html', 'sourcelink.html', # 'searchbox.html']``. # html_sidebars = { '**': [ 'relations.html', # needs 'show_related': True theme option to display 'searchbox.html', ] } html_context = { "display_github": True, # Integrate GitHub "github_user": "GhostofGoes", # Username "github_repo": "getmac", # Repo name "github_version": "main", # Version "conf_py_path": "/", # Path in the checkout to the docs root } # -- Options for manual page output ------------------------------------------ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). # TODO: auto-build and include the man page in the release archive man_pages = [ (master_doc, 'getmac', 'Cross-platform Python package to get MAC addresses', [author], 1) ] # -- Extension configuration ------------------------------------------------- def setup(app): app.add_config_value('recommonmark_config', { 'auto_toc_tree_section': 'Contents', 'enable_eval_rst': True, 'enable_auto_doc_ref': True, }, True) app.add_transform(AutoStructify) getmac-0.9.5/docs/darwin.md000066400000000000000000000021321464534747600155450ustar00rootroot00000000000000May need VirtualBox 6.1.30. At the time I had 6.1.34 and it wasn't working, but I think it might've been caused by the USB thingy that's now fixed in the Vagrantfile. This may or may not be needed, keeping here for reference: ```shell cd "C:\Program Files\Oracle\VirtualBox\" VBoxManage.exe modifyvm "getmac-osx-mojave" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff VBoxManage setextradata "getmac-osx-mojave" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3" VBoxManage setextradata "getmac-osx-mojave" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0" VBoxManage setextradata "getmac-osx-mojave" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple" VBoxManage setextradata "getmac-osx-mojave" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" VBoxManage setextradata "getmac-osx-mojave" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1 VBoxManage modifyvm "getmac-osx-mojave" --cpu-profile "Intel Xeon X5482 3.20GHz" ``` Get version info: ```bash sw_vers system_profiler SPSoftwareDataType ``` getmac-0.9.5/docs/releasing.md000066400000000000000000000025431464534747600162400ustar00rootroot00000000000000 ## Requirements **NOTE**: Linux is required to build the `.deb` package. ```bash python -m pip install -U pip pip install -U setuptools twine wheel pip install -U stdeb ``` ## Cutting a release 1. Increment version number in `getmac/getmac.py` 2. Update CHANGELOG header from UNRELEASED to the version and add the date 3. Run static analysis checks (`tox -e check`) 4. Run the test suite on the main supported platforms (`tox`) a) Windows b) Ubuntu c) CentOS d) OSX 5. Ensure a pip install from source works on the main platforms: ```bash pip install https://github.com/ghostofgoes/getmac/archive/main.tar.gz ``` 6. Clean the environment: `bash ./scripts/clean.sh` 7. Build the sdist and wheel (`.whl`) ```bash python setup.py sdist bdist_wheel --universal ``` 8. Upload the sdist and wheel (`.whl`) ```bash twine upload dist/* ``` 9. Build the Debian package ```bash python setup.py --command-packages=stdeb.command bdist_deb ``` 10. Create a tagged release on GitHub including: a) The relevant section of the CHANGELOG in the body b) The source and binary wheels c) The `.deb` package (which will be in `./deb_dist`) 11. Edit the package name in `setup.py` to `get-mac`, and re-run steps 7 and 8 (build and upload), since people apparently don't check their dependencies and ignore runtime warnings. 12. Announce the release in the normal places getmac-0.9.5/docs/requirements.txt000066400000000000000000000000511464534747600172210ustar00rootroot00000000000000sphinx>=1.7 recommonmark sphinx_rtd_themegetmac-0.9.5/docs/rewrite.md000066400000000000000000000070261464534747600157510ustar00rootroot00000000000000# Rewrite summary **NOTE**: The public API of `getmac` is **unchanged** as part of this rewrite. `get_mac_address()` is still the primary way of getting a MAC address, it's just the "under the hood" internals that have changed completely. ## Motivation The current system of finding a MAC is, to put it bluntly, throw commands at the wall, see if they stick, and promptly forget what stuck for next time. While this *has* worked up till now, it's a hack built on hacks and has needed a rewrite for a while. It's prone to false-positives (multiple nasty bugs were caused by this), is quite slow ("misses" can take *seconds* to return!), extremely difficult to test (and thus aforementioned bugs were missed), and is generally a unreadable pile of spaghetti to anyone except me. ## Rewrite The rewrite is built from the ground up as a class-based modular architecture. Each "method" (a way of getting a MAC) is implemented as a subclass of the `Method` base class. The methods define what platforms they apply to (`platforms`, e.g. `platforms = {"windows", "wsl"}`), the type of method (`method_type`, e.g. `method_type = "ip4"`) and other attributes, such as if they make a network request as part of the check (`network_request`). There are two functions that are implemented by `Method` subclasses: `test()` and `get(arg)`. The `test()` functions implements a *fast* test for the feasibility of the method, e.g. checking if the `/proc/net/arp` file exists for the `ArpFile` method. The `get(arg)` functions implements the actual functionality of looking up the MAC, e.g. in the case of `ArpFile`, parsing the contents of `/proc/net/arp`. When `get_mac_address()` is called for the first time for a particular method type (e.g. `"iface"`), a cache is initialized for that method type (in `initialize_method_cache()`): 1. Create a list of all methods 2. Remove any that don't apply to this method type (e.g. `"iface"` or `"ip4"`) 3. Remove any that don't apply to the current platform (e.g. `"windows"`) 4. If method type is `ip`, `ip4` or `ip6`, and `network_request=False`, remove any methods that result in network traffic. These will have the attribute `Method.network_request = True`. 5. Test all methods by calling `test()` and remove any that fail (return `False`) 6. Store any methods that remain in the cache for this method type (`"iface"`) The first of the methods in the cache is used to fulfill the `get_mac_address()` via a call to `get(arg)` on the method. If there's a critical failure during the `get()`, then the method is marked as unusable, removed from the cache, and the next method in the cache is used instead. Some methods can't be tested reliably without starting a process, which is expensive, so instead we fail them on first attempt. Calling a single method addresses the old system's issue of trying every method until there was a success, which led to "misses" (no MAC available for whatever was requested) taking several seconds (or longer in extreme cases). ## Benefits The new system has a number of benefits - Reduction of false-positives and false-negatives by improving method selection accuracy (platform, validity, etc.) - *Significantly* faster overall - "Misses" have the same performance as "Hits" - Easier to test, since each method can be tested directly via it's class - Easier to type annotate and analyze with mypy - Easier to read, improving reviewability and ease of contributing for newcomers - Extensible! Custom methods can be defined and added at runtime (which is perfect if you have some particular edge case but aren't able to open-source it). getmac-0.9.5/getmac/000077500000000000000000000000001464534747600142515ustar00rootroot00000000000000getmac-0.9.5/getmac/__init__.py000066400000000000000000000001201464534747600163530ustar00rootroot00000000000000from .getmac import __version__, get_mac_address __all__ = ["get_mac_address"] getmac-0.9.5/getmac/__main__.py000066400000000000000000000067331464534747600163540ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import argparse import logging import sys from . import getmac def main(): # type: () -> None parser = argparse.ArgumentParser( "getmac", description="Get the MAC address of system network " "interfaces or remote hosts on the LAN", ) parser.add_argument( "--version", action="version", version="getmac %s" % getmac.__version__ ) parser.add_argument( "-v", "--verbose", action="store_true", help="Enable output messages" ) parser.add_argument( "-d", "--debug", action="count", help="Enable debugging output. Add characters to " "increase verbosity of output, e.g. '-dd'.", ) parser.add_argument( "-N", "--no-net", "--no-network-requests", action="store_true", dest="NO_NET", help="Do not use arping or send a UDP packet to refresh the ARP table", ) parser.add_argument( "--override-port", type=int, metavar="PORT", help="Override the default UDP port used to refresh the ARP table " "if network requests are enabled and arping is unavailable", ) parser.add_argument( "--override-platform", type=str, default=None, metavar="PLATFORM", help="Override the platform detection with the given value " "(e.g. 'linux', 'windows', 'freebsd', etc.'). " "Any values returned by platform.system() are valid.", ) parser.add_argument( "--force-method", type=str, default=None, metavar="METHOD", help="Force a specific method to be used, e.g. 'IpNeighborShow'. " "This will be used regardless of it's method type or platform " "compatibility, and Method.test() will NOT be checked!", ) group = parser.add_mutually_exclusive_group(required=False) group.add_argument( "-i", "--interface", type=str, default=None, help="Name of a network interface on the system", ) group.add_argument( "-4", "--ip", type=str, default=None, help="IPv4 address of a remote host" ) group.add_argument( "-6", "--ip6", type=str, default=None, help="IPv6 address of a remote host" ) group.add_argument( "-n", "--hostname", type=str, default=None, help="Hostname of a remote host" ) args = parser.parse_args() if args.debug or args.verbose: logging.basicConfig( format="%(levelname)-8s %(message)s", level=logging.DEBUG, stream=sys.stderr ) if args.debug: getmac.DEBUG = args.debug if args.override_port: port = int(args.override_port) getmac.log.debug( "Using UDP port %d (overriding the default port %d)", port, getmac.PORT ) getmac.PORT = port if args.override_platform: getmac.OVERRIDE_PLATFORM = args.override_platform.strip().lower() if args.force_method: getmac.FORCE_METHOD = args.force_method.strip().lower() mac = getmac.get_mac_address( interface=args.interface, ip=args.ip, ip6=args.ip6, hostname=args.hostname, network_request=not args.NO_NET, ) if mac is not None: print(mac) # noqa: T001, T201 sys.exit(0) # Exit success! else: sys.exit(1) # Exit with error since it failed to find a MAC if __name__ == "__main__": main() getmac-0.9.5/getmac/getmac.py000066400000000000000000001757701464534747600161040ustar00rootroot00000000000000# -*- coding: utf-8 -*- # http://web.archive.org/web/20140718071917/http://multivax.com/last_question.html """ Get the MAC address of remote hosts or network interfaces. It provides a platform-independent interface to get the MAC addresses of: - System network interfaces (by interface name) - Remote hosts on the local network (by IPv4/IPv6 address or hostname) It provides one function: ``get_mac_address()`` .. code-block:: python :caption: Examples from getmac import get_mac_address eth_mac = get_mac_address(interface="eth0") win_mac = get_mac_address(interface="Ethernet 3") ip_mac = get_mac_address(ip="192.168.0.1") ip6_mac = get_mac_address(ip6="::1") host_mac = get_mac_address(hostname="localhost") updated_mac = get_mac_address(ip="10.0.0.1", network_request=True) """ import ctypes import logging import os import platform import re import shlex import socket import struct import sys import traceback import warnings from subprocess import CalledProcessError, check_output try: # Python 3 from subprocess import DEVNULL # type: ignore except ImportError: # Python 2 DEVNULL = open(os.devnull, "wb") # type: ignore # Used for mypy (a data type analysis tool) # If you're copying the code, this section can be safely removed try: from typing import TYPE_CHECKING if TYPE_CHECKING: from typing import Dict, List, Optional, Set, Tuple, Type, Union except ImportError: pass # Configure logging log = logging.getLogger("getmac") # type: logging.Logger if not log.handlers: log.addHandler(logging.NullHandler()) __version__ = "0.9.5" PY2 = sys.version_info[0] == 2 # type: bool # Configurable settings DEBUG = 0 # type: int PORT = 55555 # type: int # Monkeypatch shutil.which for python 2.7 (TODO(python3): remove shutilwhich.py) if PY2: from .shutilwhich import which else: from shutil import which # Platform identifiers if PY2: _UNAME = platform.uname() # type: Tuple[str, str, str, str, str, str] _SYST = _UNAME[0] # type: str else: _UNAME = platform.uname() # type: platform.uname_result _SYST = _UNAME.system # type: str if _SYST == "Java": try: import java.lang _SYST = str(java.lang.System.getProperty("os.name")) except ImportError: _java_err_msg = "Can't determine OS: couldn't import java.lang on Jython" log.critical(_java_err_msg) warnings.warn(_java_err_msg, RuntimeWarning) WINDOWS = _SYST == "Windows" # type: bool DARWIN = _SYST == "Darwin" # type: bool OPENBSD = _SYST == "OpenBSD" # type: bool FREEBSD = _SYST == "FreeBSD" # type: bool NETBSD = _SYST == "NetBSD" # type: bool SOLARIS = _SYST == "SunOS" # type: bool # Not including Darwin or Solaris as a "BSD" BSD = OPENBSD or FREEBSD or NETBSD # type: bool # Windows Subsystem for Linux (WSL) WSL = False # type: bool LINUX = False # type: bool if _SYST == "Linux": if "Microsoft" in platform.version(): WSL = True else: LINUX = True # NOTE: "Linux" methods apply to Android without modifications # If there's Android-specific stuff then we can add a platform # identifier for it. ANDROID = ( hasattr(sys, "getandroidapilevel") or "ANDROID_STORAGE" in os.environ ) # type: bool # Generic platform identifier used for filtering methods PLATFORM = _SYST.lower() # type: str if PLATFORM == "linux" and "Microsoft" in platform.version(): PLATFORM = "wsl" # User-configurable override to force a specific platform # This will change to a function argument in 1.0.0 OVERRIDE_PLATFORM = "" # type: str # Force a specific method to be used for all lookups # Used for debugging and testing FORCE_METHOD = "" # type: str # Get and cache the configured system PATH on import # The process environment does not change after a process is started PATH = os.environ.get("PATH", os.defpath).split(os.pathsep) # type: List[str] if not WINDOWS: PATH.extend(("/sbin", "/usr/sbin")) else: # TODO: Prevent edge case on Windows where our script "getmac.exe" # gets added to the path ahead of the actual Windows getmac.exe # This just handles case where it's in a virtualenv, won't work /w global scripts PATH = [p for p in PATH if "\\getmac\\Scripts" not in p] # Build the str after modifications are made PATH_STR = os.pathsep.join(PATH) # type: str # Use a copy of the environment so we don't # modify the process's current environment. ENV = dict(os.environ) # type: Dict[str, str] ENV["LC_ALL"] = "C" # Ensure ASCII output so we parse correctly # Constants IP4 = 0 IP6 = 1 INTERFACE = 2 HOSTNAME = 3 MAC_RE_COLON = r"([0-9a-fA-F]{2}(?::[0-9a-fA-F]{2}){5})" MAC_RE_DASH = r"([0-9a-fA-F]{2}(?:-[0-9a-fA-F]{2}){5})" # On OSX, some MACs in arp output may have a single digit instead of two # Examples: "18:4f:32:5a:64:5", "14:cc:20:1a:99:0" # This can also happen on other platforms, like Solaris MAC_RE_SHORT = r"([0-9a-fA-F]{1,2}(?::[0-9a-fA-F]{1,2}){5})" # Ensure we only log the Python 2 warning once WARNED_UNSUPPORTED_PYTHONS = False # Cache of commands that have been checked for existence by check_command() CHECK_COMMAND_CACHE = {} # type: Dict[str, bool] def check_command(command): # type: (str) -> bool if command not in CHECK_COMMAND_CACHE: CHECK_COMMAND_CACHE[command] = bool(which(command, path=PATH_STR)) return CHECK_COMMAND_CACHE[command] def check_path(filepath): # type: (str) -> bool return os.path.exists(filepath) and os.access(filepath, os.R_OK) def _clean_mac(mac): # type: (Optional[str]) -> Optional[str] """Check and format a string result to be lowercase colon-separated MAC.""" if mac is None: return None # Handle cases where it's bytes (which are the same as str in PY2) mac = str(mac) if not PY2: # Strip bytestring conversion artifacts # TODO(python3): check for bytes and decode instead of this weird hack for garbage_string in ["b'", "'", "\\n", "\\r"]: mac = mac.replace(garbage_string, "") # Remove trailing whitespace, make lowercase, remove spaces, # and replace dashes '-' with colons ':'. mac = mac.strip().lower().replace(" ", "").replace("-", ":") # Fix cases where there are no colons if ":" not in mac and len(mac) == 12: log.debug("Adding colons to MAC %s", mac) mac = ":".join(mac[i : i + 2] for i in range(0, len(mac), 2)) # Pad single-character octets with a leading zero (e.g. Darwin's ARP output) elif len(mac) < 17: log.debug( "Length of MAC %s is %d, padding single-character octets with zeros", mac, len(mac), ) parts = mac.split(":") new_mac = [] for part in parts: if len(part) == 1: new_mac.append("0" + part) else: new_mac.append(part) mac = ":".join(new_mac) # MAC address should ALWAYS be 17 characters before being returned if len(mac) != 17: log.warning("MAC address %s is not 17 characters long!", mac) mac = None elif mac.count(":") != 5: log.warning("MAC address %s is missing colon (':') characters", mac) mac = None return mac def _read_file(filepath): # type: (str) -> Optional[str] try: with open(filepath) as f: return f.read() # This is IOError on Python 2.7 except (OSError, IOError): # noqa: B014 log.debug("Could not find file: '%s'", filepath) return None def _search(regex, text, group_index=0, flags=0): # type: (str, str, int, int) -> Optional[str] if not text: if DEBUG: log.debug("No text to _search()") return None match = re.search(regex, text, flags) if match: return match.groups()[group_index] return None def _popen(command, args): # type: (str, str) -> str for directory in PATH: executable = os.path.join(directory, command) if ( os.path.exists(executable) and os.access(executable, os.F_OK | os.X_OK) and not os.path.isdir(executable) ): break else: executable = command if DEBUG >= 3: log.debug("Running: '%s %s'", executable, args) return _call_proc(executable, args) def _call_proc(executable, args): # type: (str, str) -> str if WINDOWS: cmd = executable + " " + args # type: ignore else: cmd = [executable] + shlex.split(args) # type: ignore output = check_output(cmd, stderr=DEVNULL, env=ENV) if DEBUG >= 4: log.debug("Output from '%s' command: %s", executable, str(output)) if not PY2 and isinstance(output, bytes): return str(output, "utf-8") else: return str(output) def _uuid_convert(mac): # type: (int) -> str return ":".join(("%012X" % mac)[i : i + 2] for i in range(0, 12, 2)) def _fetch_ip_using_dns(): # type: () -> str """ Determines the IP address of the default network interface. Sends a UDP packet to Cloudflare's DNS (``1.1.1.1``), which should go through the default interface. This populates the source address of the socket, which we then inspect and return. """ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("1.1.1.1", 53)) ip = s.getsockname()[0] s.close() # NOTE: sockets don't have context manager in 2.7 :( return ip class Method: #: Valid platform identifier strings VALID_PLATFORM_NAMES = { "android", "darwin", "linux", "windows", "wsl", "openbsd", "freebsd", "sunos", "other", } #: Platforms supported by a method platforms = set() # type: Set[str] #: The type of method, e.g. does it get the MAC of a interface? #: Allowed values: {ip, ip4, ip6, iface, default_iface} method_type = "" # type: str #: If the method makes a network request as part of the check network_request = False # type: bool #: Marks the method as unable to be used, e.g. if there was a runtime #: error indicating the method won't work on the current platform. unusable = False # type: bool def test(self): # type: () -> bool # noqa: T484 """Low-impact test that the method is feasible, e.g. command exists.""" pass # pragma: no cover # TODO: automatically clean MAC on return def get(self, arg): # type: (str) -> Optional[str] """ Core logic of the method that performs the lookup. .. warning:: If the method itself fails to function an exception will be raised! (for instance, if some command arguments are invalid, or there's an internal error with the command, or a bug in the code). Args: arg (str): What the method should get, such as an IP address or interface name. In the case of default_iface methods, this is not used and defaults to an empty string. Returns: Lowercase colon-separated MAC address, or None if one could not be found. """ pass # pragma: no cover @classmethod def __str__(cls): # type: () -> str return cls.__name__ # TODO(python3): do we want to keep this around? It calls 3 commands and is # quite inefficient. We should just take the methods and use directly. class UuidArpGetNode(Method): platforms = {"linux", "darwin", "sunos", "other"} method_type = "ip" def test(self): # type: () -> bool try: from uuid import _arp_getnode # type: ignore return True except Exception: return False def get(self, arg): # type: (str) -> Optional[str] from uuid import _arp_getnode # type: ignore backup = socket.gethostbyname try: socket.gethostbyname = lambda x: arg # noqa: F841 mac1 = _arp_getnode() if mac1 is not None: mac1 = _uuid_convert(mac1) mac2 = _arp_getnode() mac2 = _uuid_convert(mac2) if mac1 == mac2: return mac1 except Exception: raise finally: socket.gethostbyname = backup return None class ArpFile(Method): platforms = {"linux"} method_type = "ip4" _path = os.environ.get("ARP_PATH", "/proc/net/arp") # type: str def test(self): # type: () -> bool return check_path(self._path) def get(self, arg): # type: (str) -> Optional[str] if not arg: return None data = _read_file(self._path) if data is None: self.unusable = True return None if data is not None and len(data) > 1: # Need a space, otherwise a search for 192.168.16.2 # will match 192.168.16.254 if it comes first! return _search(re.escape(arg) + r" .+" + MAC_RE_COLON, data) return None class ArpFreebsd(Method): platforms = {"freebsd"} method_type = "ip" def test(self): # type: () -> bool return check_command("arp") def get(self, arg): # type: (str) -> Optional[str] regex = r"\(" + re.escape(arg) + r"\)\s+at\s+" + MAC_RE_COLON return _search(regex, _popen("arp", arg)) class ArpOpenbsd(Method): platforms = {"openbsd"} method_type = "ip" _regex = r"[ ]+" + MAC_RE_COLON # type: str def test(self): # type: () -> bool return check_command("arp") def get(self, arg): # type: (str) -> Optional[str] return _search(re.escape(arg) + self._regex, _popen("arp", "-an")) class ArpVariousArgs(Method): platforms = {"linux", "darwin", "freebsd", "sunos", "other"} method_type = "ip" _regex_std = r"\)\s+at\s+" + MAC_RE_COLON # type: str _regex_darwin = r"\)\s+at\s+" + MAC_RE_SHORT # type: str _args = ( ("", True), # "arp 192.168.1.1" # Linux ("-an", False), # "arp -an" ("-an", True), # "arp -an 192.168.1.1" # Darwin, WSL, Linux distros??? ("-a", False), # "arp -a" ("-a", True), # "arp -a 192.168.1.1" ) _args_tested = False # type: bool _good_pair = () # type: Union[Tuple, Tuple[str, bool]] def test(self): # type: () -> bool return check_command("arp") def get(self, arg): # type: (str) -> Optional[str] if not arg: return None # Ensure output from testing command on first call isn't wasted command_output = "" # Test which arguments are valid to the command # This will NOT test which regex is valid if not self._args_tested: for pair_to_test in self._args: try: cmd_args = [pair_to_test[0]] # if True, then include IP as a command argument if pair_to_test[1]: cmd_args.append(arg) command_output = _popen("arp", " ".join(cmd_args)) self._good_pair = pair_to_test break except CalledProcessError as ex: if DEBUG: log.debug( "ArpVariousArgs pair test failed for (%s, %s): %s", pair_to_test[0], pair_to_test[1], str(ex), ) if not self._good_pair: self.unusable = True return None self._args_tested = True if not command_output: # if True, then include IP as a command argument cmd_args = [self._good_pair[0]] if self._good_pair[1]: cmd_args.append(arg) command_output = _popen("arp", " ".join(cmd_args)) escaped = re.escape(arg) _good_regex = ( self._regex_darwin if DARWIN or SOLARIS else self._regex_std ) # type: str return _search(r"\(" + escaped + _good_regex, command_output) class ArpExe(Method): """ Query the Windows ARP table using ``arp.exe`` to find the MAC address of a remote host. This only works for IPv4, since the ARP table is IPv4-only. Microsoft Documentation: `arp ` """ # noqa: E501 platforms = {"windows", "wsl"} method_type = "ip4" def test(self): # type: () -> bool # NOTE: specifying "arp.exe" instead of "arp" lets this work # seamlessly on WSL1 as well. On WSL2 it doesn't matter, since # it's basically just a Linux VM with some lipstick. return check_command("arp.exe") def get(self, arg): # type: (str) -> Optional[str] return _search(MAC_RE_DASH, _popen("arp.exe", "-a %s" % arg)) class ArpingHost(Method): """ Use ``arping`` command to determine the MAC of a host. Supports three variants of ``arping`` - "habets" arping by Thomas Habets (`GitHub `__) On Debian-based distros, ``apt install arping`` will install Habets arping. - "iputils" arping, from the ``iputils-arping`` `package `__ - "busybox" arping, included with BusyBox (a small executable "distro") (`further reading `__) BusyBox's arping quite similar to iputils-arping. The arguments for our purposes are the same, and the output is also the same. There's even a TODO in busybox's arping code referencing iputils arping. There are several differences: - The return code from bad arguments is 1, not 2 like for iputils-arping - The MAC address in output is lowercase (vs. uppercase in iputils-arping) This was a pain to obtain samples for busybox on Windows. I recommend using WSL and arping'ing the Docker gateway (for WSL2 distros). NOTE: it must be run as root using ``sudo busybox arping``. """ platforms = {"linux", "darwin"} method_type = "ip4" network_request = True _is_iputils = True # type: bool _habets_args = "-r -C 1 -c 1 %s" # type: str _iputils_args = "-f -c 1 %s" # type: str def test(self): # type: () -> bool return check_command("arping") def get(self, arg): # type: (str) -> Optional[str] # If busybox or iputils, this will just work, and if host ping fails, # then it'll exit with code 1 and this function will return None. # # If it's Habets, then it'll exit code 1 and have "invalid option" # and/or the help message in the output. # In the case of Habets, set self._is_iputils to False, # then re-try with Habets args. try: if self._is_iputils: command_output = _popen("arping", self._iputils_args % arg) if command_output: return _search( r" from %s \[(%s)\]" % (re.escape(arg), MAC_RE_COLON), command_output, ) else: return self._call_habets(arg) except CalledProcessError as ex: if ex.output and self._is_iputils: if not PY2 and isinstance(ex.output, bytes): output = str(ex.output, "utf-8").lower() else: output = str(ex.output).lower() if "habets" in output or "invalid option" in output: if DEBUG: log.debug("Falling back to Habets arping") self._is_iputils = False try: return self._call_habets(arg) except CalledProcessError: pass return None def _call_habets(self, arg): # type: (str) -> Optional[str] command_output = _popen("arping", self._habets_args % arg) if command_output: return command_output.strip() else: return None class CtypesHost(Method): """ Uses ``SendARP`` from the Windows ``Iphlpapi`` to get the MAC address of a remote IPv4 host. Microsoft Documentation: `SendARP function (iphlpapi.h) `__ """ # noqa: E501 platforms = {"windows"} method_type = "ip4" network_request = True def test(self): # type: () -> bool try: return ctypes.windll.wsock32.inet_addr(b"127.0.0.1") > 0 # noqa: T484 except Exception: return False def get(self, arg): # type: (str) -> Optional[str] if not PY2: # Convert to bytes on Python 3+ (Fixes GitHub issue #7) arg = arg.encode() # type: ignore try: inetaddr = ctypes.windll.wsock32.inet_addr(arg) # type: ignore if inetaddr in (0, -1): raise Exception except Exception: # TODO: this assumes failure is due to arg being a hostname # We should be explicit about only accepting ipv4 addresses # and handle any hostname resolution in calling code hostip = socket.gethostbyname(arg) inetaddr = ctypes.windll.wsock32.inet_addr(hostip) # type: ignore buffer = ctypes.c_buffer(6) addlen = ctypes.c_ulong(ctypes.sizeof(buffer)) # https://docs.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-sendarp send_arp = ctypes.windll.Iphlpapi.SendARP # type: ignore if send_arp(inetaddr, 0, ctypes.byref(buffer), ctypes.byref(addlen)) != 0: return None # Convert binary data into a string. macaddr = "" for intval in struct.unpack("BBBBBB", buffer): # type: ignore if intval > 15: replacestr = "0x" else: replacestr = "x" macaddr = "".join([macaddr, hex(intval).replace(replacestr, "")]) return macaddr class IpNeighborShow(Method): platforms = {"linux", "other"} method_type = "ip" # IPv6 and IPv4 def test(self): # type: () -> bool return check_command("ip") def get(self, arg): # type: (str) -> Optional[str] output = _popen("ip", "neighbor show %s" % arg) if not output: return None try: # NOTE: the space prevents accidental matching of partial IPs return ( output.partition(arg + " ")[2].partition("lladdr")[2].strip().split()[0] ) except IndexError as ex: log.debug("IpNeighborShow failed with exception: %s", str(ex)) return None class SysIfaceFile(Method): platforms = {"linux", "wsl"} method_type = "iface" _path = "/sys/class/net/" # type: str def test(self): # type: () -> bool # Imperfect, but should work well enough return check_path(self._path) def get(self, arg): # type: (str) -> Optional[str] data = _read_file(self._path + arg + "/address") # NOTE: if "/sys/class/net/" exists, but interface file doesn't, # then that means the interface doesn't exist # Sometimes this can be empty or a single newline character return None if data is not None and len(data) < 17 else data class UuidLanscan(Method): platforms = {"other"} method_type = "iface" def test(self): # type: () -> bool try: from uuid import _find_mac # noqa: T484 return check_command("lanscan") except Exception: return False def get(self, arg): # type: (str) -> Optional[str] from uuid import _find_mac # type: ignore if not PY2: arg = bytes(arg, "utf-8") # type: ignore mac = _find_mac("lanscan", "-ai", [arg], lambda i: 0) if mac: return _uuid_convert(mac) return None class FcntlIface(Method): platforms = {"linux", "wsl"} method_type = "iface" def test(self): # type: () -> bool try: import fcntl return True except Exception: # Broad except to handle unknown effects return False def get(self, arg): # type: (str) -> Optional[str] import fcntl if not PY2: arg = arg.encode() # type: ignore s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # 0x8927 = SIOCGIFADDR info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack("256s", arg[:15])) if PY2: return ":".join(["%02x" % ord(char) for char in info[18:24]]) else: return ":".join(["%02x" % ord(chr(char)) for char in info[18:24]]) class GetmacExe(Method): """ Uses Windows-builtin ``getmac.exe`` to get a interface's MAC address. Microsoft Documentation: `getmac `__ """ # noqa: E501 platforms = {"windows"} method_type = "iface" _regexes = [ # Connection Name (r"\r\n", r".*" + MAC_RE_DASH + r".*\r\n"), # Network Adapter (the human-readable name) (r"\r\n.*", r".*" + MAC_RE_DASH + r".*\r\n"), ] # type: List[Tuple[str, str]] _champ = () # type: Union[tuple, Tuple[str, str]] def test(self): # type: () -> bool # NOTE: the scripts from this library (getmac) are excluded from the # path used for checking variables, in getmac.getmac.PATH (defined # at the top of this file). Otherwise, this would get messy quickly :) return check_command("getmac.exe") def get(self, arg): # type: (str) -> Optional[str] try: # /nh: Suppresses table headers # /v: Verbose command_output = _popen("getmac.exe", "/NH /V") except CalledProcessError as ex: # This shouldn't cause an exception if it's valid command log.error("getmac.exe failed, marking unusable. Exception: %s", str(ex)) self.unusable = True return None if self._champ: return _search(self._champ[0] + arg + self._champ[1], command_output) for pair in self._regexes: result = _search(pair[0] + arg + pair[1], command_output) if result: self._champ = pair return result return None class IpconfigExe(Method): """ Uses ``ipconfig.exe`` to find interface MAC addresses on Windows. This is generally pretty reliable and works across a wide array of versions and releases. I'm not sure if it works pre-XP though. Microsoft Documentation: `ipconfig `__ """ # noqa: E501 platforms = {"windows"} method_type = "iface" _regex = ( r"(?:\n?[^\n]*){1,8}Physical Address[ .:]+" + MAC_RE_DASH + r"\r\n" ) # type: str def test(self): # type: () -> bool return check_command("ipconfig.exe") def get(self, arg): # type: (str) -> Optional[str] return _search(arg + self._regex, _popen("ipconfig.exe", "/all")) class WmicExe(Method): """ Use ``wmic.exe`` on Windows to find the MAC address of a network interface. Microsoft Documentation: `wmic `__ .. warning:: WMIC is deprecated as of Windows 10 21H1. This method may not work on Windows 11 and may stop working at some point on Windows 10 (unlikely, but possible). """ # noqa: E501 platforms = {"windows"} method_type = "iface" def test(self): # type: () -> bool return check_command("wmic.exe") def get(self, arg): # type: (str) -> Optional[str] command_output = _popen( "wmic.exe", 'nic where "NetConnectionID = \'%s\'" get "MACAddress" /value' % arg, ) # Negative: "No Instance(s) Available" # Positive: "MACAddress=00:FF:E7:78:95:A0" # NOTE: .partition() always returns 3 parts, # therefore it won't cause an IndexError return command_output.strip().partition("=")[2] class DarwinNetworksetupIface(Method): """ Use ``networksetup`` on MacOS (Darwin) to get the MAC address of a specific interface. I think that this is or was a BSD utility, but I haven't seen it on other BSDs (FreeBSD, OpenBSD, etc.). So, I'm treating it as a Darwin-specific utility until further notice. If you know otherwise, please open a PR :) If the command is present, it should always work, though naturally that is contingent upon the whims of Apple in newer MacOS releases. Man page: `networksetup (8) `__ """ platforms = {"darwin"} method_type = "iface" def test(self): # type: () -> bool return check_command("networksetup") def get(self, arg): # type: (str) -> Optional[str] command_output = _popen("networksetup", "-getmacaddress %s" % arg) return _search(MAC_RE_COLON, command_output) # This only took 15-20 hours of throwing my brain against a wall multiple times # over the span of 1-2 years to figure out. It works for almost all conceivable # output from "ifconfig", and probably netstat too. It can probably be made more # efficient by someone who actually knows how to write regex. # [: ]\s?(?:flags=|\s).*?(?:(?:\w+[: ]\s?flags=)|\s(?:ether|address|HWaddr|hwaddr|lladdr)[ :]?\s?([0-9a-fA-F]{2}(?::[0-9a-fA-F]{2}){5})) # noqa: E501 IFCONFIG_REGEX = ( r"[: ]\s?(?:flags=|\s).*?(?:" r"(?:\w+[: ]\s?flags=)|" # Prevent interfaces w/o a MAC from matching r"\s(?:ether|address|HWaddr|hwaddr|lladdr)[ :]?\s?" # Handle various prefixes r"([0-9a-fA-F]{2}(?::[0-9a-fA-F]{2}){5}))" # Match the MAC ) def _parse_ifconfig(iface, command_output): # type: (str, str) -> Optional[str] if not iface or not command_output: return None # Sanity check on input e.g. if user does "eth0:" as argument iface = iface.strip(":") # "(?:^|\s)": prevent an input of "h0" from matching on "eth0" search_re = r"(?:^|\s)" + iface + IFCONFIG_REGEX return _search(search_re, command_output, flags=re.DOTALL) class IfconfigWithIfaceArg(Method): """ ``ifconfig`` command with the interface name as an argument (e.g. ``ifconfig eth0``). """ platforms = {"linux", "wsl", "freebsd", "openbsd", "other"} method_type = "iface" def test(self): # type: () -> bool return check_command("ifconfig") def get(self, arg): # type: (str) -> Optional[str] try: command_output = _popen("ifconfig", arg) except CalledProcessError as err: # Return code of 1 means interface doesn't exist if err.returncode == 1: return None else: raise err # this will cause another method to be used return _parse_ifconfig(arg, command_output) # TODO: combine this with IfconfigWithArg/IfconfigNoArg # (need to do live testing on Darwin) class IfconfigEther(Method): platforms = {"darwin"} method_type = "iface" _tested_arg = False # type: bool _iface_arg = False # type: bool def test(self): # type: () -> bool return check_command("ifconfig") def get(self, arg): # type: (str) -> Optional[str] # Check if this version of "ifconfig" accepts an interface argument command_output = "" if not self._tested_arg: try: command_output = _popen("ifconfig", arg) self._iface_arg = True except CalledProcessError: self._iface_arg = False self._tested_arg = True if self._iface_arg and not command_output: # Don't repeat work on first run command_output = _popen("ifconfig", arg) else: command_output = _popen("ifconfig", "") return _parse_ifconfig(arg, command_output) # TODO: create new methods, IfconfigNoArgs and IfconfigVariousArgs # TODO: unit tests class IfconfigOther(Method): """ Wild 'Shot in the Dark' attempt at ``ifconfig`` for unknown platforms. """ platforms = {"linux", "other"} method_type = "iface" # "-av": Tru64 system? _args = ( ("", (r"(?::| ).*?\sether\s", r"(?::| ).*?\sHWaddr\s")), ("-a", r".*?HWaddr\s"), ("-v", r".*?HWaddr\s"), ("-av", r".*?Ether\s"), ) _args_tested = False # type: bool _good_pair = [] # type: List[Union[str, Tuple[str, str]]] def test(self): # type: () -> bool return check_command("ifconfig") def get(self, arg): # type: (str) -> Optional[str] if not arg: return None # Cache output from testing command so first call isn't wasted command_output = "" # Test which arguments are valid to the command if not self._args_tested: for pair_to_test in self._args: try: command_output = _popen("ifconfig", pair_to_test[0]) self._good_pair = list(pair_to_test) # noqa: T484 if isinstance(self._good_pair[1], str): self._good_pair[1] += MAC_RE_COLON break except CalledProcessError as ex: if DEBUG: log.debug( "IfconfigOther pair test failed for (%s, %s): %s", pair_to_test[0], pair_to_test[1], str(ex), ) if not self._good_pair: self.unusable = True return None self._args_tested = True if not command_output and isinstance(self._good_pair[0], str): command_output = _popen("ifconfig", self._good_pair[0]) # Handle the two possible search terms if isinstance(self._good_pair[1], tuple): for term in self._good_pair[1]: regex = term + MAC_RE_COLON result = _search(re.escape(arg) + regex, command_output) if result: # changes type from tuple to str, so the else statement # will be hit on the next call to this method self._good_pair[1] = regex return result return None else: return _search(re.escape(arg) + self._good_pair[1], command_output) class NetstatIface(Method): platforms = {"linux", "wsl", "other"} method_type = "iface" # ".*?": non-greedy # https://docs.python.org/3/howto/regex.html#greedy-versus-non-greedy _regexes = [ r": .*?ether " + MAC_RE_COLON, r": .*?HWaddr " + MAC_RE_COLON, # Ubuntu 12.04 and other older kernels r" .*?Link encap:Ethernet HWaddr " + MAC_RE_COLON, ] # type: List[str] _working_regex = "" # type: str def test(self): # type: () -> bool return check_command("netstat") # TODO: consolidate the parsing logic between IfconfigOther and netstat def get(self, arg): # type: (str) -> Optional[str] # NOTE: netstat and ifconfig pull from the same kernel source and # therefore have the same output format on the same platform. command_output = _popen("netstat", "-iae") if not command_output: log.warning("no netstat output, marking unusable") self.unusable = True return None if self._working_regex: # Use regex that worked previously. This can still return None in # the case of interface not existing, but at least it's a bit faster. return _search(arg + self._working_regex, command_output, flags=re.DOTALL) # See if either regex matches for regex in self._regexes: result = _search(arg + regex, command_output, flags=re.DOTALL) if result: self._working_regex = regex return result return None # TODO: Add to IpLinkIface # TODO: New method for "ip addr"? (this would be useful for CentOS and others as a fallback) # (r"state UP.*\n.*ether " + MAC_RE_COLON, 0, "ip", ["link","addr"]), # (r"wlan.*\n.*ether " + MAC_RE_COLON, 0, "ip", ["link","addr"]), # (r"ether " + MAC_RE_COLON, 0, "ip", ["link","addr"]), # _regexes = ( # r".*\n.*link/ether " + MAC_RE_COLON, # # Android 6.0.1+ (and likely other platforms as well) # r"state UP.*\n.*ether " + MAC_RE_COLON, # r"wlan.*\n.*ether " + MAC_RE_COLON, # r"ether " + MAC_RE_COLON, # ) # type: Tuple[str, str, str, str] class IpLinkIface(Method): platforms = {"linux", "wsl", "android", "other"} method_type = "iface" _regex = r".*\n.*link/ether " + MAC_RE_COLON # type: str _tested_arg = False # type: bool _iface_arg = False # type: bool def test(self): # type: () -> bool return check_command("ip") def get(self, arg): # type: (str) -> Optional[str] # Check if this version of "ip link" accepts an interface argument # Not accepting one is a quirk of older versions of 'iproute2' # TODO: is it "ip link " on some platforms and "ip link show " on others? command_output = "" if not self._tested_arg: try: command_output = _popen("ip", "link show " + arg) self._iface_arg = True except CalledProcessError as err: # Output: 'Command "eth0" is unknown, try "ip link help"' if err.returncode != 255: raise err self._tested_arg = True if self._iface_arg: if not command_output: # Don't repeat work on first run command_output = _popen("ip", "link show " + arg) return _search(arg + self._regex, command_output) else: # TODO: improve this regex to not need extra portion for no arg command_output = _popen("ip", "link") return _search(arg + r":" + self._regex, command_output) class DefaultIfaceLinuxRouteFile(Method): """ Get the default interface by parsing the ``/proc/net/route`` file. This is the same source as the ``route`` command, however it's much faster to read this file than to call ``route``. If it fails for whatever reason, we can fall back on the system commands (e.g for a platform that has a route command, but doesn't use ``/proc``, such as BSD-based platforms). """ platforms = {"linux", "wsl"} method_type = "default_iface" def test(self): # type: () -> bool return check_path("/proc/net/route") def get(self, arg=""): # type: (str) -> Optional[str] data = _read_file("/proc/net/route") if data is not None and len(data) > 1: for line in data.split("\n")[1:-1]: line = line.strip() if not line: continue # Some have tab separators, some have spaces if "\t" in line: sep = "\t" else: sep = " " iface_name, dest = line.split(sep)[:2] if dest == "00000000": return iface_name if DEBUG: log.debug( "Failed to find default interface in data from " "'/proc/net/route', no destination of '00000000' was found" ) elif DEBUG: log.warning("No data from /proc/net/route") return None class DefaultIfaceRouteCommand(Method): platforms = {"linux", "wsl", "other"} method_type = "default_iface" def test(self): # type: () -> bool return check_command("route") def get(self, arg=""): # type: (str) -> Optional[str] output = _popen("route", "-n") try: return output.partition("0.0.0.0")[2].partition("\n")[0].split()[-1] except IndexError as ex: # index errors means no default route in output? log.debug("DefaultIfaceRouteCommand failed for %s: %s", arg, str(ex)) return None class DefaultIfaceRouteGetCommand(Method): platforms = {"darwin", "freebsd", "other"} method_type = "default_iface" def test(self): # type: () -> bool return check_command("route") def get(self, arg=""): # type: (str) -> Optional[str] output = _popen("route", "get default") if not output: return None try: return output.partition("interface: ")[2].strip().split()[0].strip() except IndexError as ex: log.debug("DefaultIfaceRouteCommand failed for %s: %s", arg, str(ex)) return None class DefaultIfaceIpRoute(Method): # NOTE: this is slightly faster than "route" since # there is less output than "route -n" platforms = {"linux", "wsl", "other"} method_type = "default_iface" def test(self): # type: () -> bool return check_command("ip") def get(self, arg=""): # type: (str) -> Optional[str] output = _popen("ip", "route list 0/0") if not output: if DEBUG: log.debug("DefaultIfaceIpRoute failed: no output") return None return output.partition("dev")[2].partition("proto")[0].strip() class DefaultIfaceOpenBsd(Method): platforms = {"openbsd"} method_type = "default_iface" def test(self): # type: () -> bool return check_command("route") def get(self, arg=""): # type: (str) -> Optional[str] output = _popen("route", "-nq show -inet -gateway -priority 1") return output.partition("127.0.0.1")[0].strip().rpartition(" ")[2] class DefaultIfaceFreeBsd(Method): platforms = {"freebsd"} method_type = "default_iface" def test(self): # type: () -> bool return check_command("netstat") def get(self, arg=""): # type: (str) -> Optional[str] output = _popen("netstat", "-r") return _search(r"default[ ]+\S+[ ]+\S+[ ]+(\S+)[\r\n]+", output) # TODO: order methods by effectiveness/reliability # Use a class attribute maybe? e.g. "score", then sort by score in cache METHODS = [ # NOTE: CtypesHost is faster than ArpExe because of sub-process startup times :) CtypesHost, ArpFile, ArpingHost, SysIfaceFile, FcntlIface, UuidLanscan, GetmacExe, IpconfigExe, WmicExe, ArpExe, DarwinNetworksetupIface, ArpFreebsd, ArpOpenbsd, IfconfigWithIfaceArg, IfconfigEther, IfconfigOther, IpLinkIface, NetstatIface, IpNeighborShow, ArpVariousArgs, UuidArpGetNode, DefaultIfaceLinuxRouteFile, DefaultIfaceIpRoute, DefaultIfaceRouteCommand, DefaultIfaceRouteGetCommand, DefaultIfaceOpenBsd, DefaultIfaceFreeBsd, ] # type: List[Type[Method]] # Primary method to use for a given method type METHOD_CACHE = { "ip4": None, "ip6": None, "iface": None, "default_iface": None, } # type: Dict[str, Optional[Method]] # Order of methods is determined by: # Platform + version # Performance (file read > command) # Reliability (how well I know/understand the command to work) FALLBACK_CACHE = { "ip4": [], "ip6": [], "iface": [], "default_iface": [], } # type: Dict[str, List[Method]] DEFAULT_IFACE = "" # type: str def get_method_by_name(method_name): # type: (str) -> Optional[Type[Method]] for method in METHODS: if method.__name__.lower() == method_name.lower(): return method return None def get_instance_from_cache(method_type, method_name): # type: (str, str) -> Optional[Method] """ Get the class for a named Method from the caches. METHOD_CACHE is checked first, and if that fails, then any entries in FALLBACK_CACHE are checked. If both fail, None is returned. Args: method_type: method type to initialize the cache for. Allowed values are: ``ip4`` | ``ip6`` | ``iface`` | ``default_iface`` """ if str(METHOD_CACHE[method_type]) == method_name: return METHOD_CACHE[method_type] for f_meth in FALLBACK_CACHE[method_type]: if str(f_meth) == method_name: return f_meth return None def _swap_method_fallback(method_type, swap_with): # type: (str, str) -> bool if str(METHOD_CACHE[method_type]) == swap_with: return True found = None # type: Optional[Method] for f_meth in FALLBACK_CACHE[method_type]: if str(f_meth) == swap_with: found = f_meth break if not found: return False curr = METHOD_CACHE[method_type] FALLBACK_CACHE[method_type].remove(found) METHOD_CACHE[method_type] = found FALLBACK_CACHE[method_type].insert(0, curr) # noqa: T484 return True def _warn_critical(err_msg): # type: (str) -> None log.critical(err_msg) warnings.warn( "%s. NOTICE: this warning will likely turn into a raised exception in getmac 1.0.0!" % err_msg, RuntimeWarning, ) def initialize_method_cache( method_type, network_request=True ): # type: (str, bool) -> bool """ Initialize the method cache for the given method type. Args: method_type: method type to initialize the cache for. Allowed values are: ``ip4`` | ``ip6`` | ``iface`` | ``default_iface`` network_request: if methods that make network requests should be included (those methods that have the attribute ``network_request`` set to ``True``) """ if METHOD_CACHE.get(method_type): if DEBUG: log.debug( "Method cache already initialized for method type '%s'", method_type ) return True log.debug("Initializing '%s' method cache (platform: '%s')", method_type, PLATFORM) if OVERRIDE_PLATFORM: log.warning( "Platform override is set, using '%s' as platform " "instead of detected platform '%s'", OVERRIDE_PLATFORM, PLATFORM, ) platform = OVERRIDE_PLATFORM else: platform = PLATFORM if DEBUG >= 4: meth_strs = ", ".join(m.__name__ for m in METHODS) # type: str log.debug("%d methods available: %s", len(METHODS), meth_strs) # Filter methods by the type of MAC we're looking for, such as "ip" # for remote host methods or "iface" for local interface methods. type_methods = [ method for method in METHODS if (method.method_type != "ip" and method.method_type == method_type) # Methods with a type of "ip" can handle both IPv4 and IPv6 or (method.method_type == "ip" and method_type in ["ip4", "ip6"]) ] # type: List[Type[Method]] if not type_methods: _warn_critical("No valid methods matching MAC type '%s'" % method_type) return False if DEBUG >= 2: type_strs = ", ".join(tm.__name__ for tm in type_methods) # type: str log.debug( "%d type-filtered methods for '%s': %s", len(type_methods), method_type, type_strs, ) # Filter methods by the platform we're running on platform_methods = [ method for method in type_methods if platform in method.platforms ] # type: List[Type[Method]] if not platform_methods: # If there isn't a method for the current platform, # then fallback to the generic platform "other". warn_msg = ( "No methods for platform '%s'! Your system may not be supported. " "Falling back to platform 'other'." % platform ) log.warning(warn_msg) warnings.warn(warn_msg, RuntimeWarning) platform_methods = [ method for method in type_methods if "other" in method.platforms ] if DEBUG >= 2: plat_strs = ", ".join(pm.__name__ for pm in platform_methods) # type: str log.debug( "%d platform-filtered methods for '%s' (method_type='%s'): %s", len(platform_methods), platform, method_type, plat_strs, ) if not platform_methods: _warn_critical( "No valid methods found for MAC type '%s' and platform '%s'" % (method_type, platform) ) return False filtered_methods = platform_methods # type: List[Type[Method]] # If network_request is False, then remove any methods that have network_request=True if not network_request: filtered_methods = [m for m in platform_methods if not m.network_request] # Determine which methods work on the current system tested_methods = [] # type: List[Method] for method_class in filtered_methods: method_instance = method_class() # type: Method try: test_result = method_instance.test() # type: bool except Exception: test_result = False if test_result: tested_methods.append(method_instance) # First successful test goes in the cache if not METHOD_CACHE[method_type]: METHOD_CACHE[method_type] = method_instance elif DEBUG: log.debug("Test failed for method '%s'", str(method_instance)) if not tested_methods: _warn_critical( "All %d '%s' methods failed to test!" % (len(filtered_methods), method_type) ) return False if DEBUG >= 2: tested_strs = ", ".join(str(ts) for ts in tested_methods) # type: str log.debug( "%d tested methods for '%s': %s", len(tested_methods), method_type, tested_strs, ) # Populate fallback cache with all the tested methods, minus the currently active method if METHOD_CACHE[method_type] and METHOD_CACHE[method_type] in tested_methods: tested_methods.remove(METHOD_CACHE[method_type]) # noqa: T484 FALLBACK_CACHE[method_type] = tested_methods if DEBUG: log.debug( "Current method cache: %s", str({k: str(v) for k, v in METHOD_CACHE.items()}), ) log.debug( "Current fallback cache: %s", str({k: str(v) for k, v in FALLBACK_CACHE.items()}), ) log.debug("Finished initializing '%s' method cache", method_type) return True def _remove_unusable(method, method_type): # type: (Method, str) -> Optional[Method] if not FALLBACK_CACHE[method_type]: log.warning("No fallback method for unusable method '%s'!", str(method)) METHOD_CACHE[method_type] = None else: METHOD_CACHE[method_type] = FALLBACK_CACHE[method_type].pop(0) log.warning( "Falling back to '%s' for unusable method '%s'", str(METHOD_CACHE[method_type]), str(method), ) return METHOD_CACHE[method_type] def _attempt_method_get( method, method_type, arg ): # type: (Method, str, str) -> Optional[str] """ Attempt to use methods, and if they fail, fallback to the next method in the cache. """ if not METHOD_CACHE[method_type] and not FALLBACK_CACHE[method_type]: _warn_critical("No usable methods found for MAC type '%s'" % method_type) return None if DEBUG: log.debug( "Attempting get() (method='%s', method_type='%s', arg='%s')", str(method), method_type, arg, ) result = None try: result = method.get(arg) except CalledProcessError as ex: # Don't mark return code 1 on a process as unusable! # Example of return code 1 on ifconfig from WSL: # Blake:goesc$ ifconfig eth8 # eth8: error fetching interface information: Device not found # Blake:goesc$ echo $? # 1 # Methods where an exit code of 1 makes it invalid should handle the # CalledProcessError, inspect the return code, and set self.unusable = True if ex.returncode != 1: log.warning( "Cached Method '%s' failed for '%s' lookup with process exit " "code '%d' != 1, marking unusable. Exception: %s", str(method), method_type, ex.returncode, str(ex), ) method.unusable = True except Exception as ex: log.warning( "Cached Method '%s' failed for '%s' lookup with unhandled exception: %s", str(method), method_type, str(ex), ) method.unusable = True # When an unhandled exception occurs (or exit code other than 1), remove # the method from the cache and reinitialize with next candidate. if not result and method.unusable: new_method = _remove_unusable(method, method_type) if not new_method: return None return _attempt_method_get(new_method, method_type, arg) return result def get_by_method(method_type, arg="", network_request=True): # type: (str, str, bool) -> Optional[str] """ Query for a MAC using a specific method. Args: method_type: the type of lookup being performed. Allowed values are: ``ip4``, ``ip6``, ``iface``, ``default_iface`` arg: Argument to pass to the method, e.g. an interface name or IP address network_request: if methods that make network requests should be included (those methods that have the attribute ``network_request`` set to ``True``) """ if not arg and method_type != "default_iface": log.error("Empty arg for method '%s' (raw value: %s)", method_type, repr(arg)) return None if FORCE_METHOD: log.warning( "Forcing method '%s' to be used for '%s' lookup (arg: '%s')", FORCE_METHOD, method_type, arg, ) forced_method = get_method_by_name(FORCE_METHOD) if not forced_method: log.error("Invalid FORCE_METHOD method name '%s'", FORCE_METHOD) return None return forced_method().get(arg) method = METHOD_CACHE.get(method_type) # type: Optional[Method] if not method: # Initialize the cache if it hasn't been already if not initialize_method_cache(method_type, network_request): log.error( "Failed to initialize method cache for method '%s' (arg: '%s')", method_type, arg, ) return None method = METHOD_CACHE[method_type] if not method: log.error( "Initialization failed for method '%s'. It may not be supported " "on this platform or another issue occurred.", method_type, ) return None # TODO: add a "net_ok" argument, check network_request attribute # on method in CACHE, if not then keep checking for method in # FALLBACK_CACHE that has network_request. result = _attempt_method_get(method, method_type, arg) # Log normal get() failures if debugging is enabled if DEBUG and not result: log.debug("Method '%s' failed for '%s' lookup", str(method), method_type) return result def get_mac_address( # noqa: C901 interface=None, ip=None, ip6=None, hostname=None, network_request=True ): # type: (Optional[str], Optional[str], Optional[str], Optional[str], bool) -> Optional[str] """ Get an Unicast IEEE 802 MAC-48 address from a local interface or remote host. Only ONE of the first four arguments may be used (``interface``,``ip``, ``ip6``, or ``hostname``). If none of the arguments are selected, the default network interface for the system will be used. .. warning:: In getmac 1.0.0, exceptions will be raised if the method cache initialization fails (in other words, if there are no valid methods found for the type of MAC requested). .. warning:: You MUST provide :class:`str` typed arguments, REGARDLESS of Python version .. note:: ``"localhost"`` or ``"127.0.0.1"`` will always return ``"00:00:00:00:00:00"`` .. note:: It is assumed that you are using Ethernet or Wi-Fi. While other protocols such as Bluetooth may work, this has not been tested and should not be relied upon. If you need this functionality, please open an issue (or better yet, a Pull Request ;))! .. note:: Exceptions raised by methods are handled silently and returned as :obj:`None`. Args: interface (str): Name of a local network interface (e.g "Ethernet 3", "eth0", "ens32") ip (str): Canonical dotted decimal IPv4 address of a remote host (e.g ``192.168.0.1``) ip6 (str): Canonical shortened IPv6 address of a remote host (e.g ``ff02::1:ffe7:7f19``) hostname (str): DNS hostname of a remote host (e.g "router1.mycorp.com", "localhost") network_request (bool): If network requests should be made when attempting to find the MAC of a remote host. If the ``arping`` command is available, this will be used. If not, a UDP packet will be sent to the remote host to populate the ARP/NDP tables for IPv4/IPv6. The port this packet is sent to can be configured using the module variable ``getmac.PORT``. Returns: Lowercase colon-separated MAC address, or :obj:`None` if one could not be found or there was an error. """ # noqa: E501 if DEBUG: import timeit start_time = timeit.default_timer() if PY2 or (sys.version_info[0] == 3 and sys.version_info[1] < 7): global WARNED_UNSUPPORTED_PYTHONS if not WARNED_UNSUPPORTED_PYTHONS: warning_string = ( "Support for Python versions < 3.7 is deprecated and will be " "removed in getmac 1.0.0. If you are stuck on an unsupported " "Python, considor loosely pinning the version of this package " 'in your dependency list, e.g. "getmac<1.0.0" or "getmac~=0.9.0".' ) warnings.warn(warning_string, DeprecationWarning) log.warning(warning_string) # Ensure it appears in any logs WARNED_UNSUPPORTED_PYTHONS = True if (hostname and hostname == "localhost") or (ip and ip == "127.0.0.1"): return "00:00:00:00:00:00" # Resolve hostname to an IP address if hostname: # Exceptions will be handled silently and returned as a None try: # TODO: can this return a IPv6 address? If so, handle that! ip = socket.gethostbyname(hostname) except Exception as ex: log.error("Could not resolve hostname '%s': %s", hostname, ex) if DEBUG: log.debug(traceback.format_exc()) return None if ip6: if not socket.has_ipv6: log.error( "Cannot get the MAC address of a IPv6 host: " "IPv6 is not supported on this system" ) return None elif ":" not in ip6: log.error("Invalid IPv6 address (no ':'): %s", ip6) return None mac = None if network_request and (ip or ip6): send_udp_packet = True # type: bool # If IPv4, use ArpingHost or CtypesHost if they're available instead # of populating the ARP table. This provides more reliable results # and a ARP packet is lower impact than a UDP packet. if ip: if not METHOD_CACHE["ip4"]: initialize_method_cache("ip4", network_request) # If ArpFile succeeds, just use that, since it's # significantly faster than arping (file read vs. # spawning a process). if not FORCE_METHOD or FORCE_METHOD.lower() == "arpfile": af_meth = get_instance_from_cache("ip4", "ArpFile") if af_meth: mac = _attempt_method_get(af_meth, "ip4", ip) # TODO: add tests for this logic (arpfile => fallback) # This seems to be a common course of GitHub issues, # so fixing it for good and adding robust tests is # probably a good idea. if not mac: for arp_meth in ["CtypesHost", "ArpingHost"]: if FORCE_METHOD and FORCE_METHOD.lower() != arp_meth: continue if arp_meth == str(METHOD_CACHE["ip4"]): send_udp_packet = False break elif any( arp_meth == str(x) for x in FALLBACK_CACHE["ip4"] ) and _swap_method_fallback("ip4", arp_meth): send_udp_packet = False break # Populate the ARP table by sending an empty UDP packet to a high port if send_udp_packet and not mac: if DEBUG: log.debug( "Attempting to populate ARP table with UDP packet to %s:%d", ip if ip else ip6, PORT, ) if ip: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) else: sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) try: if ip: sock.sendto(b"", (ip, PORT)) else: sock.sendto(b"", (ip6, PORT)) except Exception: log.error("Failed to send ARP table population packet") if DEBUG: log.debug(traceback.format_exc()) finally: sock.close() elif DEBUG: log.debug( "Not sending UDP packet, using network request method '%s' instead", str(METHOD_CACHE["ip4"]), ) # Setup the address hunt based on the arguments specified if not mac: if ip6: mac = get_by_method("ip6", ip6) elif ip: mac = get_by_method("ip4", ip) elif interface: mac = get_by_method("iface", interface) else: # Default to searching for interface # Default to finding MAC of the interface with the default route if WINDOWS and network_request: default_iface_ip = _fetch_ip_using_dns() mac = get_by_method("ip4", default_iface_ip) elif WINDOWS: # TODO: implement proper default interface detection on windows # (add a Method subclass to implement DefaultIface on Windows) mac = get_by_method("iface", "Ethernet") else: global DEFAULT_IFACE if not DEFAULT_IFACE: DEFAULT_IFACE = get_by_method("default_iface") # noqa: T484 if DEFAULT_IFACE: DEFAULT_IFACE = str(DEFAULT_IFACE).strip() # TODO: better fallback if default iface lookup fails if not DEFAULT_IFACE and BSD: DEFAULT_IFACE = "em0" elif not DEFAULT_IFACE and DARWIN: # OSX, maybe? DEFAULT_IFACE = "en0" elif not DEFAULT_IFACE: DEFAULT_IFACE = "eth0" mac = get_by_method("iface", DEFAULT_IFACE) # TODO: hack to fallback to loopback if lookup fails if not mac: mac = get_by_method("iface", "lo") log.debug("Raw MAC found: %s", mac) # Log how long it took if DEBUG: duration = timeit.default_timer() - start_time log.debug("getmac took %.4f seconds", duration) return _clean_mac(mac) getmac-0.9.5/getmac/shutilwhich.py000066400000000000000000000051031464534747600171550ustar00rootroot00000000000000# -*- coding: utf-8 -*- # This is a stopgap to maintain Python 2.7 support for the 0.9.0 release. # # Code copied from the "shutilwhich" project by Marc Brinkmann (@mbr) # Source: https://github.com/mbr/shutilwhich # # We can't depend on it in setup.py since getmac has the __version__, # which is imported in setup.py, which requires shutilwhich to be installed, # leading to the typical problem: which came first, the Python or the Egg? :) import os import sys # Everything below this point has been copied verbatim from the Python-3.3 # sources. def which(cmd, mode=os.F_OK | os.X_OK, path=None): """Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be overridden with a custom search path. """ # Check that a given file can be accessed with the correct mode. # Additionally check that `file` is not a directory, as on Windows # directories pass the os.access check. def _access_check(fn, mode): return os.path.exists(fn) and os.access(fn, mode) and not os.path.isdir(fn) # Short circuit. If we're given a full path which matches the mode # and it exists, we're done here. if _access_check(cmd, mode): return cmd path = (path or os.environ.get("PATH", os.defpath)).split(os.pathsep) if sys.platform == "win32": # The current directory takes precedence on Windows. if os.curdir not in path: path.insert(0, os.curdir) # PATHEXT is necessary to check on Windows. pathext = os.environ.get("PATHEXT", "").split(os.pathsep) # See if the given file matches any of the expected path extensions. # This will allow us to short circuit when given "python.exe". matches = [cmd for ext in pathext if cmd.lower().endswith(ext.lower())] # If it does match, only test that one, otherwise we have to try # others. files = [cmd] if matches else [cmd + ext.lower() for ext in pathext] else: # On other platforms you don't have things like PATHEXT to tell you # what file suffixes are executable, so just pass on cmd as-is. files = [cmd] seen = set() for dir in path: dir = os.path.normcase(dir) if dir not in seen: seen.add(dir) for thefile in files: name = os.path.join(dir, thefile) if _access_check(name, mode): return name return None getmac-0.9.5/packaging/000077500000000000000000000000001464534747600147355ustar00rootroot00000000000000getmac-0.9.5/packaging/Dockerfile000066400000000000000000000003411464534747600167250ustar00rootroot00000000000000FROM python:3 LABEL maintainer="Christopher Goes " LABEL project_url="https://github.com/GhostofGoes/getmac" ADD .. /opt/getmac WORKDIR /opt/getmac RUN python setup.py install ENTRYPOINT ["getmac"] getmac-0.9.5/packaging/rpm/000077500000000000000000000000001464534747600155335ustar00rootroot00000000000000getmac-0.9.5/packaging/rpm/build-rpm-python2.sh000066400000000000000000000010501464534747600213570ustar00rootroot00000000000000#!/usr/bin/env bash SPECPATH="./packaging/python2-getmac.spec" sudo dnf install gcc rpm-build rpm-devel rpmlint make python bash coreutils diffutils patch rpmdevtools rpmdev-setuptree mkdir getmac-$1 mkdir getmac-$1/docs mkdir getmac-$1/docs/man cp -rt getmac-$1 getmac setup.py README.md LICENSE cp docs/man/getmac2.1 getmac-$1/docs/man tar czf getmac-$1.tar.gz getmac-$1 mv getmac-$1.tar.gz ~/rpmbuild/SOURCES/ cp "$SPECPATH" ~/rpmbuild/SPECS/ rm -rf getmac-$1 cd ~/rpmbuild/SPECS/ rpmbuild -bs python2-getmac.spec rpmbuild -bb python2-getmac.spec getmac-0.9.5/packaging/rpm/build-rpm-python3.sh000066400000000000000000000010471464534747600213660ustar00rootroot00000000000000#!/usr/bin/env bash SPECPATH="./packaging/python3-getmac.spec" sudo dnf install gcc rpm-build rpm-devel rpmlint make python bash coreutils diffutils patch rpmdevtools rpmdev-setuptree mkdir getmac-$1 mkdir getmac-$1/docs mkdir getmac-$1/docs/man cp -rt getmac-$1 getmac setup.py README.md LICENSE cp docs/man/getmac.1 getmac-$1/docs/man tar czf getmac-$1.tar.gz getmac-$1 mv getmac-$1.tar.gz ~/rpmbuild/SOURCES/ cp "$SPECPATH" ~/rpmbuild/SPECS/ rm -rf getmac-$1 cd ~/rpmbuild/SPECS/ rpmbuild -bs python3-getmac.spec rpmbuild -bb python3-getmac.spec getmac-0.9.5/packaging/rpm/man/000077500000000000000000000000001464534747600163065ustar00rootroot00000000000000getmac-0.9.5/packaging/rpm/man/getmac.1000066400000000000000000000253151464534747600176360ustar00rootroot00000000000000.\" Man page generated from reStructuredText. . .TH "GETMAC" "1" "Oct 06, 2018" "0.6.0" "getmac" .SH NAME getmac \- Cross-platform Python package to get MAC addresses . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. \fI\%Latest version on PyPI\fP \fI\%Documentation status\fP \fI\%Travis CI build status\fP \fI\%Appveyor build status\fP .sp Get the MAC address of remote LAN hosts and system network interfaces using Python. .sp It provides a platform\-independant interface to get the MAC addresses of: .INDENT 0.0 .IP \(bu 2 System network interfaces (by interface name) .IP \(bu 2 Remote hosts on the local network (by IPv4/IPv6 address or hostname) .UNINDENT .sp It provides one function: \fBget_mac_address()\fP .sp \fI\%asciicast\fP .sp \fI\%asciicast\fP .INDENT 0.0 .IP \(bu 2 Pure\-Python .IP \(bu 2 Supports Python 2.6+, 3.4+, pypy, and pypy3 .IP \(bu 2 No dependencies .IP \(bu 2 Small size .IP \(bu 2 Can be used as an independent .py file .IP \(bu 2 Simple terminal tool (when installed as a package) .UNINDENT .SH PYTHON EXAMPLES .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C from getmac import get_mac_address eth_mac = get_mac_address(interface="eth0") win_mac = get_mac_address(interface="Ethernet 3") ip_mac = get_mac_address(ip="192.168.0.1") ip6_mac = get_mac_address(ip6="::1") host_mac = get_mac_address(hostname="localhost") updated_mac = get_mac_address(ip="10.0.0.1", network_request=True) # Enabling debugging from getmac import getmac getmac.DEBUG = 2 # DEBUG level 2 print(getmac.get_mac_address(interface="Ethernet 3")) # Changing the port used for updating ARP table (UDP packet) from getmac import getmac getmac.PORT = 44444 # Default: 55555 print(get_mac_address(ip="192.168.0.1", network_request=True)) .ft P .fi .UNINDENT .UNINDENT .SH TERMINAL EXAMPLES .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C getmac \-\-help getmac \-\-version # No arguments will return MAC of the default interface. getmac python \-m getmac # Interface names, IPv4/IPv6 addresses, or Hostnames can be specified getmac \-\-interface ens33 getmac \-\-ip 192.168.0.1 getmac \-\-ip6 ::1 getmac \-\-hostname home.router # Running as a Python module with shorthands for the arguments python \-m getmac \-i \(aqEthernet 4\(aq python \-m getmac \-4 192.168.0.1 python \-m getmac \-6 ::1 python \-m getmac \-n home.router # Getting the MAC address of a remote host obviously requires # the ARP table to be populated. By default, getmac will do # this for you by sending a small UDP packet to a high port (55555) # If you don\(aqt want this to happen, you can disable it. # This is useful if you\(aqre 100% certain the ARP table will be # populated already, or in red team/forensic scenarios. getmac \-\-no\-network\-request \-4 192.168.0.1 python \-m getmac \-\-no\-network\-request \-n home.router # Debug levels can be specified with \(aq\-d\(aq getmac \-\-debug python \-m getmac \-d \-i enp11s4 python \-m getmac \-dd \-n home.router .ft P .fi .UNINDENT .UNINDENT .sp Note: the terminal interface will not work on Python 2.6 and older (Sorry RHEL 6 users!). .SH GET_MAC_ADDRESS() .INDENT 0.0 .IP \(bu 2 \fBinterface\fP: Name of a network interface on the system. .IP \(bu 2 \fBip\fP: IPv4 address of a remote host. .IP \(bu 2 \fBip6\fP: IPv6 address of a remote host. .IP \(bu 2 \fBhostname\fP: Hostname of a remote host. .IP \(bu 2 \fBnetwork_request\fP: If an network request should be made to update and populate the ARP/NDP table of remote hosts used to lookup MACs in most circumstances. Disable this if you want to just use what\(aqs already in the table, or if you have requirements to prevent network traffic. The network request is a empty UDP packet sent to a high port, 55555 by default. This can be changed by setting \fBgetmac.PORT\fP to the desired integer value. Additionally, on Windows, this will send a UDP packet to 1.1.1.1:53 to attempt to determine the default interface. .UNINDENT .SH NOTES .INDENT 0.0 .IP \(bu 2 If none of the arguments are selected, the default network interface for the system will be used. .IP \(bu 2 "Remote hosts" refer to hosts in your local layer 2 network, also commonly referred to as a "broadcast domain", "LAN", or "VLAN". As far as I know, there is not a reliable method to get a MAC address for a remote host external to the LAN. If you know any methods otherwise, please open a GitHub issue or shoot me an email, I\(aqd love to be wrong about this. .IP \(bu 2 The first four arguments are mutually exclusive. \fBnetwork_request\fP does not have any functionality when the \fBinterface\fP argument is specified, and can be safely set if using in a script. .IP \(bu 2 The physical transport is assumed to be Ethernet (802.3). Others, such as Wi\-Fi (802.11), are currently not tested or considored. I plan to address this in the future, and am definitely open to pull requests or issues related to this, including error reports. .IP \(bu 2 Exceptions will be handled silently and returned as a None. If you run into problems, you can set DEBUG to true and get more information about what\(aqs happening. If you\(aqre still having issues, please create an issue on GitHub and include the output with DEBUG enabled. .IP \(bu 2 Messages are output using the \fBwarnings\fP module, and \fBprint()\fP if \fBgetmac.DEBUG\fP enabled (any value greater than 0). If you are using logging, they can be captured using logging.captureWarnings(). Otherwise, they can be suppressed using warnings.filterwarnings("ignore"). https://docs.python.org/3/library/warnings.html .UNINDENT .SH DOCKER EXAMPLES .sp Run getmac container and provide flags .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C docker run \-it ghostofgoes/getmac:latest \-\-help docker run \-it ghostofgoes/getmac:latest \-\-version docker run \-it ghostofgoes/getmac:latest \-n localhost .ft P .fi .UNINDENT .UNINDENT .sp There is a pre\-built container located on the \fI\%Docker hub\fP\&. Alternatively, you can build the image yourself (from the repository root directory): .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C docker build . \-t getmac .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 Windows .INDENT 2.0 .IP \(bu 2 Commands: \fBgetmac\fP, \fBipconfig\fP .IP \(bu 2 Libraries: \fBuuid\fP, \fBctypes\fP .IP \(bu 2 Third\-party Packages: \fBnetifaces\fP, \fBpsutil\fP, \fBscapy\fP .UNINDENT .IP \(bu 2 Linux/Unix .INDENT 2.0 .IP \(bu 2 Commands: \fBarp\fP, \fBip\fP, \fBifconfig\fP, \fBnetstat\fP, \fBip link\fP .IP \(bu 2 Libraries: \fBuuid\fP, \fBfcntl\fP .IP \(bu 2 Third\-party Packages: \fBnetifaces\fP, \fBpsutil\fP, \fBscapy\fP, \fBarping\fP .IP \(bu 2 Default interfaces: \fBroute\fP, \fBip route list\fP .IP \(bu 2 Files: \fB/sys/class/net/X/address\fP, \fB/proc/net/arp\fP .UNINDENT .IP \(bu 2 Mac OSX (Darwin) .INDENT 2.0 .IP \(bu 2 \fBnetworksetup\fP .IP \(bu 2 Same commands as Linux .UNINDENT .IP \(bu 2 WSL: Windows commands are used for remote hosts, and Unix commands are used for interfaces .UNINDENT .sp All or almost all features should work on "supported" platforms (OSes). .INDENT 0.0 .IP \(bu 2 Windows .INDENT 2.0 .IP \(bu 2 Desktop: 7, 8, 8.1, 10 .IP \(bu 2 Server: TBD .IP \(bu 2 (Partially supported, untested): 2000, XP, Vista .UNINDENT .IP \(bu 2 Linux distros .INDENT 2.0 .IP \(bu 2 CentOS/RHEL 6+ .IP \(bu 2 Ubuntu 16+ (14 and older should work as well) .IP \(bu 2 Fedora .UNINDENT .IP \(bu 2 MacOSX (Darwin) .INDENT 2.0 .IP \(bu 2 The latest two versions probably (TBD) .UNINDENT .IP \(bu 2 Windows Subsystem for Linux (WSL) .IP \(bu 2 Docker .UNINDENT .sp All sub\-versions are the latest available on your platform (with the exception of 2.6). .INDENT 0.0 .IP \(bu 2 2.6.6 (CentOS 6/RHEL 6 version) .IP \(bu 2 2.7 .IP \(bu 2 3.4 .IP \(bu 2 3.5 .IP \(bu 2 3.6 .IP \(bu 2 3.7 .UNINDENT .sp Please report any problems by opening a issue on GitHub! .SH CAVEATS .INDENT 0.0 .IP \(bu 2 Depending on the platform, there could be a performance detriment, due to heavy usage of regular expressions. .IP \(bu 2 Platform test coverage is imperfect. If you\(aqre having issues, then you might be using a platform I haven\(aqt been able to test. Keep calm, open a GitHub issue, and I\(aqd be more than happy to help. .IP \(bu 2 Older Python versions (2.5/3.3 and older) are not officially supported. If you\(aqre running these, all is not lost! Simply copy/paste \fBgetmac.py\fP into your codebase and make the necessary edits to be compatible with your version and distribution of Python. .UNINDENT .SH KNOWN ISSUES .INDENT 0.0 .IP \(bu 2 Hostnames for IPv6 devices are not yet supported. .IP \(bu 2 Windows: the "default" of selecting the default route interface only works effectively if \fBnetwork_request\fP is enabled. Otherwise, \fBEthernet\fP as the default. .IP \(bu 2 There is are currently no automated tests for Python 2.6, which means there is a much higher potential for regressions. Open an issue if you encounter any. .UNINDENT .sp Contributors are more than welcome! See the \fI\%contribution guide\fP to get started, and checkout the \fI\%todo list\fP for a full list of tasks and bugs. .sp Before submitting a PR, please make sure you\(aqve completed the \fI\%pull request checklist\fP! .sp The \fI\%Python Discord server\fP is a good place to ask questions or discuss the project (Handle: @KnownError). .SH CONTRIBUTORS .INDENT 0.0 .IP \(bu 2 Christopher Goes (@ghostofgoes) \- Author and maintainer .IP \(bu 2 Calvin Tran (@cyberhobbes) \- Windows interface detection improvements .IP \(bu 2 Izra Faturrahman (@Frizz925) \- Unit tests using the platform samples .IP \(bu 2 Jose Gonzalez (@Komish) \- Docker container and Docker testing .IP \(bu 2 @fortunate\-man \- Awesome usage videos .IP \(bu 2 @martmists \- legacy Python compatibility improvements .UNINDENT .sp Many of the methods used to acquire an address and the core logic framework are attributed to the CPython project\(aqs UUID implementation. .INDENT 0.0 .IP \(bu 2 https://github.com/python/cpython/blob/master/Lib/uuid.py .IP \(bu 2 https://github.com/python/cpython/blob/2.7/Lib/uuid.py .UNINDENT .SH OTHER NOTABLE SOURCES .INDENT 0.0 .IP \(bu 2 \fI\%_unix_fcntl_by_interface\fP .IP \(bu 2 \fI\%_windows_get_remote_mac_ctypes\fP .IP \(bu 2 \fI\%String joining\fP .UNINDENT .sp MIT. Feel free to copy, modify, and use to your heart\(aqs content. Enjoy :) .SH AUTHOR Christopher Goes .SH COPYRIGHT 2018, Christopher Goes .\" Generated by docutils manpage writer. . getmac-0.9.5/packaging/rpm/man/getmac2.1000066400000000000000000000253151464534747600177200ustar00rootroot00000000000000.\" Man page generated from reStructuredText. . .TH "GETMAC" "1" "Oct 06, 2018" "0.6.0" "getmac" .SH NAME getmac \- Cross-platform Python package to get MAC addresses . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. \fI\%Latest version on PyPI\fP \fI\%Documentation status\fP \fI\%Travis CI build status\fP \fI\%Appveyor build status\fP .sp Get the MAC address of remote LAN hosts and system network interfaces using Python. .sp It provides a platform\-independant interface to get the MAC addresses of: .INDENT 0.0 .IP \(bu 2 System network interfaces (by interface name) .IP \(bu 2 Remote hosts on the local network (by IPv4/IPv6 address or hostname) .UNINDENT .sp It provides one function: \fBget_mac_address()\fP .sp \fI\%asciicast\fP .sp \fI\%asciicast\fP .INDENT 0.0 .IP \(bu 2 Pure\-Python .IP \(bu 2 Supports Python 2.6+, 3.4+, pypy, and pypy3 .IP \(bu 2 No dependencies .IP \(bu 2 Small size .IP \(bu 2 Can be used as an independent .py file .IP \(bu 2 Simple terminal tool (when installed as a package) .UNINDENT .SH PYTHON EXAMPLES .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C from getmac import get_mac_address eth_mac = get_mac_address(interface="eth0") win_mac = get_mac_address(interface="Ethernet 3") ip_mac = get_mac_address(ip="192.168.0.1") ip6_mac = get_mac_address(ip6="::1") host_mac = get_mac_address(hostname="localhost") updated_mac = get_mac_address(ip="10.0.0.1", network_request=True) # Enabling debugging from getmac import getmac getmac.DEBUG = 2 # DEBUG level 2 print(getmac.get_mac_address(interface="Ethernet 3")) # Changing the port used for updating ARP table (UDP packet) from getmac import getmac getmac.PORT = 44444 # Default: 55555 print(get_mac_address(ip="192.168.0.1", network_request=True)) .ft P .fi .UNINDENT .UNINDENT .SH TERMINAL EXAMPLES .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C getmac \-\-help getmac \-\-version # No arguments will return MAC of the default interface. getmac python \-m getmac # Interface names, IPv4/IPv6 addresses, or Hostnames can be specified getmac \-\-interface ens33 getmac \-\-ip 192.168.0.1 getmac \-\-ip6 ::1 getmac \-\-hostname home.router # Running as a Python module with shorthands for the arguments python \-m getmac \-i \(aqEthernet 4\(aq python \-m getmac \-4 192.168.0.1 python \-m getmac \-6 ::1 python \-m getmac \-n home.router # Getting the MAC address of a remote host obviously requires # the ARP table to be populated. By default, getmac will do # this for you by sending a small UDP packet to a high port (55555) # If you don\(aqt want this to happen, you can disable it. # This is useful if you\(aqre 100% certain the ARP table will be # populated already, or in red team/forensic scenarios. getmac \-\-no\-network\-request \-4 192.168.0.1 python \-m getmac \-\-no\-network\-request \-n home.router # Debug levels can be specified with \(aq\-d\(aq getmac \-\-debug python \-m getmac \-d \-i enp11s4 python \-m getmac \-dd \-n home.router .ft P .fi .UNINDENT .UNINDENT .sp Note: the terminal interface will not work on Python 2.6 and older (Sorry RHEL 6 users!). .SH GET_MAC_ADDRESS() .INDENT 0.0 .IP \(bu 2 \fBinterface\fP: Name of a network interface on the system. .IP \(bu 2 \fBip\fP: IPv4 address of a remote host. .IP \(bu 2 \fBip6\fP: IPv6 address of a remote host. .IP \(bu 2 \fBhostname\fP: Hostname of a remote host. .IP \(bu 2 \fBnetwork_request\fP: If an network request should be made to update and populate the ARP/NDP table of remote hosts used to lookup MACs in most circumstances. Disable this if you want to just use what\(aqs already in the table, or if you have requirements to prevent network traffic. The network request is a empty UDP packet sent to a high port, 55555 by default. This can be changed by setting \fBgetmac.PORT\fP to the desired integer value. Additionally, on Windows, this will send a UDP packet to 1.1.1.1:53 to attempt to determine the default interface. .UNINDENT .SH NOTES .INDENT 0.0 .IP \(bu 2 If none of the arguments are selected, the default network interface for the system will be used. .IP \(bu 2 "Remote hosts" refer to hosts in your local layer 2 network, also commonly referred to as a "broadcast domain", "LAN", or "VLAN". As far as I know, there is not a reliable method to get a MAC address for a remote host external to the LAN. If you know any methods otherwise, please open a GitHub issue or shoot me an email, I\(aqd love to be wrong about this. .IP \(bu 2 The first four arguments are mutually exclusive. \fBnetwork_request\fP does not have any functionality when the \fBinterface\fP argument is specified, and can be safely set if using in a script. .IP \(bu 2 The physical transport is assumed to be Ethernet (802.3). Others, such as Wi\-Fi (802.11), are currently not tested or considored. I plan to address this in the future, and am definitely open to pull requests or issues related to this, including error reports. .IP \(bu 2 Exceptions will be handled silently and returned as a None. If you run into problems, you can set DEBUG to true and get more information about what\(aqs happening. If you\(aqre still having issues, please create an issue on GitHub and include the output with DEBUG enabled. .IP \(bu 2 Messages are output using the \fBwarnings\fP module, and \fBprint()\fP if \fBgetmac.DEBUG\fP enabled (any value greater than 0). If you are using logging, they can be captured using logging.captureWarnings(). Otherwise, they can be suppressed using warnings.filterwarnings("ignore"). https://docs.python.org/3/library/warnings.html .UNINDENT .SH DOCKER EXAMPLES .sp Run getmac container and provide flags .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C docker run \-it ghostofgoes/getmac:latest \-\-help docker run \-it ghostofgoes/getmac:latest \-\-version docker run \-it ghostofgoes/getmac:latest \-n localhost .ft P .fi .UNINDENT .UNINDENT .sp There is a pre\-built container located on the \fI\%Docker hub\fP\&. Alternatively, you can build the image yourself (from the repository root directory): .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C docker build . \-t getmac .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 Windows .INDENT 2.0 .IP \(bu 2 Commands: \fBgetmac\fP, \fBipconfig\fP .IP \(bu 2 Libraries: \fBuuid\fP, \fBctypes\fP .IP \(bu 2 Third\-party Packages: \fBnetifaces\fP, \fBpsutil\fP, \fBscapy\fP .UNINDENT .IP \(bu 2 Linux/Unix .INDENT 2.0 .IP \(bu 2 Commands: \fBarp\fP, \fBip\fP, \fBifconfig\fP, \fBnetstat\fP, \fBip link\fP .IP \(bu 2 Libraries: \fBuuid\fP, \fBfcntl\fP .IP \(bu 2 Third\-party Packages: \fBnetifaces\fP, \fBpsutil\fP, \fBscapy\fP, \fBarping\fP .IP \(bu 2 Default interfaces: \fBroute\fP, \fBip route list\fP .IP \(bu 2 Files: \fB/sys/class/net/X/address\fP, \fB/proc/net/arp\fP .UNINDENT .IP \(bu 2 Mac OSX (Darwin) .INDENT 2.0 .IP \(bu 2 \fBnetworksetup\fP .IP \(bu 2 Same commands as Linux .UNINDENT .IP \(bu 2 WSL: Windows commands are used for remote hosts, and Unix commands are used for interfaces .UNINDENT .sp All or almost all features should work on "supported" platforms (OSes). .INDENT 0.0 .IP \(bu 2 Windows .INDENT 2.0 .IP \(bu 2 Desktop: 7, 8, 8.1, 10 .IP \(bu 2 Server: TBD .IP \(bu 2 (Partially supported, untested): 2000, XP, Vista .UNINDENT .IP \(bu 2 Linux distros .INDENT 2.0 .IP \(bu 2 CentOS/RHEL 6+ .IP \(bu 2 Ubuntu 16+ (14 and older should work as well) .IP \(bu 2 Fedora .UNINDENT .IP \(bu 2 MacOSX (Darwin) .INDENT 2.0 .IP \(bu 2 The latest two versions probably (TBD) .UNINDENT .IP \(bu 2 Windows Subsystem for Linux (WSL) .IP \(bu 2 Docker .UNINDENT .sp All sub\-versions are the latest available on your platform (with the exception of 2.6). .INDENT 0.0 .IP \(bu 2 2.6.6 (CentOS 6/RHEL 6 version) .IP \(bu 2 2.7 .IP \(bu 2 3.4 .IP \(bu 2 3.5 .IP \(bu 2 3.6 .IP \(bu 2 3.7 .UNINDENT .sp Please report any problems by opening a issue on GitHub! .SH CAVEATS .INDENT 0.0 .IP \(bu 2 Depending on the platform, there could be a performance detriment, due to heavy usage of regular expressions. .IP \(bu 2 Platform test coverage is imperfect. If you\(aqre having issues, then you might be using a platform I haven\(aqt been able to test. Keep calm, open a GitHub issue, and I\(aqd be more than happy to help. .IP \(bu 2 Older Python versions (2.5/3.3 and older) are not officially supported. If you\(aqre running these, all is not lost! Simply copy/paste \fBgetmac.py\fP into your codebase and make the necessary edits to be compatible with your version and distribution of Python. .UNINDENT .SH KNOWN ISSUES .INDENT 0.0 .IP \(bu 2 Hostnames for IPv6 devices are not yet supported. .IP \(bu 2 Windows: the "default" of selecting the default route interface only works effectively if \fBnetwork_request\fP is enabled. Otherwise, \fBEthernet\fP as the default. .IP \(bu 2 There is are currently no automated tests for Python 2.6, which means there is a much higher potential for regressions. Open an issue if you encounter any. .UNINDENT .sp Contributors are more than welcome! See the \fI\%contribution guide\fP to get started, and checkout the \fI\%todo list\fP for a full list of tasks and bugs. .sp Before submitting a PR, please make sure you\(aqve completed the \fI\%pull request checklist\fP! .sp The \fI\%Python Discord server\fP is a good place to ask questions or discuss the project (Handle: @KnownError). .SH CONTRIBUTORS .INDENT 0.0 .IP \(bu 2 Christopher Goes (@ghostofgoes) \- Author and maintainer .IP \(bu 2 Calvin Tran (@cyberhobbes) \- Windows interface detection improvements .IP \(bu 2 Izra Faturrahman (@Frizz925) \- Unit tests using the platform samples .IP \(bu 2 Jose Gonzalez (@Komish) \- Docker container and Docker testing .IP \(bu 2 @fortunate\-man \- Awesome usage videos .IP \(bu 2 @martmists \- legacy Python compatibility improvements .UNINDENT .sp Many of the methods used to acquire an address and the core logic framework are attributed to the CPython project\(aqs UUID implementation. .INDENT 0.0 .IP \(bu 2 https://github.com/python/cpython/blob/master/Lib/uuid.py .IP \(bu 2 https://github.com/python/cpython/blob/2.7/Lib/uuid.py .UNINDENT .SH OTHER NOTABLE SOURCES .INDENT 0.0 .IP \(bu 2 \fI\%_unix_fcntl_by_interface\fP .IP \(bu 2 \fI\%_windows_get_remote_mac_ctypes\fP .IP \(bu 2 \fI\%String joining\fP .UNINDENT .sp MIT. Feel free to copy, modify, and use to your heart\(aqs content. Enjoy :) .SH AUTHOR Christopher Goes .SH COPYRIGHT 2018, Christopher Goes .\" Generated by docutils manpage writer. . getmac-0.9.5/packaging/rpm/python2-getmac.spec000066400000000000000000000177401464534747600212610ustar00rootroot00000000000000%global srcname getmac Name: python2-%{srcname} Version: 0.6.0 Release: 0 Summary: Python module to get the MAC address of local network interfaces and LAN hosts License: MIT URL: https://github.com/GhostofGoes/getmac Source0: https://github.com/GhostofGoes/getmac/releases/download/0.6.0/getmac-0.6.0.tar.gz BuildArch: noarch BuildRequires: python2-devel, python2-setuptools %description Pure-python module to get the MAC address of remote hosts or network interfaces. It provides a platform-independent interface to get the MAC addresses of network interfaces on the local system(by interface name) and remote hosts on the local network (by IPv4/IPv6 address or host-name). %{?python_provide:%python_provide python3-getmac} %prep %autosetup -n %{srcname}-%{version} %build %py2_build %install %py2_install %files %license LICENSE %doc README.md %{python2_sitelib}/%{srcname}/ %{python2_sitelib}/%{srcname}-*.egg-info/ /usr/bin/getmac2 %{_mandir}/man1/* %changelog * Sat Oct 6 2018 Christopher Goes 0.6.0-0 - Windows default interface detection if `network_request` is enabled (Credit: @cyberhobbes) - Docker container (Credit: @Komish) - Changed name to `getmac`. This applies to everything, including command line tool, PyPI, GitHub, and the documentation. This is a breaking change, but needed to happen to remove a huge amount of ambiguity that was causing issues with packaging, documentation, and several other efforts, not to mention my sanity. Long-term, the only downside is a conflict on Windows CLI with `getmac.exe`. - Use proper Python 2-compatible print functions (Credit: @martmists) - Support for Python 2.5. It is not feasible to test, and potentially breaks some useful language features, such as `__future__` - Variables PORT and DEBUG from top-level package imports, since changing them would have no actual effect on execution. Instead, use `getmac.getmac.DEBUG`. - Added example videos demonstrating usage (Credit: @fortunate-man) - Added contribution guide - Added documentation on ReadTheDocs - Added a manpage * Mon Sep 24 2018 Christopher Goes 0.5-0 - Full support for Windows Subsystem for Linux (WSL). This is working for all features, including default interface selection! The only edge case is lookup of remote host IP addresses that are actually local interfaces won't resolve to a MAC (which should be ff-ff-ff-ff-ff-ff). - Require `argparse` if Python version is 2.6 or older - Updated tox tests: added Jython and IronPython, removed 2.6 * Fri Sep 21 2018 Christopher Goes 0.4-0 - New methods for remote host MACs - New methods for interface MACs - DEBUG levels: DEBUG value is now an integer, and increasing it will increase the amount and verbosity of output. On the CLI, it can be configured by increasing the amount of characters for the debug argument, e.g. '-dd' for DEBUG level 2. - Jython support (Note: on Windows Jython currently only works with interfaces) - IronPython support - Significant performance improvement for remote hosts. Previously, the average for `get_mac_address(ip='10.0.0.100')` was 1.71 seconds. Now, the average is `12.7 miliseconds`, with the special case of a unpopulated arp table being only slightly higher. This was brought about by changes in how the arp table is populated. The original method was to use the host's `ping` command to send an ICMP packet to the host. This took time, which heavily delayed the ability to actually get an address. The solution is to instead simply send a empty UDP packet to a high port. The port this packet is sent to can be configured using the module variable `getmac.PORT`. - "Fixed" resolution of localhost/127.0.0.1 by hardcoding the response. This should resolve a lot of problematic edge cases. I'm ok with this for now since I don't know of a case when it isn't all zeroes. - Greatly increased the reliability of getting host and interface MACs on Windows - Improved debugging output - Tightened up the size of `getmac.py` - Various minor stability and performance improvements - Add LICENSE to PyPI package - Support for Python 3.2 and 3.3. The total downloads from PyPI with those versions in August was ~53k and ~407K, respectfully. The majority of those are likely from automated testing (e.g. TravisCI) and not actual users. Therefore, I've decided to drop support to simplify development, especially since before 3.4 the 3.x series was still very much a "work in progress". - Added automated tests for Windows using Appveyor - Tox runner for tests - Added github.io page - Improved TravisCI testing * Thu Aug 30 2018 Christopher Goes 0.3-0 - Attempt to use Python modules if they're installed. This is useful for larger projects that already have them installed as dependencies, as they provide a more reliable means of getting information. - New methods for remote MACs - New methods for Interface MACs - Certain critical failures that should never happen will now warn instead of failing silently. - Added a sanity check to the `ip6` argument (IPv6 addresses) - Improved performance in some areas - Improved debugging output - Major Bugfix: search of `proc/net/arp` would return shorter addresses in the same subnet if they came earlier in the sequence. Example: a search for `192.168.16.2` on Linux would instead return the MAC address of `192.168.16.254` with no errors or warning whatsoever. - Significantly improved default interface detection. Default interfaces are now properly detected on Linux and most other POSIX platforms with `ip` or `route` commands available, or the `netifaces` Python module. - Makefile - Vagrantfile to spin up testing VMs for various platforms using [Vagrant](https://www.vagrantup.com/docs/) - Added more samples of command output on platforms (Ubuntu 18.04 LTS) * Sun Aug 26 2018 Christopher Goes 0.2-4 - Fixed identification of remote host on OSX - Resolved hangs and noticeable lag that occurred when "network_request" was True (the default) * Tue Aug 7 2018 Christopher Goes 0.2-3 - Remote host for Python 3 on Windows * Wed Apr 18 2018 Christopher Goes 0.2-2 - Short versions of CLI arguments (e.g. "-i" for "--interface") - Improved usage of "ping" across platforms and IP versions - Various minor tweaks for performance - Improved Windows detection - Use of ping command with hostname - Improvements to internal code * Sun Apr 15 2018 Christopher Goes 0.2-1 - Nothing changed. PyPI just won't let me push changes without a new version. * Sun Apr 15 2018 Christopher Goes 0.2-0 - Checks for default interface on Linux systems - New methods of hunting for addresses on Windows, Mac OS X, and Linux - CLI will output nothing if it failed, instead of "None" - CLI will return with 1 on failure, 0 on success - No CLI arguments now implies the default host network interface - Added an argumnent for debugging: `--debug` - Removed `-d` option from `--no-network-requests` - Interfaces on Windows and Linux (including Bash for Windows) - Many bugs - Support for Python 2.6 on the CLI - Overhaul of internals * Sun Apr 15 2018 Christopher Goes 0.1-0: - Addition of a terminal command: `get-mac` - Ability to run as a module from the command line: `python -m getmac` - `arp_request` argument was renamed to `network_request` - Updated docstring - Slight reduction in the size of getmac.py - Overhauled the README - Moved tests into their own folder - Added Python 3.7 to list of supported snakes * Sun Nov 12 2017 Christopher Goes 0.0-4: - Python 2.6 compatibility * Sat Nov 11 2017 Christopher Goes 0.0-3: - Fixed some addresses returning without colons - Added more rigorous checks on addresses before returning them * Sat Nov 11 2017 Christopher Goes 0.0-2: - Remove print statements and other debugging output * Mon Oct 23 2017 Christopher Goes 0.0-1 - Initial pre-alpha getmac-0.9.5/packaging/rpm/python3-getmac.spec000066400000000000000000000177371464534747600212700ustar00rootroot00000000000000%global srcname getmac Name: python3-%{srcname} Version: 0.6.0 Release: 0 Summary: Python module to get the MAC address of local network interfaces and LAN hosts License: MIT URL: https://github.com/GhostofGoes/getmac Source0: https://github.com/GhostofGoes/getmac/releases/download/0.6.0/getmac-0.6.0.tar.gz BuildArch: noarch BuildRequires: python3-devel, python3-setuptools %description Pure-python module to get the MAC address of remote hosts or network interfaces. It provides a platform-independent interface to get the MAC addresses of network interfaces on the local system(by interface name) and remote hosts on the local network (by IPv4/IPv6 address or host-name). %{?python_provide:%python_provide python3-getmac} %prep %autosetup -n %{srcname}-%{version} %build %py3_build %install %py3_install %files %license LICENSE %doc README.md %{python3_sitelib}/%{srcname}/ %{python3_sitelib}/%{srcname}-*.egg-info/ /usr/bin/getmac %{_mandir}/man1/* %changelog * Sat Oct 6 2018 Christopher Goes 0.6.0-0 - Windows default interface detection if `network_request` is enabled (Credit: @cyberhobbes) - Docker container (Credit: @Komish) - Changed name to `getmac`. This applies to everything, including command line tool, PyPI, GitHub, and the documentation. This is a breaking change, but needed to happen to remove a huge amount of ambiguity that was causing issues with packaging, documentation, and several other efforts, not to mention my sanity. Long-term, the only downside is a conflict on Windows CLI with `getmac.exe`. - Use proper Python 2-compatible print functions (Credit: @martmists) - Support for Python 2.5. It is not feasible to test, and potentially breaks some useful language features, such as `__future__` - Variables PORT and DEBUG from top-level package imports, since changing them would have no actual effect on execution. Instead, use `getmac.getmac.DEBUG`. - Added example videos demonstrating usage (Credit: @fortunate-man) - Added contribution guide - Added documentation on ReadTheDocs - Added a manpage * Mon Sep 24 2018 Christopher Goes 0.5-0 - Full support for Windows Subsystem for Linux (WSL). This is working for all features, including default interface selection! The only edge case is lookup of remote host IP addresses that are actually local interfaces won't resolve to a MAC (which should be ff-ff-ff-ff-ff-ff). - Require `argparse` if Python version is 2.6 or older - Updated tox tests: added Jython and IronPython, removed 2.6 * Fri Sep 21 2018 Christopher Goes 0.4-0 - New methods for remote host MACs - New methods for interface MACs - DEBUG levels: DEBUG value is now an integer, and increasing it will increase the amount and verbosity of output. On the CLI, it can be configured by increasing the amount of characters for the debug argument, e.g. '-dd' for DEBUG level 2. - Jython support (Note: on Windows Jython currently only works with interfaces) - IronPython support - Significant performance improvement for remote hosts. Previously, the average for `get_mac_address(ip='10.0.0.100')` was 1.71 seconds. Now, the average is `12.7 miliseconds`, with the special case of a unpopulated arp table being only slightly higher. This was brought about by changes in how the arp table is populated. The original method was to use the host's `ping` command to send an ICMP packet to the host. This took time, which heavily delayed the ability to actually get an address. The solution is to instead simply send a empty UDP packet to a high port. The port this packet is sent to can be configured using the module variable `getmac.PORT`. - "Fixed" resolution of localhost/127.0.0.1 by hardcoding the response. This should resolve a lot of problematic edge cases. I'm ok with this for now since I don't know of a case when it isn't all zeroes. - Greatly increased the reliability of getting host and interface MACs on Windows - Improved debugging output - Tightened up the size of `getmac.py` - Various minor stability and performance improvements - Add LICENSE to PyPI package - Support for Python 3.2 and 3.3. The total downloads from PyPI with those versions in August was ~53k and ~407K, respectfully. The majority of those are likely from automated testing (e.g. TravisCI) and not actual users. Therefore, I've decided to drop support to simplify development, especially since before 3.4 the 3.x series was still very much a "work in progress". - Added automated tests for Windows using Appveyor - Tox runner for tests - Added github.io page - Improved TravisCI testing * Thu Aug 30 2018 Christopher Goes 0.3-0 - Attempt to use Python modules if they're installed. This is useful for larger projects that already have them installed as dependencies, as they provide a more reliable means of getting information. - New methods for remote MACs - New methods for Interface MACs - Certain critical failures that should never happen will now warn instead of failing silently. - Added a sanity check to the `ip6` argument (IPv6 addresses) - Improved performance in some areas - Improved debugging output - Major Bugfix: search of `proc/net/arp` would return shorter addresses in the same subnet if they came earlier in the sequence. Example: a search for `192.168.16.2` on Linux would instead return the MAC address of `192.168.16.254` with no errors or warning whatsoever. - Significantly improved default interface detection. Default interfaces are now properly detected on Linux and most other POSIX platforms with `ip` or `route` commands available, or the `netifaces` Python module. - Makefile - Vagrantfile to spin up testing VMs for various platforms using [Vagrant](https://www.vagrantup.com/docs/) - Added more samples of command output on platforms (Ubuntu 18.04 LTS) * Sun Aug 26 2018 Christopher Goes 0.2-4 - Fixed identification of remote host on OSX - Resolved hangs and noticeable lag that occurred when "network_request" was True (the default) * Tue Aug 7 2018 Christopher Goes 0.2-3 - Remote host for Python 3 on Windows * Wed Apr 18 2018 Christopher Goes 0.2-2 - Short versions of CLI arguments (e.g. "-i" for "--interface") - Improved usage of "ping" across platforms and IP versions - Various minor tweaks for performance - Improved Windows detection - Use of ping command with hostname - Improvements to internal code * Sun Apr 15 2018 Christopher Goes 0.2-1 - Nothing changed. PyPI just won't let me push changes without a new version. * Sun Apr 15 2018 Christopher Goes 0.2-0 - Checks for default interface on Linux systems - New methods of hunting for addresses on Windows, Mac OS X, and Linux - CLI will output nothing if it failed, instead of "None" - CLI will return with 1 on failure, 0 on success - No CLI arguments now implies the default host network interface - Added an argumnent for debugging: `--debug` - Removed `-d` option from `--no-network-requests` - Interfaces on Windows and Linux (including Bash for Windows) - Many bugs - Support for Python 2.6 on the CLI - Overhaul of internals * Sun Apr 15 2018 Christopher Goes 0.1-0: - Addition of a terminal command: `get-mac` - Ability to run as a module from the command line: `python -m getmac` - `arp_request` argument was renamed to `network_request` - Updated docstring - Slight reduction in the size of getmac.py - Overhauled the README - Moved tests into their own folder - Added Python 3.7 to list of supported snakes * Sun Nov 12 2017 Christopher Goes 0.0-4: - Python 2.6 compatibility * Sat Nov 11 2017 Christopher Goes 0.0-3: - Fixed some addresses returning without colons - Added more rigorous checks on addresses before returning them * Sat Nov 11 2017 Christopher Goes 0.0-2: - Remove print statements and other debugging output * Mon Oct 23 2017 Christopher Goes 0.0-1 - Initial pre-alpha getmac-0.9.5/scripts/000077500000000000000000000000001464534747600145005ustar00rootroot00000000000000getmac-0.9.5/scripts/centos-provision.sh000066400000000000000000000016211464534747600203550ustar00rootroot00000000000000#!/bin/sh # Basic Provisioning for CentOS7 # -y: 'yes' to all prompts # -t: continues through errors (so our whole system setup isn't halted by some repo error) # -q: quiet sudo yum -y -t -q update sudo yum -y -t -q install epel-release sudo yum -y -t -q install yum-utils \ git make \ dos2unix nano \ python-pip python-setuptools python-virtualenv \ rpm-build rpm-sign rpmdevtools # https://stackoverflow.com/a/23317640/2214380 sudo yum -y -t -q install python34 python34-setuptools python34-virtualenv # note: can't install pip anymore, too old :) #sudo easy_install-3.4 pip #sudo pip3 install virtualenv # Pull down the codebase git clone https://github.com/GhostofGoes/getmac.git # Create Python virtual environments mkdir -p "$HOME/.virtualenvs/" python3.4 -m virtualenv --python=python3.4 "$HOME/.virtualenvs/getmac34" python -m virtualenv --python=python2 "$HOME/.virtualenvs/getmac27" getmac-0.9.5/scripts/clean.sh000066400000000000000000000005161464534747600161200ustar00rootroot00000000000000#!/usr/bin/env bash find . -name '*.pyc' -delete find . -name '*.pyo' -delete find . -name '__pycache__' -delete find . -name '*~' -delete rm -f getmac-*.tar.gz rm -rf build/ rm -rf dist/ rm -rf deb_dist/ rm -rf *.egg rm -rf *.egg-info rm -rf .tox/ rm -rf .pytest_cache/ rm -rf .mypy_cache/ rm -rf htmlcov rm -f .coverage.coverage getmac-0.9.5/scripts/openbsd-provision.sh000066400000000000000000000007231464534747600205160ustar00rootroot00000000000000#!/usr/bin/env bash sudo pkg_add python-2.7.15p0 python-3.6.6p1 \ py-pip-9.0.3 py3-pip-9.0.3 \ py-virtualenv-16.0.0 # Workaround for $HOME not being mounted as wxallowed # http://openbsd-archive.7691.n7.nabble.com/Best-Practices-python-virtualenv-td342219.html sudo mkdir -p "/usr/local/.virtualenvs/" sudo chown vagrant: /usr/local/.virtualenvs/ python3 -m venv "/usr/local/.virtualenvs/getmac36" python2 -m virtualenv "/usr/local/.virtualenvs/getmac27" getmac-0.9.5/scripts/solaris-provision.sh000066400000000000000000000002541464534747600205370ustar00rootroot00000000000000#!/usr/bin/env bash sudo pkgadd -d http://get.opencsw.org/now sudo /opt/csw/bin/pkgutil -U sudo /opt/csw/bin/pkgutil -y -i python27 sudo /opt/csw/bin/pkgutil -y -i py_pip getmac-0.9.5/scripts/ubuntu-provision.sh000066400000000000000000000011001464534747600203740ustar00rootroot00000000000000#!/bin/sh # Basic Provisioning for Ubuntu set -e sudo apt-get update -y sudo apt-get install -y \ git make dos2unix nano \ python python-pip python-setuptools python-virtualenv python-dev \ python3 python3-pip python3-setuptools python3-virtualenv python3-dev # Pull down the codebase cd "$HOME" || exit git clone https://github.com/GhostofGoes/getmac.git # Create Python virtual environments mkdir -p "$HOME/.virtualenvs/" python3 -m virtualenv --python=python3 "$HOME/.virtualenvs/getmac3" python -m virtualenv --python=python2 "$HOME/.virtualenvs/getmac27" getmac-0.9.5/setup.py000066400000000000000000000065751464534747600145400ustar00rootroot00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- import sys from io import open # Python 2 compatibility from setuptools import setup from getmac.getmac import __version__ # Build the page that will be displayed on PyPI from the README and CHANGELOG with open("README.md", encoding="utf-8") as f: long_description = f.read() long_description += "\n\n" with open("CHANGELOG.md", encoding="utf-8") as f: long_description += f.read() setup( name="getmac", version=__version__, author="Christopher Goes", author_email="ghostofgoes@gmail.com", description="Get MAC addresses of remote hosts and local interfaces", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/GhostofGoes/getmac", project_urls={ # "Documentation": "https://getmac.readthedocs.io/en/latest/", "Changelog": "https://github.com/GhostofGoes/getmac/blob/main/CHANGELOG.md", "Issue tracker": "https://github.com/GhostofGoes/getmac/issues", "Source": "https://github.com/GhostofGoes/getmac", "Discord server": "https://discord.gg/python", }, license="MIT", data_files=[], packages=["getmac"], zip_safe=True, entry_points={"console_scripts": ["getmac2 = getmac.__main__:main"]} if sys.version_info[:2] <= (2, 7) else {"console_scripts": ["getmac = getmac.__main__:main"]}, install_requires=[], python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", keywords=[ "getmac", "get-mac", "macaddress", "mac-address", "mac", "ethernet", "mac-48", "networking", "network", "networking", "layer2", "layer-2", "802.3", ], classifiers=[ # TODO(python3): update classifiers # TODO(1.0.0): change to 5 - Production/Stable "Development Status :: 4 - Beta", "Environment :: Console", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Operating System :: MacOS", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Programming Language :: Python :: Implementation :: IronPython", "Programming Language :: Python :: Implementation :: Jython", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "Intended Audience :: Information Technology", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Libraries", "Topic :: System :: Systems Administration", "Topic :: System :: Networking", "Topic :: Utilities", ], ) getmac-0.9.5/tests/000077500000000000000000000000001464534747600141535ustar00rootroot00000000000000getmac-0.9.5/tests/__init__.py000066400000000000000000000000001464534747600162520ustar00rootroot00000000000000getmac-0.9.5/tests/conftest.py000066400000000000000000000006471464534747600163610ustar00rootroot00000000000000# -*- coding: utf-8 -*- import io from os import path import pytest import getmac getmac.getmac.DEBUG = 4 @pytest.fixture() def get_sample(): def _get_sample(sample_path): sdir = path.realpath(path.join(path.dirname(__file__), "samples")) with io.open( path.join(sdir, sample_path), "rt", newline="", encoding="utf-8" ) as f: return f.read() return _get_sample getmac-0.9.5/tests/samples/000077500000000000000000000000001464534747600156175ustar00rootroot00000000000000getmac-0.9.5/tests/samples/OSX/000077500000000000000000000000001464534747600162705ustar00rootroot00000000000000getmac-0.9.5/tests/samples/OSX/arp_-a.out000066400000000000000000000006001464534747600201540ustar00rootroot00000000000000? (192.168.1.1) at 58:6d:8f:7:c9:94 on en0 ifscope [ethernet] ? (192.168.1.118) at a4:5e:60:e3:ca:33 on en0 ifscope [ethernet] ? (192.168.1.120) at c4:8e:8f:61:82:db on en0 ifscope [ethernet] ? (192.168.1.135) at 18:4f:32:5a:64:5 on en0 ifscope [ethernet] ? (192.168.1.156) at 14:cc:20:1a:99:0 on en0 ifscope [ethernet] ? (192.168.1.255) at ff:ff:ff:ff:ff:ff on en0 ifscope [ethernet]getmac-0.9.5/tests/samples/OSX/arp_-an.out000066400000000000000000000006001464534747600203320ustar00rootroot00000000000000? (192.168.1.1) at 58:6d:8f:7:c9:94 on en0 ifscope [ethernet] ? (192.168.1.118) at a4:5e:60:e3:ca:33 on en0 ifscope [ethernet] ? (192.168.1.120) at c4:8e:8f:61:82:db on en0 ifscope [ethernet] ? (192.168.1.135) at 18:4f:32:5a:64:5 on en0 ifscope [ethernet] ? (192.168.1.156) at 14:cc:20:1a:99:0 on en0 ifscope [ethernet] ? (192.168.1.255) at ff:ff:ff:ff:ff:ff on en0 ifscope [ethernet]getmac-0.9.5/tests/samples/OSX/ifconfig.out000066400000000000000000000047751464534747600206220ustar00rootroot00000000000000lo0: flags=8049 mtu 16384 options=1203 inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 nd6 options=201 gif0: flags=8010 mtu 1280 stf0: flags=0<> mtu 1280 XHC20: flags=0<> mtu 0 en0: flags=8863 mtu 1500 ether 2c:f0:ee:2f:c7:de inet6 fe80::cb2:1475:3b0e:f102%en0 prefixlen 64 secured scopeid 0x5 inet6 2601:7c0:c500:cd6:142d:a305:c33e:30e4 prefixlen 64 autoconf secured inet6 2601:7c0:c500:cd6:3dec:c265:d58f:c8fd prefixlen 64 autoconf temporary inet6 2601:7c0:c500:cd6::4862 prefixlen 64 dynamic inet 10.0.0.162 netmask 0xffffff00 broadcast 10.0.0.255 nd6 options=201 media: autoselect status: active p2p0: flags=8843 mtu 2304 ether 0e:f0:ee:2f:c7:de media: autoselect status: inactive awdl0: flags=8943 mtu 1484 ether b2:eb:94:59:0b:d4 inet6 fe80::b0eb:94ff:fe59:bd4%awdl0 prefixlen 64 scopeid 0x8 nd6 options=201 media: autoselect status: active en1: flags=8963 mtu 1500 options=60 ether 32:00:10:bf:60:00 media: autoselect status: inactive bridge0: flags=8863 mtu 1500 options=63 ether 32:00:10:bf:60:00 Configuration: id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0 maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200 root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0 ipfilter disabled flags 0x2 member: en1 flags=3 ifmaxaddr 0 port 9 priority 0 path cost 0 nd6 options=201 media: status: inactive utun0: flags=8051 mtu 2000 options=6403 inet6 fe80::5938:2cce:9a98:e047%utun0 prefixlen 64 scopeid 0xb nd6 options=201 utun1: flags=8051 mtu 1380 options=6403 inet6 fe80::a3ce:859:4a43:6070%utun1 prefixlen 64 scopeid 0xc nd6 options=201 utun2: flags=8051 mtu 1380 options=6403 inet6 fe80::4106:b315:d5f9:1a4f%utun2 prefixlen 64 scopeid 0xd nd6 options=201 getmac-0.9.5/tests/samples/WSL2_kali_2023.1/000077500000000000000000000000001464534747600201535ustar00rootroot00000000000000getmac-0.9.5/tests/samples/WSL2_kali_2023.1/busbox_arping_--ridic.out000066400000000000000000000014101464534747600250460ustar00rootroot00000000000000arping: unrecognized option '--ridic' BusyBox v1.35.0 (Debian 1:1.35.0-4+b3) multi-call binary. Usage: arping [-fqbDUA] [-c CNT] [-w TIMEOUT] [-I IFACE] [-s SRC_IP] DST_IP Send ARP requests/replies -f Quit on first ARP reply -q Quiet -b Keep broadcasting, don't go unicast -D Exit with 1 if DST_IP replies -U Unsolicited ARP mode, update your neighbors -A ARP answer mode, update your neighbors -c N Stop after sending N ARP requests -w TIMEOUT Seconds to wait for ARP reply -I IFACE Interface to use (default eth0) -s SRC_IP Sender IP address DST_IP Target IP address getmac-0.9.5/tests/samples/WSL2_kali_2023.1/busybox_arping_-f_-c_1_172-29-16-1.out000066400000000000000000000002741464534747600263260ustar00rootroot00000000000000ARPING 172.29.16.1 from 172.29.17.66 eth0 Unicast reply from 172.29.16.1 [00:15:5d:20:f2:73] 0.175ms Sent 1 probe(s) (0 broadcast(s)) Received 1 response(s) (0 request(s), 0 broadcast(s)) getmac-0.9.5/tests/samples/WSL2_kali_2023.1/habets_arping_-f_-c_1_172-29-16-1.out000066400000000000000000000006571464534747600261060ustar00rootroot00000000000000arping: invalid option -- 'f' ARPing 2.23, by Thomas Habets usage: arping [ -0aAbdDeFpPqrRuUvzZ ] [ -w ] [ -W ] [ -S ] [ -T ] [ -t ] [ -c ] [ -C ] [ -i ] [ -m ] [ -g ] [ -V ] [ -Q ] For complete usage info, use --help or check the manpage. getmac-0.9.5/tests/samples/WSL2_kali_2023.1/iputils_arping_--help.out000066400000000000000000000012761464534747600251050ustar00rootroot00000000000000arping: invalid option -- '-' Usage: arping [options] Options: -f quit on first reply -q be quiet -b keep on broadcasting, do not unicast -D duplicate address detection mode -U unsolicited ARP mode, update your neighbours -A ARP answer mode, update your neighbours -V print version and exit -c how many packets to send -w how long to wait for a reply -i set interval between packets (default: 1 second) -I which ethernet device to use -s source ip address dns name or ip address For more details see arping(8). getmac-0.9.5/tests/samples/WSL_ubuntu_18.04/000077500000000000000000000000001464534747600204205ustar00rootroot00000000000000getmac-0.9.5/tests/samples/WSL_ubuntu_18.04/ifconfig.out000066400000000000000000000144251464534747600227430ustar00rootroot00000000000000eth0: flags=4163 mtu 1500 inet 10.1.1.111 netmask 255.255.255.0 broadcast 10.0.0.255 inet6 fe80::d1a5:787d:4c36:db2f prefixlen 64 scopeid 0xfd ether b4:2e:99:36:1e:64 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth1: flags=4163 mtu 1500 inet 192.168.17.1 netmask 255.255.255.0 broadcast 192.168.17.255 inet6 fe80::5c07:67a6:7f15:9bab prefixlen 64 scopeid 0xfd ether 00:50:56:c0:00:01 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth2: flags=4163 mtu 1500 inet 192.168.235.1 netmask 255.255.255.0 broadcast 192.168.235.255 inet6 fe80::a12b:835:ea84:a256 prefixlen 64 scopeid 0xfd ether 00:50:56:c0:00:08 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth4: flags=4163 mtu 1500 inet 172.29.80.1 netmask 255.255.240.0 broadcast 172.29.95.255 inet6 fe80::d1e5:9273:4ac4:70f5 prefixlen 64 scopeid 0xfd ether 00:15:5d:4f:eb:ba (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth5: flags=4163 mtu 1500 inet 172.28.64.1 netmask 255.255.240.0 broadcast 172.28.79.255 inet6 fe80::9c39:305:316b:dbb6 prefixlen 64 scopeid 0xfd ether 00:15:5d:6e:6f:b3 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth6: flags=4163 mtu 1500 inet 172.31.112.1 netmask 255.255.240.0 broadcast 172.31.127.255 inet6 fe80::f489:53fc:2d7f:63ef prefixlen 64 scopeid 0xfd ether 00:15:5d:eb:24:56 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth7: flags=4163 mtu 1500 inet 172.18.192.1 netmask 255.255.240.0 broadcast 172.18.207.255 inet6 fe80::185a:82d8:747:a641 prefixlen 64 scopeid 0xfd ether 00:15:5d:b3:e0:57 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth8: flags=4163 mtu 1500 inet 192.168.176.1 netmask 255.255.240.0 broadcast 192.168.191.255 inet6 fe80::4cb7:47ff:dbce:6e31 prefixlen 64 scopeid 0xfd ether 00:15:5d:83:d9:0a (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth9: flags=4163 mtu 1500 inet 172.21.96.1 netmask 255.255.240.0 broadcast 172.21.111.255 inet6 fe80::cd0f:cd2f:c367:13d4 prefixlen 64 scopeid 0xfd ether 00:15:5d:6f:a9:e2 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth10: flags=4163 mtu 1500 inet 172.19.192.1 netmask 255.255.240.0 broadcast 172.19.207.255 inet6 fe80::1442:4968:adcd:596e prefixlen 64 scopeid 0xfd ether 00:15:5d:0a:ad:ac (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth11: flags=4163 mtu 1500 inet 172.24.176.1 netmask 255.255.240.0 broadcast 172.24.191.255 inet6 fe80::5d25:1914:b104:7bf4 prefixlen 64 scopeid 0xfd ether 00:15:5d:e7:41:c3 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth12: flags=4163 mtu 1500 inet 192.168.38.1 netmask 255.255.255.0 broadcast 192.168.38.255 inet6 fe80::f133:a3dc:2230:165d prefixlen 64 scopeid 0xfd ether 0a:00:27:00:00:1e (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth13: flags=4163 mtu 1500 inet 192.168.56.1 netmask 255.255.255.0 broadcast 192.168.56.255 inet6 fe80::857f:1b2d:b973:b0f9 prefixlen 64 scopeid 0xfd ether 0a:00:27:00:00:1d (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 1500 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0xfe loop (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 getmac-0.9.5/tests/samples/WSL_ubuntu_18.04/ifconfig_eth8.out000066400000000000000000000007221464534747600236660ustar00rootroot00000000000000eth8: flags=4163 mtu 1500 inet 192.168.176.1 netmask 255.255.240.0 broadcast 192.168.191.255 inet6 fe80::4cb7:47ff:dbce:6e31 prefixlen 64 scopeid 0xfd ether 00:15:5d:83:d9:0a (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 getmac-0.9.5/tests/samples/WSL_ubuntu_18.04/ip_link.out000066400000000000000000000030721464534747600226000ustar00rootroot000000000000004: eth0: mtu 1500 group default qlen 1 link/ether b4:2e:99:36:1e:33 18: eth1: mtu 1500 group default qlen 1 link/ether 00:50:56:c0:00:01 37: eth2: mtu 1500 group default qlen 1 link/ether 00:50:56:c0:00:08 16: eth3: <> mtu 1500 group default qlen 1 link/ether b4:2e:99:35:1e:86 13: eth4: mtu 1500 group default qlen 1 link/ether 00:15:5d:4f:eb:ba 31: eth5: mtu 1500 group default qlen 1 link/ether 00:15:5d:6e:6f:b3 74: eth6: mtu 1500 group default qlen 1 link/ether 00:15:5d:eb:24:56 80: eth7: mtu 1500 group default qlen 1 link/ether 00:15:5d:b3:e0:57 86: eth8: mtu 1500 group default qlen 1 link/ether 00:15:5d:83:d9:0a 92: eth9: mtu 1500 group default qlen 1 link/ether 00:15:5d:6f:a9:e2 98: eth10: mtu 1500 group default qlen 1 link/ether 00:15:5d:0a:ad:ac 106: eth11: mtu 1500 group default qlen 1 link/ether 00:15:5d:e7:41:c3 30: eth12: mtu 1500 group default qlen 1 link/ether 0a:00:27:00:00:1e 29: eth13: mtu 1500 group default qlen 1 link/ether 0a:00:27:00:00:1d 2: eth14: <> mtu 1500 group default qlen 1 link/ether d4:3b:04:1a:0f:26 1: lo: mtu 1500 group default qlen 1 link/loopback 00:00:00:00:00:00 14: eth15: <> mtu 1500 group default qlen 1 link/ether 00:ff:36:20:68:56 getmac-0.9.5/tests/samples/WSL_ubuntu_18.04/ip_route_list_0slash0.out000066400000000000000000000000711464534747600253620ustar00rootroot00000000000000none default via 10.0.0.1 dev eth0 proto unspec metric 0 getmac-0.9.5/tests/samples/WSL_ubuntu_18.04/netstat_-iae.out000066400000000000000000000112631464534747600235310ustar00rootroot00000000000000Kernel Interface table eth0: flags=4163 mtu 1500 inet 10.0.0.222 netmask 255.255.255.0 broadcast 10.0.0.255 inet6 fe80::d1a5:787d:4c36:db2f prefixlen 64 scopeid 0xfd ether b4:2e:99:35:1e:84 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth1: flags=4163 mtu 1500 inet 192.168.17.1 netmask 255.255.255.0 broadcast 192.168.17.255 inet6 fe80::5c07:67a6:7f15:9bab prefixlen 64 scopeid 0xfd ether 00:50:56:c0:00:01 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth2: flags=4163 mtu 1500 inet 192.168.235.1 netmask 255.255.255.0 broadcast 192.168.235.255 inet6 fe80::a12b:835:ea84:a256 prefixlen 64 scopeid 0xfd ether 00:50:56:c0:00:08 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth3: flags=64 mtu 1500 inet 169.254.39.142 netmask 255.255.0.0 inet6 fe80::35e0:eb42:9039:278e prefixlen 64 scopeid 0xfd ether b4:2e:99:35:1e:86 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth4: flags=4163 mtu 1500 inet 192.168.84.1 netmask 255.255.255.0 broadcast 192.168.84.255 inet6 fe80::c45c:29cc:f16d:350d prefixlen 64 scopeid 0xfd ether 0a:00:27:00:00:0c (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth5: flags=4163 mtu 1500 inet 192.168.38.1 netmask 255.255.255.0 broadcast 192.168.38.255 inet6 fe80::d0d7:cafa:5c08:bc45 prefixlen 64 scopeid 0xfd ether 0a:00:27:00:00:18 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth6: flags=4163 mtu 1500 inet 192.168.56.1 netmask 255.255.255.0 broadcast 192.168.56.255 inet6 fe80::790c:3100:c91d:7928 prefixlen 64 scopeid 0xfd ether 0a:00:27:00:00:17 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth7: flags=64 mtu 1500 inet 169.254.6.106 netmask 255.255.0.0 inet6 fe80::496e:8127:ddba:66a prefixlen 64 scopeid 0xfd ether d4:3b:04:1a:0f:26 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth8: flags=64 mtu 1500 inet 169.254.93.91 netmask 255.255.0.0 inet6 fe80::7119:c849:1c4d:5d5b prefixlen 64 scopeid 0xfd ether 00:ff:36:20:68:56 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth9: flags=64 mtu 65535 unspec [NONE SET] netmask 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 ether 00:00:00:00:00:00 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 1500 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0xfe loop (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 getmac-0.9.5/tests/samples/WSL_ubuntu_18.04/route_-n.out000066400000000000000000000054601464534747600227060ustar00rootroot00000000000000Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.0.0.1 255.255.255.255 U 0 0 0 eth0 10.0.0.0 0.0.0.0 255.255.255.0 U 256 0 0 eth0 10.0.0.222 0.0.0.0 255.255.255.255 U 256 0 0 eth0 10.0.0.255 0.0.0.0 255.255.255.255 U 256 0 0 eth0 224.0.0.0 0.0.0.0 240.0.0.0 U 256 0 0 eth0 255.255.255.255 0.0.0.0 255.255.255.255 U 256 0 0 eth0 192.168.17.0 0.0.0.0 255.255.255.0 U 256 0 0 eth1 192.168.17.1 0.0.0.0 255.255.255.255 U 256 0 0 eth1 192.168.17.255 0.0.0.0 255.255.255.255 U 256 0 0 eth1 224.0.0.0 0.0.0.0 240.0.0.0 U 256 0 0 eth1 255.255.255.255 0.0.0.0 255.255.255.255 U 256 0 0 eth1 192.168.235.0 0.0.0.0 255.255.255.0 U 256 0 0 eth2 192.168.235.1 0.0.0.0 255.255.255.255 U 256 0 0 eth2 192.168.235.255 0.0.0.0 255.255.255.255 U 256 0 0 eth2 224.0.0.0 0.0.0.0 240.0.0.0 U 256 0 0 eth2 255.255.255.255 0.0.0.0 255.255.255.255 U 256 0 0 eth2 192.168.84.0 0.0.0.0 255.255.255.0 U 256 0 0 eth4 192.168.84.1 0.0.0.0 255.255.255.255 U 256 0 0 eth4 192.168.84.255 0.0.0.0 255.255.255.255 U 256 0 0 eth4 224.0.0.0 0.0.0.0 240.0.0.0 U 256 0 0 eth4 255.255.255.255 0.0.0.0 255.255.255.255 U 256 0 0 eth4 192.168.38.0 0.0.0.0 255.255.255.0 U 256 0 0 eth5 192.168.38.1 0.0.0.0 255.255.255.255 U 256 0 0 eth5 192.168.38.255 0.0.0.0 255.255.255.255 U 256 0 0 eth5 224.0.0.0 0.0.0.0 240.0.0.0 U 256 0 0 eth5 255.255.255.255 0.0.0.0 255.255.255.255 U 256 0 0 eth5 192.168.56.0 0.0.0.0 255.255.255.0 U 256 0 0 eth6 192.168.56.1 0.0.0.0 255.255.255.255 U 256 0 0 eth6 192.168.56.255 0.0.0.0 255.255.255.255 U 256 0 0 eth6 224.0.0.0 0.0.0.0 240.0.0.0 U 256 0 0 eth6 255.255.255.255 0.0.0.0 255.255.255.255 U 256 0 0 eth6 127.0.0.0 0.0.0.0 255.0.0.0 U 256 0 0 lo 127.0.0.1 0.0.0.0 255.255.255.255 U 256 0 0 lo 127.255.255.255 0.0.0.0 255.255.255.255 U 256 0 0 lo 224.0.0.0 0.0.0.0 240.0.0.0 U 256 0 0 lo 255.255.255.255 0.0.0.0 255.255.255.255 U 256 0 0 lo getmac-0.9.5/tests/samples/android_6.0.1_no_root__ip_addr.txt000066400000000000000000000052101464534747600241000ustar00rootroot000000000000001: lo: mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: dummy0: mtu 1500 qdisc noqueue state UNKNOWN link/ether 0a:15:3d:6f:80:b5 brd ff:ff:ff:ff:ff:ff inet6 fe80::815:3dff:fe6f:80b5/64 scope link valid_lft forever preferred_lft forever 3: sit0: mtu 1480 qdisc noop state DOWN link/sit 0.0.0.0 brd 0.0.0.0 4: rmnet0: mtu 2000 qdisc pfifo_fast state UNKNOWN qlen 1000 link/[530] 12: rmnet_data0: mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000 link/[530] inet 10.154.82.227/29 scope global rmnet_data0 valid_lft forever preferred_lft forever inet6 fe80::af7f:6329:c609:a060/64 scope link valid_lft forever preferred_lft forever 13: rmnet_data1: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 14: rmnet_data2: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 15: rmnet_data3: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 16: rmnet_data4: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 17: rmnet_data5: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 18: rmnet_data6: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 19: rmnet_data7: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 20: r_rmnet_data0: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 21: r_rmnet_data1: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 22: r_rmnet_data2: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 23: r_rmnet_data3: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 24: r_rmnet_data4: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 25: r_rmnet_data5: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 26: r_rmnet_data6: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 27: r_rmnet_data7: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 28: r_rmnet_data8: <> mtu 1500 qdisc noop state DOWN qlen 1000 link/[530] 31: wlan0: mtu 1500 qdisc mq state UP qlen 1000 link/ether 00:0a:f5:52:24:04 brd ff:ff:ff:ff:ff:ff inet 192.168.1.150/24 brd 192.168.1.255 scope global wlan0 valid_lft forever preferred_lft forever inet6 fe80::20a:f5ff:fe52:2404/64 scope link valid_lft forever preferred_lft forever 32: p2p0: mtu 1500 qdisc mq state DOWN qlen 1000 link/ether 02:0a:f5:52:24:04 brd ff:ff:ff:ff:ff:ff getmac-0.9.5/tests/samples/android_6.0.1_no_root__ip_link.txt000066400000000000000000000044411464534747600241300ustar00rootroot000000000000001: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: dummy0: mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT link/ether 0a:15:3d:6f:80:b5 brd ff:ff:ff:ff:ff:ff 3: sit0: mtu 1480 qdisc noop state DOWN mode DEFAULT link/sit 0.0.0.0 brd 0.0.0.0 4: rmnet0: mtu 2000 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 1000 link/[530] 12: rmnet_data0: mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 1000 link/[530] 13: rmnet_data1: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 14: rmnet_data2: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 15: rmnet_data3: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 16: rmnet_data4: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 17: rmnet_data5: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 18: rmnet_data6: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 19: rmnet_data7: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 20: r_rmnet_data0: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 21: r_rmnet_data1: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 22: r_rmnet_data2: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 23: r_rmnet_data3: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 24: r_rmnet_data4: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 25: r_rmnet_data5: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 26: r_rmnet_data6: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 27: r_rmnet_data7: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 28: r_rmnet_data8: <> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/[530] 31: wlan0: mtu 1500 qdisc mq state UP mode DORMANT qlen 1000 link/ether 00:0a:f5:52:24:04 brd ff:ff:ff:ff:ff:ff 32: p2p0: mtu 1500 qdisc mq state DOWN mode DORMANT qlen 1000 link/ether 02:0a:f5:52:24:04 brd ff:ff:ff:ff:ff:ff getmac-0.9.5/tests/samples/android_6/000077500000000000000000000000001464534747600174645ustar00rootroot00000000000000getmac-0.9.5/tests/samples/android_6/cat_proc-net-arp.out000066400000000000000000000002341464534747600233520ustar00rootroot00000000000000IP address HW type Flags HW address Mask Device 10.0.2.2 0x1 0x2 52:55:0a:00:02:02 * eth0 getmac-0.9.5/tests/samples/android_6/cat_proc-net-route.out000066400000000000000000000005031464534747600237250ustar00rootroot00000000000000Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT eth0 00000000 0202000A 0003 0 0 0 00000000 0 0 0 eth0 0002000A 00000000 0001 0 0 0 00FFFFFF 0 0 0 getmac-0.9.5/tests/samples/android_6/cat_sys-class-net-eth0-address.out000066400000000000000000000000221464534747600260240ustar00rootroot0000000000000052:54:00:12:34:56 getmac-0.9.5/tests/samples/android_6/ifconfig.out000066400000000000000000000015671464534747600220120ustar00rootroot00000000000000lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope: Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 TX bytes:0 eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:56 inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 inet6 addr: fe80::5054:ff:fe12:3456/64 Scope: Link inet6 addr: fec0::5054:ff:fe12:3456/64 Scope: Site UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1755 errors:0 dropped:0 overruns:0 frame:0 TX packets:1242 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1953861 TX bytes:256681 getmac-0.9.5/tests/samples/android_6/ifconfig_eth0.out000066400000000000000000000010071464534747600227170ustar00rootroot00000000000000eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:56 inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 inet6 addr: fe80::5054:ff:fe12:3456/64 Scope: Link inet6 addr: fec0::5054:ff:fe12:3456/64 Scope: Site UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1755 errors:0 dropped:0 overruns:0 frame:0 TX packets:1242 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1953861 TX bytes:256681 getmac-0.9.5/tests/samples/android_6/ip_addr.out000066400000000000000000000014521464534747600216210ustar00rootroot000000000000001: lo: mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fec0::5054:ff:fe12:3456/64 scope site dynamic valid_lft 86081sec preferred_lft 14081sec inet6 fe80::5054:ff:fe12:3456/64 scope link valid_lft forever preferred_lft forever 3: sit0: mtu 1480 qdisc noop state DOWN link/sit 0.0.0.0 brd 0.0.0.0 getmac-0.9.5/tests/samples/android_6/ip_link.out000066400000000000000000000006051464534747600216430ustar00rootroot000000000000001: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff 3: sit0: mtu 1480 qdisc noop state DOWN mode DEFAULT link/sit 0.0.0.0 brd 0.0.0.0 getmac-0.9.5/tests/samples/android_6/ip_link_show_eth0.out000066400000000000000000000002341464534747600236210ustar00rootroot000000000000002: eth0: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff getmac-0.9.5/tests/samples/android_6/ip_neighbor.out000066400000000000000000000001501464534747600224760ustar00rootroot00000000000000fe80::2 dev eth0 lladdr 52:56:00:00:00:02 router STALE 10.0.2.2 dev eth0 lladdr 52:55:0a:00:02:02 STALE getmac-0.9.5/tests/samples/android_6/ip_neighbor_show_10.0.2.2.out000066400000000000000000000000611464534747600244750ustar00rootroot0000000000000010.0.2.2 dev eth0 lladdr 52:55:0a:00:02:02 STALE getmac-0.9.5/tests/samples/android_6/ip_route_list.out000066400000000000000000000001341464534747600230740ustar00rootroot00000000000000default via 10.0.2.2 dev eth0 10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15 getmac-0.9.5/tests/samples/android_6/ip_route_list_0slash0.out000066400000000000000000000000361464534747600244270ustar00rootroot00000000000000default via 10.0.2.2 dev eth0 getmac-0.9.5/tests/samples/android_6/netstat.out000066400000000000000000000273431464534747600217100ustar00rootroot00000000000000Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 1 0 ::ffff:10.0.2.15:44094 slc08s02-in-f10.1e100.net:https CLOSE_WAIT tcp 0 0 ::ffff:10.0.2.15:49898 dd-in-f188.1e100.net:5228 ESTABLISHED tcp 0 0 ::ffff:10.0.2.15:41798 slc09s02-in-f10.1e100.net:https ESTABLISHED tcp 0 0 ::ffff:10.0.2.15:41018 dd-in-f188.1e100.net:5228 ESTABLISHED tcp 1 0 ::ffff:10.0.2.15:38431 slc08s01-in-f10.1e100.net:https CLOSE_WAIT tcp 0 0 ::ffff:10.0.2.15:44896 ya-in-f188.1e100.net:5228 ESTABLISHED tcp 1 0 ::ffff:10.0.2.15:46642 slc09s02-in-f10.1e100.net:https CLOSE_WAIT Active UNIX domain sockets (w/o servers) Proto RefCnt Flags Type State I-Node Path unix 16 [ ] DGRAM 5131 /dev/socket/logdw unix 2 [ ] STREAM 7537 /dev/socket/sap_uim_socket1 unix 3 [ ] SEQPACKET CONNECTED 12088 unix 3 [ ] STREAM CONNECTED 12778 unix 3 [ ] STREAM CONNECTED 4248 unix 3 [ ] STREAM CONNECTED 12668 unix 2 [ ] DGRAM 6384 unix 3 [ ] STREAM CONNECTED 20062 unix 3 [ ] STREAM CONNECTED 11844 unix 3 [ ] STREAM CONNECTED 16194 unix 3 [ ] STREAM CONNECTED 12902 unix 3 [ ] STREAM CONNECTED 4254 unix 3 [ ] STREAM CONNECTED 14732 @jdwp-control unix 3 [ ] STREAM CONNECTED 9927 unix 3 [ ] STREAM CONNECTED 8916 unix 3 [ ] STREAM CONNECTED 20568 unix 3 [ ] SEQPACKET CONNECTED 19670 unix 3 [ ] STREAM CONNECTED 10089 @jdwp-control unix 3 [ ] STREAM CONNECTED 16743 unix 3 [ ] STREAM CONNECTED 11374 /dev/socket/mdns unix 3 [ ] SEQPACKET CONNECTED 12456 unix 3 [ ] SEQPACKET CONNECTED 12078 unix 3 [ ] STREAM CONNECTED 8780 unix 3 [ ] STREAM CONNECTED 19914 unix 3 [ ] STREAM CONNECTED 14042 unix 3 [ ] STREAM CONNECTED 12402 unix 3 [ ] STREAM CONNECTED 12475 /dev/socket/zygote unix 3 [ ] STREAM CONNECTED 29478 unix 3 [ ] STREAM CONNECTED 9353 @jdwp-control unix 3 [ ] STREAM CONNECTED 16412 unix 3 [ ] STREAM CONNECTED 12761 unix 2 [ ] DGRAM 3719 unix 3 [ ] SEQPACKET CONNECTED 12363 unix 2 [ ] SEQPACKET CONNECTED 20480 unix 3 [ ] STREAM CONNECTED 13384 @jdwp-control unix 2 [ ] DGRAM 7563 unix 3 [ ] STREAM CONNECTED 17376 unix 3 [ ] STREAM CONNECTED 15689 @jdwp-control unix 3 [ ] STREAM CONNECTED 8267 /dev/socket/cryptd unix 3 [ ] STREAM CONNECTED 16432 unix 3 [ ] STREAM CONNECTED 11290 /dev/socket/vold unix 2 [ ] DGRAM 5149 unix 3 [ ] STREAM CONNECTED 17244 unix 2 [ ] DGRAM 7564 unix 3 [ ] STREAM CONNECTED 10306 unix 3 [ ] STREAM CONNECTED 16547 unix 3 [ ] STREAM CONNECTED 12660 unix 3 [ ] STREAM CONNECTED 31747 unix 2 [ ] DGRAM 4691 unix 3 [ ] STREAM CONNECTED 20058 unix 3 [ ] STREAM CONNECTED 9929 @jdwp-control unix 3 [ ] STREAM CONNECTED 12776 @jdwp-control unix 3 [ ] SEQPACKET CONNECTED 9079 unix 3 [ ] STREAM CONNECTED 11843 unix 2 [ ] DGRAM 7583 unix 3 [ ] STREAM CONNECTED 12901 unix 3 [ ] STREAM CONNECTED 14730 unix 3 [ ] SEQPACKET CONNECTED 12107 unix 3 [ ] SEQPACKET CONNECTED 9363 /dev/socket/lmkd unix 3 [ ] STREAM CONNECTED 16744 unix 3 [ ] STREAM CONNECTED 8503 unix 3 [ ] STREAM CONNECTED 11373 unix 3 [ ] SEQPACKET CONNECTED 12455 unix 3 [ ] SEQPACKET CONNECTED 19672 unix 3 [ ] STREAM CONNECTED 10087 unix 3 [ ] STREAM CONNECTED 16196 @jdwp-control unix 3 [ ] STREAM CONNECTED 8504 unix 3 [ ] SEQPACKET CONNECTED 12364 unix 3 [ ] STREAM CONNECTED 11408 unix 3 [ ] SEQPACKET CONNECTED 19652 unix 3 [ ] STREAM CONNECTED 14047 unix 3 [ ] SEQPACKET CONNECTED 8961 unix 3 [ ] STREAM CONNECTED 17375 unix 3 [ ] STREAM CONNECTED 4055 unix 3 [ ] STREAM CONNECTED 10299 /dev/socket/installd unix 3 [ ] STREAM CONNECTED 8781 unix 3 [ ] STREAM CONNECTED 9354 unix 3 [ ] STREAM CONNECTED 16399 unix 3 [ ] STREAM CONNECTED 15833 unix 3 [ ] STREAM CONNECTED 12756 @jdwp-control unix 3 [ ] STREAM CONNECTED 20567 unix 3 [ ] STREAM CONNECTED 11289 unix 3 [ ] STREAM CONNECTED 14044 @jdwp-control unix 3 [ ] STREAM CONNECTED 16430 @jdwp-control unix 2 [ ] DGRAM 5160 unix 3 [ ] STREAM CONNECTED 16453 unix 3 [ ] SEQPACKET CONNECTED 12180 unix 3 [ ] STREAM CONNECTED 4255 unix 3 [ ] STREAM CONNECTED 12664 unix 3 [ ] STREAM CONNECTED 31746 unix 3 [ ] STREAM CONNECTED 20093 unix 3 [ ] SEQPACKET CONNECTED 11287 unix 2 [ ] DGRAM 4699 unix 3 [ ] STREAM CONNECTED 20060 @jdwp-control unix 3 [ ] STREAM CONNECTED 11547 @jdwp-control unix 3 [ ] STREAM CONNECTED 16849 unix 3 [ ] SEQPACKET CONNECTED 6398 unix 3 [ ] STREAM CONNECTED 9720 unix 3 [ ] SEQPACKET CONNECTED 19673 unix 3 [ ] STREAM CONNECTED 32376 unix 3 [ ] STREAM CONNECTED 11822 unix 3 [ ] STREAM CONNECTED 12933 unix 3 [ ] SEQPACKET CONNECTED 12108 unix 3 [ ] SEQPACKET CONNECTED 12325 unix 3 [ ] STREAM CONNECTED 4252 unix 3 [ ] STREAM CONNECTED 14680 @jdwp-control unix 3 [ ] SEQPACKET CONNECTED 8960 unix 3 [ ] STREAM CONNECTED 10092 unix 3 [ ] SEQPACKET CONNECTED 19653 unix 3 [ ] STREAM CONNECTED 4100 unix 3 [ ] SEQPACKET CONNECTED 19554 unix 3 [ ] SEQPACKET CONNECTED 9078 unix 3 [ ] SEQPACKET CONNECTED 11393 unix 3 [ ] SEQPACKET CONNECTED 12454 unix 3 [ ] STREAM CONNECTED 8458 unix 3 [ ] STREAM CONNECTED 17374 unix 3 [ ] STREAM CONNECTED 12774 unix 3 [ ] SEQPACKET CONNECTED 8233 unix 3 [ ] STREAM CONNECTED 16398 unix 3 [ ] STREAM CONNECTED 18934 unix 3 [ ] STREAM CONNECTED 17722 @jdwp-control unix 3 [ ] STREAM CONNECTED 9355 unix 3 [ ] STREAM CONNECTED 16428 unix 3 [ ] STREAM CONNECTED 4056 unix 3 [ ] STREAM CONNECTED 30720 unix 3 [ ] SEQPACKET CONNECTED 18658 unix 2 [ ] DGRAM 5840 unix 3 [ ] STREAM CONNECTED 12754 unix 3 [ ] STREAM CONNECTED 16452 unix 3 [ ] SEQPACKET CONNECTED 12181 unix 3 [ ] SEQPACKET CONNECTED 4270 unix 3 [ ] STREAM CONNECTED 13341 @jdwp-control unix 3 [ ] SEQPACKET CONNECTED 11288 unix 3 [ ] STREAM CONNECTED 15106 @jdwp-control unix 3 [ ] SEQPACKET CONNECTED 8234 unix 3 [ ] STREAM CONNECTED 20094 unix 3 [ ] STREAM CONNECTED 12666 @jdwp-control unix 3 [ ] STREAM CONNECTED 16850 unix 2 [ ] DGRAM 7576 unix 3 [ ] STREAM CONNECTED 14678 unix 3 [ ] STREAM CONNECTED 11545 unix 3 [ ] STREAM CONNECTED 32375 unix 3 [ ] SEQPACKET CONNECTED 12087 unix 3 [ ] SEQPACKET CONNECTED 6397 unix 3 [ ] STREAM CONNECTED 4247 unix 3 [ ] STREAM CONNECTED 12669 unix 3 [ ] STREAM CONNECTED 9703 @jdwp-control unix 3 [ ] STREAM CONNECTED 20061 unix 3 [ ] STREAM CONNECTED 12779 unix 3 [ ] STREAM CONNECTED 15104 unix 3 [ ] STREAM CONNECTED 11824 @jdwp-control unix 3 [ ] STREAM CONNECTED 15835 @jdwp-control unix 3 [ ] STREAM CONNECTED 9719 unix 3 [ ] STREAM CONNECTED 4253 unix 3 [ ] STREAM CONNECTED 19916 @jdwp-control unix 3 [ ] STREAM CONNECTED 12932 unix 2 [ ] DGRAM 6266 unix 3 [ ] SEQPACKET CONNECTED 12457 unix 3 [ ] STREAM CONNECTED 10091 unix 3 [ ] STREAM CONNECTED 8917 /dev/socket/rild unix 3 [ ] SEQPACKET CONNECTED 19669 unix 3 [ ] STREAM CONNECTED 4101 unix 3 [ ] SEQPACKET CONNECTED 11392 unix 3 [ ] STREAM CONNECTED 12403 /dev/socket/netd unix 3 [ ] STREAM CONNECTED 14048 unix 3 [ ] SEQPACKET CONNECTED 19555 unix 3 [ ] SEQPACKET CONNECTED 12077 unix 3 [ ] STREAM CONNECTED 29480 @jdwp-control unix 3 [ ] STREAM CONNECTED 17720 unix 3 [ ] STREAM CONNECTED 9351 unix 3 [ ] STREAM CONNECTED 17373 unix 3 [ ] STREAM CONNECTED 12762 unix 2 [ ] DGRAM 3732 unix 3 [ ] STREAM CONNECTED 18935 unix 3 [ ] STREAM CONNECTED 16413 unix 3 [ ] SEQPACKET CONNECTED 18657 unix 3 [ ] STREAM CONNECTED 15687 unix 3 [ ] STREAM CONNECTED 8266 unix 3 [ ] STREAM CONNECTED 30719 unix 3 [ ] SEQPACKET CONNECTED 4271 /dev/socket/logdr unix 3 [ ] STREAM CONNECTED 16433 unix 3 [ ] STREAM CONNECTED 12661 unix 2 [ ] DGRAM 7572 unix 3 [ ] STREAM CONNECTED 13339 unix 3 [ ] STREAM CONNECTED 16548 unix 3 [ ] STREAM CONNECTED 17245 unix 3 [ ] STREAM CONNECTED 13382 getmac-0.9.5/tests/samples/android_6/netstat_-r.out000066400000000000000000000004031464534747600222720ustar00rootroot00000000000000Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface default 10.0.2.2 0.0.0.0 UG 0 0 0 eth0 10.0.2.0 * 255.255.255.0 U 0 0 0 eth0 getmac-0.9.5/tests/samples/android_6/route.out000066400000000000000000000004001464534747600213450ustar00rootroot00000000000000Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 10.0.2.2 0.0.0.0 UG 0 0 0 eth0 10.0.2.0 * 255.255.255.0 U 0 0 0 eth0 getmac-0.9.5/tests/samples/android_6/route_-n.out000066400000000000000000000004001464534747600217370ustar00rootroot00000000000000Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.0.2.2 0.0.0.0 UG 0 0 0 eth0 10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 getmac-0.9.5/tests/samples/android_9/000077500000000000000000000000001464534747600174675ustar00rootroot00000000000000getmac-0.9.5/tests/samples/android_9/cat_proc-net-arp.out000066400000000000000000000003541464534747600233600ustar00rootroot00000000000000IP address HW type Flags HW address Mask Device 192.168.232.1 0x1 0x2 02:00:00:00:01:00 * wlan0 192.168.200.1 0x1 0x2 8e:8f:aa:c9:d2:8b * radio0 getmac-0.9.5/tests/samples/android_9/cat_proc-net-route.out000066400000000000000000000005041464534747600237310ustar00rootroot00000000000000Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT radio0 00C8A8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0 wlan0 00E8A8C0 00000000 0001 0 0 0 00F8FFFF 0 0 0 getmac-0.9.5/tests/samples/android_9/ifconfig.out000066400000000000000000000027341464534747600220120ustar00rootroot00000000000000radio0 Link encap:UNSPEC inet addr:192.168.200.2 Bcast:192.168.200.255 Mask:255.255.255.0 inet6 addr: fec0::c57b:bd73:5c94:f9c6/64 Scope: Site inet6 addr: fec0::4437:e2ff:feae:b87f/64 Scope: Site inet6 addr: fe80::4437:e2ff:feae:b87f/64 Scope: Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:189 errors:0 dropped:0 overruns:0 frame:0 TX packets:195 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:207020 TX bytes:27853 lo Link encap:UNSPEC inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope: Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:0 TX bytes:0 wlan0 Link encap:UNSPEC Driver mac80211_hwsim inet addr:192.168.232.2 Bcast:192.168.239.255 Mask:255.255.248.0 inet6 addr: fec0::f160:96eb:7e7e:335b/64 Scope: Site inet6 addr: fec0::ff:fe00:0/64 Scope: Site inet6 addr: fe80::ff:fe00:0/64 Scope: Link UP BROADCAST RUNNING MULTICAST MTU:1400 Metric:1 RX packets:36828 errors:0 dropped:0 overruns:0 frame:0 TX packets:9793 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:27308980 TX bytes:1056665 getmac-0.9.5/tests/samples/android_9/ifconfig_wlan0.out000066400000000000000000000010771464534747600231120ustar00rootroot00000000000000wlan0 Link encap:UNSPEC Driver mac80211_hwsim inet addr:192.168.232.2 Bcast:192.168.239.255 Mask:255.255.248.0 inet6 addr: fec0::f160:96eb:7e7e:335b/64 Scope: Site inet6 addr: fec0::ff:fe00:0/64 Scope: Site inet6 addr: fe80::ff:fe00:0/64 Scope: Link UP BROADCAST RUNNING MULTICAST MTU:1400 Metric:1 RX packets:36833 errors:0 dropped:0 overruns:0 frame:0 TX packets:9798 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:27309238 TX bytes:1057085 getmac-0.9.5/tests/samples/android_9/ip_addr.out000066400000000000000000000036101464534747600216220ustar00rootroot000000000000001: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 3: wlan0: mtu 1400 qdisc mq state UP group default qlen 1000 link/ether 02:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff inet 192.168.232.2/21 brd 192.168.239.255 scope global wlan0 valid_lft forever preferred_lft forever inet6 fec0::f160:96eb:7e7e:335b/64 scope site temporary dynamic valid_lft 86272sec preferred_lft 14272sec inet6 fec0::ff:fe00:0/64 scope site dynamic mngtmpaddr valid_lft 86272sec preferred_lft 14272sec inet6 fe80::ff:fe00:0/64 scope link valid_lft forever preferred_lft forever 6: ip_vti0@NONE: mtu 1364 qdisc noop state DOWN group default qlen 1 link/ipip 0.0.0.0 brd 0.0.0.0 7: ip6_vti0@NONE: mtu 1500 qdisc noop state DOWN group default qlen 1 link/tunnel6 :: brd :: 8: sit0@NONE: mtu 1480 qdisc noop state DOWN group default qlen 1 link/sit 0.0.0.0 brd 0.0.0.0 9: ip6tnl0@NONE: mtu 1452 qdisc noop state DOWN group default qlen 1 link/tunnel6 :: brd :: 11: radio0@if10: mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 46:37:e2:ae:b8:7f brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 192.168.200.2/24 brd 192.168.200.255 scope global radio0 valid_lft forever preferred_lft forever inet6 fec0::c57b:bd73:5c94:f9c6/64 scope site temporary dynamic valid_lft 86272sec preferred_lft 14272sec inet6 fec0::4437:e2ff:feae:b87f/64 scope site dynamic mngtmpaddr valid_lft 86272sec preferred_lft 14272sec inet6 fe80::4437:e2ff:feae:b87f/64 scope link valid_lft forever preferred_lft forever getmac-0.9.5/tests/samples/android_9/ip_link.out000066400000000000000000000017401464534747600216470ustar00rootroot000000000000001: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 3: wlan0: mtu 1400 qdisc mq state UP mode DORMANT group default qlen 1000 link/ether 02:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 6: ip_vti0@NONE: mtu 1364 qdisc noop state DOWN mode DEFAULT group default qlen 1 link/ipip 0.0.0.0 brd 0.0.0.0 7: ip6_vti0@NONE: mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1 link/tunnel6 :: brd :: 8: sit0@NONE: mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1 link/sit 0.0.0.0 brd 0.0.0.0 9: ip6tnl0@NONE: mtu 1452 qdisc noop state DOWN mode DEFAULT group default qlen 1 link/tunnel6 :: brd :: 11: radio0@if10: mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000 link/ether 46:37:e2:ae:b8:7f brd ff:ff:ff:ff:ff:ff link-netnsid 0 getmac-0.9.5/tests/samples/android_9/ip_neighbor.out000066400000000000000000000003741464534747600225110ustar00rootroot00000000000000192.168.232.1 dev wlan0 lladdr 02:00:00:00:01:00 STALE 192.168.200.1 dev radio0 lladdr 8e:8f:aa:c9:d2:8b STALE fe80::ff:fe00:100 dev wlan0 lladdr 02:00:00:00:01:00 router STALE fe80::8c8f:aaff:fec9:d28b dev radio0 lladdr 8e:8f:aa:c9:d2:8b router STALE getmac-0.9.5/tests/samples/android_9/ip_route_list.out000066400000000000000000000002131464534747600230750ustar00rootroot00000000000000192.168.200.0/24 dev radio0 proto kernel scope link src 192.168.200.2 192.168.232.0/21 dev wlan0 proto kernel scope link src 192.168.232.2 getmac-0.9.5/tests/samples/android_9/netstat.out000066400000000000000000000560651464534747600217160ustar00rootroot00000000000000Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 192.168.232.2:57128 52.46.158.51:https ESTABLISHED tcp 0 0 192.168.232.2:46716 151.101.2.206:https ESTABLISHED tcp 0 0 192.168.232.2:53776 209.54.177.54:https ESTABLISHED tcp 0 0 192.168.232.2:59490 atl14s08-in-f130.:https ESTABLISHED tcp 0 0 192.168.232.2:53762 209.54.177.54:https ESTABLISHED tcp 0 0 192.168.232.2:53686 209.54.177.54:https ESTABLISHED tcp 0 0 192.168.232.2:53686 209.54.177.54:https ESTABLISHED tcp 32 0 192.168.232.2:44904 lciapi-dfw-08.nin:https CLOSE_WAIT tcp 0 0 192.168.232.2:53694 209.54.177.54:https ESTABLISHED tcp 0 0 192.168.232.2:35844 54.239.17.248:https ESTABLISHED tcp 0 0 192.168.232.2:53658 209.54.177.54:https ESTABLISHED tcp 0 0 192.168.232.2:44550 52.46.153.177:https ESTABLISHED tcp 0 0 192.168.232.2:53768 209.54.177.54:https ESTABLISHED tcp 0 0 192.168.232.2:58656 30.90.190.35.bc.g:https ESTABLISHED tcp 0 0 192.168.232.2:51076 dfw25s25-in-f4.1e:https ESTABLISHED tcp 0 0 192.168.232.2:45234 104.244.42.195:https ESTABLISHED tcp 0 0 192.168.232.2:53766 209.54.177.54:https ESTABLISHED tcp 0 0 192.168.232.2:57718 52.94.243.89:https ESTABLISHED tcp 0 0 192.168.232.2:39210 text-lb.codfw.wik:https ESTABLISHED tcp 0 0 192.168.232.2:59552 server-52-85-90-1:https ESTABLISHED tcp 32 0 192.168.232.2:53468 238.133.212.35.bc:https CLOSE_WAIT tcp 0 0 192.168.232.2:48672 a23-220-246-154.de:http ESTABLISHED tcp 0 0 192.168.232.2:60520 172.67.13.182:https ESTABLISHED tcp 0 0 192.168.232.2:45358 rq-in-f155.1e100.:https ESTABLISHED tcp 0 0 192.168.232.2:42244 dfw25s41-in-f14.1:https ESTABLISHED tcp 0 0 192.168.232.2:57642 dfw25s48-in-f4.1e:https ESTABLISHED tcp 0 0 192.168.232.2:50382 a104-87-5-56.depl:https ESTABLISHED tcp 0 0 192.168.232.2:53764 209.54.177.54:https ESTABLISHED tcp 0 0 192.168.232.2:60522 server-143-204-16:https ESTABLISHED tcp 0 0 192.168.232.2:32904 dfw28s23-in-f6.1e:https ESTABLISHED tcp 0 0 192.168.232.2:60066 e1-rr.ycpi.dnb.ya:https ESTABLISHED tcp 0 0 192.168.232.2:49770 38.71.2.235:https ESTABLISHED tcp 0 0 192.168.232.2:38166 server-13-33-252-:https ESTABLISHED tcp 0 0 192.168.232.2:51868 dfw28s31-in-f14.1:https ESTABLISHED tcp 0 0 192.168.232.2:39904 8.28.7.81:https ESTABLISHED tcp 0 0 192.168.232.2:51864 dfw28s31-in-f14.1:https ESTABLISHED tcp 0 0 192.168.232.2:42214 52.46.144.121:https ESTABLISHED tcp 0 0 192.168.232.2:51238 dfw25s25-in-f4.1e:https ESTABLISHED tcp 0 0 192.168.232.2:50312 a104-87-5-56.depl:https ESTABLISHED tcp 0 0 192.168.232.2:37556 dfw28s29-in-f14.1:https ESTABLISHED tcp 0 0 192.168.232.2:37108 server-143-204-26:https ESTABLISHED tcp 0 0 192.168.232.2:53690 209.54.177.54:https ESTABLISHED tcp 0 0 192.168.232.2:47376 server-18-65-25-7:https ESTABLISHED tcp 0 0 192.168.232.2:38528 spcms.pbp.vip.ne1:https ESTABLISHED tcp 0 0 192.168.232.2:58780 151.101.2.132:https ESTABLISHED tcp 0 0 192.168.232.2:33746 server-143-204-34:https ESTABLISHED tcp 0 0 192.168.232.2:53770 209.54.177.54:https ESTABLISHED tcp 0 0 192.168.232.2:47064 server-52-84-54-2:https ESTABLISHED tcp 0 0 192.168.232.2:50166 50.57.31.206:https ESTABLISHED tcp 0 0 192.168.232.2:33728 server-143-204-34:https ESTABLISHED tcp 0 0 192.168.232.2:57388 rw-in-f94.1e100.n:https ESTABLISHED tcp 0 0 192.168.232.2:34814 rs-in-f139.1e100.:https ESTABLISHED tcp 0 0 192.168.232.2:35846 54.239.17.248:https ESTABLISHED tcp 32 0 192.168.232.2:47638 ec2-54-167-168-13:https CLOSE_WAIT tcp 0 0 192.168.232.2:52146 218.64.98.34.bc.g:https ESTABLISHED tcp 0 0 192.168.232.2:39700 rt-in-f95.1e100.n:https ESTABLISHED tcp 0 0 192.168.232.2:57386 rw-in-f94.1e100.n:https ESTABLISHED tcp 0 0 192.168.232.2:60180 dfw28s30-in-f14.1:https ESTABLISHED tcp 0 0 192.168.232.2:56560 lax17s02-in-f2.1e:https ESTABLISHED tcp 32 0 192.168.232.2:43994 ec2-3-227-221-25.:https CLOSE_WAIT tcp 32 0 192.168.232.2:54036 ec2-44-239-223-37:https CLOSE_WAIT tcp 0 0 192.168.232.2:57572 rw-in-f94.1e100.n:https ESTABLISHED tcp 0 0 192.168.232.2:60928 ec2-52-45-83-18.c:https ESTABLISHED tcp 0 0 192.168.232.2:60316 104.36.113.107:https ESTABLISHED tcp6 1 1 ::ffff:192.168.23:58470 dfw25s42-in-f10.1:https LAST_ACK tcp6 0 0 ::ffff:192.168.23:34620 dfw28s27-in-f14.1:https TIME_WAIT tcp6 0 0 ::ffff:192.168.23:50728 rw-in-f91.1e100.n:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:58564 dfw25s42-in-f10.1:https TIME_WAIT tcp6 0 0 ::ffff:192.168.23:58576 dfw25s42-in-f10.1:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:44766 den16s07-in-f7.1e:https TIME_WAIT tcp6 1 1 ::ffff:192.168.23:58466 dfw25s42-in-f10.1:https LAST_ACK tcp6 0 0 ::ffff:192.168.23:34630 dfw28s27-in-f14.1:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:58820 dfw25s42-in-f10.1:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:37768 dfw25s46-in-f16.1:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:58578 dfw25s42-in-f10.1:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:58558 dfw25s42-in-f10.1:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:34622 dfw28s27-in-f14.1:https TIME_WAIT tcp6 0 0 ::ffff:192.168.23:38694 dfw28s30-in-f3.1e:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:57582 rw-in-f94.1e100.n:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:51584 dfw28s31-in-f14.1:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:41156 rr-in-f188.1e100.n:5228 ESTABLISHED tcp6 0 0 ::ffff:192.168.23:50724 rw-in-f91.1e100.n:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:36128 dfw25s41-in-f3.1e:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:34632 dfw28s27-in-f14.1:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:58824 dfw25s42-in-f10.1:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:34882 dfw28s27-in-f14.1:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:58566 dfw25s42-in-f10.1:https TIME_WAIT tcp6 0 0 ::ffff:192.168.23:38692 dfw28s30-in-f3.1e:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:57592 rw-in-f94.1e100.n:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:52218 dfw28s29-in-f10.1:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:51326 dfw25s44-in-f3.1e:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:38690 dfw28s30-in-f3.1e:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:57136 dfw25s48-in-f3.1e:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:57586 rw-in-f94.1e100.n:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:57590 rw-in-f94.1e100.n:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:34876 dfw28s27-in-f14.1:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:53342 dfw28s27-in-f10.1:https ESTABLISHED tcp6 0 0 ::ffff:192.168.23:35114 rq-in-f95.1e100.n:https ESTABLISHED udp 2560 0 192.168.232.2:bootpc 192.168.232.1:bootps ESTABLISHED Active UNIX domain sockets (w/o servers) Proto RefCnt Flags Type State I-Node Path unix 90 [ ] DGRAM 8197 /dev/socket/logdw unix 4 [ ] DGRAM 7052 /dev/socket/statsdw unix 2 [ ] DGRAM 15506 /dev/socket/wpa_wlan0 unix 2 [ ] DGRAM 5916 unix 2 [ ] DGRAM 16580 unix 3 [ ] SEQPACKET CONNECTED 14152 unix 3 [ ] SEQPACKET CONNECTED 5013 unix 3 [ ] SEQPACKET CONNECTED 13522 unix 2 [ ] DGRAM 60515 unix 3 [ ] SEQPACKET CONNECTED 57082 unix 3 [ ] SEQPACKET CONNECTED 27919 unix 3 [ ] SEQPACKET CONNECTED 13743 unix 3 [ ] SEQPACKET CONNECTED 10908 unix 3 [ ] SEQPACKET CONNECTED 51175 unix 3 [ ] SEQPACKET CONNECTED 15239 unix 2 [ ] DGRAM 6536 unix 3 [ ] SEQPACKET CONNECTED 15647 unix 3 [ ] STREAM CONNECTED 58586 unix 3 [ ] SEQPACKET CONNECTED 27671 unix 3 [ ] STREAM CONNECTED 5001 unix 3 [ ] STREAM CONNECTED 22783 unix 2 [ ] DGRAM 7248 unix 2 [ ] DGRAM 8723 unix 3 [ ] STREAM CONNECTED 22793 unix 3 [ ] STREAM CONNECTED 27821 unix 2 [ ] DGRAM 21762 unix 3 [ ] STREAM CONNECTED 10400 unix 2 [ ] DGRAM 24773 unix 3 [ ] SEQPACKET CONNECTED 14933 unix 3 [ ] SEQPACKET CONNECTED 12152 unix 2 [ ] DGRAM 6464 unix 3 [ ] STREAM CONNECTED 49970 unix 3 [ ] SEQPACKET CONNECTED 52939 unix 3 [ ] SEQPACKET CONNECTED 26907 unix 2 [ ] DGRAM 7410 unix 2 [ ] DGRAM 8666 unix 3 [ ] SEQPACKET CONNECTED 57075 unix 2 [ ] DGRAM 11605 unix 2 [ ] DGRAM 8475 unix 3 [ ] SEQPACKET CONNECTED 27669 unix 3 [ ] STREAM CONNECTED 28445 unix 3 [ ] SEQPACKET CONNECTED 15718 unix 2 [ ] DGRAM 52881 unix 3 [ ] SEQPACKET CONNECTED 51174 unix 3 [ ] SEQPACKET CONNECTED 49935 unix 2 [ ] DGRAM 9445 unix 3 [ ] STREAM CONNECTED 50020 unix 3 [ ] STREAM CONNECTED 27467 unix 2 [ ] DGRAM 10311 unix 3 [ ] STREAM CONNECTED 54944 unix 3 [ ] SEQPACKET CONNECTED 54198 unix 3 [ ] SEQPACKET CONNECTED 57644 unix 2 [ ] DGRAM 8404 unix 2 [ ] DGRAM 5353 unix 3 [ ] STREAM CONNECTED 22294 /dev/socket/mdnsd unix 3 [ ] SEQPACKET CONNECTED 10913 unix 2 [ ] DGRAM 25870 unix 2 [ ] DGRAM 49983 unix 3 [ ] SEQPACKET CONNECTED 12802 unix 3 [ ] STREAM CONNECTED 49969 unix 3 [ ] SEQPACKET CONNECTED 11898 unix 2 [ ] DGRAM 7144 unix 3 [ ] STREAM CONNECTED 54008 unix 3 [ ] SEQPACKET CONNECTED 27042 unix 3 [ ] SEQPACKET CONNECTED 14776 unix 3 [ ] SEQPACKET CONNECTED 8484 unix 3 [ ] STREAM CONNECTED 27824 unix 3 [ ] SEQPACKET CONNECTED 13744 unix 2 [ ] DGRAM 21948 unix 3 [ ] SEQPACKET CONNECTED 10912 unix 2 [ ] DGRAM 5895 unix 3 [ ] STREAM CONNECTED 26451 unix 3 [ ] STREAM CONNECTED 22787 unix 3 [ ] SEQPACKET CONNECTED 5012 unix 2 [ ] DGRAM 13521 unix 2 [ ] DGRAM 60445 unix 3 [ ] SEQPACKET CONNECTED 57076 unix 3 [ ] STREAM CONNECTED 58589 unix 3 [ ] SEQPACKET CONNECTED 53922 unix 2 [ ] DGRAM 44751 unix 2 [ ] DGRAM 7549 unix 3 [ ] SEQPACKET CONNECTED 15237 unix 3 [ ] DGRAM 9450 unix 3 [ ] SEQPACKET CONNECTED 10845 /dev/socket/lmkd unix 2 [ ] DGRAM 13830 unix 3 [ ] SEQPACKET CONNECTED 27806 unix 3 [ ] SEQPACKET CONNECTED 15801 unix 3 [ ] STREAM CONNECTED 10399 unix 3 [ ] STREAM CONNECTED 22782 unix 2 [ ] DGRAM 16787 unix 3 [ ] STREAM CONNECTED 57961 unix 3 [ ] SEQPACKET CONNECTED 53920 unix 2 [ ] DGRAM 7339 unix 3 [ ] SEQPACKET CONNECTED 14934 unix 3 [ ] SEQPACKET CONNECTED 12153 unix 3 [ ] SEQPACKET CONNECTED 15654 unix 3 [ ] SEQPACKET CONNECTED 27670 unix 3 [ ] SEQPACKET CONNECTED 14773 unix 3 [ ] STREAM CONNECTED 49976 unix 3 [ ] STREAM CONNECTED 52993 unix 3 [ ] SEQPACKET CONNECTED 9182 unix 2 [ ] DGRAM 60247 unix 2 [ ] DGRAM 25780 unix 3 [ ] STREAM CONNECTED 12254 unix 2 [ ] DGRAM 8279 unix 2 [ ] DGRAM 59179 unix 2 [ ] DGRAM 26826 unix 2 [ ] DGRAM 10307 unix 2 [ ] DGRAM 41955 unix 3 [ ] SEQPACKET CONNECTED 27672 unix 3 [ ] DGRAM 9449 unix 3 [ ] STREAM CONNECTED 11882 unix 3 [ ] SEQPACKET CONNECTED 10911 unix 3 [ ] SEQPACKET CONNECTED 25860 unix 3 [ ] SEQPACKET CONNECTED 27922 unix 3 [ ] STREAM CONNECTED 54943 unix 3 [ ] SEQPACKET CONNECTED 57645 unix 3 [ ] SEQPACKET CONNECTED 9181 unix 3 [ ] SEQPACKET CONNECTED 27041 unix 3 [ ] SEQPACKET CONNECTED 25885 unix 2 [ ] DGRAM 16414 unix 2 [ ] DGRAM 8367 unix 2 [ ] DGRAM 5347 unix 3 [ ] STREAM CONNECTED 55693 unix 2 [ ] DGRAM 43292 unix 2 [ ] DGRAM 7572 unix 3 [ ] SEQPACKET CONNECTED 12801 unix 2 [ ] DGRAM 15251 unix 3 [ ] SEQPACKET CONNECTED 11899 unix 2 [ ] DGRAM 9235 unix 3 [ ] STREAM CONNECTED 23484 /dev/socket/adbd unix 3 [ ] SEQPACKET CONNECTED 15238 unix 2 [ ] DGRAM 32978 unix 3 [ ] STREAM CONNECTED 58588 unix 3 [ ] SEQPACKET CONNECTED 53923 unix 2 [ ] DGRAM 7537 unix 3 [ ] SEQPACKET CONNECTED 25859 unix 3 [ ] STREAM CONNECTED 22788 unix 3 [ ] STREAM CONNECTED 57962 unix 3 [ ] SEQPACKET CONNECTED 9183 unix 3 [ ] SEQPACKET CONNECTED 60477 unix 3 [ ] SEQPACKET CONNECTED 57077 unix 3 [ ] STREAM CONNECTED 27823 unix 3 [ ] STREAM CONNECTED 13615 unix 3 [ ] STREAM CONNECTED 22010 unix 3 [ ] SEQPACKET CONNECTED 10910 unix 3 [ ] SEQPACKET CONNECTED 15800 unix 3 [ ] SEQPACKET CONNECTED 14775 unix 3 [ ] STREAM CONNECTED 49963 unix 2 [ ] DGRAM 6494 unix 3 [ ] SEQPACKET CONNECTED 15653 unix 2 [ ] DGRAM 58554 unix 3 [ ] SEQPACKET CONNECTED 53921 unix 2 [ ] DGRAM 39343 unix 2 [ ] DGRAM 7319 unix 3 [ ] STREAM CONNECTED 26450 unix 3 [ ] STREAM CONNECTED 22794 unix 3 [ ] SEQPACKET CONNECTED 5015 unix 2 [ ] DGRAM 5867 unix 3 [ ] STREAM CONNECTED 13795 unix 3 [ ] SEQPACKET CONNECTED 27805 unix 3 [ ] SEQPACKET CONNECTED 24551 unix 2 [ ] DGRAM 10753 unix 3 [ ] SEQPACKET CONNECTED 52938 unix 2 [ ] DGRAM 43492 unix 3 [ ] SEQPACKET CONNECTED 11900 unix 2 [ ] DGRAM 9254 unix 3 [ ] SEQPACKET CONNECTED 25445 unix 3 [ ] STREAM CONNECTED 58585 unix 2 [ ] DGRAM 8127 unix 2 [ ] DGRAM 57805 unix 2 [ ] DGRAM 9014 unix 3 [ ] STREAM CONNECTED 54953 unix 3 [ ] SEQPACKET CONNECTED 25886 unix 3 [ ] STREAM CONNECTED 12255 @com.android.internal.os.WebViewZygoteInit/217180c6-360f-40f5-aa66-e97c8c084d59 unix 2 [ ] DGRAM 8232 unix 2 [ ] DGRAM 53016 unix 3 [ ] STREAM CONNECTED 14532 unix 3 [ ] STREAM CONNECTED 28446 unix 2 [ ] DGRAM 13843 unix 3 [ ] SEQPACKET CONNECTED 12800 unix 3 [ ] SEQPACKET CONNECTED 25223 unix 3 [ ] STREAM CONNECTED 49962 unix 3 [ ] STREAM CONNECTED 14370 /dev/socket/netd unix 3 [ ] SEQPACKET CONNECTED 9245 unix 2 [ ] DGRAM 5225 unix 3 [ ] SEQPACKET CONNECTED 27035 unix 2 [ ] DGRAM 23026 unix 2 [ ] DGRAM 7747 unix 3 [ ] STREAM CONNECTED 54948 unix 3 [ ] SEQPACKET CONNECTED 9180 unix 2 [ ] DGRAM 17014 unix 2 [ ] DGRAM 8320 unix 2 [ ] DGRAM 5379 unix 3 [ ] SEQPACKET CONNECTED 24550 unix 3 [ ] SEQPACKET CONNECTED 10915 unix 3 [ ] SEQPACKET CONNECTED 14146 unix 3 [ ] SEQPACKET CONNECTED 27921 unix 3 [ ] STREAM CONNECTED 54007 unix 3 [ ] SEQPACKET CONNECTED 14151 unix 2 [ ] DGRAM 10350 unix 3 [ ] STREAM CONNECTED 25681 unix 2 [ ] DGRAM 15497 unix 3 [ ] STREAM CONNECTED 27822 unix 3 [ ] STREAM CONNECTED 12796 /dev/socket/zygote unix 3 [ ] STREAM CONNECTED 52995 unix 3 [ ] SEQPACKET CONNECTED 10909 unix 3 [ ] STREAM CONNECTED 5002 unix 2 [ ] DGRAM 9002 unix 3 [ ] SEQPACKET CONNECTED 57074 unix 3 [ ] STREAM CONNECTED 55692 unix 3 [ ] SEQPACKET CONNECTED 26906 unix 2 [ ] DGRAM 7268 unix 3 [ ] SEQPACKET CONNECTED 15240 unix 2 [ ] DGRAM 12065 unix 2 [ ] DGRAM 6502 unix 3 [ ] SEQPACKET CONNECTED 15648 unix 3 [ ] STREAM CONNECTED 14382 /dev/socket/mdns unix 3 [ ] STREAM CONNECTED 49975 unix 2 [ ] DGRAM 6433 unix 2 [ ] DGRAM 21819 unix 3 [ ] SEQPACKET CONNECTED 14774 unix 3 [ ] SEQPACKET CONNECTED 5014 unix 2 [ ] DGRAM 5846 unix 3 [ ] SEQPACKET CONNECTED 60478 unix 3 [ ] SEQPACKET CONNECTED 57081 unix 2 [ ] DGRAM 58311 unix 3 [ ] STREAM CONNECTED 50019 unix 2 [ ] DGRAM 38529 unix 3 [ ] STREAM CONNECTED 27468 unix 2 [ ] DGRAM 12264 unix 2 [ ] DGRAM 53058 unix 3 [ ] SEQPACKET CONNECTED 15717 unix 3 [ ] SEQPACKET CONNECTED 49934 unix 2 [ ] DGRAM 9262 unix 3 [ ] SEQPACKET CONNECTED 25444 unix 3 [ ] STREAM CONNECTED 52996 unix 3 [ ] STREAM CONNECTED 14533 unix 2 [ ] DGRAM 29185 unix 3 [ ] STREAM CONNECTED 52992 unix 3 [ ] STREAM CONNECTED 54954 unix 2 [ ] DGRAM 16433 unix 2 [ ] DGRAM 59058 unix 3 [ ] SEQPACKET CONNECTED 27036 unix 2 [ ] DGRAM 7542 unix 3 [ ] SEQPACKET CONNECTED 54197 unix 3 [ ] SEQPACKET CONNECTED 12799 unix 3 [ ] SEQPACKET CONNECTED 25222 unix 3 [ ] SEQPACKET CONNECTED 11897 unix 3 [ ] SEQPACKET CONNECTED 9246 unix 2 [ ] DGRAM 24448 unix 3 [ ] SEQPACKET CONNECTED 10914 unix 3 [ ] SEQPACKET CONNECTED 14147 unix 3 [ ] SEQPACKET CONNECTED 27920 unix 3 [ ] STREAM CONNECTED 54949 unix 3 [ ] SEQPACKET CONNECTED 8485 /dev/socket/logdr unix 2 [ ] DGRAM 8410 unix 2 [ ] DGRAM 5378 getmac-0.9.5/tests/samples/android_9/netstat_-r.out000066400000000000000000000004061464534747600223000ustar00rootroot00000000000000Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.200.0 * 255.255.255.0 U 0 0 0 radio0 192.168.232.0 * 255.255.248.0 U 0 0 0 wlan0 getmac-0.9.5/tests/samples/freebsd11/000077500000000000000000000000001464534747600173735ustar00rootroot00000000000000getmac-0.9.5/tests/samples/freebsd11/arp_-a.out000066400000000000000000000003251464534747600212630ustar00rootroot00000000000000? (10.0.2.15) at 08:00:27:ab:b0:67 on em0 permanent [ethernet] ? (10.0.2.2) at 52:54:00:12:35:02 on em0 expires in 903 seconds [ethernet] ? (10.0.2.3) at 52:54:00:12:35:03 on em0 expires in 906 seconds [ethernet] getmac-0.9.5/tests/samples/freebsd11/arp_10-0-2-2.out000066400000000000000000000001121464534747600216330ustar00rootroot00000000000000? (10.0.2.2) at 52:54:00:12:35:02 on em0 expires in 610 seconds [ethernet]getmac-0.9.5/tests/samples/freebsd11/ifconfig.out000066400000000000000000000013551464534747600217140ustar00rootroot00000000000000em0: flags=8843 metric 0 mtu 1500 options=9b ether 08:00:27:ab:b0:67 hwaddr 08:00:27:ab:b0:67 inet 10.0.2.15 netmask 0xffffff00 broadcast 10.0.2.255 nd6 options=29 media: Ethernet autoselect (1000baseT ) status: active lo0: flags=8049 metric 0 mtu 16384 options=680003 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 inet 127.0.0.1 netmask 0xff000000 nd6 options=21 groups: lo getmac-0.9.5/tests/samples/freebsd11/ifconfig_em0.out000066400000000000000000000005601464534747600224520ustar00rootroot00000000000000em0: flags=8843 metric 0 mtu 1500 options=9b ether 08:00:27:33:37:26 hwaddr 08:00:27:33:37:26 inet 10.0.2.15 netmask 0xffffff00 broadcast 10.0.2.255 nd6 options=29 media: Ethernet autoselect (1000baseT ) status: active getmac-0.9.5/tests/samples/freebsd11/netstat_-ia.out000066400000000000000000000021561464534747600223400ustar00rootroot00000000000000Name Mtu Network Address Ipkts Ierrs Idrop Opkts Oerrs Coll em0 1500 08:00:27:ab:b0:67 1292 0 0 871 0 0 em0 - 10.0.2.0/24 10.0.2.15 1287 - - 866 - - lo0 16384 lo0 4 0 0 4 0 0 lo0 - localhost localhost 4 - - 4 - - ff02::202%lo0 ff01::1%lo0 ff02::2:80f5:5922 ff02::2:ff80:f559 ff02::1%lo0 ff02::1:ff00:1%lo lo0 - fe80::%lo0/64 fe80::1%lo0 0 - - 0 - - ff02::202%lo0 ff01::1%lo0 ff02::2:80f5:5922 ff02::2:ff80:f559 ff02::1%lo0 ff02::1:ff00:1%lo lo0 - your-net localhost 0 - - 0 - - 224.0.0.1 getmac-0.9.5/tests/samples/freebsd11/netstat_r.out000066400000000000000000000013611464534747600221300ustar00rootroot00000000000000Routing tables Internet: Destination Gateway Flags Netif Expire default 10.0.2.2 UGS em0 10.0.2.0/24 link#1 U em0 10.0.2.15 link#1 UHS lo0 getmac-freebsd link#2 UH lo0 Internet6: Destination Gateway Flags Netif Expire ::/96 localhost UGRS lo0 localhost link#2 UH lo0 ::ffff:0.0.0.0/96 localhost UGRS lo0 fe80::/10 localhost UGRS lo0 fe80::%lo0/64 link#2 U lo0 fe80::1%lo0 link#2 UHS lo0 ff02::/16 localhost UGRS lo0getmac-0.9.5/tests/samples/freebsd11/route_get_default.out000066400000000000000000000004471464534747600236320ustar00rootroot00000000000000 route to: default destination: default mask: default gateway: 10.0.2.2 fib: 0 interface: em0 flags: recvpipe sendpipe ssthresh rtt,msec mtu weight expire 0 0 0 0 1500 1 0 getmac-0.9.5/tests/samples/ifconfig.out000066400000000000000000000015251464534747600201370ustar00rootroot00000000000000 eth0 Link encap:Ethernet HWaddr 74:d4:35:e9:45:71 inet addr:10.0.0.104 Bcast:10.0.0.255 Mask:255.255.255.0 inet6 addr: fe80::30e1:92aa:53e7:7f19/64 Scope:Global UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Global UP LOOPBACK RUNNING MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)getmac-0.9.5/tests/samples/ip_link_list.out000066400000000000000000000006131464534747600210300ustar00rootroot00000000000000 7: eth0: mtu 1500 group default qlen 1 link/ether 74:d4:35:e9:45:71 3: eth1: <> mtu 1500 group default qlen 1 link/ether 00:ff:55:4d:4a:3b 1: lo: mtu 1500 group default qlen 1 link/loopback 00:00:00:00:00:00 5: eth2: <> mtu 1472 group default qlen 1 link/ether 00:00:00:00:00:00:00:e0:00:00:00:00:00:00:00:00getmac-0.9.5/tests/samples/macos_10.12.6/000077500000000000000000000000001464534747600176065ustar00rootroot00000000000000getmac-0.9.5/tests/samples/macos_10.12.6/arp_-an.out000066400000000000000000000002711464534747600216540ustar00rootroot00000000000000? (10.0.2.2) at 52:54:0:12:35:2 on en0 ifscope [ethernet] ? (10.0.2.3) at 52:54:0:12:35:3 on en0 ifscope [ethernet] ? (224.0.0.251) at 1:0:5e:0:0:fb on en0 ifscope permanent [ethernet] getmac-0.9.5/tests/samples/macos_10.12.6/arp_10.0.2.3.out000066400000000000000000000000721464534747600220570ustar00rootroot00000000000000? (10.0.2.3) at 52:54:0:12:35:3 on en0 ifscope [ethernet] getmac-0.9.5/tests/samples/macos_10.12.6/ifconfig.out000066400000000000000000000013751464534747600221310ustar00rootroot00000000000000lo0: flags=8049 mtu 16384 options=1203 inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 nd6 options=201 gif0: flags=8010 mtu 1280 stf0: flags=0<> mtu 1280 en0: flags=8863 mtu 1500 options=2b ether 08:00:27:2b:c2:ed inet6 fe80::18d8:82a8:174e:ac2%en0 prefixlen 64 secured scopeid 0x4 inet 10.0.2.15 netmask 0xffffff00 broadcast 10.0.2.255 nd6 options=201 media: autoselect (1000baseT ) status: active getmac-0.9.5/tests/samples/macos_10.12.6/ifconfig_en0.out000066400000000000000000000006331464534747600226670ustar00rootroot00000000000000en0: flags=8863 mtu 1500 options=2b ether 08:00:27:2b:c2:ed inet6 fe80::18d8:82a8:174e:ac2%en0 prefixlen 64 secured scopeid 0x4 inet 10.0.2.15 netmask 0xffffff00 broadcast 10.0.2.255 nd6 options=201 media: autoselect (1000baseT ) status: active getmac-0.9.5/tests/samples/macos_10.12.6/ipconfig_getifaddr_en0.out000066400000000000000000000000121464534747600247010ustar00rootroot0000000000000010.0.2.15 getmac-0.9.5/tests/samples/macos_10.12.6/netstat_-i.out000066400000000000000000000014141464534747600224060ustar00rootroot00000000000000Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll lo0 16384 132 0 132 0 0 lo0 16384 127 localhost 132 - 132 - - lo0 16384 localhost ::1 132 - 132 - - lo0 16384 fe80::1%lo0 fe80:1::1 132 - 132 - - gif0* 1280 0 0 0 0 0 stf0* 1280 0 0 0 0 0 en0 1500 08:00:27:2b:c2:ed 2859 0 2930 0 0 en0 1500 this-macboo fe80:4::18d8:82a8 2859 - 2930 - - en0 1500 10.0.2/24 10.0.2.15 2859 - 2930 - - getmac-0.9.5/tests/samples/macos_10.12.6/netstat_-ia.out000066400000000000000000000033131464534747600225470ustar00rootroot00000000000000Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll lo0 16384 132 0 132 0 0 lo0 16384 127 localhost 132 - 132 - - 224.0.0.251 all-systems.mcast.net lo0 16384 localhost ::1 132 - 132 - - ff02::fb (refs: 1) ff02::2:ff33:9cc0 (refs: 1) ff01::1 (refs: 1) ff02::1 (refs: 1) ff02::1:ff00:1 (refs: 1) lo0 16384 fe80::1%lo0 fe80:1::1 132 - 132 - - ff02::fb (refs: 1) ff02::2:ff33:9cc0 (refs: 1) ff01::1 (refs: 1) ff02::1 (refs: 1) ff02::1:ff00:1 (refs: 1) gif0* 1280 0 0 0 0 0 stf0* 1280 0 0 0 0 0 en0 1500 08:00:27:2b:c2:ed 2872 0 2943 0 0 en0 1500 this-macboo fe80:4::18d8:82a8 2872 - 2943 - - ff02::fb (refs: 1) ff01::1 (refs: 1) ff02::2:ff9a:82d9 (refs: 1) ff02::1 (refs: 1) ff02::1:ff4e:ac2 (refs: 1) en0 1500 10.0.2/24 10.0.2.15 2872 - 2943 - - 224.0.0.251 all-systems.mcast.net getmac-0.9.5/tests/samples/macos_10.12.6/netstat_-rn.out000066400000000000000000000036171464534747600226040ustar00rootroot00000000000000Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire default 10.0.2.2 UGSc 9 0 en0 10.0.2/24 link#4 UCS 1 0 en0 10.0.2.2/32 link#4 UCS 1 0 en0 10.0.2.2 52:54:0:12:35:2 UHLWIir 12 1838 en0 389 10.0.2.3 52:54:0:12:35:3 UHLWI 0 21 en0 1113 10.0.2.15/32 link#4 UCS 0 0 en0 127 127.0.0.1 UCS 0 0 lo0 127.0.0.1 127.0.0.1 UH 2 50 lo0 169.254 link#4 UCS 0 0 en0 224.0.0/4 link#4 UmCS 1 0 en0 224.0.0.251 1:0:5e:0:0:fb UHmLWI 0 0 en0 255.255.255.255/32 link#4 UCS 0 0 en0 Internet6: Destination Gateway Flags Netif Expire ::1 ::1 UHL lo0 fe80::%lo0/64 fe80::1%lo0 UcI lo0 fe80::1%lo0 link#1 UHLI lo0 fe80::%en0/64 link#4 UCI en0 fe80::18d8:82a8:174e:ac2%en0 8:0:27:2b:c2:ed UHLI lo0 ff01::%lo0/32 ::1 UmCI lo0 ff01::%en0/32 link#4 UmCI en0 ff02::%lo0/32 ::1 UmCI lo0 ff02::%en0/32 link#4 UmCI en0 getmac-0.9.5/tests/samples/macos_10.12.6/networksetup_-getmacaddress_en0.out000066400000000000000000000000621464534747600266140ustar00rootroot00000000000000Ethernet Address: 08:00:27:2b:c2:ed (Device: en0) getmac-0.9.5/tests/samples/macos_10.12.6/route_-n_get_default.out000066400000000000000000000004651464534747600244370ustar00rootroot00000000000000 route to: default destination: default mask: default gateway: 10.0.2.2 interface: en0 flags: recvpipe sendpipe ssthresh rtt,msec rttvar hopcount mtu expire 0 0 0 0 0 0 1500 0 getmac-0.9.5/tests/samples/macos_10.12.6/sw_vers.out000066400000000000000000000001071464534747600220250ustar00rootroot00000000000000ProductName: Mac OS X ProductVersion: 10.12.6 BuildVersion: 16G29 getmac-0.9.5/tests/samples/netbsd8.2/000077500000000000000000000000001464534747600173265ustar00rootroot00000000000000getmac-0.9.5/tests/samples/netbsd8.2/arp_10-0-2-2.out000066400000000000000000000000511464534747600215700ustar00rootroot00000000000000? (10.0.2.2) at 52:54:00:12:35:02 on wm0 getmac-0.9.5/tests/samples/netbsd8.2/arp_a.out000066400000000000000000000001221464534747600211340ustar00rootroot00000000000000? (10.0.2.2) at 52:54:00:12:35:02 on wm0 ? (10.0.2.3) at 52:54:00:12:35:03 on wm0 getmac-0.9.5/tests/samples/netbsd8.2/ifconfig.out000066400000000000000000000014121464534747600216410ustar00rootroot00000000000000wm0: flags=0x8843 mtu 1500 capabilities=2bf80 capabilities=2bf80 capabilities=2bf80 enabled=0 ec_capabilities=7 ec_enabled=0 address: 08:00:27:ce:da:53 media: Ethernet autoselect (1000baseT full-duplex) status: active inet 10.0.2.15/24 broadcast 10.0.2.255 flags 0x0 inet6 fe80::f965:4fbc:7807:5fe9%wm0/64 flags 0x0 scopeid 0x1 lo0: flags=0x8049 mtu 33624 inet 127.0.0.1/8 flags 0x0 inet6 ::1/128 flags 0x20 inet6 fe80::1%lo0/64 flags 0x0 scopeid 0x2 getmac-0.9.5/tests/samples/netbsd8.2/ifconfig_wm0.out000066400000000000000000000011211464534747600224210ustar00rootroot00000000000000wm0: flags=0x8843 mtu 1500 capabilities=2bf80 capabilities=2bf80 capabilities=2bf80 enabled=0 ec_capabilities=7 ec_enabled=0 address: 08:00:27:ce:da:53 media: Ethernet autoselect (1000baseT full-duplex) status: active inet 10.0.2.15/24 broadcast 10.0.2.255 flags 0x0 inet6 fe80::f965:4fbc:7807:5fe9%wm0/64 flags 0x0 scopeid 0x1 getmac-0.9.5/tests/samples/netstat_-ian_aix.out000066400000000000000000000006511464534747600216010ustar00rootroot00000000000000Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll en0 1500 link#2 fe.ad.c.1.23.4 1714807956 0 711348489 0 0 01:00:5e:00:00:01 en0 1500 192.168.129 x071 1714807956 0 711348489 0 0 224.0.0.1 en0 1500 192.168.90 x071 1714807956 0 711348489 0 0 224.0.0.1 getmac-0.9.5/tests/samples/netstat_-ian_unknown.out000066400000000000000000000021641464534747600225200ustar00rootroot00000000000000Name Mtu Network Address Ipkts Ierrs Idrop Opkts Oerrs Coll vtnet 1500 52:54:00:9d:0e:67 10017 0 0 8174 0 0 vtnet - fe80::%vtnet0 fe80::5054:ff:fe9 0 - - 4 - - vtnet - 192.168.122.0 192.168.122.45 8844 - - 8171 - - lo0 16384 lo0 260148 0 0 260148 0 0 lo0 - ::1/128 ::1 193 - - 193 - - ff01::1%lo0 ff02::2:2eb7:74fa ff02::2:ff2e:b774 ff02::1%lo0 ff02::1:ff00:1%lo lo0 - fe80::%lo0/64 fe80::1%lo0 0 - - 0 - - ff01::1%lo0 ff02::2:2eb7:74fa ff02::2:ff2e:b774 ff02::1%lo0 ff02::1:ff00:1%lo lo0 - 127.0.0.0/8 127.0.0.1 259955 - - 259955 - - 224.0.0.1 getmac-0.9.5/tests/samples/openbsd_6/000077500000000000000000000000001464534747600174765ustar00rootroot00000000000000getmac-0.9.5/tests/samples/openbsd_6/arp_an.out000066400000000000000000000004451464534747600214720ustar00rootroot00000000000000Host Ethernet Address Netif Expire Flags 10.0.2.2 52:54:00:12:35:02 em0 2m53s 10.0.2.3 52:54:00:12:35:03 em0 expired 10.0.2.15 08:00:27:18:64:56 em0 permanent lgetmac-0.9.5/tests/samples/openbsd_6/ifconfig.out000066400000000000000000000013431464534747600220140ustar00rootroot00000000000000lo0: flags=8049 mtu 32768 index 3 priority 0 llprio 3 groups: lo inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3 inet 127.0.0.1 netmask 0xff000000 em0: flags=8843 mtu 1500 lladdr 08:00:27:18:64:56 index 1 priority 0 llprio 3 groups: egress media: Ethernet autoselect (1000baseT full-duplex) status: active inet 10.0.2.15 netmask 0xffffff00 broadcast 10.0.2.255 enc0: flags=0<> index 2 priority 0 llprio 3 groups: enc status: active pflog0: flags=141 mtu 33136 index 4 priority 0 llprio 3 groups: pfloggetmac-0.9.5/tests/samples/openbsd_6/ifconfig_em0.out000066400000000000000000000004551464534747600225600ustar00rootroot00000000000000em0: flags=8843 mtu 1500 lladdr 08:00:27:18:64:56 index 1 priority 0 llprio 3 groups: egress media: Ethernet autoselect (1000baseT full-duplex) status: active inet 10.0.2.15 netmask 0xffffff00 broadcast 10.0.2.255getmac-0.9.5/tests/samples/openbsd_6/route_nq_show_inet_gateway_priority_1.out000066400000000000000000000003771464534747600300530ustar00rootroot00000000000000Routing tables Internet: Destination Gateway Flags Refs Use Mtu Prio Iface 10.0.2.255 10.0.2.15 UHb 0 0 - 1 em0 127.0.0.1 127.0.0.1 UHhl 1 2 32768 1 lo0getmac-0.9.5/tests/samples/solaris10/000077500000000000000000000000001464534747600174345ustar00rootroot00000000000000getmac-0.9.5/tests/samples/solaris10/arp_-a.out000066400000000000000000000007021464534747600213230ustar00rootroot00000000000000Net to Media Table: IPv4 Device IP Address Mask Flags Phys Addr ------ -------------------- --------------- -------- --------------- e1000g0 10.0.2.2 255.255.255.255 o 52:54:00:12:35:02 e1000g0 10.0.2.3 255.255.255.255 o 52:54:00:12:35:03 e1000g0 vagrant-solaris10.dev 255.255.255.255 SPLA 08:00:27:45:ce:99 e1000g0 base-address.mcast.net 240.0.0.0 SM 01:00:5e:00:00:00 getmac-0.9.5/tests/samples/solaris10/arp_10-0-2-2.out000066400000000000000000000000471464534747600217030ustar00rootroot0000000000000010.0.2.2 (10.0.2.2) at 52:54:0:12:35:2 getmac-0.9.5/tests/samples/solaris10/ifconfig_-a.out000066400000000000000000000004121464534747600223230ustar00rootroot00000000000000lo0: flags=2001000849 mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 e1000g0: flags=1004843 mtu 1500 index 2 inet 10.0.2.15 netmask ffffff00 broadcast 10.0.2.255 getmac-0.9.5/tests/samples/solaris10/ifconfig_e1000g0.out000066400000000000000000000002171464534747600230050ustar00rootroot00000000000000e1000g0: flags=1004843 mtu 1500 index 2 inet 10.0.2.15 netmask ffffff00 broadcast 10.0.2.255 getmac-0.9.5/tests/samples/solaris10/netstat.out000066400000000000000000000006511464534747600216510ustar00rootroot00000000000000 TCP: IPv4 Local Address Remote Address Swind Send-Q Rwind Recv-Q State -------------------- -------------------- ----- ------ ----- ------ ----------- vagrant-solaris10.dev.ssh 10.0.2.2.62701 65535 0 49640 0 ESTABLISHED Active UNIX domain sockets Address Type Vnode Conn Local Addr Remote Addr ffffffff85fc6cb8 stream-ord ffffffff85fc5d80 00000000 /var/run/.inetd.uds getmac-0.9.5/tests/samples/solaris10/netstat_-a.out000066400000000000000000000046311464534747600222300ustar00rootroot00000000000000 UDP: IPv4 Local Address Remote Address State -------------------- -------------------- ---------- *.bootpc Idle *.dhcpv6-client Idle vagrant-solaris10.dev.bootpc Idle *.sunrpc Idle *.* Unbound *.32771 Idle UDP: IPv6 Local Address Remote Address State If --------------------------------- --------------------------------- ---------- ----- *.dhcpv6-client Idle TCP: IPv4 Local Address Remote Address Swind Send-Q Rwind Recv-Q State -------------------- -------------------- ----- ------ ----- ------ ----------- *.* *.* 0 0 49152 0 IDLE localhost.4999 *.* 0 0 49152 0 LISTEN *.sunrpc *.* 0 0 49152 0 LISTEN *.* *.* 0 0 49152 0 IDLE *.ssh *.* 0 0 49152 0 LISTEN vagrant-solaris10.dev.32831 162.255.119.217.smtp 0 0 49640 0 SYN_SENT localhost.smtp *.* 0 0 49152 0 LISTEN localhost.submission *.* 0 0 49152 0 LISTEN vagrant-solaris10.dev.ssh 10.0.2.2.62701 65535 35 49640 0 ESTABLISHED TCP: IPv6 Local Address Remote Address Swind Send-Q Rwind Recv-Q State If --------------------------------- --------------------------------- ----- ------ ----- ------ ----------- ----- *.* *.* 0 0 49152 0 IDLE *.ssh *.* 0 0 49152 0 LISTEN SCTP: Local Address Remote Address Swind Send-Q Rwind Recv-Q StrsI/O State ------------------------------- ------------------------------- ------ ------ ------ ------ ------- ----------- 0.0.0.0 0.0.0.0 0 0 102400 0 32/32 CLOSED Active UNIX domain sockets Address Type Vnode Conn Local Addr Remote Addr ffffffff85fc6cb8 stream-ord ffffffff85fc5d80 00000000 /var/run/.inetd.uds getmac-0.9.5/tests/samples/solaris10/netstat_-i.out000066400000000000000000000003671464534747600222420ustar00rootroot00000000000000Name Mtu Net/Dest Address Ipkts Ierrs Opkts Oerrs Collis Queue lo0 8232 loopback localhost 253 0 253 0 0 0 e1000g0 1500 vagrant-solaris10.dev vagrant-solaris10.dev 27630 0 14952 0 0 0 getmac-0.9.5/tests/samples/ubuntu_12.04/000077500000000000000000000000001464534747600176655ustar00rootroot00000000000000getmac-0.9.5/tests/samples/ubuntu_12.04/ifconfig.out000066400000000000000000000015421464534747600222040ustar00rootroot00000000000000eth0 Link encap:Ethernet HWaddr 08:00:27:e8:81:6f inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fee8:816f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:46041 errors:0 dropped:0 overruns:0 frame:0 TX packets:4240 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:64717219 (64.7 MB) TX bytes:469672 (469.6 KB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) getmac-0.9.5/tests/samples/ubuntu_12.04/ifconfig_eth0.out000066400000000000000000000007421464534747600231250ustar00rootroot00000000000000eth0 Link encap:Ethernet HWaddr 08:00:27:e8:81:6f inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fee8:816f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:46070 errors:0 dropped:0 overruns:0 frame:0 TX packets:4255 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:64719241 (64.7 MB) TX bytes:471174 (471.1 KB) getmac-0.9.5/tests/samples/ubuntu_12.04/ip_a.out000066400000000000000000000011611464534747600213250ustar00rootroot000000000000001: lo: mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:e8:81:6f brd ff:ff:ff:ff:ff:ff inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::a00:27ff:fee8:816f/64 scope link valid_lft forever preferred_lft forever getmac-0.9.5/tests/samples/ubuntu_12.04/netstat_iae.out000066400000000000000000000015711464534747600227220ustar00rootroot00000000000000Kernel Interface table eth0 Link encap:Ethernet HWaddr 08:00:27:e8:81:6f inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fee8:816f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:46294 errors:0 dropped:0 overruns:0 frame:0 TX packets:4386 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:64734723 (64.7 MB) TX bytes:482106 (482.1 KB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) getmac-0.9.5/tests/samples/ubuntu_18.04/000077500000000000000000000000001464534747600176735ustar00rootroot00000000000000getmac-0.9.5/tests/samples/ubuntu_18.04/arp_-a.out000066400000000000000000000001671464534747600215670ustar00rootroot00000000000000? (192.168.16.254) at 00:50:56:e1:2f:51 [ether] on ens33 _gateway (192.168.16.2) at 00:50:56:f1:4c:50 [ether] on ens33 getmac-0.9.5/tests/samples/ubuntu_18.04/arp_-an.out000066400000000000000000000001601464534747600217360ustar00rootroot00000000000000? (192.168.16.254) at 00:50:56:e1:2f:51 [ether] on ens33 ? (192.168.16.2) at 00:50:56:f1:4c:50 [ether] on ens33 getmac-0.9.5/tests/samples/ubuntu_18.04/arping-habets.out000066400000000000000000000000221464534747600231420ustar00rootroot0000000000000000:50:56:e8:32:3c getmac-0.9.5/tests/samples/ubuntu_18.04/arping-iputils.out000066400000000000000000000002441464534747600233730ustar00rootroot00000000000000ARPING 192.168.16.254 from 192.168.16.42 ens33 Unicast reply from 192.168.16.254 [00:50:56:E8:32:3C] 7.521ms Sent 1 probes (1 broadcast(s)) Received 1 response(s) getmac-0.9.5/tests/samples/ubuntu_18.04/cat_proc-net-arp.out000066400000000000000000000003531464534747600235630ustar00rootroot00000000000000IP address HW type Flags HW address Mask Device 192.168.16.254 0x1 0x2 00:50:56:e1:2f:51 * ens33 192.168.16.2 0x1 0x2 00:50:56:f1:4c:50 * ens33 getmac-0.9.5/tests/samples/ubuntu_18.04/ifconfig.out000066400000000000000000000024021464534747600222060ustar00rootroot00000000000000docker0: flags=4099 mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255 ether 02:42:33:bf:3e:40 txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens33: flags=4163 mtu 1500 inet 192.168.16.129 netmask 255.255.255.0 broadcast 192.168.16.255 inet6 fe80::830:deaa:bcf5:d965 prefixlen 64 scopeid 0x20 ether 00:0c:29:b5:72:37 txqueuelen 1000 (Ethernet) RX packets 1048476 bytes 1517297592 (1.5 GB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 282398 bytes 22138690 (22.1 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 8483 bytes 789209 (789.2 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 8483 bytes 789209 (789.2 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 getmac-0.9.5/tests/samples/ubuntu_18.04/ifconfig_ens33.out000066400000000000000000000007611464534747600232270ustar00rootroot00000000000000ens33: flags=4163 mtu 1500 inet 192.168.16.129 netmask 255.255.255.0 broadcast 192.168.16.255 inet6 fe80::830:deaa:bcf5:d965 prefixlen 64 scopeid 0x20 ether 00:0c:29:b5:72:37 txqueuelen 1000 (Ethernet) RX packets 1048503 bytes 1517300382 (1.5 GB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 282411 bytes 22139680 (22.1 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 getmac-0.9.5/tests/samples/ubuntu_18.04/ip_link.out000066400000000000000000000007611464534747600220550ustar00rootroot000000000000001: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: ens33: mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:0c:29:b5:72:37 brd ff:ff:ff:ff:ff:ff 3: docker0: mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default link/ether 02:42:33:bf:3e:40 brd ff:ff:ff:ff:ff:ff getmac-0.9.5/tests/samples/ubuntu_18.04/ip_link_list.out000066400000000000000000000007611464534747600231100ustar00rootroot000000000000001: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: ens33: mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:0c:29:b5:72:37 brd ff:ff:ff:ff:ff:ff 3: docker0: mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default link/ether 02:42:33:bf:3e:40 brd ff:ff:ff:ff:ff:ff getmac-0.9.5/tests/samples/ubuntu_18.04/ip_link_show_eth0.out000066400000000000000000000002501464534747600240260ustar00rootroot000000000000002: eth0: mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 08:00:27:12:33:44 brd ff:ff:ff:ff:ff:ff getmac-0.9.5/tests/samples/ubuntu_18.04/ip_neighbor_show.out000066400000000000000000000001621464534747600237500ustar00rootroot00000000000000192.168.16.254 dev ens33 lladdr 00:50:56:e1:2f:51 STALE 192.168.16.2 dev ens33 lladdr 00:50:56:f1:4c:50 REACHABLE getmac-0.9.5/tests/samples/ubuntu_18.04/ip_neighbor_show_192-168-16-2.out000066400000000000000000000000661464534747600252450ustar00rootroot00000000000000192.168.16.2 dev ens33 lladdr 00:50:56:f1:4c:50 DELAY getmac-0.9.5/tests/samples/ubuntu_18.04/ip_route_list_0slash0.out000066400000000000000000000000721464534747600246360ustar00rootroot00000000000000default via 192.168.16.2 dev ens33 proto dhcp metric 100 getmac-0.9.5/tests/samples/ubuntu_18.04/lsb_release_-a.out000066400000000000000000000001271464534747600232610ustar00rootroot00000000000000Distributor ID: Ubuntu Description: Ubuntu 18.04.1 LTS Release: 18.04 Codename: bionic getmac-0.9.5/tests/samples/ubuntu_18.04/netstat_iae.out000066400000000000000000000024311464534747600227240ustar00rootroot00000000000000Kernel Interface table docker0: flags=4099 mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255 ether 02:42:33:bf:3e:40 txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens33: flags=4163 mtu 1500 inet 192.168.16.129 netmask 255.255.255.0 broadcast 192.168.16.255 inet6 fe80::830:deaa:bcf5:d965 prefixlen 64 scopeid 0x20 ether 00:0c:29:b5:72:37 txqueuelen 1000 (Ethernet) RX packets 1054841 bytes 1523848969 (1.5 GB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 285767 bytes 22501440 (22.5 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 8923 bytes 829290 (829.2 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 8923 bytes 829290 (829.2 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 getmac-0.9.5/tests/samples/ubuntu_18.04/route_-n.out000066400000000000000000000006401464534747600221540ustar00rootroot00000000000000Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.16.2 0.0.0.0 UG 100 0 0 ens33 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 ens33 172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0 192.168.16.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33 getmac-0.9.5/tests/samples/ubuntu_18.10/000077500000000000000000000000001464534747600176705ustar00rootroot00000000000000getmac-0.9.5/tests/samples/ubuntu_18.10/proc_net_arp.out000066400000000000000000000013031464534747600230710ustar00rootroot00000000000000IP address HW type Flags HW address Mask Device 104.198.143.177 0x1 0x0 00:00:00:00:00:00 * ens34 104.198.143.177 0x1 0x0 00:00:00:00:00:00 * docker0 104.197.3.80 0x1 0x0 00:00:00:00:00:00 * ens34 104.197.3.80 0x1 0x0 00:00:00:00:00:00 * docker0 192.168.95.254 0x1 0x0 00:50:56:fa:b7:54 * ens34 192.168.95.1 0x1 0x2 00:50:56:c0:00:0a * ens34 192.168.16.254 0x1 0x2 00:50:56:e8:32:3c * ens33 192.168.16.2 0x1 0x2 00:50:56:e1:a8:4a * ens33 getmac-0.9.5/tests/samples/ubuntu_18.10/proc_net_route.out000066400000000000000000000014001464534747600234430ustar00rootroot00000000000000Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT ens33 00000000 0210A8C0 0003 0 0 100 00000000 0 0 0 ens33 0000FEA9 00000000 0001 0 0 1000 0000FFFF 0 0 0 docker0 000011AC 00000000 0001 0 0 0 0000FFFF 0 0 0 ens33 0010A8C0 00000000 0001 0 0 100 00FFFFFF 0 0 0 ens34 005FA8C0 00000000 0001 0 0 101 00FFFFFF 0 0 0 getmac-0.9.5/tests/samples/windows_10/000077500000000000000000000000001464534747600176115ustar00rootroot00000000000000getmac-0.9.5/tests/samples/windows_10/arp_-a.out000066400000000000000000000061231464534747600215030ustar00rootroot00000000000000 Interface: 10.0.0.185 --- 0x5 Internet Address Physical Address Type 10.0.0.1 6a-d7-9a-29-2b-82 dynamic 10.0.0.175 78-28-ca-c4-66-fe dynamic 10.0.0.187 5c-aa-fd-5e-49-48 dynamic 10.0.0.198 b8-e9-37-46-ff-76 dynamic 10.0.0.255 ff-ff-ff-ff-ff-ff static 224.0.0.2 01-00-5e-00-00-02 static 224.0.0.22 01-00-5e-00-00-16 static 224.0.0.251 01-00-5e-00-00-fb static 224.0.0.252 01-00-5e-00-00-fc static 224.168.100.1 01-00-5e-28-64-01 static 239.255.255.250 01-00-5e-7f-ff-fa static 255.255.255.255 ff-ff-ff-ff-ff-ff static Interface: 192.168.84.1 --- 0xc Internet Address Physical Address Type 192.168.84.255 ff-ff-ff-ff-ff-ff static 224.0.0.2 01-00-5e-00-00-02 static 224.0.0.22 01-00-5e-00-00-16 static 224.0.0.251 01-00-5e-00-00-fb static 224.0.0.252 01-00-5e-00-00-fc static 239.255.255.250 01-00-5e-7f-ff-fa static Interface: 192.168.17.1 --- 0x10 Internet Address Physical Address Type 192.168.17.255 ff-ff-ff-ff-ff-ff static 224.0.0.2 01-00-5e-00-00-02 static 224.0.0.22 01-00-5e-00-00-16 static 224.0.0.251 01-00-5e-00-00-fb static 224.0.0.252 01-00-5e-00-00-fc static 239.255.255.250 01-00-5e-7f-ff-fa static Interface: 192.168.56.1 --- 0x17 Internet Address Physical Address Type 192.168.56.255 ff-ff-ff-ff-ff-ff static 224.0.0.2 01-00-5e-00-00-02 static 224.0.0.22 01-00-5e-00-00-16 static 224.0.0.251 01-00-5e-00-00-fb static 224.0.0.252 01-00-5e-00-00-fc static 239.255.255.250 01-00-5e-7f-ff-fa static Interface: 192.168.38.1 --- 0x18 Internet Address Physical Address Type 192.168.38.255 ff-ff-ff-ff-ff-ff static 224.0.0.2 01-00-5e-00-00-02 static 224.0.0.22 01-00-5e-00-00-16 static 224.0.0.251 01-00-5e-00-00-fb static 224.0.0.252 01-00-5e-00-00-fc static 239.255.255.250 01-00-5e-7f-ff-fa static Interface: 192.168.235.1 --- 0x1c Internet Address Physical Address Type 192.168.235.255 ff-ff-ff-ff-ff-ff static 224.0.0.2 01-00-5e-00-00-02 static 224.0.0.22 01-00-5e-00-00-16 static 224.0.0.251 01-00-5e-00-00-fb static 224.0.0.252 01-00-5e-00-00-fc static 239.255.255.250 01-00-5e-7f-ff-fa static Interface: 172.17.112.1 --- 0x48 Internet Address Physical Address Type 172.17.127.255 ff-ff-ff-ff-ff-ff static 224.0.0.2 01-00-5e-00-00-02 static 224.0.0.22 01-00-5e-00-00-16 static 224.0.0.251 01-00-5e-00-00-fb static 239.255.255.250 01-00-5e-7f-ff-fa static getmac-0.9.5/tests/samples/windows_10/arp_-a_10.0.0.175.out000066400000000000000000000002141464534747600226050ustar00rootroot00000000000000 Interface: 10.0.0.185 --- 0x5 Internet Address Physical Address Type 10.0.0.175 78-28-ca-c4-66-fe dynamic getmac-0.9.5/tests/samples/windows_10/getmac.out000066400000000000000000000010071464534747600216000ustar00rootroot00000000000000 Ethernet Killer E2200 Gi 74-D4-35-E9-45-73 Media disconnected Ethernet 2 Intel(R) Ethern 74-D4-35-E9-45-71 \Device\Tcpip_{3BE773AE-DC23-4526-AEE9-6AB6C5346119} Ethernet 3 Xbox Wireless A 62-45-B4-EB-44-79 N/A Ethernet 4 TAP-Windows Ada 00-FF-17-15-F8-C8 Media disconnected VMware Network VMware Virtual 00-50-56-C0-00-01 \Device\Tcpip_{FA9D6581-A7E7-4D99-91C8-DEF29F2EA807} VMware Network VMware Virtual 00-50-56-C0-00-08 \Device\Tcpip_{E4E0E83D-B56D-4849-8AA1-9B9AAD78CFFB}getmac-0.9.5/tests/samples/windows_10/ipconfig-all.out000066400000000000000000000076001464534747600227110ustar00rootroot00000000000000 Windows IP Configuration Host Name . . . . . . . . . . . . : Supercomputer-14 Primary Dns Suffix . . . . . . . : Node Type . . . . . . . . . . . . : Hybrid IP Routing Enabled. . . . . . . . : No WINS Proxy Enabled. . . . . . . . : No Ethernet adapter Ethernet 3: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Intel(R) Ethernet Connection I217-V Physical Address. . . . . . . . . : 74-D4-35-E9-45-71 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::30e1:92aa:53e7:7f19%7(Preferred) IPv4 Address. . . . . . . . . . . : 10.0.0.104(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Lease Obtained. . . . . . . . . . : Wednesday, October 25, 2017 06:24:49 PM Lease Expires . . . . . . . . . . : Sunday, October 29, 2017 08:34:48 PM Default Gateway . . . . . . . . . : 10.0.0.1 DHCP Server . . . . . . . . . . . : 10.0.0.1 DHCPv6 IAID . . . . . . . . . . . : 141874229 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-21-69-FF-48-62-45-B4-EB-44-79 DNS Servers . . . . . . . . . . . : 8.8.8.8 208.67.220.220 NetBIOS over Tcpip. . . . . . . . : Enabled Ethernet adapter VMware Network Adapter VMnet1: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet1 Physical Address. . . . . . . . . : 00-50-56-C0-00-01 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::5915:5273:fcc5:20f3%14(Preferred) IPv4 Address. . . . . . . . . . . : 192.168.21.1(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Lease Obtained. . . . . . . . . . : Friday, October 27, 2017 08:34:57 PM Lease Expires . . . . . . . . . . : Friday, October 27, 2017 09:04:57 PM Default Gateway . . . . . . . . . : DHCP Server . . . . . . . . . . . : 192.168.21.254 DHCPv6 IAID . . . . . . . . . . . : 234901590 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-21-69-FF-48-62-45-B4-EB-44-79 DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1 fec0:0:0:ffff::2%1 fec0:0:0:ffff::3%1 NetBIOS over Tcpip. . . . . . . . : Enabled Ethernet adapter VMware Network Adapter VMnet8: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet8 Physical Address. . . . . . . . . : 00-50-56-C0-00-08 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::8ddb:6e5b:2b44:79d6%15(Preferred) IPv4 Address. . . . . . . . . . . : 192.168.107.1(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Lease Obtained. . . . . . . . . . : Friday, October 27, 2017 08:35:00 PM Lease Expires . . . . . . . . . . : Friday, October 27, 2017 09:05:00 PM Default Gateway . . . . . . . . . : DHCP Server . . . . . . . . . . . : 192.168.107.254 DHCPv6 IAID . . . . . . . . . . . : 251678806 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-21-69-FF-48-62-45-B4-EB-44-79 DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1 fec0:0:0:ffff::2%1 fec0:0:0:ffff::3%1 Primary WINS Server . . . . . . . : 192.168.107.2 NetBIOS over Tcpip. . . . . . . . : Enabled Tunnel adapter Local Area Connection* 1: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Microsoft Teredo Tunneling Adapter Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0 DHCP Enabled. . . . . . . . . . . : No Autoconfiguration Enabled . . . . : Yes getmac-0.9.5/tests/samples/windows_10/netsh_int_ipv4_show_neigh.out000066400000000000000000000173201464534747600255140ustar00rootroot00000000000000 Interface 1: Loopback Pseudo-Interface 1 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- 224.0.0.2 Permanent 224.0.0.22 Permanent 224.0.0.251 Permanent 224.0.0.252 Permanent 233.89.188.1 Permanent 239.0.0.250 Permanent 239.255.255.250 Permanent Interface 13: Local Area Connection 2 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- 224.0.0.2 01-00-5e-00-00-02 Permanent 224.0.0.22 01-00-5e-00-00-16 Permanent 224.0.0.251 01-00-5e-00-00-fb Permanent 224.0.0.252 01-00-5e-00-00-fc Permanent 233.89.188.1 01-00-5e-59-bc-01 Permanent 239.0.0.250 01-00-5e-00-00-fa Permanent 239.255.255.250 01-00-5e-7f-ff-fa Permanent Interface 5: Ethernet 4 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- 10.0.0.1 6a-d7-9a-29-2b-82 Reachable 10.0.0.175 78-28-ca-c4-66-fe Stale 10.0.0.187 5c-aa-fd-5e-49-48 Stale 10.0.0.198 b8-e9-37-46-ff-76 Stale 10.0.0.255 ff-ff-ff-ff-ff-ff Permanent 224.0.0.2 01-00-5e-00-00-02 Permanent 224.0.0.22 01-00-5e-00-00-16 Permanent 224.0.0.251 01-00-5e-00-00-fb Permanent 224.0.0.252 01-00-5e-00-00-fc Permanent 224.168.100.1 01-00-5e-28-64-01 Permanent 239.255.255.250 01-00-5e-7f-ff-fa Permanent 255.255.255.255 ff-ff-ff-ff-ff-ff Permanent Interface 16: VMware Network Adapter VMnet1 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- 192.168.17.1 00-00-00-00-00-00 Unreachable 192.168.17.255 ff-ff-ff-ff-ff-ff Permanent 224.0.0.2 01-00-5e-00-00-02 Permanent 224.0.0.22 01-00-5e-00-00-16 Permanent 224.0.0.251 01-00-5e-00-00-fb Permanent 224.0.0.252 01-00-5e-00-00-fc Permanent 239.255.255.250 01-00-5e-7f-ff-fa Permanent Interface 28: VMware Network Adapter VMnet8 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- 192.168.235.255 ff-ff-ff-ff-ff-ff Permanent 224.0.0.2 01-00-5e-00-00-02 Permanent 224.0.0.22 01-00-5e-00-00-16 Permanent 224.0.0.251 01-00-5e-00-00-fb Permanent 224.0.0.252 01-00-5e-00-00-fc Permanent 239.255.255.250 01-00-5e-7f-ff-fa Permanent Interface 15: Ethernet 5 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- 224.0.0.2 01-00-5e-00-00-02 Permanent 224.0.0.22 01-00-5e-00-00-16 Permanent 224.0.0.251 01-00-5e-00-00-fb Permanent 224.0.0.252 01-00-5e-00-00-fc Permanent 233.89.188.1 01-00-5e-59-bc-01 Permanent 239.0.0.250 01-00-5e-00-00-fa Permanent 239.255.255.250 01-00-5e-7f-ff-fa Permanent Interface 12: Ethernet 6 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- 192.168.84.255 ff-ff-ff-ff-ff-ff Permanent 224.0.0.2 01-00-5e-00-00-02 Permanent 224.0.0.22 01-00-5e-00-00-16 Permanent 224.0.0.251 01-00-5e-00-00-fb Permanent 224.0.0.252 01-00-5e-00-00-fc Permanent 239.255.255.250 01-00-5e-7f-ff-fa Permanent Interface 72: vEthernet (WSL) Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- 172.17.127.255 ff-ff-ff-ff-ff-ff Permanent 224.0.0.2 01-00-5e-00-00-02 Permanent 224.0.0.22 01-00-5e-00-00-16 Permanent 224.0.0.251 01-00-5e-00-00-fb Permanent 239.255.255.250 01-00-5e-7f-ff-fa Permanent Interface 24: VirtualBox Host-Only Network #2 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- 192.168.38.255 ff-ff-ff-ff-ff-ff Permanent 224.0.0.2 01-00-5e-00-00-02 Permanent 224.0.0.22 01-00-5e-00-00-16 Permanent 224.0.0.251 01-00-5e-00-00-fb Permanent 224.0.0.252 01-00-5e-00-00-fc Permanent 239.255.255.250 01-00-5e-7f-ff-fa Permanent Interface 23: VirtualBox Host-Only Network Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- 192.168.56.255 ff-ff-ff-ff-ff-ff Permanent 224.0.0.2 01-00-5e-00-00-02 Permanent 224.0.0.22 01-00-5e-00-00-16 Permanent 224.0.0.251 01-00-5e-00-00-fb Permanent 224.0.0.252 01-00-5e-00-00-fc Permanent 239.255.255.250 01-00-5e-7f-ff-fa Permanent Interface 2: Bluetooth Network Connection 2 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- 224.0.0.2 01-00-5e-00-00-02 Permanent 224.0.0.22 01-00-5e-00-00-16 Permanent 224.0.0.251 01-00-5e-00-00-fb Permanent 224.0.0.252 01-00-5e-00-00-fc Permanent 233.89.188.1 01-00-5e-59-bc-01 Permanent 239.0.0.250 01-00-5e-00-00-fa Permanent 239.255.255.250 01-00-5e-7f-ff-fa Permanent getmac-0.9.5/tests/samples/windows_10/netsh_int_ipv4_show_route.out000066400000000000000000000074401464534747600255620ustar00rootroot00000000000000 Publish Type Met Prefix Idx Gateway/Interface Name ------- -------- --- ------------------------ --- ------------------------ No Manual 0 0.0.0.0/0 5 10.0.0.1 No System 256 10.0.0.0/24 5 Ethernet 4 No System 256 10.0.0.185/32 5 Ethernet 4 No System 256 10.0.0.255/32 5 Ethernet 4 No System 256 127.0.0.0/8 1 Loopback Pseudo-Interface 1 No System 256 127.0.0.1/32 1 Loopback Pseudo-Interface 1 No System 256 127.255.255.255/32 1 Loopback Pseudo-Interface 1 No System 256 172.17.112.0/20 72 vEthernet (WSL) No System 256 172.17.112.1/32 72 vEthernet (WSL) No System 256 172.17.127.255/32 72 vEthernet (WSL) No System 256 192.168.17.0/24 16 VMware Network Adapter VMnet1 No System 256 192.168.17.1/32 16 VMware Network Adapter VMnet1 No System 256 192.168.17.255/32 16 VMware Network Adapter VMnet1 No System 256 192.168.38.0/24 24 VirtualBox Host-Only Network #2 No System 256 192.168.38.1/32 24 VirtualBox Host-Only Network #2 No System 256 192.168.38.255/32 24 VirtualBox Host-Only Network #2 No System 256 192.168.56.0/24 23 VirtualBox Host-Only Network No System 256 192.168.56.1/32 23 VirtualBox Host-Only Network No System 256 192.168.56.255/32 23 VirtualBox Host-Only Network No System 256 192.168.84.0/24 12 Ethernet 6 No System 256 192.168.84.1/32 12 Ethernet 6 No System 256 192.168.84.255/32 12 Ethernet 6 No System 256 192.168.235.0/24 28 VMware Network Adapter VMnet8 No System 256 192.168.235.1/32 28 VMware Network Adapter VMnet8 No System 256 192.168.235.255/32 28 VMware Network Adapter VMnet8 No System 256 224.0.0.0/4 1 Loopback Pseudo-Interface 1 No System 256 224.0.0.0/4 12 Ethernet 6 No System 256 224.0.0.0/4 23 VirtualBox Host-Only Network No System 256 224.0.0.0/4 24 VirtualBox Host-Only Network #2 No System 256 224.0.0.0/4 13 Local Area Connection 2 No System 256 224.0.0.0/4 5 Ethernet 4 No System 256 224.0.0.0/4 15 Ethernet 5 No System 256 224.0.0.0/4 2 Bluetooth Network Connection 2 No System 256 224.0.0.0/4 28 VMware Network Adapter VMnet8 No System 256 224.0.0.0/4 16 VMware Network Adapter VMnet1 No System 256 224.0.0.0/4 72 vEthernet (WSL) No System 256 255.255.255.255/32 1 Loopback Pseudo-Interface 1 No System 256 255.255.255.255/32 12 Ethernet 6 No System 256 255.255.255.255/32 23 VirtualBox Host-Only Network No System 256 255.255.255.255/32 24 VirtualBox Host-Only Network #2 No System 256 255.255.255.255/32 13 Local Area Connection 2 No System 256 255.255.255.255/32 5 Ethernet 4 No System 256 255.255.255.255/32 15 Ethernet 5 No System 256 255.255.255.255/32 2 Bluetooth Network Connection 2 No System 256 255.255.255.255/32 28 VMware Network Adapter VMnet8 No System 256 255.255.255.255/32 16 VMware Network Adapter VMnet1 No System 256 255.255.255.255/32 72 vEthernet (WSL) getmac-0.9.5/tests/samples/windows_10/netsh_int_ipv6_show_neigh.out000066400000000000000000000371501464534747600255210ustar00rootroot00000000000000 Interface 1: Loopback Pseudo-Interface 1 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- ff02::2 Permanent ff02::c Permanent ff02::16 Permanent ff02::fb Permanent ff02::1:2 Permanent ff02::1:3 Permanent ff02::1:ff50:9b3c Permanent ff02::1:fff7:3628 Permanent Interface 13: Local Area Connection 2 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- fe80::42b0:34ff:fe74:afdd 00-00-00-00-00-00 Unreachable fe80::53a9:a35:d347:49b3 00-00-00-00-00-00 Unreachable fe80::5c07:67a6:7f15:9bab 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1bc 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1d8 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66f0 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66fe 00-00-00-00-00-00 Unreachable fe80::a12b:835:ea84:a256 00-00-00-00-00-00 Unreachable fe80::a8e9:ed20:c1ca:2689 00-00-00-00-00-00 Unreachable fe80::bae9:37ff:fe46:ff76 00-00-00-00-00-00 Unreachable fe80::ca6c:3dff:fe76:48a5 00-00-00-00-00-00 Unreachable ff02::2 33-33-00-00-00-02 Permanent ff02::c 33-33-00-00-00-0c Permanent ff02::16 33-33-00-00-00-16 Permanent ff02::fb 33-33-00-00-00-fb Permanent ff02::1:2 33-33-00-01-00-02 Permanent ff02::1:3 33-33-00-01-00-03 Permanent ff02::1:ff50:9b3c 33-33-ff-50-9b-3c Permanent ff02::1:fff7:3628 33-33-ff-f7-36-28 Permanent Interface 5: Ethernet 4 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- fe80::42b0:34ff:fe74:afdd 00-00-00-00-00-00 Unreachable fe80::53a9:a35:d347:49b3 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1bc 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1d8 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66f0 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66fe 00-00-00-00-00-00 Unreachable fe80::a8e9:ed20:c1ca:2689 00-00-00-00-00-00 Unreachable fe80::bae9:37ff:fe46:ff76 00-00-00-00-00-00 Unreachable fe80::ca6c:3dff:fe76:48a5 00-00-00-00-00-00 Unreachable ff02::1 33-33-00-00-00-01 Permanent ff02::2 33-33-00-00-00-02 Permanent ff02::c 33-33-00-00-00-0c Permanent ff02::16 33-33-00-00-00-16 Permanent ff02::fb 33-33-00-00-00-fb Permanent ff02::1:2 33-33-00-01-00-02 Permanent ff02::1:3 33-33-00-01-00-03 Permanent ff02::1:ff36:db2f 33-33-ff-36-db-2f Permanent ff02::1:fff7:3628 33-33-ff-f7-36-28 Permanent Interface 16: VMware Network Adapter VMnet1 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- fe80::42b0:34ff:fe74:afdd 00-00-00-00-00-00 Unreachable fe80::53a9:a35:d347:49b3 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1bc 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1d8 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66f0 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66fe 00-00-00-00-00-00 Unreachable fe80::a8e9:ed20:c1ca:2689 00-00-00-00-00-00 Unreachable fe80::bae9:37ff:fe46:ff76 00-00-00-00-00-00 Unreachable fe80::ca6c:3dff:fe76:48a5 00-00-00-00-00-00 Unreachable ff02::1 33-33-00-00-00-01 Permanent ff02::2 33-33-00-00-00-02 Permanent ff02::c 33-33-00-00-00-0c Permanent ff02::16 33-33-00-00-00-16 Permanent ff02::fb 33-33-00-00-00-fb Permanent ff02::1:2 33-33-00-01-00-02 Permanent ff02::1:3 33-33-00-01-00-03 Permanent ff02::1:ff15:9bab 33-33-ff-15-9b-ab Permanent ff02::1:fff7:3628 33-33-ff-f7-36-28 Permanent Interface 28: VMware Network Adapter VMnet8 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- fe80::42b0:34ff:fe74:afdd 00-00-00-00-00-00 Unreachable fe80::53a9:a35:d347:49b3 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1bc 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1d8 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66f0 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66fe 00-00-00-00-00-00 Unreachable fe80::a8e9:ed20:c1ca:2689 00-00-00-00-00-00 Unreachable fe80::bae9:37ff:fe46:ff76 00-00-00-00-00-00 Unreachable fe80::ca6c:3dff:fe76:48a5 00-00-00-00-00-00 Unreachable ff02::1 33-33-00-00-00-01 Permanent ff02::2 33-33-00-00-00-02 Permanent ff02::c 33-33-00-00-00-0c Permanent ff02::16 33-33-00-00-00-16 Permanent ff02::fb 33-33-00-00-00-fb Permanent ff02::1:2 33-33-00-01-00-02 Permanent ff02::1:3 33-33-00-01-00-03 Permanent ff02::1:ff84:a256 33-33-ff-84-a2-56 Permanent ff02::1:fff7:3628 33-33-ff-f7-36-28 Permanent Interface 15: Ethernet 5 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- fe80::42b0:34ff:fe74:afdd 00-00-00-00-00-00 Unreachable fe80::53a9:a35:d347:49b3 00-00-00-00-00-00 Unreachable fe80::5c07:67a6:7f15:9bab 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1bc 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1d8 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66f0 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66fe 00-00-00-00-00-00 Unreachable fe80::a12b:835:ea84:a256 00-00-00-00-00-00 Unreachable fe80::a8e9:ed20:c1ca:2689 00-00-00-00-00-00 Unreachable fe80::bae9:37ff:fe46:ff76 00-00-00-00-00-00 Unreachable fe80::ca6c:3dff:fe76:48a5 00-00-00-00-00-00 Unreachable ff02::2 33-33-00-00-00-02 Permanent ff02::c 33-33-00-00-00-0c Permanent ff02::16 33-33-00-00-00-16 Permanent ff02::fb 33-33-00-00-00-fb Permanent ff02::1:2 33-33-00-01-00-02 Permanent ff02::1:3 33-33-00-01-00-03 Permanent ff02::1:ff50:9b3c 33-33-ff-50-9b-3c Permanent ff02::1:fff7:3628 33-33-ff-f7-36-28 Permanent Interface 12: Ethernet 6 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- fe80::42b0:34ff:fe74:afdd 00-00-00-00-00-00 Unreachable fe80::53a9:a35:d347:49b3 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1bc 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1d8 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66f0 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66fe 00-00-00-00-00-00 Unreachable fe80::a8e9:ed20:c1ca:2689 00-00-00-00-00-00 Unreachable fe80::bae9:37ff:fe46:ff76 00-00-00-00-00-00 Unreachable fe80::ca6c:3dff:fe76:48a5 00-00-00-00-00-00 Unreachable ff02::1 33-33-00-00-00-01 Permanent ff02::2 33-33-00-00-00-02 Permanent ff02::c 33-33-00-00-00-0c Permanent ff02::16 33-33-00-00-00-16 Permanent ff02::fb 33-33-00-00-00-fb Permanent ff02::1:2 33-33-00-01-00-02 Permanent ff02::1:3 33-33-00-01-00-03 Permanent ff02::1:ff6d:350d 33-33-ff-6d-35-0d Permanent ff02::1:fff7:3628 33-33-ff-f7-36-28 Permanent Interface 72: vEthernet (WSL) Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- ff02::1 33-33-00-00-00-01 Permanent ff02::2 33-33-00-00-00-02 Permanent ff02::c 33-33-00-00-00-0c Permanent ff02::16 33-33-00-00-00-16 Permanent ff02::fb 33-33-00-00-00-fb Permanent ff02::1:2 33-33-00-01-00-02 Permanent ff02::1:ff76:c285 33-33-ff-76-c2-85 Permanent Interface 24: VirtualBox Host-Only Network #2 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- fe80::42b0:34ff:fe74:afdd 00-00-00-00-00-00 Unreachable fe80::53a9:a35:d347:49b3 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1bc 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1d8 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66f0 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66fe 00-00-00-00-00-00 Unreachable fe80::a8e9:ed20:c1ca:2689 00-00-00-00-00-00 Unreachable fe80::bae9:37ff:fe46:ff76 00-00-00-00-00-00 Unreachable fe80::ca6c:3dff:fe76:48a5 00-00-00-00-00-00 Unreachable ff02::1 33-33-00-00-00-01 Permanent ff02::2 33-33-00-00-00-02 Permanent ff02::c 33-33-00-00-00-0c Permanent ff02::16 33-33-00-00-00-16 Permanent ff02::fb 33-33-00-00-00-fb Permanent ff02::1:2 33-33-00-01-00-02 Permanent ff02::1:3 33-33-00-01-00-03 Permanent ff02::1:ff08:bc45 33-33-ff-08-bc-45 Permanent ff02::1:fff7:3628 33-33-ff-f7-36-28 Permanent Interface 23: VirtualBox Host-Only Network Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- fe80::42b0:34ff:fe74:afdd 00-00-00-00-00-00 Unreachable fe80::53a9:a35:d347:49b3 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1bc 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1d8 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66f0 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66fe 00-00-00-00-00-00 Unreachable fe80::a8e9:ed20:c1ca:2689 00-00-00-00-00-00 Unreachable fe80::bae9:37ff:fe46:ff76 00-00-00-00-00-00 Unreachable fe80::ca6c:3dff:fe76:48a5 00-00-00-00-00-00 Unreachable ff02::1 33-33-00-00-00-01 Permanent ff02::2 33-33-00-00-00-02 Permanent ff02::c 33-33-00-00-00-0c Permanent ff02::16 33-33-00-00-00-16 Permanent ff02::fb 33-33-00-00-00-fb Permanent ff02::1:2 33-33-00-01-00-02 Permanent ff02::1:3 33-33-00-01-00-03 Permanent ff02::1:ff1d:7928 33-33-ff-1d-79-28 Permanent ff02::1:fff7:3628 33-33-ff-f7-36-28 Permanent Interface 2: Bluetooth Network Connection 2 Internet Address Physical Address Type -------------------------------------------- ----------------- ----------- fe80::42b0:34ff:fe74:afdd 00-00-00-00-00-00 Unreachable fe80::53a9:a35:d347:49b3 00-00-00-00-00-00 Unreachable fe80::5c07:67a6:7f15:9bab 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1bc 00-00-00-00-00-00 Unreachable fe80::7a28:caff:feae:b1d8 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66f0 00-00-00-00-00-00 Unreachable fe80::7a28:caff:fec4:66fe 00-00-00-00-00-00 Unreachable fe80::a12b:835:ea84:a256 00-00-00-00-00-00 Unreachable fe80::a8e9:ed20:c1ca:2689 00-00-00-00-00-00 Unreachable fe80::bae9:37ff:fe46:ff76 00-00-00-00-00-00 Unreachable fe80::ca6c:3dff:fe76:48a5 00-00-00-00-00-00 Unreachable ff02::2 33-33-00-00-00-02 Permanent ff02::c 33-33-00-00-00-0c Permanent ff02::16 33-33-00-00-00-16 Permanent ff02::fb 33-33-00-00-00-fb Permanent ff02::1:2 33-33-00-01-00-02 Permanent ff02::1:3 33-33-00-01-00-03 Permanent ff02::1:ff50:9b3c 33-33-ff-50-9b-3c Permanent ff02::1:fff7:3628 33-33-ff-f7-36-28 Permanent getmac-0.9.5/tests/samples/windows_10/netsh_int_ipv6_show_route.out000066400000000000000000000052571464534747600255700ustar00rootroot00000000000000 Publish Type Met Prefix Idx Gateway/Interface Name ------- -------- --- ------------------------ --- ------------------------ No System 256 ::1/128 1 Loopback Pseudo-Interface 1 No System 256 fe80::/64 12 Ethernet 6 No System 256 fe80::/64 23 VirtualBox Host-Only Network No System 256 fe80::/64 24 VirtualBox Host-Only Network #2 No System 256 fe80::/64 13 Local Area Connection 2 No System 256 fe80::/64 5 Ethernet 4 No System 256 fe80::/64 15 Ethernet 5 No System 256 fe80::/64 2 Bluetooth Network Connection 2 No System 256 fe80::/64 28 VMware Network Adapter VMnet8 No System 256 fe80::/64 16 VMware Network Adapter VMnet1 No System 256 fe80::/64 72 vEthernet (WSL) No System 256 fe80::35e0:eb42:9039:278e/128 15 Ethernet 5 No System 256 fe80::496e:8127:ddba:66a/128 2 Bluetooth Network Connection 2 No System 256 fe80::5c07:67a6:7f15:9bab/128 16 VMware Network Adapter VMnet1 No System 256 fe80::60bd:73eb:8d76:c285/128 72 vEthernet (WSL) No System 256 fe80::7119:c849:1c4d:5d5b/128 13 Local Area Connection 2 No System 256 fe80::790c:3100:c91d:7928/128 23 VirtualBox Host-Only Network No System 256 fe80::a12b:835:ea84:a256/128 28 VMware Network Adapter VMnet8 No System 256 fe80::c45c:29cc:f16d:350d/128 12 Ethernet 6 No System 256 fe80::d0d7:cafa:5c08:bc45/128 24 VirtualBox Host-Only Network #2 No System 256 fe80::d1a5:787d:4c36:db2f/128 5 Ethernet 4 No System 256 ff00::/8 1 Loopback Pseudo-Interface 1 No System 256 ff00::/8 12 Ethernet 6 No System 256 ff00::/8 23 VirtualBox Host-Only Network No System 256 ff00::/8 24 VirtualBox Host-Only Network #2 No System 256 ff00::/8 13 Local Area Connection 2 No System 256 ff00::/8 5 Ethernet 4 No System 256 ff00::/8 15 Ethernet 5 No System 256 ff00::/8 2 Bluetooth Network Connection 2 No System 256 ff00::/8 28 VMware Network Adapter VMnet8 No System 256 ff00::/8 16 VMware Network Adapter VMnet1 No System 256 ff00::/8 72 vEthernet (WSL) getmac-0.9.5/tests/samples/windows_10/route_print_-4.out000066400000000000000000000103161464534747600232150ustar00rootroot00000000000000=========================================================================== Interface List 15...b4 2e 99 35 1e 86 ......Intel(R) Ethernet Connection (7) I219-V 72...00 15 5d 79 b6 61 ......Hyper-V Virtual Ethernet Adapter 5...b4 2e 99 35 1e 84 ......Intel(R) I211 Gigabit Network Connection 12...0a 00 27 00 00 0c ......WireGuard Tunnel 24...0a 00 27 00 00 18 ......VirtualBox Host-Only Ethernet Adapter #2 23...0a 00 27 00 00 17 ......VirtualBox Host-Only Ethernet Adapter 16...00 50 56 c0 00 01 ......VMware Virtual Ethernet Adapter for VMnet1 28...00 50 56 c0 00 08 ......VMware Virtual Ethernet Adapter for VMnet8 2...d4 3b 04 1a 0f 26 ......Bluetooth Device (Personal Area Network) #2 1...........................Software Loopback Interface 1 =========================================================================== IPv4 Route Table =========================================================================== Active Routes: Network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 10.0.0.1 10.0.0.185 25 10.0.0.0 255.255.255.0 On-link 10.0.0.185 281 10.0.0.185 255.255.255.255 On-link 10.0.0.185 281 10.0.0.255 255.255.255.255 On-link 10.0.0.185 281 127.0.0.0 255.0.0.0 On-link 127.0.0.1 331 127.0.0.1 255.255.255.255 On-link 127.0.0.1 331 127.255.255.255 255.255.255.255 On-link 127.0.0.1 331 172.17.112.0 255.255.240.0 On-link 172.17.112.1 271 172.17.112.1 255.255.255.255 On-link 172.17.112.1 271 172.17.127.255 255.255.255.255 On-link 172.17.112.1 271 192.168.17.0 255.255.255.0 On-link 192.168.17.1 291 192.168.17.1 255.255.255.255 On-link 192.168.17.1 291 192.168.17.255 255.255.255.255 On-link 192.168.17.1 291 192.168.38.0 255.255.255.0 On-link 192.168.38.1 281 192.168.38.1 255.255.255.255 On-link 192.168.38.1 281 192.168.38.255 255.255.255.255 On-link 192.168.38.1 281 192.168.56.0 255.255.255.0 On-link 192.168.56.1 281 192.168.56.1 255.255.255.255 On-link 192.168.56.1 281 192.168.56.255 255.255.255.255 On-link 192.168.56.1 281 192.168.84.0 255.255.255.0 On-link 192.168.84.1 281 192.168.84.1 255.255.255.255 On-link 192.168.84.1 281 192.168.84.255 255.255.255.255 On-link 192.168.84.1 281 192.168.235.0 255.255.255.0 On-link 192.168.235.1 291 192.168.235.1 255.255.255.255 On-link 192.168.235.1 291 192.168.235.255 255.255.255.255 On-link 192.168.235.1 291 224.0.0.0 240.0.0.0 On-link 127.0.0.1 331 224.0.0.0 240.0.0.0 On-link 192.168.84.1 281 224.0.0.0 240.0.0.0 On-link 192.168.56.1 281 224.0.0.0 240.0.0.0 On-link 192.168.38.1 281 224.0.0.0 240.0.0.0 On-link 10.0.0.185 281 224.0.0.0 240.0.0.0 On-link 192.168.235.1 291 224.0.0.0 240.0.0.0 On-link 192.168.17.1 291 224.0.0.0 240.0.0.0 On-link 172.17.112.1 271 255.255.255.255 255.255.255.255 On-link 127.0.0.1 331 255.255.255.255 255.255.255.255 On-link 192.168.84.1 281 255.255.255.255 255.255.255.255 On-link 192.168.56.1 281 255.255.255.255 255.255.255.255 On-link 192.168.38.1 281 255.255.255.255 255.255.255.255 On-link 10.0.0.185 281 255.255.255.255 255.255.255.255 On-link 192.168.235.1 291 255.255.255.255 255.255.255.255 On-link 192.168.17.1 291 255.255.255.255 255.255.255.255 On-link 172.17.112.1 271 =========================================================================== Persistent Routes: None getmac-0.9.5/tests/samples/windows_10/route_print_-6.out000066400000000000000000000046111464534747600232200ustar00rootroot00000000000000=========================================================================== Interface List 15...b4 2e 99 35 1e 86 ......Intel(R) Ethernet Connection (7) I219-V 72...00 15 5d 79 b6 61 ......Hyper-V Virtual Ethernet Adapter 5...b4 2e 99 35 1e 84 ......Intel(R) I211 Gigabit Network Connection 12...0a 00 27 00 00 0c ......WireGuard Tunnel 24...0a 00 27 00 00 18 ......VirtualBox Host-Only Ethernet Adapter #2 23...0a 00 27 00 00 17 ......VirtualBox Host-Only Ethernet Adapter 16...00 50 56 c0 00 01 ......VMware Virtual Ethernet Adapter for VMnet1 28...00 50 56 c0 00 08 ......VMware Virtual Ethernet Adapter for VMnet8 2...d4 3b 04 1a 0f 26 ......Bluetooth Device (Personal Area Network) #2 1...........................Software Loopback Interface 1 =========================================================================== IPv6 Route Table =========================================================================== Active Routes: If Metric Network Destination Gateway 1 331 ::1/128 On-link 12 281 fe80::/64 On-link 23 281 fe80::/64 On-link 24 281 fe80::/64 On-link 5 281 fe80::/64 On-link 28 291 fe80::/64 On-link 16 291 fe80::/64 On-link 72 271 fe80::/64 On-link 16 291 fe80::5c07:67a6:7f15:9bab/128 On-link 72 271 fe80::60bd:73eb:8d76:c285/128 On-link 23 281 fe80::790c:3100:c91d:7928/128 On-link 28 291 fe80::a12b:835:ea84:a256/128 On-link 12 281 fe80::c45c:29cc:f16d:350d/128 On-link 24 281 fe80::d0d7:cafa:5c08:bc45/128 On-link 5 281 fe80::d1a5:787d:4c36:db2f/128 On-link 1 331 ff00::/8 On-link 12 281 ff00::/8 On-link 23 281 ff00::/8 On-link 24 281 ff00::/8 On-link 5 281 ff00::/8 On-link 28 291 ff00::/8 On-link 16 291 ff00::/8 On-link 72 271 ff00::/8 On-link =========================================================================== Persistent Routes: None getmac-0.9.5/tests/samples/windows_10/wmic_nic.out000066400000000000000000000000461464534747600221320ustar00rootroot00000000000000 MACAddress=00:FF:17:15:F8:C8 getmac-0.9.5/tests/style-requirements.txt000066400000000000000000000013671464534747600206040ustar00rootroot00000000000000check-manifest==0.49 codespell==2.2.2 flake8>=5.0.0 flake8-bugbear==23.1.20;python_version>='3.5' flake8-import-order==0.18.2 flake8-tidy-imports==4.8.0 flake8-print==5.0.0 flake8-builtins==2.1.0 flake8-blind-except==0.2.1 flake8-comprehensions==3.10.1 flake8-debugger==4.1.2 pep8-naming==0.13.3 flake8-string-format==0.3.0 flake8-broken-line==0.6.0 flake8-mutable==1.2.0 flake8-pytest-style==1.6.0 # flake8-annotations 3.0.0 removes support for PEP-484 type comments flake8-annotations<3.0.0 flake8-black;python_version>='3.6' # NOTE: the released version of flake8-mypy is buggy on Windows (17.8.0) # flake8-mypy;python_version>='3.5' https://github.com/ambv/flake8-mypy/archive/master.tar.gz bandit>=1.6.0 black==22.12.0;python_version>='3.6' vulture==2.7 getmac-0.9.5/tests/test-requirements.txt000066400000000000000000000002621464534747600204140ustar00rootroot00000000000000pytest<5 pytest-randomly==1.2.3 pytest-mock==1.10.4 pytest-benchmark==3.2.2 pytest-cov==2.7.1 # TODO: older pytest-xdist isn't working on windows # pytest-xdist==1.34.0 # psutil getmac-0.9.5/tests/test_cli.py000066400000000000000000000042001464534747600163270ustar00rootroot00000000000000# -*- coding: utf-8 -*- import platform import sys from subprocess import PIPE, Popen import pytest from getmac import __version__, get_mac_address PY2 = sys.version_info[0] == 2 BASE_CMD = [sys.executable, "-m", "getmac"] def run_cmd(command): # type: (list) -> str stdout, _ = Popen(command, stdout=PIPE, stderr=PIPE).communicate() return stdout.decode("utf-8").strip() def test_cli_main_basic(): assert run_cmd(BASE_CMD) == get_mac_address() def test_cli_main_verbose(): assert get_mac_address() in run_cmd(BASE_CMD + ["--verbose"]) def test_cli_main_debug(): assert get_mac_address() in run_cmd(BASE_CMD + ["--verbose", "--debug"]) def test_cli_main_invalid_interface(): assert run_cmd(BASE_CMD + ["--interface", "INVALIDTESTINTERFACE"]) == "" def test_cli_help(): assert run_cmd(BASE_CMD + ["--help"]) != "" @pytest.mark.skipif( PY2, reason="This doesn't work in Python 2.7 " "and I don't care enough to figure out why", ) def test_cli_version(): assert __version__ in run_cmd(BASE_CMD + ["--version"]) def test_cli_multiple_debug_levels(): assert get_mac_address() in run_cmd(BASE_CMD + ["-v", "-dd"]) assert get_mac_address() in run_cmd(BASE_CMD + ["-v", "-ddd"]) assert get_mac_address() in run_cmd(BASE_CMD + ["-v", "-dddd"]) def test_cli_no_net(): assert get_mac_address(hostname="localhost") in run_cmd( BASE_CMD + ["-n", "localhost", "--no-network-requests"] ) def test_cli_override_port(): assert ( run_cmd(BASE_CMD + ["-v", "-dd", "-4", "127.0.0.1", "--override-port", "44444"]) != "" ) def test_cli_localhost(): assert run_cmd(BASE_CMD + ["-4", "127.0.0.1"]) != "" assert run_cmd(BASE_CMD + ["-n", "localhost"]) != "" assert run_cmd(BASE_CMD + ["--no-network-requests", "-4", "127.0.0.1"]) != "" assert run_cmd(BASE_CMD + ["--no-network-requests", "-n", "localhost"]) != "" # TODO: figure out how to properly test CLI commands and isolate platform-specific behavior def test_cli_override_platform(): plat = platform.system().lower() assert run_cmd(BASE_CMD + ["-v", "-dd", "--override-platform", plat]) != "" getmac-0.9.5/tests/test_getmac.py000066400000000000000000000316541464534747600170350ustar00rootroot00000000000000# -*- coding: utf-8 -*- import inspect import sys from subprocess import CalledProcessError import pytest from getmac import get_mac_address, getmac PY2 = sys.version_info[0] == 2 MAC_RE_COLON = r"([0-9a-fA-F]{2}(?::[0-9a-fA-F]{2}){5})" def test_all_methods_defined_are_in_methods_list(): """Test that all methods present in getmac.py are in the METHODS list.""" def _is_method(member): return ( inspect.isclass(member) and issubclass(member, getmac.Method) and member is not getmac.Method ) members = [m[1] for m in inspect.getmembers(getmac, _is_method)] assert set(members) == set(getmac.METHODS) assert len(members) == len(getmac.METHODS) def test_method_platform_strings_are_valid(): """test "platforms" for all methods have a valid platform name.""" for method in getmac.METHODS: assert method.platforms <= getmac.Method.VALID_PLATFORM_NAMES def test_check_path(): assert getmac.check_path(__file__) def test_clean_mac(): assert getmac._clean_mac(None) is None assert getmac._clean_mac("") is None assert getmac._clean_mac("00:00:00:00:00:00:00:00:00") is None assert getmac._clean_mac("00:0000:0000") is None assert getmac._clean_mac("00000000000000000") is None assert getmac._clean_mac(" 00-50-56-C0-00-01 ") == "00:50:56:c0:00:01" assert getmac._clean_mac("000000000000") == "00:00:00:00:00:00" def test_search(get_sample): text = get_sample("ifconfig.out") regex = r"HWaddr " + MAC_RE_COLON assert getmac._search(regex, "") is None assert getmac._search(regex, text, 0) == "74:d4:35:e9:45:71" def test_popen(mocker): mocker.patch("getmac.getmac.PATH", []) m = mocker.patch("getmac.getmac._call_proc", return_value="SUCCESS") assert getmac._popen("TESTCMD", "ARGS") == "SUCCESS" m.assert_called_once_with("TESTCMD", "ARGS") def test_call_proc(mocker): mocker.patch("getmac.getmac.DEVNULL", "DEVNULL") mocker.patch("getmac.getmac.ENV", "ENV") mocker.patch("getmac.getmac.WINDOWS", True) m = mocker.patch("getmac.getmac.check_output", return_value="WINSUCCESS") assert getmac._call_proc("CMD", "arg") == "WINSUCCESS" m.assert_called_once_with("CMD" + " " + "arg", stderr="DEVNULL", env="ENV") mocker.patch("getmac.getmac.WINDOWS", False) m = mocker.patch("getmac.getmac.check_output", return_value="YAY") assert getmac._call_proc("CMD", "arg1 arg2") == "YAY" m.assert_called_once_with(["CMD", "arg1", "arg2"], stderr="DEVNULL", env="ENV") def test_uuid_convert(): assert getmac._uuid_convert(2482700837424) == "02:42:0C:80:62:30" assert getmac._uuid_convert(278094213753144) == "FC:EC:DA:D3:29:38" def test_read_file_return(mocker, get_sample): data = get_sample("ifconfig.out") mock_open = mocker.mock_open(read_data=data) if PY2: mocker.patch("__builtin__.open", mock_open) else: mocker.patch("builtins.open", mock_open) assert getmac._read_file("ifconfig.out") == data mock_open.assert_called_once_with("ifconfig.out") def test_read_file_not_exist(): assert getmac._read_file("DOESNOTEXIST") is None def test_fetch_ip_using_dns(mocker): m = mocker.patch("socket.socket") m.return_value.getsockname.return_value = ("1.2.3.4", 51327) assert getmac._fetch_ip_using_dns() == "1.2.3.4" def test_get_method_by_name(): assert not getmac.get_method_by_name("") assert not getmac.get_method_by_name("invalidmethodname") assert getmac.get_method_by_name("ArpFile") == getmac.ArpFile assert getmac.get_method_by_name("getmacexe") == getmac.GetmacExe def test_get_instance_from_cache(mocker): with pytest.raises(KeyError): getmac.get_instance_from_cache("", "") inst = getmac.ArpFile() mocker.patch("getmac.getmac.METHOD_CACHE", {"ip4": inst}) assert getmac.get_instance_from_cache("ip4", "ArpFile") is inst mocker.patch("getmac.getmac.METHOD_CACHE", {"ip4": None}) assert getmac.get_instance_from_cache("ip4", "ArpFile") is None def test_swap_method_fallback(mocker): mocker.patch("getmac.getmac.METHOD_CACHE", {"ip4": getmac.ArpExe()}) mocker.patch("getmac.getmac.FALLBACK_CACHE", {"ip4": [getmac.CtypesHost()]}) assert getmac._swap_method_fallback("ip4", "ArpExe") assert not getmac._swap_method_fallback("ip4", "InvalidMethod") assert getmac._swap_method_fallback("ip4", "CtypesHost") assert isinstance(getmac.METHOD_CACHE["ip4"], getmac.Method) assert str(getmac.METHOD_CACHE["ip4"]) == "CtypesHost" assert isinstance(getmac.FALLBACK_CACHE["ip4"][0], getmac.Method) assert str(getmac.FALLBACK_CACHE["ip4"][0]) == "ArpExe" @pytest.mark.parametrize("method_type", ["ip4", "ip6", "iface", "default_iface"]) def test_initialize_method_cache_valid_types(mocker, method_type): mocker.patch( "getmac.getmac.METHOD_CACHE", {"ip4": None, "ip6": None, "iface": None, "default_iface": None}, ) mocker.patch("getmac.getmac.FALLBACK_CACHE", {}) mocker.patch("getmac.getmac.PLATFORM", "linux") assert getmac.initialize_method_cache(method_type) assert getmac.METHOD_CACHE[method_type] is not None if method_type in ["ip4", "ip6"]: assert getmac.FALLBACK_CACHE[method_type] def test_initialize_method_cache_initialized(mocker): mocker.patch( "getmac.getmac.METHOD_CACHE", {"ip4": getmac.ArpFile(), "ip6": None, "iface": None, "default_iface": None}, ) mocker.patch("getmac.getmac.FALLBACK_CACHE", {}) mocker.patch("getmac.getmac.PLATFORM", "linux") assert getmac.initialize_method_cache("ip4") assert str(getmac.METHOD_CACHE["ip4"]) == "ArpFile" assert isinstance(getmac.METHOD_CACHE["ip4"], getmac.Method) def test_initialize_method_cache_bad_type(mocker): mocker.patch( "getmac.getmac.METHOD_CACHE", {"ip4": None, "ip6": None, "iface": None, "default_iface": None}, ) mocker.patch("getmac.getmac.FALLBACK_CACHE", {}) mocker.patch("getmac.getmac.PLATFORM", "linux") with pytest.warns(RuntimeWarning): assert not getmac.initialize_method_cache("invalid_method_type") with pytest.warns(RuntimeWarning): assert not getmac.initialize_method_cache("ip") def test_initialize_method_cache_platform_override(mocker): mocker.patch("getmac.getmac.METHODS", [getmac.GetmacExe, getmac.IfconfigEther]) mocker.patch( "getmac.getmac.METHOD_CACHE", {"ip4": None, "ip6": None, "iface": None, "default_iface": None}, ) mocker.patch("getmac.getmac.FALLBACK_CACHE", {}) mocker.patch("getmac.getmac.PLATFORM", "windows") mocker.patch("getmac.getmac.OVERRIDE_PLATFORM", "darwin") mocker.patch("getmac.getmac.check_command", return_value=True) assert getmac.initialize_method_cache("iface") assert getmac.OVERRIDE_PLATFORM == "darwin" assert getmac.PLATFORM == "windows" assert isinstance(getmac.METHOD_CACHE["iface"], getmac.IfconfigEther) def test_initialize_method_cache_no_network_request(mocker): mocker.patch( "getmac.getmac.METHOD_CACHE", {"ip4": None, "ip6": None, "iface": None, "default_iface": None}, ) mocker.patch("getmac.getmac.FALLBACK_CACHE", {}) mocker.patch("getmac.getmac.PLATFORM", "linux") mocker.patch("getmac.getmac.check_command", return_value=True) mocker.patch("getmac.getmac.check_path", return_value=True) assert getmac.initialize_method_cache("ip4", network_request=False) assert getmac.PLATFORM == "linux" assert isinstance(getmac.METHOD_CACHE["ip4"], getmac.ArpFile) def test_get_by_method(mocker, get_sample): mocker.patch( "getmac.getmac.METHOD_CACHE", { "ip4": getmac.ArpExe(), "ip6": getmac.IpNeighborShow(), "iface": getmac.WmicExe(), "default_iface": getmac.DefaultIfaceOpenBsd(), }, ) # ip4 content = get_sample("windows_10/arp_-a_10.0.0.175.out") mocker.patch("getmac.getmac._popen", return_value=content) assert getmac.get_by_method("ip4", "10.0.0.175") == "78-28-ca-c4-66-fe" # ip6 content = get_sample("android_9/ip_neighbor.out") mocker.patch("getmac.getmac._popen", return_value=content) assert ( getmac.get_by_method("ip6", "fe80::8c8f:aaff:fec9:d28b") == "8e:8f:aa:c9:d2:8b" ) # iface content = get_sample("windows_10/wmic_nic.out") mocker.patch("getmac.getmac._popen", return_value=content) assert getmac.get_by_method("iface", "Ethernet 3") == "00:FF:17:15:F8:C8" # default_iface content = get_sample("openbsd_6/route_nq_show_inet_gateway_priority_1.out") mocker.patch("getmac.getmac._popen", return_value=content) assert getmac.get_by_method("default_iface") == "em0" def test_get_by_method_errors(mocker): assert getmac.get_by_method("iface", arg="") is None mocker.patch( "getmac.getmac.METHOD_CACHE", {"ip4": None, "ip6": None, "iface": None, "default_iface": None}, ) mocker.patch("getmac.getmac.initialize_method_cache", return_value=False) assert getmac.get_by_method("iface", arg="ens33") is None mocker.patch("getmac.getmac.initialize_method_cache", return_value=True) assert getmac.get_by_method("iface", arg="ens33") is None mocker.patch( "getmac.getmac.METHOD_CACHE", { "ip4": None, "ip6": None, "iface": getmac.SysIfaceFile(), "default_iface": None, }, ) mocker.patch("getmac.getmac._read_file", return_value="") mocker.patch("getmac.getmac.DEBUG", 1) assert getmac.get_by_method("iface", arg="ens33") is None def test_get_by_method_force_method(mocker): mocker.patch("getmac.getmac.FORCE_METHOD", "testing123") assert getmac.get_by_method("iface", arg="some_arg") is None mocker.patch("getmac.getmac._read_file", return_value="00:0c:29:b5:72:37\n") mocker.patch("getmac.getmac.FORCE_METHOD", "SysIfaceFile") assert getmac.get_by_method("iface", "ens33") == "00:0c:29:b5:72:37\n" def test_get_mac_address_force_method(mocker): mocker.patch("getmac.getmac._read_file", return_value="00:0c:29:b5:72:37\n") mocker.patch("getmac.getmac.FORCE_METHOD", "SysIfaceFile") assert getmac.get_mac_address(interface="ens33") == "00:0c:29:b5:72:37" def test_get_mac_address_localhost(): assert get_mac_address(hostname="localhost") == "00:00:00:00:00:00" assert get_mac_address(ip="127.0.0.1") == "00:00:00:00:00:00" result = get_mac_address(hostname="localhost", network_request=False) assert result == "00:00:00:00:00:00" def test_get_mac_address_interface(mocker): mocker.patch("getmac.getmac.get_by_method", return_value="00:0c:29:b5:72:37") assert getmac.get_mac_address(interface="ens33") == "00:0c:29:b5:72:37" getmac.get_by_method.assert_called_once_with("iface", "ens33") def test_get_mac_address_ip(mocker): mocker.patch("getmac.getmac.get_by_method", return_value="00:01:02:04:00:12") assert getmac.get_mac_address(ip="192.0.2.2") == "00:01:02:04:00:12" getmac.get_by_method.assert_called_once_with("ip4", "192.0.2.2") def test_get_mac_address_ip6(mocker): mocker.patch("socket.has_ipv6", False) assert getmac.get_mac_address(ip6="fe80::1") is None mocker.patch("socket.has_ipv6", True) assert getmac.get_mac_address(ip6="192.168.0.1") is None mocker.patch("getmac.getmac.get_by_method", return_value="00:01:02:04:00:00") assert getmac.get_mac_address(ip6="fe80::1") == "00:01:02:04:00:00" getmac.get_by_method.assert_called_once_with("ip6", "fe80::1") def test_get_mac_address_hostname(mocker): cpe = CalledProcessError(cmd="socket.gaierror", returncode=1) mocker.patch("socket.gethostbyname", side_effect=cpe) assert getmac.get_mac_address(hostname="bogus") is None mocker.patch("socket.gethostbyname", return_value="192.0.2.22") mocker.patch("getmac.getmac.get_by_method", return_value="00:01:02:04:00:22") assert getmac.get_mac_address(hostname="test_hostname") == "00:01:02:04:00:22" getmac.get_by_method.assert_called_once_with("ip4", "192.0.2.22") def test_get_mac_address_default_args_windows_net_request_true(mocker): mocker.patch("getmac.getmac.WINDOWS", True) mocker.patch("getmac.getmac.get_by_method", return_value="00:FF:17:15:F8:C8") assert getmac.get_mac_address(network_request=False) == "00:ff:17:15:f8:c8" getmac.get_by_method.assert_called_once_with("iface", "Ethernet") mocker.patch("getmac.getmac.get_by_method", return_value="78:28:ca:c4:66:fe") mocker.patch("getmac.getmac._fetch_ip_using_dns", return_value="10.0.0.175") assert getmac.get_mac_address(network_request=True) == "78:28:ca:c4:66:fe" getmac.get_by_method.assert_called_once_with("ip4", "10.0.0.175") def test_get_mac_address_default_args_fallback_global(mocker): mocker.patch("getmac.getmac.WINDOWS", False) mocker.patch("getmac.getmac.DEFAULT_IFACE", "eth0") mocker.patch("getmac.getmac.get_by_method", return_value="08:00:27:e8:81:6f") assert getmac.get_mac_address() == "08:00:27:e8:81:6f" getmac.get_by_method.assert_called_once_with("iface", "eth0") getmac-0.9.5/tests/test_methods.py000066400000000000000000000561601464534747600172370ustar00rootroot00000000000000# -*- coding: utf-8 -*- import platform import socket import sys import uuid from subprocess import CalledProcessError import pytest from getmac import getmac # TODO: freebsd11/netstat_-ia.out # TODO: netstat_-ian_aix.out # TODO: netstat_-ian_unknown.out # TODO: macos_10.12.6/netstat_-i.out # TODO: macos_10.12.6/netstat_-ia.out def test_darwinnetworksetupiface(benchmark, mocker, get_sample): content = get_sample("macos_10.12.6/networksetup_-getmacaddress_en0.out") mocker.patch("getmac.getmac._popen", return_value=content) assert "08:00:27:2b:c2:ed" == benchmark( getmac.DarwinNetworksetupIface().get, arg="en0" ) mocker.patch("getmac.getmac._popen", return_value=None) assert not getmac.DarwinNetworksetupIface().get("en0") mocker.patch("getmac.getmac._popen", return_value="") assert not getmac.DarwinNetworksetupIface().get("en0") mocker.patch("getmac.getmac.check_command", return_value=True) assert getmac.DarwinNetworksetupIface().test() is True getmac.check_command.assert_called_once_with("networksetup") ifconfigether_samples = [ ("2c:f0:ee:2f:c7:de", "OSX/ifconfig.out"), ("08:00:27:2b:c2:ed", "macos_10.12.6/ifconfig.out"), ("08:00:27:2b:c2:ed", "macos_10.12.6/ifconfig_en0.out"), ] @pytest.mark.parametrize(("mac", "sample_file"), ifconfigether_samples) def test_ifconfigether_darwin(benchmark, mocker, get_sample, mac, sample_file): content = get_sample(sample_file) mocker.patch("getmac.getmac._popen", return_value=content) assert mac == benchmark(getmac.IfconfigEther().get, arg="en0") if sample_file == "OSX/ifconfig.out": assert "b2:eb:94:59:0b:d4" == getmac.IfconfigEther().get("awdl0") assert "32:00:10:bf:60:00" == getmac.IfconfigEther().get("bridge0") assert not getmac.IfconfigEther().get("en") assert not getmac.IfconfigEther().get("lo") assert not getmac.IfconfigEther().get("lo0") assert not getmac.IfconfigEther().get("gif0") assert not getmac.IfconfigEther().get("stf0") assert not getmac.IfconfigEther().get("XHC20") assert not getmac.IfconfigEther().get("utun0") # TODO: several of these should be a different method without a interface arg ifconfig_samples = [ ("74:d4:35:e9:45:71", "eth0", "ifconfig.out"), ("00:0c:29:b5:72:37", "ens33", "ubuntu_18.04/ifconfig_ens33.out"), ("08:00:27:e8:81:6f", "eth0", "ubuntu_12.04/ifconfig.out"), ("08:00:27:e8:81:6f", "eth0", "ubuntu_12.04/ifconfig_eth0.out"), ("00:15:5d:83:d9:0a", "eth8", "WSL_ubuntu_18.04/ifconfig_eth8.out"), # NOTE: the freebsd samples were taken on different machines, hence different MACs ("08:00:27:33:37:26", "em0", "freebsd11/ifconfig_em0.out"), ("08:00:27:ab:b0:67", "em0", "freebsd11/ifconfig.out"), ("2c:f0:ee:2f:c7:de", "en0", "OSX/ifconfig.out"), ("b2:eb:94:59:0b:d4", "awdl0", "OSX/ifconfig.out"), ("32:00:10:bf:60:00", "bridge0", "OSX/ifconfig.out"), ("08:00:27:18:64:56", "em0", "openbsd_6/ifconfig.out"), ("08:00:27:18:64:56", "em0", "openbsd_6/ifconfig_em0.out"), ] @pytest.mark.parametrize(("mac", "iface", "sample_file"), ifconfig_samples) def test_parse_ifconfig_samples(benchmark, get_sample, mac, iface, sample_file): content = get_sample(sample_file) assert mac == benchmark(getmac._parse_ifconfig, iface=iface, command_output=content) # check trailing ":" is stripped assert mac == getmac._parse_ifconfig(iface + ":", content) # Ensure no overmatches or false-positives occur assert not getmac._parse_ifconfig("l", content) assert not getmac._parse_ifconfig("lo", content) assert not getmac._parse_ifconfig("lo0", content) assert not getmac._parse_ifconfig("lo0:", content) assert not getmac._parse_ifconfig("ether", content) assert not getmac._parse_ifconfig("eth", content) assert not getmac._parse_ifconfig("em", content) assert not getmac._parse_ifconfig("e", content) assert not getmac._parse_ifconfig("h0", content) assert not getmac._parse_ifconfig("docker0", content) assert not getmac._parse_ifconfig("XHC20", content) assert not getmac._parse_ifconfig("utun0", content) assert not getmac._parse_ifconfig("enc0", content) assert not getmac._parse_ifconfig("pflog0", content) assert not getmac._parse_ifconfig("", content) def test_parse_ifconfig_bad_params(): assert not getmac._parse_ifconfig(None, None) assert not getmac._parse_ifconfig("", "") assert not getmac._parse_ifconfig(" ", "") assert not getmac._parse_ifconfig(" ", " ") assert not getmac._parse_ifconfig(" ", " ether ") @pytest.mark.parametrize(("mac", "iface", "sample_file"), ifconfig_samples) def test_ifconfigwithifacearg_samples(mocker, get_sample, mac, iface, sample_file): content = get_sample(sample_file) mocker.patch("getmac.getmac._popen", return_value=content) assert mac == getmac.IfconfigWithIfaceArg().get(iface) def test_ifconfigwithifacearg_bad_exits(mocker): cpe = CalledProcessError(cmd="ifconfig", returncode=1) mocker.patch("getmac.getmac._popen", side_effect=cpe) assert getmac.IfconfigWithIfaceArg().get("eth0") is None cpe = CalledProcessError(cmd="ifconfig", returncode=255) mocker.patch("getmac.getmac._popen", side_effect=cpe) with pytest.raises(CalledProcessError): getmac.IfconfigWithIfaceArg().get("eth0") def test_arping_host_habets(benchmark, mocker, get_sample): content = get_sample("ubuntu_18.04/arping-habets.out") mocker.patch("getmac.getmac._popen", return_value=content) ap = getmac.ArpingHost() ap._is_iputils = False ap.get("192.168.16.254") assert "00:50:56:e8:32:3c" == benchmark(ap.get, arg="192.168.16.254") def test_arping_host_iputils(benchmark, mocker, get_sample): content = get_sample("ubuntu_18.04/arping-iputils.out") mocker.patch("getmac.getmac._popen", return_value=content) ap = getmac.ArpingHost() ap.get("192.168.16.254") assert "00:50:56:E8:32:3C" == benchmark(ap.get, arg="192.168.16.254") def test_arping_host_busybox(benchmark, mocker, get_sample): content = get_sample("WSL2_kali_2023.1/busybox_arping_-f_-c_1_172-29-16-1.out") mocker.patch("getmac.getmac._popen", return_value=content) ap = getmac.ArpingHost() ap.get("172.29.16.1") assert "00:15:5d:20:f2:73" == benchmark(ap.get, arg="172.29.16.1") def test_windows_10_iface_getmac_exe(benchmark, mocker, get_sample): content = get_sample("windows_10/getmac.out") mocker.patch("getmac.getmac._popen", return_value=content) assert "74-D4-35-E9-45-71" == benchmark(getmac.GetmacExe().get, arg="Ethernet 2") def test_windows_10_iface_ipconfig(benchmark, mocker, get_sample): content = get_sample("windows_10/ipconfig-all.out") mocker.patch("getmac.getmac._popen", return_value=content) assert "74-D4-35-E9-45-71" == benchmark(getmac.IpconfigExe().get, arg="Ethernet 3") def test_windows_10_iface_wmic(benchmark, mocker, get_sample): content = get_sample("windows_10/wmic_nic.out") mocker.patch("getmac.getmac._popen", return_value=content) assert "00:FF:17:15:F8:C8" == benchmark(getmac.WmicExe().get, arg="Ethernet 3") @pytest.mark.parametrize( ("mac", "ip", "sample_file"), [("78-28-ca-c4-66-fe", "10.0.0.175", "windows_10/arp_-a_10.0.0.175.out")], ) def test_arpexe_samples(benchmark, mocker, get_sample, mac, ip, sample_file): content = get_sample(sample_file) mocker.patch("getmac.getmac._popen", return_value=content) assert mac == benchmark(getmac.ArpExe().get, arg=ip) mocker.patch("getmac.getmac.check_command", return_value=True) assert getmac.ArpExe().test() is True getmac.check_command.assert_called_once_with("arp.exe") def test_openbsd_get_default_iface(benchmark, mocker, get_sample): content = get_sample("openbsd_6/route_nq_show_inet_gateway_priority_1.out") mocker.patch("getmac.getmac._popen", return_value=content) assert "em0" == benchmark(getmac.DefaultIfaceOpenBsd().get) mocker.patch("getmac.getmac._popen", return_value="") assert not getmac.DefaultIfaceOpenBsd().get() mocker.patch("getmac.getmac.check_command", return_value=True) assert getmac.DefaultIfaceOpenBsd().test() is True getmac.check_command.assert_called_once_with("route") def test_openbsd_remote(benchmark, mocker, get_sample): content = get_sample("openbsd_6/arp_an.out") mocker.patch("getmac.getmac._popen", return_value=content) assert "52:54:00:12:35:02" == benchmark(getmac.ArpOpenbsd().get, arg="10.0.2.2") assert "52:54:00:12:35:03" == getmac.ArpOpenbsd().get("10.0.2.3") assert "08:00:27:18:64:56" == getmac.ArpOpenbsd().get("10.0.2.15") mocker.patch("getmac.getmac.check_command", return_value=True) assert getmac.ArpOpenbsd().test() is True getmac.check_command.assert_called_once_with("arp") def test_freebsd_get_default_iface(benchmark, mocker, get_sample): content = get_sample("freebsd11/netstat_r.out") mocker.patch("getmac.getmac._popen", return_value=content) assert "em0" == benchmark(getmac.DefaultIfaceFreeBsd().get) mocker.patch("getmac.getmac.check_command", return_value=True) assert getmac.DefaultIfaceFreeBsd().test() is True getmac.check_command.assert_called_once_with("netstat") @pytest.mark.parametrize( ("mac", "ip", "sample_file"), [ ("52:54:00:12:35:02", "10.0.2.2", "freebsd11/arp_-a.out"), ("08:00:27:ab:b0:67", "10.0.2.15", "freebsd11/arp_-a.out"), ("52:54:00:12:35:02", "10.0.2.2", "freebsd11/arp_10-0-2-2.out"), ], ) def test_arpfreebsd_samples(benchmark, mocker, get_sample, mac, ip, sample_file): content = get_sample(sample_file) mocker.patch("getmac.getmac._popen", return_value=content) assert mac == benchmark(getmac.ArpFreebsd().get, arg=ip) assert not getmac.ArpFreebsd().get("") assert not getmac.ArpFreebsd().get("10.") assert not getmac.ArpFreebsd().get("10.10.10.10") assert not getmac.ArpFreebsd().get(mac) assert not getmac.ArpFreebsd().get("em0") mocker.patch("getmac.getmac.check_command", return_value=True) assert getmac.ArpFreebsd().test() is True getmac.check_command.assert_called_once_with("arp") @pytest.mark.parametrize( ("mac", "ip", "sample_file"), [ ("00:50:56:f1:4c:50", "192.168.16.2", "ubuntu_18.04/cat_proc-net-arp.out"), ("00:50:56:e1:a8:4a", "192.168.16.2", "ubuntu_18.10/proc_net_arp.out"), ("00:50:56:e8:32:3c", "192.168.16.254", "ubuntu_18.10/proc_net_arp.out"), ("00:50:56:c0:00:0a", "192.168.95.1", "ubuntu_18.10/proc_net_arp.out"), ("00:50:56:fa:b7:54", "192.168.95.254", "ubuntu_18.10/proc_net_arp.out"), ("52:55:0a:00:02:02", "10.0.2.2", "android_6/cat_proc-net-arp.out"), ("02:00:00:00:01:00", "192.168.232.1", "android_9/cat_proc-net-arp.out"), ("8e:8f:aa:c9:d2:8b", "192.168.200.1", "android_9/cat_proc-net-arp.out"), ], ) def test_arpfile_samples(benchmark, mocker, get_sample, mac, ip, sample_file): content = get_sample(sample_file) mocker.patch("getmac.getmac._read_file", return_value=content) assert mac == benchmark(getmac.ArpFile().get, arg=ip) assert not getmac.ArpFile().get("0.0.0.0") assert not getmac.ArpFile().get("104.0.0.0") assert not getmac.ArpFile().get("") assert not getmac.ArpFile().get(mac) mocker.patch("getmac.getmac._read_file", return_value=None) assert not getmac.ArpFile().get(ip) mocker.patch("getmac.getmac._read_file", return_value="") assert not getmac.ArpFile().get(ip) @pytest.mark.parametrize( ("mac", "ip", "sample_file"), [ ( "00:50:56:f1:4c:50", "192.168.16.2", "ubuntu_18.04/ip_neighbor_show_192-168-16-2.out", ), ("00:50:56:f1:4c:50", "192.168.16.2", "ubuntu_18.04/ip_neighbor_show.out"), ("52:55:0a:00:02:02", "10.0.2.2", "android_6/ip_neighbor_show_10.0.2.2.out"), ("52:55:0a:00:02:02", "10.0.2.2", "android_6/ip_neighbor.out"), ("52:56:00:00:00:02", "fe80::2", "android_6/ip_neighbor.out"), ("8e:8f:aa:c9:d2:8b", "192.168.200.1", "android_9/ip_neighbor.out"), ("8e:8f:aa:c9:d2:8b", "fe80::8c8f:aaff:fec9:d28b", "android_9/ip_neighbor.out"), ], ) def test_ipneighshow_samples(benchmark, mocker, get_sample, mac, ip, sample_file): content = get_sample(sample_file) mocker.patch("getmac.getmac._popen", return_value=content) assert mac == benchmark(getmac.IpNeighborShow().get, arg=ip) assert getmac.IpNeighborShow().get("bad") is None @pytest.mark.parametrize( ("mac", "iface", "sample_file"), [ ("00:0c:29:b5:72:37", "ens33", "ubuntu_18.04/netstat_iae.out"), ("02:42:33:bf:3e:40", "docker0", "ubuntu_18.04/netstat_iae.out"), ("08:00:27:e8:81:6f", "eth0", "ubuntu_12.04/netstat_iae.out"), ("b4:2e:99:35:1e:84", "eth0", "WSL_ubuntu_18.04/netstat_-iae.out"), ("0a:00:27:00:00:0c", "eth4", "WSL_ubuntu_18.04/netstat_-iae.out"), ], ) def test_netstatiface_samples(benchmark, mocker, get_sample, mac, iface, sample_file): content = get_sample(sample_file) mocker.patch("getmac.getmac._popen", return_value=content) assert mac == benchmark(getmac.NetstatIface().get, arg=iface) assert getmac.NetstatIface().get("lo") is None assert getmac.NetstatIface().get("ens") is None assert getmac.NetstatIface().get("ens3") is None assert getmac.NetstatIface().get("ens333") is None assert getmac.NetstatIface().get("docker") is None assert getmac.NetstatIface().get("eth") is None assert getmac.NetstatIface().get("eth00") is None # TODO: improve netstat regex. # On Linux, it uses the same source as ifconfig (the Kernel Interface Table), # so we can just use the same regex that we use for Ifconfig* methods # assert getmac.NetstatIface().get("Kernel") is None # assert getmac.NetstatIface().get("e") is None mocker.patch("getmac.getmac._popen", return_value=None) assert getmac.NetstatIface().get("eth0") is None mocker.patch("getmac.getmac._popen", return_value=" ") assert getmac.NetstatIface().get("eth0") is None def test_ip_link_iface_bad_returncode(mocker, get_sample): """Test the exception handling works for old-style ip link.""" content = get_sample("ip_link_list.out") cpe = CalledProcessError(cmd="", returncode=255) mocker.patch("getmac.getmac._popen", side_effect=[cpe, content]) except_method = getmac.IpLinkIface() assert "74:d4:35:e9:45:71" == except_method.get("eth0") @pytest.mark.parametrize( ("expected_mac", "iface_arg"), [ ("b4:2e:99:36:1e:33", "eth0"), ("b4:2e:99:35:1e:86", "eth3"), ("00:15:5d:83:d9:0a", "eth8"), (None, "lo"), ("00:ff:36:20:68:56", "eth15"), (None, "eth16"), (None, "eth"), ], ) def test_ip_link_iface_wsl(benchmark, mocker, get_sample, expected_mac, iface_arg): mocker.patch("getmac.getmac.IpLinkIface._tested_arg", True) mocker.patch("getmac.getmac.IpLinkIface._iface_arg", False) content = get_sample("WSL_ubuntu_18.04/ip_link.out") mocker.patch("getmac.getmac._popen", return_value=content) assert expected_mac == benchmark(getmac.IpLinkIface().get, arg=iface_arg) @pytest.mark.parametrize( ("mac", "iface", "sample_file"), [ ("08:00:27:12:33:44", "eth0", "ubuntu_18.04/ip_link_show_eth0.out"), ("00:0c:29:b5:72:37", "ens33", "ubuntu_18.04/ip_link_list.out"), ("00:0c:29:b5:72:37", "ens33", "ubuntu_18.04/ip_link.out"), ("74:d4:35:e9:45:71", "eth0", "ip_link_list.out"), ("52:54:00:12:34:56", "eth0", "android_6/ip_link.out"), ("46:37:e2:ae:b8:7f", "radio0@if10", "android_9/ip_link.out"), ], ) def test_iplinkiface_samples(benchmark, mocker, get_sample, mac, iface, sample_file): content = get_sample(sample_file) mocker.patch("getmac.getmac._popen", return_value=content) assert mac == benchmark(getmac.IpLinkIface().get, arg=iface) # TODO: IpLinkIface regexes need improvements # assert getmac.IpLinkIface().get("eth") is None # assert getmac.IpLinkIface().get("et") is None # assert getmac.IpLinkIface().get("e") is None assert getmac.IpLinkIface().get("e0") is None assert getmac.IpLinkIface().get("en33") is None assert getmac.IpLinkIface().get("sit0") is None assert getmac.IpLinkIface().get("radio@if10") is None # assert getmac.IpLinkIface().get("") is None @pytest.mark.parametrize( ("expected_iface", "sample_file"), [ ("ens33", "ubuntu_18.04/route_-n.out"), ("eth0", "WSL_ubuntu_18.04/route_-n.out"), ("eth0", "android_6/route_-n.out"), ], ) def test_default_iface_route_command( benchmark, mocker, get_sample, expected_iface, sample_file ): content = get_sample(sample_file) mocker.patch("getmac.getmac._popen", return_value=content) assert expected_iface == benchmark(getmac.DefaultIfaceRouteCommand().get) mocker.patch("getmac.getmac._popen", return_value="") assert not getmac.DefaultIfaceRouteCommand().get() mocker.patch("getmac.getmac._popen", return_value="0.0.0.0 ") assert not getmac.DefaultIfaceRouteCommand().get() @pytest.mark.parametrize( ("iface", "sample_file"), [ ("ens33", "ubuntu_18.10/proc_net_route.out"), ("eth0", "android_6/cat_proc-net-route.out"), (None, "android_9/cat_proc-net-route.out"), ], ) def test_defaultifacelinuxroutefile_samples( benchmark, mocker, get_sample, iface, sample_file ): content = get_sample(sample_file) mocker.patch("getmac.getmac._read_file", return_value=content) assert benchmark(getmac.DefaultIfaceLinuxRouteFile().get) == iface def test_defaultifacelinuxroutefile(mocker): mocker.patch("getmac.getmac._read_file", return_value=None) assert getmac.DefaultIfaceLinuxRouteFile().get() is None mocker.patch("getmac.getmac._read_file", return_value="") assert getmac.DefaultIfaceLinuxRouteFile().get() is None @pytest.mark.parametrize( ("iface", "sample_file"), [ ("ens33", "ubuntu_18.04/ip_route_list_0slash0.out"), ("eth0", "WSL_ubuntu_18.04/ip_route_list_0slash0.out"), ("eth0", "android_6/ip_route_list_0slash0.out"), ], ) def test_defaultifaceiproute_samples(benchmark, mocker, get_sample, iface, sample_file): content = get_sample(sample_file) mocker.patch("getmac.getmac._popen", return_value=content) assert iface == benchmark(getmac.DefaultIfaceIpRoute().get) def test_defaultifaceiproute(mocker): mocker.patch("getmac.getmac._popen", return_value=None) assert getmac.DefaultIfaceIpRoute().get() is None mocker.patch("getmac.getmac._popen", return_value="") assert getmac.DefaultIfaceIpRoute().get() is None mocker.patch("getmac.getmac._popen", return_value="asdfalksj3") assert not getmac.DefaultIfaceIpRoute().get() @pytest.mark.parametrize( ("iface", "sample_file"), [ ("en0", "macos_10.12.6/route_-n_get_default.out"), ("em0", "freebsd11/route_get_default.out"), ], ) def test_defaultifaceroutegetcommand_samples( benchmark, mocker, get_sample, iface, sample_file ): content = get_sample(sample_file) mocker.patch("getmac.getmac._popen", return_value=content) assert iface == benchmark(getmac.DefaultIfaceRouteGetCommand().get) mocker.patch("getmac.getmac._popen", return_value=None) assert not getmac.DefaultIfaceRouteGetCommand().get() mocker.patch("getmac.getmac._popen", return_value="") assert not getmac.DefaultIfaceRouteGetCommand().get() # test with bad input (hit the except indexerror case) mocker.patch("getmac.getmac._popen", return_value="interface:") assert not getmac.DefaultIfaceRouteGetCommand().get() mocker.patch("getmac.getmac.check_command", return_value=True) assert getmac.DefaultIfaceRouteGetCommand().test() is True getmac.check_command.assert_called_once_with("route") @pytest.mark.parametrize( ("mac", "ip", "sample_file"), [ ("58:6d:8f:07:c9:94", "192.168.1.1", "OSX/arp_-a.out"), ("58:6d:8f:07:c9:94", "192.168.1.1", "OSX/arp_-an.out"), ("00:50:56:f1:4c:50", "192.168.16.2", "ubuntu_18.04/arp_-a.out"), ("00:50:56:f1:4c:50", "192.168.16.2", "ubuntu_18.04/arp_-an.out"), ("52:54:00:12:35:02", "10.0.2.2", "freebsd11/arp_10-0-2-2.out"), ("52:54:00:12:35:02", "10.0.2.2", "solaris10/arp_10-0-2-2.out"), ], ) def test_arp_various_args(benchmark, mocker, get_sample, mac, ip, sample_file): content = get_sample(sample_file) mocker.patch("getmac.getmac._popen", return_value=content) if "OSX" in sample_file: mocker.patch("getmac.getmac.DARWIN", return_value=True) elif "solaris" in sample_file: mocker.patch("getmac.getmac.SOLARIS", return_value=True) result = benchmark(getmac.ArpVariousArgs().get, arg=ip) # NOTE: Darwin and Solaris will return MACs without leading zeroes, # e.g. "58:6d:8f:7:c9:94" instead of "58:6d:8f:07:c9:94" # # It makes more sense to me to just handle the weird mac here # in the test instead of adding redundant logic for cleaning # the result to the method. if "OSX" in sample_file: assert result == "58:6d:8f:7:c9:94" elif "solaris" in sample_file: assert result == "52:54:0:12:35:2" if "OSX" in sample_file or "solaris" in sample_file: result = getmac._clean_mac(result) assert mac == result def test_sys_iface_file(mocker): mocker.patch("getmac.getmac._read_file", return_value="00:0c:29:b5:72:37\n") assert getmac.SysIfaceFile().get("ens33") == "00:0c:29:b5:72:37\n" mocker.patch("getmac.getmac._read_file", return_value=None) assert getmac.SysIfaceFile().get("ens33") is None @pytest.mark.skipif( platform.system() != "Linux", reason="Can't reliably mock fcntl on non-Linux platforms", ) def test_fcntl_iface(mocker): data = ( b"enp3s0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00t\xd45\xe9" b"Es\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" ) mocker.patch("fcntl.ioctl", return_value=data) m = mocker.patch("socket.socket") assert getmac.FcntlIface().get("enp3s0") == "74:d4:35:e9:45:73" m.assert_called_once_with(socket.AF_INET, socket.SOCK_DGRAM) # Python 2.7.5 (CentOS 7) doesn't have this... # The commit adding it: https://bit.ly/2Hnd7bN (no idea what release it was in) @pytest.mark.skipif( not hasattr(uuid, "_arp_getnode"), reason="This version of Python doesn't have uuid._arp_getnode", ) def test_uuid_arp_get_node(mocker): mocker.patch("uuid._arp_getnode", return_value=278094213753144) assert getmac.UuidArpGetNode().get("10.0.0.1") == "FC:EC:DA:D3:29:38" mocker.patch("uuid._arp_getnode", return_value=None) assert getmac.UuidArpGetNode().get("10.0.0.1") is None assert getmac.UuidArpGetNode().get("en0") is None @pytest.mark.skipif( sys.version_info[0] == 3 and sys.version_info[1] >= 9, reason="Python 3.9+ doesn't have uuid._find_mac", ) def test_uuid_lanscan(mocker): mocker.patch("uuid._find_mac", return_value=2482700837424) assert getmac.UuidLanscan().get("en1") == "02:42:0C:80:62:30" mocker.patch("uuid._find_mac", return_value=None) assert getmac.UuidLanscan().get("10.0.0.1") is None assert getmac.UuidLanscan().get("en0") is None mocker.patch("getmac.getmac.check_command", return_value=True) assert getmac.UuidLanscan().test() is True getmac.check_command.assert_called_once_with("lanscan") getmac-0.9.5/tox.ini000066400000000000000000000050201464534747600143210ustar00rootroot00000000000000[tox] envlist = py{37,38,39,310,311,312,py}-{linux,macos,windows},ironpython-windows,pypy3-{linux,macos,windows} skip_missing_interpreters = true [gh-actions] python = 3.7: py37 3.8: py38 3.9: py39 3.10: py310 3.11: py311 3.12: py312 pypy-3.7: pypy3 pypy-3.8: pypy3 pypy-3.9: pypy3 [gh-actions:env] PLATFORM = ubuntu-20.04: linux ubuntu-latest: linux macos-13: macos macos-latest: macos windows-latest: windows [testenv] setenv = PIP_DISABLE_PIP_VERSION_CHECK = 1 passenv = SSL_CERT_FILE TOXENV CI CODECOV_* platform = linux: linux macos: darwin windows: win32 deps = -rtests/test-requirements.txt ; TODO: --benchmark-enable? commands = ; -n auto (TODO: older pytest-xdist isn't working on windows) pytest --basetemp={envtmpdir} --benchmark-disable --cov=getmac \ --cov-report term --cov-report html --cov-report xml \ --cov-config=.coveragerc {posargs} [testenv:benchmark] description = "Run the test suite with benchmarks enabled" commands = ; -n auto (TODO: older pytest-xdist isn't working on windows) pytest --basetemp={envtmpdir} --benchmark-enable {posargs} [testenv:check] description = "Run code quality, static analysis, and spelling checks" setenv = PIP_DISABLE_PIP_VERSION_CHECK = 1 MYPYPATH=getmac deps = -rtests/style-requirements.txt basepython = py3 commands = codespell --check-filenames --skip="*.log,*.out,build,dist,*.pyc,*.class,*.git,*.vagrant,*.tox,*.egg-info,*.idea,*.vscode,_build,.doctrees,htmlcov,.venv,.mypy_cache,deb_dist,*getmac2.1,*getmac.1,./packaging/rpm/man/*" --ignore-words-list "ether,Expresso,expresso,Espresso,espresso" flake8 getmac tests setup.py bandit --quiet --recursive --skip B404,B603,B104 getmac setup.py vulture --min-confidence 100 getmac tests setup.py python setup.py --quiet check --strict --metadata check-manifest --quiet {toxinidir} [flake8] max-line-length = 99 application-import-names = getmac exclude = .github, .vagrant, docs, packaging, samples, scripts, *.egg-info, __pycache__, .git, .tox, .venv getmac/shutilwhich.py ignore = E203, W503, E401, F401, E226, B902, ANN101, ANN102, T499 per-file-ignores = tests/*.py:ANN001,ANN002,ANN003,ANN201,ANN202 import-order-style = pycharm show-source = True max-complexity = 38 [pytest] minversion = 3.4 testpaths = tests norecursedirs = .github getmac samples scripts .git .tox .vagrant .idea .vscode dist build *.egg .* .venv addopts = --tb=short filterwarnings = ignore::DeprecationWarning