Advertisement
Malic

Untitled

Sep 13th, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. import sqlite3
  2. import json
  3. import requests
  4. import re
  5. import smtplib
  6. import dns.resolver
  7. domain=input("pls enter domain name")#the domain will synchrone with the other files
  8. employName=[]
  9. with open(f"{domain}.txt") as f:
  10. for x in f:
  11. res = x[1:].split(",")
  12. d={}
  13. job=[]
  14. for xx in res:
  15. if(":" in xx):
  16. d[xx.split(":")[0].replace("'","")]=xx.split(":")[1].replace("'","")
  17. for j in d.values():
  18. job.append(j)
  19. d=d.keys()
  20. for i in d:
  21. employName.append(i)
  22.  
  23.  
  24.  
  25. with open(f"{domain}.text")as g:#open the other file
  26. file=g.readline()
  27. # print(file)
  28. # print(type(file))
  29. form="'[]"
  30. file2=""
  31. for i in file:
  32. if i in form:
  33. pass
  34. else:
  35. file2=file2+i
  36. #print(file2)
  37. file2=file2.split(",")
  38. emailList=file2
  39. format=[]
  40. m=0
  41. for i in emailList:
  42. if i[m]!="@":
  43. m=m+1
  44. else:
  45. format.append(i[m::])
  46. format=list(dict.fromkeys(format))
  47. #print(format)
  48.  
  49. fullName=[]
  50. j=0
  51. for i in employName:
  52. fullName.append(i)
  53. #print(fullName)
  54. for i in fullName:
  55. fullName[j]=i.replace(" ","")#make the name without space
  56. j+=1
  57. #print(fullName)
  58. choose=int(input(f"which format do you want press number with the len\nfrom 0-{(len(format)-1)}\n{format}"))
  59. choose=format[choose]
  60. newEmailFake=[]
  61. for i in fullName:
  62. newEmailFake.append(f"{i+choose}")
  63. print(newEmailFake)
  64.  
  65.  
  66.  
  67. # Address used for SMTP MAIL FROM command
  68. fromAddress = 'corn@bt.com'
  69.  
  70. # Simple Regex for syntax checking
  71. #regex = '^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$'
  72.  
  73. # Email address to verify
  74. for i in newEmailFake:
  75. addressToVerify = str(i)
  76.  
  77. # # Syntax check
  78. # #match = re.match(regex, addressToVerify)
  79. # #if match == None:
  80. # #print('Bad Syntax')
  81. # #raise ValueError('Bad Syntax')
  82.  
  83. splitAddress = addressToVerify.split('@')
  84. domain1 = str(splitAddress[1])
  85. print('Domain:', domain1)
  86.  
  87. records = dns.resolver.query(domain1, 'MX')
  88. print(records)
  89. mxRecord = records[0].exchange
  90. print(mxRecord)#output .
  91. mxRecord = str(mxRecord)
  92. print(mxRecord)# output .
  93.  
  94. # SMTP lib setup (use debug level for full output)
  95. server = smtplib.SMTP()
  96. print(server)
  97. server.set_debuglevel(0)
  98. print(server)
  99.  
  100. server.connect(mxRecord)
  101. print(server.connect(mxRecord))
  102. server.helo(server.local_hostname) ### server.local_hostname(Get local server hostname)
  103. print(server.helo(server.local_hostname))
  104. server.mail(fromAddress)
  105. # print(server.mail(fromAddress))
  106. #
  107. # code, message = server.rcpt(str(addressToVerify))
  108. # server.quit()
  109. #
  110. # #print(code)
  111. # #print(message)
  112. #
  113. # # Assume SMTP response 250 is success
  114. # if code == 250:
  115. # print('Success')
  116. # else:
  117. # print('Bad')
  118. #
  119. #
  120. #
  121. #
  122. #
  123. #
  124. #
  125. # #
  126. # # #if there is no file in this name its will create" If you call "sqlite3.connect('company.db')" again, it will open the previously created database"
  127. # # connection=sqlite3.connect("my_repo.db")#create database same as "create data base command"
  128. # #
  129. # # cursor=connection.cursor()
  130. # # #
  131. # # #cursor.execute('''drop table fake_list''')#for remove table
  132. # # # cursor in SQL and databases is a control structure to
  133. # # # traverse over the records in a database. So it's used for the fetching of the results
  134. # #
  135. # # #the variable incluse the syntax of the sql
  136. # # sqlCommand="""
  137. # # create table fake_list (
  138. # # fullname VARCHAR(50),
  139. # # job VARCHAR(100),
  140. # # email VARCHAR(50));"""
  141. # # cursor.execute(sqlCommand)
  142. # # for (i,b,t) in zip(fullName,newEmailFake,job):
  143. # # sqlCommand=f'''INSERT INTO fake_list (fullname,email,job) values ("{i}","{b}","{t}");'''
  144. # # cursor.execute(sqlCommand)
  145. # # save=int(input("do yo want to save the change?\n press 1 if yes "))
  146. # # if save==1:
  147. # # connection.commit()#save the change
  148. # # connection.close()#close the connection
  149. # #
  150. # # else:
  151. # # pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement