Ejemplo n.º 1
0
 def view(self):
     output = []
     cmd = "ps -ef | grep pppd | grep -v grep | awk '{print $2}'"
     pids = mcommon.call_cmdstr(cmd)
     if len(pids) > 0:
         for pid in pids:
             data = {}
             cmd = "tdbdump -k pppd%s /var/run/ppp/pppd2.tdb"%pid
             raw = mcommon.call_cmdstr(cmd)[0]
             for line in raw.split(";"):
                 if "PPPLOGNAME" in line: 
                     key, data[key] = line.split("=", 1)
                 if "PEERNAME" in line: 
                     key, data[key] = line.split("=", 1)
                 elif "IPREMOTE" in line:
                     key, data[key] = line.split("=", 1)
                     data[key] = data[key].split("\\")[0]
             cmd = "ps -p %s -o etime="%pid                
             raw = mcommon.call_cmdstr(cmd)[0]
             conninfo = {}
             conninfo['uptime'] = raw.strip()
             conninfo['src_ip'] = self._captureSrcIP(data['IPREMOTE'])
             conninfo['user'] = data['PEERNAME'] if data.get('PEERNAME') != None else data.get('PPPLOGNAME')
             conninfo['lan_ip'] = data['IPREMOTE']
             output.append(copy.deepcopy(conninfo))
     return output
Ejemplo n.º 2
0
 def cut(self, *paras):
     vpnip = paras[0]
     cmd = "ps -ef | grep pppd | grep -v grep | grep %s | awk '{print $2}'"%vpnip
     pid = mcommon.call_cmdstr(cmd)
     if len(pid) > 0:
         cmd = "kill -9 %s"%pid[0]
         mcommon.call_cmdstr(cmd)
     return {'status' : 0}
Ejemplo n.º 3
0
 def status(self):
     cmd = "ps -ef | grep radiusd | grep -v grep"
     output = mcommon.call_cmdstr(cmd)
     if len(output) > 0 and "radiusd -t" in output[0]:
         return "active"
     else:
         return "failed"
Ejemplo n.º 4
0
 def NTLMPasswd_adduser(self, *paras):
     user = paras[0]
     passwd = paras[1]
     cmd = "printf '%s'| iconv -t utf16le | openssl md4"%passwd
     output = mcommon.call_cmdstr(cmd)[0]
     ntlm_passwd = output.split("=", 1)[1].strip()
     with open("/etc/smbpasswd", 'a') as fw:
         template = "%s:0:%s:%s:[U         ]:LCT-00000000:%s"%(user, ntlm_passwd, ntlm_passwd, user)
         fw.write(template + "\n")
     return {'status' : 0}
Ejemplo n.º 5
0
 def status(self):
     cmd = "systemctl is-active xl2tpd"
     output = mcommon.call_cmdstr(cmd)[0]
     return output