Skip to main content

Python-generate_mac

Python library for working with Ethernet MAC addresses. Functions for generating transforming and testing MAC addresses.

Uses Wireshark's manuf, or s similarly formated file as input for specific Vendor ID(VID) bytes, for creating more

Supported functions:

Generate

total_random() - Procedurely generated MAC address, using random function.

vid_file_random(file) - uses random line from wireshark's manuf file

vid_file_vendor(file, vendor name, desc=optional) - specify a vendor name, uses wireshark's manuf file instead of being completely random. May optionally specify desc, which searches description within the vendor field

vid_provided(vid bytes) - specify the VID bytes when calling the function. Random device bytes will be generated.

Test

list_vendors(file) - return a python set{} of uniqe valid vendors, from a wireshark manuf file

is_mac_address(mac) - Takes a string, and checks if it is a valid Ethernet MAC address. returns True or False(bool type)

Transform

get_vid_bytes(mac) - Returns the vendor bytes(first three) from a MAC address.

another_same_vid(mac) - Generates another MAC with diffrent device bytes with same vendor bytes as input

Usage

Import and set up an object.

from generate_mac import generate_mac

Procedurely generated Vendor and Host bytes. Checks for broadcast bit

generate_mac.total_random()
'7E:CD:60:1E:AC:6E'

Read Vendor bytes from random line in a file. This has to be formated the same as wireshark's manuf file.

generate_mac.vid_file_random('/usr/share/wireshark/manuf')
'70:B3:D5:C5:40:49'

Read from a manuf file like above, but find Vendor bytes belonging to a specific vendor, by name.

generate_mac.vid_file_vendor('/usr/share/wireshark/manuf',"Motorola")
'40:88:05:4F:CE:82'

OPTIONAL: this can also now search the description field

generate_mac.vid_file_vendor('/usr/share/wireshark/manuf',"Motorola","BSG")
'00:24:37:5C:3A:8B'

Provide the vendor bytes in a string. Generate Host bytes only

generate_mac.vid_provided('00:06:8C')
'00:06:8C:35:5E:C4'

List valid vendor options as a list.

generate_mac.list_vendors('/usr/share/wireshark/manuf')
['Vendor1','Vendor2','etc']

Check if a MAC address is valid. returns a Bool(True,False)

generate_mac.is_mac_address('00:06:8C:35:5E:C4')
True

Get the VID bytes from a MAC address

generate_mac.get_vid_bytes('00:06:8C:35:5E:C4')
'00:06:8C'

Generate another MAC from the same VID bytes as current MAC

generate_mac.another_same_vid('00:06:8C:35:5E:C4')
'00:06:8C:3D:C2:F2'

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-generate_mac-1.3.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_generate_mac-1.3.1-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file python-generate_mac-1.3.1.tar.gz.

File metadata

  • Download URL: python-generate_mac-1.3.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.2 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for python-generate_mac-1.3.1.tar.gz
Algorithm Hash digest
SHA256 4573f5a46d0e3855ef0b43a01ed064d86a2b3aa02c6b878f1bb15644ec61ad0b
MD5 37963c3ced8988ce5532ef2ce0a1db8e
BLAKE2b-256 90f43ee6f686259f01eb910b5aba15b0612ee4dcfd87f88266cf420e6f7cc465

See more details on using hashes here.

File details

Details for the file python_generate_mac-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: python_generate_mac-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.0 importlib_metadata/3.7.2 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for python_generate_mac-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 42df6c9b159ce59489b09232488ed03b5eb01825cfeb41210ce5a8d1e5290953
MD5 360a1ce630ea378b488491d03d6caf45
BLAKE2b-256 9f52d8ac7cb3f23ab9bb94421f3c2d2ab20bcadeb992a26e588bf4917a01391e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.3.1 This release

2 files

1.3.0

1 file

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page