Advertisement
Scorge

Python True Generator

Jun 20th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.94 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import math
  4. import random
  5.  
  6. Big_S=list('QWERTYUIOPASDFGHJKLZXCVBNM')
  7. Low_S=list('qwertyuiopasdfghjklzxcvbnm')
  8. Num_S=list('1234567890')
  9.  
  10. lb=3
  11. ll=3
  12. ln=3
  13.  
  14. Pass=""
  15. PassA=""
  16.  
  17. m = ['6001','6002','6003','6004']
  18. h = ['6005','6006','6007','6008','6009']
  19.  
  20. vh = ['6000', '7000', '8000','9000']
  21. za = ['9260', '9261', '9262', '9263']
  22.  
  23. def Big():
  24.     for i in range(lb):
  25.         global Pass
  26.         Pass=""
  27.         n=random.randrange(len(Big_S))
  28.         Pass=Pass+Big_S[n]
  29.     return Pass
  30.  
  31. def Low():
  32.     for i in range(ll):
  33.         global Pass
  34.         n=random.randrange(len(Low_S))
  35.         Pass=Pass+Low_S[n]
  36.     return Pass
  37.  
  38. def Num():
  39.     for i in range(ln):
  40.         global Pass
  41.         n=random.randrange(len(Num_S))
  42.         Pass=Pass+Num_S[n]
  43.     return Pass
  44.  
  45. def All():
  46.     global PassA
  47.     PassA = ""
  48.     if lb>0:
  49.         PassA=Big()
  50.     if ll>0:
  51.         PassA=Low()
  52.     if ln>0:
  53.         PassA=Num()
  54.  
  55.     PassR=list(PassA)
  56.     random.shuffle(PassR)
  57.     PassEnd=""
  58.     for i in range(len(PassR)):
  59.         PassEnd=PassEnd+PassR[i]
  60.     return PassEnd
  61.  
  62. def writeUsers(i,b,hou,roo):
  63.  
  64.     o = 0;
  65.     for it in vh:
  66.         if it == str(i):
  67.             i=za[o];   
  68.         o+=1;
  69.        
  70.     global f
  71.     global f1
  72.     global f2
  73.    
  74.     global m
  75.     global h
  76.    
  77.     print("Executing: " + str(i) + "/" + str(b))   
  78.    
  79.     Passwd = All();
  80.  
  81.     Dlpn = "DLPN_ua_user"
  82.  
  83.    
  84.     for mains in m:
  85.         if mains == str(i):
  86.             Dlpn = "DLPN_ua_main"
  87.    
  88.     for mains in h:
  89.         if mains == str(i):
  90.             Dlpn = "DLPN_ua_house"
  91.  
  92.     if len(str(i)) < 3:
  93.         f1.write(str(i)+"\t\t\t"+Passwd+"\t\t"+Dlpn+"\t"+str(hou)+"\t\t"+str(roo)+"\n");                   
  94.     else:
  95.         f1.write(str(i)+"\t\t"+Passwd+"\t\t"+Dlpn+"\t"+str(hou)+"\t\t"+str(roo)+"\n");                 
  96.        
  97.     l = ['['+ str(i)+']', 'fullname = '+ str(i), 'registersip = no', 'host = dynamic', 'callgroup = 1', 'mailbox = '+ str(i),
  98.          'call-limit = 100', 'type = peer', 'username = '+ str(i), 'transfer = yes', 'callcounter = yes', 'context = '+Dlpn,
  99.          'cid_number = '+ str(i), 'hasvoicemail = no', 'vmsecret = ', 'email =', 'threewaycalling = no', 'hasdirectory = no',
  100.          'callwaiting = no', 'hasmanager = no', 'hasagent = no', 'hassip = yes', 'hasiax = no', 'secret = ' +Passwd, 'nat = force_rport,comedia',
  101.          'canreinvite = no', 'directmedia = no', 'dtmfmode = info', 'insecure = no', 'pickupgroup = 1', 'macaddress = '+ str(i),
  102.          'autoprov = yes', 'label = '+str(i), 'LINEKEYS = 1', '', '', 'linenumber = ', 'disallow = all', 'allow = ulaw,h264,alaw,h263,g722']
  103.  
  104.     for item in l:
  105.         f.write(item+"\n")
  106.    
  107.     nuls = "";
  108.     nuls = "";
  109.    
  110.     if roo < 10:
  111.         nuls = "00";
  112.     if roo > 9:
  113.         nuls = "0";
  114.     if roo > 99:
  115.         nuls = "";
  116.  
  117.     if (roo !=0):
  118.         f2.write("exten = "+str(hou)+nuls+str(roo)+",1,Goto(ringroups-custom-"+str(hou)+nuls+str(roo)+",s,1)\n");
  119.  
  120. f = open('out_users.conf','w')
  121. f1 = open('out_secrets.text','w')
  122. f2 = open('out_extention.conf','w')
  123.  
  124. f1.write("Username:\tPassword:\tRole:\t\t\tHouse:\tRoom:\n");
  125.  
  126. #panels main 1 - 4
  127. for i in range(1, 5):
  128.     writeUsers("600"+str(i),6005,0,0)
  129. #panels house 5 - 9
  130. for i in range(5, 9):
  131.     writeUsers("600"+str(i),6010,i-4,0)
  132.  
  133. f2.write("[ringgroups]\n");
  134.  
  135. #links
  136. for j in range(0, 298):
  137.     writeUsers(str(6010+j),6306,str(1),j+1)
  138.  
  139. for j in range(0, 360):
  140.     writeUsers(str(7001+j),7360,str(2),j+1)
  141.  
  142. for j in range(0, 192):
  143.     writeUsers(str(8001+j),8192,str(3),j+1)
  144.  
  145. for j in range(0, 156):
  146.     writeUsers(str(9001+j),9156,str(4),j+1)
  147.  
  148. #groups
  149. for j in range(0, 298):
  150.     nuls = "";
  151.     if j+1 < 10:
  152.         nuls = "00";
  153.     if j+1 > 9:
  154.         nuls = "0";
  155.     if j+1 > 99:
  156.         nuls = "";
  157.     f2.write("\n[ringroups-custom-"+str(1)+nuls+str(j+1)+"]\n")
  158.     f2.write("exten = s,1,NoOp(House"+str(1)+"_Room"+str(j+1)+")\n")
  159.     mess = "exten = s,1,Dial(SIP/" + str(6010+j) + ",35,${DIALOPTIONS}i)\n"
  160.     f2.write(mess);
  161.     f2.write("exten = s,1,Hangup\n");  
  162.  
  163. for j in range(0, 360):
  164.     nuls = "";
  165.     if j+1 < 10:
  166.         nuls = "00";
  167.     if j+1 > 9:
  168.         nuls = "0";
  169.     if j+1 > 99:
  170.         nuls = "";
  171.     f2.write("\n[ringroups-custom-"+str(2)+nuls+str(j+1)+"]\n")
  172.     f2.write("exten = s,1,NoOp(House"+str(2)+"_Room"+str(j+1)+")\n")
  173.     mess = "exten = s,1,Dial(SIP/" + str(7001+j) + ",35,${DIALOPTIONS}i)\n"
  174.     f2.write(mess);
  175.     f2.write("exten = s,1,Hangup\n");  
  176.    
  177. for j in range(0, 192):
  178.     nuls = "";
  179.     if j+1 < 10:
  180.         nuls = "00";
  181.     if j+1 > 9:
  182.         nuls = "0";
  183.     if j+1 > 99:
  184.         nuls = "";
  185.     f2.write("\n[ringroups-custom-"+str(3)+nuls+str(j+1)+"]\n")
  186.     f2.write("exten = s,1,NoOp(House"+str(3)+"_Room"+str(j+1)+")\n")
  187.     mess = "exten = s,1,Dial(SIP/" + str(8001+j) + ",35,${DIALOPTIONS}i)\n"
  188.     f2.write(mess);
  189.     f2.write("exten = s,1,Hangup\n");  
  190.    
  191. for j in range(0, 156):
  192.     nuls = "";
  193.     if j+1 < 10:
  194.         nuls = "00";
  195.     if j+1 > 9:
  196.         nuls = "0";
  197.     if j+1 > 99:
  198.         nuls = "";
  199.     f2.write("\n[ringroups-custom-"+str(4)+nuls+str(j+1)+"]\n")
  200.     f2.write("exten = s,1,NoOp(House"+str(4)+"_Room"+str(j+1)+")\n")
  201.     mess = "exten = s,1,Dial(SIP/" + str(9001+j) + ",35,${DIALOPTIONS}i)\n"
  202.     f2.write(mess);
  203.     f2.write("exten = s,1,Hangup\n");  
  204.    
  205. f2.close();
  206. f1.close();
  207. f.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement