Last active
May 16, 2022 08:22
-
-
Save thewh1teagle/267e8ad2982152e4637cc00165f561f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import sys | |
def ip_of_mac(mac): | |
mac = mac.lower().replace(":", "-") | |
output = str ( | |
subprocess.check_output((f'arp -a | findstr "{mac}" '), shell=True, stderr=subprocess.STDOUT) | |
) | |
if len(output) <= 125 and len(output) > 5: | |
return output.split(' ',1)[1].split(' ')[1] | |
else: | |
return "Not found" | |
if __name__ == '__main__': | |
if len(sys.argv) < 2 or any('help' in i for i in sys.argv): | |
print("Usage: {} <aa-bb-cc-dd-ee-ff>".format(sys.argv[0])) | |
exit(1) | |
try: | |
ip = ip_of_mac(sys.argv[1]) | |
print(ip) | |
except: | |
print("Not found") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment