def ip_gw_MAC(): #ip = ip_url()[0] ip = ip_url() #print(f"[d] ip neigh|grep {ip} |head -n1|awk " + "\'{print $5}\'") ip_gw_MAC = Popen('ip neigh|grep ' + ip + '|head -n1|awk \'{print $5}\'', shell=True, stdout=PIPE).stdout.read().decode("utf-8").rstrip() #return ip_gw_MAC.upper().rstrip("\n") return ip_gw_MAC.upper()[:-1] # we chop (rather than rstrip) because we may have multiple MAC for a CPE (with just the last bit incremented)
def ip_gw_MAC(): ip = ip_url()[0] ip_gw_MAC = Popen('ip neigh|grep ' + ip + '|head -n1|awk \'{print $5}\'', shell=True, stdout=PIPE).stdout.read().decode("utf-8").rstrip() #MAC_MATCH = ip_gw_MAC.upper()[:-1] #We strip the last char because [EX:AM:PL:AA:AA:01] was stored as [EX:AM:PL:AA:AA:04] return ip_gw_MAC.upper()[:-1] #why do we strip the last char?
class MService(BaseMService): def __init__(self): self.data = "" self.result = "" def read(self, filename, lines): self.data = Popen(['tail', '-n%d' % 5, filename], stdout=PIPE).communicate()[0] def deal_with(self): if self.data: self.result = self.data.upper() else: return 1 def write(self): if self.result: print(self.result.rstrip("\n"))
#print('ping6 errors: {}'.format(ip6_gw_ping.decode("utf-8").rstrip())) if len(ip6_gw) >= 3 and ip6_gw_ping.decode("utf-8").rstrip() != 1: ip_url = '[' + ip6_gw.decode("utf-8").rstrip() + ']' ip = ip6_gw.decode("utf-8").rstrip() #print('GW: {}'.format(ip_url)) else: if not ip6_gw_ping.decode("utf-8").rstrip() != 1: print('ERR: {}'.format(ip6_gw_ping.decode("utf-8").rstrip())) print( 'Using IPv4 gw: {} (maybe you should install nftables and enable IPv6?)' .format(ip)) ip_gw_MAC = Popen('ip neigh|grep ' + ip + '|head -n1|awk \'{print $5}\'', shell=True, stdout=PIPE).stdout.read().decode("utf-8").rstrip() MAC_MATCH = ip_gw_MAC.upper()[:-1] #print('GW MAC: {}'.format(MAC_MATCH)) """ sudo ini_grep //GW_MAC/key /etc/wicd/wireless-settings.conf """ config = configparser.ConfigParser() config.readfp(open(WICD_WIFI_CONF)) #config.readfp(open('/etc/wicd/wireless-settings.conf')) #config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')]) #print(config.get(str(ip_gw_MAC), 'key')) for s in config.sections(): if s.startswith(MAC_MATCH) and password == '': password = config.get(s, 'key') #print("INFO: located password guess: {}".format(password)) #sys.exit(1)