I'm writing a little Python script(Python 2.7.13) to do ARP scanning. The problem is I don't know too much of Shell Scripting yet... I'm running on Kali Linux and this is what I'm using so far:
import subprocess
interface = "wlan0"
ip = subprocess.check_output("ifconfig " + interface + " | grep 'inet'| cut -d':' -f2", shell = True).strip()
By doing that I'm still getting this as ip:
'inet 192.168.0.43 netmask 255.255.255.0 broadcast 192.168.0.255\n14c\n14c'
What do I need to add to my ip assignment to get 192.168.0.43
as my ip variable?
I already looked up on the web but I just couldn't find a solution to this on Linux...
I only found really good solutions for this on the Mac OS X(Parse ifconfig to get only my IP address using Bash), but I'd like for this code to run on my Kali Linux installation first, than I can port it to Mac OS X later
I also already tried using this answer(Finding local IP addresses using Python's stdlib) but I was looking for a way of manipulating the result of ifconfig, just by using cut or awk...