Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Python library to generate a unique device fingerprint based on physical characteristics
device_fingerprint
is a Python library designed to generate a unique digital fingerprint based on the physical characteristics of an electronic device. It captures details like the device's battery status, exact system time (with millisecond precision), and MAC address. This library also provides secure handling of data by hashing with SHA-256 and encrypting using AES encryption.
To install the device_fingerprint
library, use pip
:
pip install device-fingerprint
Here's how to use the device_fingerprint
library to generate a unique fingerprint:
from device_fingerprint import DeviceFingerprint
# Define a 16-byte key for AES encryption
# AES key must be either 16, 24, or 32 bytes long
key = b'ThisIs16BytesKey!'
# Initialize the DeviceFingerprint class with your encryption key
fingerprint_generator = DeviceFingerprint(encryption_key=key)
# Generate a unique fingerprint for the device
fingerprint = fingerprint_generator.generate_fingerprint()
print(f"Fingerprint: {fingerprint}")
# Retrieve the device's MAC address
mac_address = fingerprint_generator.get_mac_address()
print(f"MAC Address: {mac_address}")
# Encrypt and decrypt data
encrypted_mac = fingerprint_generator.encrypt_data(mac_address)
print(f"Encrypted MAC Address: {encrypted_mac}")
decrypted_mac = fingerprint_generator.decrypt_data(encrypted_mac)
print(f"Decrypted MAC Address: {decrypted_mac}")
DeviceFingerprint
Constructor: DeviceFingerprint(encryption_key: bytes)
DeviceFingerprint
class with the specified AES encryption key.encryption_key
: A byte string for AES encryption. Must be 16, 24, or 32 bytes long.Method: generate_fingerprint()
Method: get_mac_address()
Method: encrypt_data(data: str)
data
: A string of data to encrypt.Method: decrypt_data(encrypted_data: str)
encrypted_data
: A string of encrypted data.Feel free to adjust the repository links and license details as needed.
FAQs
Python library to generate a unique device fingerprint based on physical characteristics
We found that Device-Fingerprint demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.