{"id":294129,"date":"2019-09-01T21:00:18","date_gmt":"2019-09-01T21:00:18","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=294129"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=294129","title":{"rendered":"\u0410\u0432\u0442\u043e\u043f\u0440\u043e\u0432\u0438\u0437\u0438\u043e\u043d\u0438\u043d\u0433 Yealink T19 + \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0430\u0434\u0440\u0435\u0441\u043d\u0430\u044f \u043a\u043d\u0438\u0433\u0430"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u041a\u043e\u0433\u0434\u0430 \u044f \u043f\u0440\u0438\u0448\u0435\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u044d\u0442\u0443 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044e, \u0443 \u043c\u0435\u043d\u044f \u0443\u0436\u0435 \u0438\u043c\u0435\u043b\u0430\u0441\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0430\u0437\u0430 \u043f\u043e ip \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u0430\u043c, \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c \u0441 asterisk \u0438 \u043d\u0430\u0448\u043b\u0435\u043f\u043a\u043e\u0439 \u0432 \u0432\u0438\u0434\u0435 FreeBPX. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u0430\u044f \u0410\u0422\u0421 Samsung IDCS500 \u0438 \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e \u0431\u044b\u043b\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0441\u0432\u044f\u0437\u0438 \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438, ip \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u0430 \u043f\u0440\u043e\u0434\u0430\u0436. \u0418 \u0432\u0441\u0435 \u0431\u044b \u0432\u0430\u0440\u0438\u043b\u043e\u0441\u044c \u0442\u0430\u043a \u0438 \u0434\u0430\u043b\u044c\u0448\u0435, \u043d\u043e \u0432 \u043e\u0434\u0438\u043d \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0434\u0435\u043d\u044c \u0431\u044b\u043b \u0434\u0430\u043d \u0443\u043a\u0430\u0437 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0432\u0441\u0435\u0445 \u043d\u0430 IP \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0438\u044e, \u0431\u044b\u043b\u0438 \u043e\u0433\u043e\u0432\u043e\u0440\u0435\u043d\u044b \u0441\u0440\u043e\u043a\u0438, \u0437\u0430\u043a\u0443\u043f\u043b\u0435\u043d\u043e \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043f\u043b\u0430\u043d \u043f\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0443 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u044f\u0442\u0438\u044f \u0432 21 \u0432\u0435\u043a \u0441\u0442\u0430\u043b \u043f\u0440\u0435\u0442\u0432\u043e\u0440\u044f\u0442\u0441\u044f \u0432 \u0436\u0438\u0437\u043d\u044c.<br \/>  \u041f\u0435\u0440\u0432\u043e\u0435 \u0447\u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u044c \u0432 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u044d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0440\u0430\u0441\u0442\u0430\u044e\u0449\u0435\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u044b\u0445 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043d\u0430\u0434\u043e \u043a\u0430\u043a-\u0442\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c, \u0432\u0442\u043e\u0440\u043e\u0435, \u0447\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0442\u0440\u0435\u0432\u043e\u0436\u0438\u043b\u043e \u0431\u044b\u043b\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u0430\u044f \u043a\u043d\u0438\u0433\u0430. \u0415\u0441\u043b\u0438 \u0441 \u043f\u0435\u0440\u0432\u044b\u043c \u043d\u0430\u043c \u043c\u043e\u0433 \u043f\u043e\u043c\u043e\u0447\u044c Endpoint Manager (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u0441\u0442\u0430\u0442\u0438 \u0432\u044b\u043f\u0438\u043b\u0438\u043b\u0438 \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 FreePBX), \u0442\u043e \u0432\u043e\u0442 \u0441 \u043a\u043d\u0438\u0433\u043e\u0439 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b:<\/p>\n<ul>\n<li>\u0412\u043e \u043f\u0435\u0440\u0432\u044b\u0445 \u043a\u0430\u043a \u043e\u0431\u0435\u0441\u043f\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0435\u0451 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439 \u0441\u043c\u0435\u043d\u0435 \u0434\u0438\u0441\u043b\u043e\u043a\u0430\u0446\u0438\u0438\/\u0442\u0435\u043a\u0443\u0447\u0435\u0441\u0442\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439? <\/li>\n<li>\u0412\u043e \u0432\u0442\u043e\u0440\u044b\u0445, \u043a\u0430\u043a \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0431\u0435\u0437\u043b\u0438\u0447\u0438\u0442\u044c \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u044b. \u0418 \u043d\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0438\u043c\u044f \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0430?<\/li>\n<\/ul>\n<p>  \u0417\u0430\u0434\u0430\u0447\u043a\u0430 \u0431\u044b\u043b\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f, \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b\u043e \u0441\u0435\u0431\u044f \u0434\u043e\u043b\u0433\u043e \u0436\u0434\u0430\u0442\u044c. \u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u043e\u043b\u043d\u044b\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433, \u0430 \u043f\u043e\u0442\u043e\u043c \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<pre><code class=\"python\">from scapy.all import sniff from scapy.layers.inet import IP import mysql.connector import ldap import getpass import tftpy import requests import os import time from string import replace  def conn_ldap(login):     ad = ldap.initialize('ldap:\/\/***.local')     ad.simple_bind_s('voip@***.local', 'password')     basedn = 'OU=IT,DC=***,DC=LOCAL'     basedn_user = 'OU=***,OU=***,DC=***,DC=LOCAL'     scope = ldap.SCOPE_SUBTREE     filterexp = &quot;(&(sAMAccountName=&quot; + login + &quot;)(ObjectClass=person))&quot;     filterexp2 = &quot;(&(ObjectClass=organizationUnit))&quot;     attrlist = ['cn']     attrlist2 = ['OU']     search = ad.search_s(basedn, scope, filterexp, attrlist)     adname = search[0][1]['cn'][0].decode('utf-8')     if adname == ' ':         search = ad.search_s(basedn_user, scope, filterexp2, attrlist2)         for i in range(1, len(search)+1):             group = search[i][1]['ou'][0]             basedn_user2 = 'OU='+group+','+basedn_user             search = ad.search_s(basedn_user2, scope, filterexp, attrlist)             adname = search[0][1]['cn'][0].decode('utf-8')             if adname != ' ':                 return adname         adname = search[0][1]['cn'][0].decode('utf-8')     ad.unbind_s()     return adname   def tftp_file_change(config,place,adname,current_account,current_account_password):      client = tftpy.TftpClient(&quot;192.168.0.3&quot;, 69)     client.download('template.cfg', place)     fileread = open(place, 'r')     line = fileread.readlines()     fileread.close()     line[5] = (('account.1.label = ').encode('utf-8') + adname.encode('utf-8') + '\\n')     line[2] = (('account.1.auth_name = ').encode('utf-8') + current_account.encode('utf-8') + '\\n')     line[3] = (('account.1.display_name = ').encode('utf-8') + current_account.encode('utf-8') + '\\n')     line[6] = (('account.1.password = ').encode('utf-8') + current_account_password[0][0] + '\\n')     filewrite = open(place, 'w')     for i in line:       filewrite.write(i)     filewrite.close()     print place     print config     client.upload(config,place)   def get_phone_inform(ipaddr):     fileconf = requests.get('http:\/\/admin:admin@'+ipaddr+'\/servlet?phonecfg=get[&accounts=1]')     conf = fileconf.text.split('|')     current_account = conf[2]     return current_account   def sniff_frame():     pcapf = sniff(count=1, timeout=70, filter=&quot;dst host 192.168.0.3 and port 5060&quot;)     if len(pcapf) == 0:         exit()     frame = pcapf[0]     macaddr = frame.src     print macaddr[:8]     if macaddr[:8] != '80:5e:c0':         exit()     ipaddr = frame[0][IP].src     return macaddr, ipaddr   def conn_mysql(query,fquery,macaddr,qwery2):     connect = mysql.connector.connect(host='192.168.0.3', database='voip', user='voip_wr', password='***')     cursor = connect.cursor()     cursor.execute(fquery)     state = cursor.fetchall()     state = bool(state[0][0])     if state == True:         cursor.execute(qwery2)         connect.commit()         connect.close()     else:         cursor.execute(query)         connect.commit()         connect.close()   def check_account(current_account):     connect = mysql.connector.connect(host='192.168.0.3', database='asterisk', user='voip_wr', password='***')     cursor = connect.cursor()     qwery = 'select data from sip where id=' + current_account + ' and keyword=&quot;secret&quot;;'     cursor.execute(qwery)     password = cursor.fetchall()     if password == ' ':         exit()     else:         return password   if __name__ == '__main__':     macaddr, ipaddr = sniff_frame()     current_account = get_phone_inform(ipaddr)     current_account_password = check_account(current_account)     macaddr = macaddr.replace(':', '')     ipaddr = ipaddr.decode('utf-8')     adname = conn_ldap(getpass.getuser())     query = 'INSERT INTO station (mac, ip, name, number) VALUES (' + '&quot;' + macaddr + '&quot;,' + '&quot;' + ipaddr + '&quot;,' + '&quot;' + adname + '&quot;,' + '&quot;' + get_phone_inform(ipaddr) + '&quot;' + ')'     qwery2 = 'UPDATE station SET ip=' + '&quot;' + ipaddr + '&quot;' + ', name=' + '&quot;' + adname + '&quot;' + ', number=' + '&quot;' + get_phone_inform(ipaddr) + '&quot;' + ' WHERE mac=' + '&quot;' + macaddr + '&quot;'     fquery = 'SELECT EXISTS(SELECT mac FROM voip.station WHERE mac=' + '&quot;' + macaddr + '&quot;)'     query = query.encode('utf-8')     fquery = fquery.encode('utf-8')     config = macaddr + '.cfg'     place = os.path.expanduser(&quot;~&quot;) + &quot;\\\\&quot; + &quot;AppData\\\\Local\\\\&quot; + config     conn_mysql(query,fquery,macaddr,qwery2)     tftp_file_change(config,place,adname,current_account,current_account_password)     requests.get('http:\/\/admin:admin@'+ipaddr+'\/cgi-bin\/ConfigManApp.com?key=AutoP')     requests.get('http:\/\/admin:admin@'+ipaddr+'\/cgi-bin\/ConfigManApp.com?key=Reboot')<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u043a \u0441\u0435\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u043b\u0435\u0444\u043e\u043d, \u0442\u0430\u043a \u043a\u0430\u043a Yealink T19 \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0448\u043b\u044e\u0437\u0430.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d \u043b\u0438? \u0438 \u043a\u0430\u043a\u043e\u0439 mac \u0438 ip \u0438\u043c\u0435\u0435\u0442 \u043d\u0430\u0448 \u0442\u0435\u043b\u0435\u0444\u043e\u043d.<\/p>\n<pre><code class=\"python\">def sniff_frame():     pcapf = sniff(count=1, timeout=70, filter=&quot;dst host 192.168.0.3 and port 5060&quot;)     if len(pcapf) == 0:         exit()     frame = pcapf[0]     macaddr = frame.src     print macaddr[:8]     if macaddr[:8] != '80:5e:c0':         exit()     ipaddr = frame[0][IP].src     return macaddr, ipaddr <\/code><\/pre>\n<p>  \u0421\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e sniff \u0438\u0437 \u0444\u0440\u0430\u0435\u043c\u0432\u043e\u0440\u043a\u0430 scapy, \u0441 \u043f\u043e\u043c\u043e\u0448\u044c\u044e \u043d\u0435\u0451 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 udp \u043f\u0430\u043a\u0435\u0442, \u0436\u0434\u0435\u043c 70 \u0441\u0435\u043a\u0443\u0434 \u0438 \u0435\u0441\u043b\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u0439\u043c\u0430\u043b\u0438 \u0432\u044b\u0445\u043e\u0434\u0438\u043c.<\/p>\n<pre><code class=\"python\">count=1, timeout=70, filter=&quot;dst host 192.168.0.3 and port 5060&quot;<\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0443\u0431\u0435\u0436\u0434\u0430\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0430\u043f\u043f\u0430\u0440\u0430\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e Yealink \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (ip \u0438 mac).<\/p>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432\u044b\u044f\u0441\u043d\u044f\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u043d\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0441 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 \u0438 \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<pre><code class=\"python\">def get_phone_inform(ipaddr):     fileconf = requests.get('http:\/\/admin:admin@'+ipaddr+'\/servlet?phonecfg=get[&accounts=1]')     conf = fileconf.text.split('|')     current_account = conf[2]     return current_account<\/code><\/pre>\n<p>  \u0412\u044b\u044f\u0441\u043d\u044f\u0435\u043c \u043f\u0430\u0440\u043e\u043b\u044c \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0430\u043a\u043a\u0430\u0443\u043d\u0442\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 asterisk.sip \u0438 \u0432 \u043d\u0435\u0439 \u043a \u043f\u043e\u043b\u044e data.<\/p>\n<pre><code class=\"python\">def check_account(current_account):     connect = mysql.connector.connect(host='192.168.0.3', database='asterisk', user='voip_wr', password='***')     cursor = connect.cursor()     qwery = 'select data from sip where id=' + current_account + ' and keyword=&quot;secret&quot;;'     cursor.execute(qwery)     password = cursor.fetchall()     if password == ' ':         exit()     else:         return password<\/code><\/pre>\n<p>  \u041d\u0443 \u0438 \u0434\u043b\u044f \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u044d\u0442\u0430\u043f\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a ldap AD \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e sAMAccountName \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u043e\u0433\u043e \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <i>getpass.getuser()<\/i> \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u043c cn \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0424\u0418\u041e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f).<\/p>\n<pre><code class=\"python\">def conn_ldap(login):     ad = ldap.initialize('ldap:\/\/***.local')     ad.simple_bind_s('voip@***.local', 'password')     basedn = 'OU=***,DC=***,DC=LOCAL'     basedn_user = 'OU=***,OU=***,DC=***,DC=LOCAL'     scope = ldap.SCOPE_SUBTREE     filterexp = &quot;(&(sAMAccountName=&quot; + login + &quot;)(ObjectClass=person))&quot;     filterexp2 = &quot;(&(ObjectClass=organizationUnit))&quot;     attrlist = ['cn']     attrlist2 = ['OU']     search = ad.search_s(basedn, scope, filterexp, attrlist)     adname = search[0][1]['cn'][0].decode('utf-8')     if adname == ' ':         search = ad.search_s(basedn_user, scope, filterexp2, attrlist2)         for i in range(1, len(search)+1):             group = search[i][1]['ou'][0]             basedn_user2 = 'OU='+group+','+basedn_user             search = ad.search_s(basedn_user2, scope, filterexp, attrlist)             adname = search[0][1]['cn'][0].decode('utf-8')             if adname != ' ':                 return adname         adname = search[0][1]['cn'][0].decode('utf-8')     ad.unbind_s()     return adname<\/code><\/pre>\n<p>  \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0432 \u0431\u0434 (\u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0442\u0430\u043c \u0436\u0435) \u0438 \u0432\u043d\u043e\u0441\u0438\u043c \u0432\u0441\u0435 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e: ip, mac, \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<pre><code class=\"python\">def conn_mysql(query,fquery,macaddr,qwery2):     connect = mysql.connector.connect(host='192.168.0.3', database='voip', user='voip_wr', password='***')     cursor = connect.cursor()     cursor.execute(fquery)     state = cursor.fetchall()     state = bool(state[0][0])     if state == True:         cursor.execute(qwery2)         connect.commit()         connect.close()     else:         cursor.execute(query)         connect.commit()         connect.close()<\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f, \u0432\u0435\u0434\u044c \u043c\u044b \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0430\u0434\u0440\u0435\u0441\u043d\u0443\u044e \u043a\u043d\u0438\u0433\u0443 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u0432\u044b, \u043d\u043e \u044f \u043f\u043e\u0448\u0435\u043b \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u043b \u0441\u044e\u0434\u0430 \u0436\u0435 \u0430\u0432\u0442\u043e\u043f\u0440\u043e\u0432\u0438\u0437\u0438\u043e\u043d\u043d\u0438\u043d\u0433 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043e\u0432.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0433\u043e tftp \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f template \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0432\u043d\u043e\u0441\u0438\u043c \u0441\u0432\u043e\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0441 \u043a\u0430\u043a mac.cfg. \u0422\u043e\u0435\u0441\u0442\u044c \u0434\u043b\u044f Yealink \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438, \u043e\u0434\u043d\u0430 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f, \u0430 \u0432\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0443 \u0438 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0432\u0438\u0434\u0430 mac_\u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430.cfg<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0444\u0430\u0439\u043b\u0435 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044e \u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043d\u0430 tftp \u0441\u0435\u0440\u0432\u0435\u0440 \u043c\u044b \u043e\u0442\u0434\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0443 \u043d\u0430 \u043f\u0440\u043e\u0432\u0438\u0437\u0438\u043e\u043d\u0438\u043d\u0433 \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u0430.<\/p>\n<pre><code class=\"pgsql\">def tftp_file_change(config,place,adname,current_account,current_account_password):      client = tftpy.TftpClient(&quot;192.168.0.3&quot;, 69)     client.download('template.cfg', place)     fileread = open(place, 'r')     line = fileread.readlines()     fileread.close()     line[5] = (('account.1.label = ').encode('utf-8') + adname.encode('utf-8') + '\\n')     line[2] = (('account.1.auth_name = ').encode('utf-8') + current_account.encode('utf-8') + '\\n')     line[3] = (('account.1.display_name = ').encode('utf-8') + current_account.encode('utf-8') + '\\n')     line[6] = (('account.1.password = ').encode('utf-8') + current_account_password[0][0] + '\\n')     filewrite = open(place, 'w')     for i in line:       filewrite.write(i)     filewrite.close()     print place     print config     client.upload(config,place)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">requests.get('http:\/\/admin:admin@'+ipaddr+'\/cgi-bin\/ConfigManApp.com?key=AutoP') requests.get('http:\/\/admin:admin@'+ipaddr+'\/cgi-bin\/ConfigManApp.com?key=Reboot')<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0435 \u0444\u0438\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430 + \u0432\u0441\u0435\u0433\u0434\u0430 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u0443\u044e \u0430\u0434\u0440\u0435\u0441\u043d\u0443\u044e \u043a\u043d\u0438\u0433\u0443 \u0432 \u043b\u0438\u0446\u0435 \u0411\u0414, \u0434\u0430\u043b\u0435\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c XML \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e PHP \u0434\u043b\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430. \u0422\u0430\u043a\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043c\u0430\u0441\u0441\u0430, \u0435\u0441\u0442\u044c \u0434\u0430\u0436\u0435 \u0443 \u0441\u0430\u043c\u043e\u0433\u043e YEALINK.<\/p>\n<p>  P.S.: \u0414\u043b\u044f \u043f\u0443\u0449\u0435\u0439 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 (\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435) \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b\u0438\u043a.<\/p><\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/465779\/\"> https:\/\/habr.com\/ru\/post\/465779\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\u041a\u043e\u0433\u0434\u0430 \u044f \u043f\u0440\u0438\u0448\u0435\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u044d\u0442\u0443 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044e, \u0443 \u043c\u0435\u043d\u044f \u0443\u0436\u0435 \u0438\u043c\u0435\u043b\u0430\u0441\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0430\u0437\u0430 \u043f\u043e ip \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u0430\u043c, \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c \u0441 asterisk \u0438 \u043d\u0430\u0448\u043b\u0435\u043f\u043a\u043e\u0439 \u0432 \u0432\u0438\u0434\u0435 FreeBPX. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u0432\u0430\u044f \u0410\u0422\u0421 Samsung IDCS500 \u0438 \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e \u0431\u044b\u043b\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0441\u0432\u044f\u0437\u0438 \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438, ip \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u0430 \u043f\u0440\u043e\u0434\u0430\u0436. \u0418 \u0432\u0441\u0435 \u0431\u044b \u0432\u0430\u0440\u0438\u043b\u043e\u0441\u044c \u0442\u0430\u043a \u0438 \u0434\u0430\u043b\u044c\u0448\u0435, \u043d\u043e \u0432 \u043e\u0434\u0438\u043d \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0434\u0435\u043d\u044c \u0431\u044b\u043b \u0434\u0430\u043d \u0443\u043a\u0430\u0437 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0432\u0441\u0435\u0445 \u043d\u0430 IP \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0438\u044e, \u0431\u044b\u043b\u0438 \u043e\u0433\u043e\u0432\u043e\u0440\u0435\u043d\u044b \u0441\u0440\u043e\u043a\u0438, \u0437\u0430\u043a\u0443\u043f\u043b\u0435\u043d\u043e \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043f\u043b\u0430\u043d \u043f\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0443 \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u044f\u0442\u0438\u044f \u0432 21 \u0432\u0435\u043a \u0441\u0442\u0430\u043b \u043f\u0440\u0435\u0442\u0432\u043e\u0440\u044f\u0442\u0441\u044f \u0432 \u0436\u0438\u0437\u043d\u044c.<br \/>  \u041f\u0435\u0440\u0432\u043e\u0435 \u0447\u0442\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u044c \u0432 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u044d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0440\u0430\u0441\u0442\u0430\u044e\u0449\u0435\u0435 \u043a\u043e\u043b-\u0432\u043e \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u044b\u0445 \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043d\u0430\u0434\u043e \u043a\u0430\u043a-\u0442\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c, \u0432\u0442\u043e\u0440\u043e\u0435, \u0447\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0442\u0440\u0435\u0432\u043e\u0436\u0438\u043b\u043e \u0431\u044b\u043b\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u0430\u044f \u043a\u043d\u0438\u0433\u0430. \u0415\u0441\u043b\u0438 \u0441 \u043f\u0435\u0440\u0432\u044b\u043c \u043d\u0430\u043c \u043c\u043e\u0433 \u043f\u043e\u043c\u043e\u0447\u044c Endpoint Manager (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a\u0441\u0442\u0430\u0442\u0438 \u0432\u044b\u043f\u0438\u043b\u0438\u043b\u0438 \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 FreePBX), \u0442\u043e \u0432\u043e\u0442 \u0441 \u043a\u043d\u0438\u0433\u043e\u0439 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b:<\/p>\n<ul>\n<li>\u0412\u043e \u043f\u0435\u0440\u0432\u044b\u0445 \u043a\u0430\u043a \u043e\u0431\u0435\u0441\u043f\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0435\u0451 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439 \u0441\u043c\u0435\u043d\u0435 \u0434\u0438\u0441\u043b\u043e\u043a\u0430\u0446\u0438\u0438\/\u0442\u0435\u043a\u0443\u0447\u0435\u0441\u0442\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439? <\/li>\n<li>\u0412\u043e \u0432\u0442\u043e\u0440\u044b\u0445, \u043a\u0430\u043a \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0431\u0435\u0437\u043b\u0438\u0447\u0438\u0442\u044c \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u044b. \u0418 \u043d\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0438\u043c\u044f \u043a\u043e\u043d\u0442\u0430\u043a\u0442\u0430?<\/li>\n<\/ul>\n<p>  \u0417\u0430\u0434\u0430\u0447\u043a\u0430 \u0431\u044b\u043b\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f, \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b\u043e \u0441\u0435\u0431\u044f \u0434\u043e\u043b\u0433\u043e \u0436\u0434\u0430\u0442\u044c. \u0421\u0435\u0439\u0447\u0430\u0441 \u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u043e\u043b\u043d\u044b\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433, \u0430 \u043f\u043e\u0442\u043e\u043c \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-294129","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/294129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=294129"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/294129\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}