As for the UP / DOWN issue.. my checks on this were very .. very rudimentary.. :|
It is however possible that your output is different from what the output is on Kali which will then impact on my parsing commands..
which makes me wonder *** I have done considering you say you running on Kali on the 2nd stdout ... :\
Yes, the first stdout (on the snapshot) is under xubuntu 15.04 and the second is with Kali, I rebooted to check that it was not an issue with ubuntu.
If i look on the code that where the check is done:
Code:
STATUS=$(ifconfig $i | sed -n '2p' | grep -io up)
if [ "$STATUS" != "UP" ] ; then STATUS=DOWN ; fi
* i am right now with thje internal interface wlan0 (the one that gives problems) connected to the Internet.
full stdout for wlan0 is
Code:
wlan0 Link encap:Ethernet HWaddr 4c:bb:58:0f:ba:aa
inet adr:192.168.2.103 Bcast:192.168.2.255 Masque:255.255.255.0
adr inet6: fe80::4ebb:58ff:fe0f:baaa/64 Scope:Lien
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Packets reçus:13293 erreurs:0 :0 overruns:0 frame:0
Paquetes TX:13117 errores:0 perdidos:0 overruns:0 carrier:0
collisions:0 lg file transmission:1000
Octets reçus:15315807 (15.3 MB) Octets transmis:1349829 (1.3 MB)
and if i use the pipe with sed that you used in the script it gives me
Code:
kcdtv@profezorapplestruff:~$ sudo ifconfig wlan0 | sed -n '2p'
inet adr:192.168.2.103 Bcast:192.168.2.255 Masque:255.255.255.0
and indeed there is no "up/UP" on this line...
* second interface, rtl8187l from loopcomm, USB, the same than yesterday, and has yesterday , it is NOT connected
Code:
sudo ifconfig wlan2
wlan2 Link encap:Ethernet HWaddr 00:1a:ef:41:3c:ba
UP BROADCAST MULTICAST MTU:1500 Metric:1
Packets reçus:0 erreurs:0 :0 overruns:0 frame:0
Paquetes TX:0 errores:0 perdidos:0 overruns:0 carrier:0
collisions:0 lg file transmission:1000
Octets reçus:0 (0.0 B) Octets transmis:0 (0.0 B)
and on this second line we have
Code:
UP BROADCAST MULTICAST MTU:1500 Metric:1
So the issue is that ifconfig stdout changes a little if we are connected or if we are not connected.
-If the interface is not connected to the Internet, everything is fine as the second line of ifconfig stdout is indeed the one with "UP BROADCAST MTU etc.."
- if we are connected : the address resolutions for IP4 is stdouted on the second line and the line with "UP BROADCAST" go downs and became the fourth line
i was thinking that maybe "awking" the first field with space as a separator will keep it simple with a single pipe and should work in any case, wherever the line is.
And by checking just the first field I assume that there shouldn't be any unwanted match with a line.
Code:
STATUS=$(ifconfig $i | awk -F' ' '{ print $1 }' | grep -io up)
if [ "$STATUS" != "UP" ] ; then STATUS=DOWN ; fi
(and by the way.. your 2nd stdout message is not hiding the MAC addresses.. )
They were spoofed. For sure, for sure....
Thanks, i modified that.
bye & take care