Issue
I am trying to isolate the MAC Address from the ifconfig
command but the output is displaying what I believe is memory code. I am running python 2.7 on a VB Kali.
root@osboxes:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.22 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::1171:bf6a:17f8:972 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:f8:15:03 txqueuelen 1000 (Ethernet)
RX packets 2593 bytes 3769210 (3.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 794 bytes 57174 (55.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Input:
#!/usr/bin/env python
import subprocess
import re
def mac_1(network):
output_check = subprocess.check_output(['ifconfig', network])
re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w", output_check)
# print(output_check)
print('[+] MAC Address is ' + str(mac_1))
Output Code:
/root/PycharmProjects/test001/venv/bin/python /root/PycharmProjects/test001/test001.py
[+] MAC Address is <function mac_1 at 0x7ff4ed70e3b0>
Process finished with exit code 0
Solution
I figure this out a few days ago and haven't had time to respond. Here is the result that I was looking for:
Input
#!/usr/bin/env python
import subprocess
import re
output_check = subprocess.check_output(['ifconfig'])
check = re.search(r"\w\w:\w\w:\w\w:\w\w:\w\w:\w\w", output_check)
print("Mac Address is: " + check.group(0))
Output
Mac Address is: 08:69:18:f9:85:06
Thank you all for your help
Answered By - gamer2die4 Answer Checked By - David Marino (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.