Skip to content

Commit 2861d61

Browse files
committed
Lots of updates for Blackhat Europe 2016. Refer to changelog.txt.
1 parent dbf7c08 commit 2861d61

7 files changed

+307
-99
lines changed

changelog.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Changelog:
2+
3+
version 2.3
4+
-----------
5+
6+
1) Accepts file with new-line separated list of IP addresses with "-l" switch.
7+
2) Smart brute-forcing. Introduced app-specific credentials in the signature file, which are tried first.
8+
3) Sqlite database integration. Yasuo output is now stored in a sqlite database.
9+
4) All output and log files are now saved in "logs" directory.
10+
5) And man there were bugs. Fixed now.

formloginbrute.rb

+50-13
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,71 @@ def usernames_and_passwords(users_file="users.txt", password_file="pass.txt")
2525
end
2626

2727
# Attempts to bruteforce a login to supplied url.
28-
def brute_by_force(url)
28+
def brute_by_force(url,dcreds)
2929
login_agent = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' }
3030
login_agent.verify_mode = OpenSSL::SSL::VERIFY_NONE
3131
login_agent.follow_meta_refresh = true
32+
#login_agent.set_proxy("localhost", 8080) #To send login request through a proxy. Mostly for debugging.
3233

3334
login_form = login_agent.get(url).form(:name => /login/)
3435

3536
# login_form could be nil in case of an exception or if the login form does
3637
# not exist. The checks in Yasuo.rb are weak.
3738
if not login_form
3839
$logboth.info("Login page not found. Looks like this instance maybe unauthenticated")
39-
return "", ""
40+
return "<None>", "<None>"
4041
end
4142

4243
username_field = login_form.field_with(name: /user|email|login|REGEMAIL|name/i)
4344
password_field = login_form.field_with(name: /pass|pwd|REGCODE/i)
45+
if not username_field
46+
$logboth.warn ("[+] Could not enumerate the username field, moving on. You should check it manually")
47+
puts ("[+] Could not enumerate the username field, moving on. You should check it manually").red
48+
username = "<Check Manually>"
49+
password = "<Check Manually>"
50+
return username, password
51+
end
4452

45-
usernames_and_passwords.each do |user, pass|
46-
username = user.chomp
47-
password = pass.chomp
53+
#Smart brute-force code starts here
54+
username = dcreds.split(':')[0].chomp
55+
password = dcreds.split(':')[1].chomp
56+
username_field.value = username
57+
password_field.value = password
58+
59+
begin
60+
$logfile.info("Trying app-specific default creds first -> #{dcreds}")
61+
puts ("[+] Trying app-specific default creds first -> #{dcreds}\n").green
62+
63+
login_request = login_form.submit
64+
#puts login_request.body #To print server response. Mostly for debugging.
65+
66+
sleep 0.5
4867

49-
if not username_field
50-
$logboth.warn ("[+] Could not enumerate the username field, moving on. You should check it manually")
51-
username = "<Check Manually>"
52-
password = "<Check Manually>"
68+
# we determine if we have logged in by looking to see if we are on
69+
# a page with the login form.
70+
if (!login_request.form_with(:name => 'login') and
71+
login_request.body.scan(/"#{username_field.name}"/i).empty? and
72+
login_request.body.scan(/"#{username_field.name}"/i).empty?)
73+
puts "[+] Yatta, found default login credentials for #{url} - #{username}:#{password}\n".green
74+
$logfile.info("[+] Yatta, found default login credentials for #{url} - #{username} / #{password}")
5375
return username, password
5476
end
77+
rescue Mechanize::ResponseCodeError => exception
78+
if (exception.response_code != '200' or
79+
exception.response_code != '301' or
80+
exception.response_code != '302')
81+
# These response codes are handled by Mechanize
82+
login_request = exception.page
83+
$logfile.warn("Invalid credentials or user does not have sufficient privileges")
84+
else
85+
$logboth.info("Unknown server error")
86+
end
87+
end
88+
#Smart brute-force code ends here
89+
90+
usernames_and_passwords.each do |user, pass|
91+
username = user.chomp
92+
password = pass.chomp
5593

5694
username_field.value = username
5795
password_field.value = password
@@ -65,7 +103,7 @@ def brute_by_force(url)
65103

66104
# we determine if we have logged in by looking to see if we are on
67105
# a page with the login form.
68-
if (login_request.body.scan(/"#{login_form.name}"/i).empty? and
106+
if (!login_request.form_with(:name => 'login') and
69107
login_request.body.scan(/"#{username_field.name}"/i).empty? and
70108
login_request.body.scan(/"#{username_field.name}"/i).empty?)
71109
puts "[+] Yatta, found default login credentials for #{url} - #{username} / #{password}\n".green
@@ -78,7 +116,7 @@ def brute_by_force(url)
78116
exception.response_code != '302')
79117
# These response codes are handled by Mechanize
80118
login_request = exception.page
81-
$logboth.warn("Invalid credentials or user does not have sufficient privileges")
119+
$logfile.warn("Invalid credentials or user does not have sufficient privileges")
82120
else
83121
$logboth.info("Unknown server error")
84122
end
@@ -89,5 +127,4 @@ def brute_by_force(url)
89127
puts "Could not find default login credentials, sucks".red
90128
return "Not Found", "Not Found"
91129
end
92-
end
93-
130+
end

pass.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ manager
22
role1
33
admin
44
pass
5+
jenkins
56
zabbix
7+
Password123
68
root
79
tomcat
810
s3cret
9-
password
11+
password

0 commit comments

Comments
 (0)