Giter Site home page Giter Site logo

bitcanon / mactool Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 314 KB

Simplify MAC Address tasks using this command-line application written in Go.

License: MIT License

Go 99.02% Shell 0.98%
formatting mac-address command-line extraction lookups vendor-lookup

mactool's People

Contributors

bitcanon avatar

Watchers

 avatar

mactool's Issues

Read input from file

Allow the user to read a file with MAC address content to be processed by the extract, lookup and format commands.

-i macdump.txt
--infile macdump.txt

Add include and exclude flags

Add a flag --include or -I that will print only lookup results that match the string provided.
Add a flag --exclude or -E that will remove lookup results that match the string provided.

Config file missing in info command

When running mactool info and the file ~/.mactool.yaml is missing the output is:

$ mactool info    
Configuration file path: 
 

Configuration file variables loaded:
 No variables defined.

It should be:

$ mactool info       
Configuration file path: 
 No configuration file exists.

Configuration file variables loaded:
 No variables defined.

Save lookup results to CSV file

It could be useful to save the lookup output into a CSV formatted file.
If the user run:

mactool lookup --outfile output.csv --csv Test to parse MACs inside.

--csv prints the output in CSV format (comma separated). Maybe add a --delimiter flag as well to allow the user to choose delimiter character in the CSV file.

--outfile output.csv saves the output to a file instead of writing it to the terminal. Maybe print a small "xxx bytes written to output.csv" when export is done.

Create info command

Create an mactool info command that will print useful information about the application.

Things like:

  • Location of the CSV database file
  • Age of CSV database
  • Location of config file (if any)
  • Print any environment variables that are currently in use (MACTOOL_xxx)
  • Print download URL of the oui.csv file
  • And more...

Improve help texts for lookup command

The help text for the CSV flag should show a default value:
Windows:

Flags:
  -f, --csv-file string   path to CSV file (default %LOCALAPPDATA%\Mactool\oui.csv)

Unix:

Flags:
  -f, --csv-file string   path to CSV file (default $HOME\.local\share\mactool\oui.csv)  

Interactive mode

When running a command in interactive mode, for example:

mactool extract

or

mactool lookup

It would be helpful to print some kind of help text to the user, like (on Unix systems):

Paste your text and press CTRL + D when done:

When running on Windows:

Paste your text and press CTRL + Z when done:

Print to stdout so the help text won't propagate to stdin of piped commands.

MAC Address Redaction

Implement a module focused on data redaction. This could include functions to replace partial or full MAC addresses with placeholders.
One could choose to replace the OUI part of the MAC address, the UID part of the MAC or the entire MAC.

This function might be useful when posting output from networking equipment in forums and such.

mactool redact ...

Improve regex matcher

Try to improve the matching of MAC addresses. The current version finds a MAC in this string:

mactool extract AA:18:FD:74:E1:A6:0B   
AA:18:FD:74:E1:A6

It should not find a MAC in this string since there is a :0B in the end:
AA:18:FD:74:E1:A6:0B
AA:18:FD:74:E1:A6

Print OS specific help

In the help texts of the commands extract, lookup and format, only print help relevant to the operating system that the command is run on:

While operating in interactive mode, enter or paste the input string and then press
Enter to proceed. To exit, use Ctrl+D (Unix) or Ctrl+Z (Windows), followed by Enter.

On Windows:

While operating in interactive mode, enter or paste the input string and then press
Enter to proceed. To exit, use Ctrl+Z (Windows), followed by Enter.

And so on, maybe different on macOS?

Add command aliases --lower and --upper

When using the command mactool format you can use the flags -l or --lower-case to reformat MAC addresses in lower case.

Add an alias for the flag called --lower as well as --upper for the upper case flag.

Unsupported MAC format

Running show mac-address on a HP 2530 switch prints MAC addresses in this format:

005d73-123456

This format is not supported by mactool.

Format command without flags

When running a mactool format without any flags the output get reformatted as xx:xx:xx:xx:xx:xx by default.

This makes it harder to use the command if you simply want to convert the MAC's to --lower or --upper.

Running mactool format without any flags should leave the input untouched.

Format has default delimiter set

When running the mactool format command without a --delimiter flag, the : is used as a default and not "OriginalDelim" as should.

Line 221 in format.go:

formatCmd.Flags().StringP("delimiter", "d", ":", "delimiter character to use between hex groups")

Add extract flag to format command

In the format command, add a flag that allow the user to perform an extract command as well prior to formatting.

A flag like --extract might be good here.

This can be handy when running on an OS that doesn't support pipes.

Default download path for oui.csv

When the mactool lookup command downloads the oui.csv file, it is stored to the current directory.

Set a default directory for the oui.csv file, compatible with all operating systems, where the file will be stored.
This should be user customizable in the config file.

Hide empty lookups

If the mactool lookup command is unable to lookup the organization name there should be a flag that omits this MAC address from the output.
Example:

mactool lookup ...
50:87:89:14:15:16 (Cisco Systems, Inc)
C4:AD:34:14:15:16 (Routerboard.com)
E2:B4:15:14:15:16    <- omit/hide this
E2:90:7B:14:15:16    <- omit/hide this
E2:B4:15:17:18:19    <- omit/hide this
60:6B:FF:11:12:13 (Nintendo Co.,Ltd)

With flag:

mactool lookup --ignore-notfound ...
50:87:89:14:15:16 (Cisco Systems, Inc)
C4:AD:34:14:15:16 (Routerboard.com)
60:6B:FF:11:12:13 (Nintendo Co.,Ltd)

Name the flag something descriptive, not --ignore-notfound :)

Create a debug flag

Implement a --debug flag for detailed output of configuration variables, environment variables and OUI database information.
It should also display information about any flags passed to the application and their corresponding values as parsed by the application.

Random MAC Address Generation

Develop a module specifically for generating random MAC addresses. This module could include functions to generate addresses with different formatting options and ensure uniqueness.

mactool generate ...

Flags:
 --vendor string       select a vendor that the generated mac will belong to

Sort output

Allow the user to sort the output of the extract and lookup commands with a simple --sort flag.
Maybe --sort-asc, --sort-desc
Or --sort, --sort asc, --sort desc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.