1
1
2
2
require 'msf/core'
3
+ require 'metasploit/framework/login_scanner/ipboard'
3
4
4
5
class Metasploit3 < Msf ::Auxiliary
5
6
@@ -25,115 +26,49 @@ def initialize
25
26
end
26
27
27
28
def run_host ( ip )
28
- connect
29
-
30
- each_user_pass do |user , pass |
31
- do_login ( user , pass , ip )
32
- end
33
- end
34
-
35
- def do_login ( user , pass , ip )
36
- begin
37
- print_status "#{ peer } - Connecting to target, searching for IP Board server nonce..."
38
-
39
- # Perform the initial request and find the server nonce, which is required to log
40
- # into IP Board
41
- res = send_request_cgi ( {
42
- 'uri' => normalize_uri ( target_uri . path ) ,
43
- 'method' => 'GET'
44
- } , 10 )
45
-
46
- unless res
47
- print_error "#{ peer } No response when trying to connect"
48
- return :connection_error
49
- end
50
-
51
- # Grab the key from within the body, or alert that it can't be found and exit out
52
- if res . body =~ /name='auth_key'\s +value='.*?((?:[a-z0-9]*))'/i
53
- server_nonce = $1
54
- print_status "#{ peer } Server nonce found, attempting to log in..."
55
- else
56
- print_error "#{ peer } Server nonce not present, potentially not an IP Board install or bad URI."
57
- print_error "#{ peer } Skipping..."
58
- return :abort
59
- end
60
-
61
- # With the server nonce found, try to log into IP Board with the user provided creds
62
- res2 = send_request_cgi ( {
63
- 'uri' => normalize_uri ( target_uri . path , "index.php?app=core&module=global§ion=login&do=process" ) ,
64
- 'method' => 'POST' ,
65
- 'vars_post' => {
66
- 'auth_key' => server_nonce ,
67
- 'ips_username' => user ,
68
- 'ips_password' => pass
69
- }
70
- } )
71
-
72
- # Default value of no creds found
73
- valid_creds = false
74
-
75
- # Iterate over header response. If the server is setting the ipsconnect and coppa cookie
76
- # then we were able to log in successfully. If they are not set, invalid credentials were
77
- # provided.
29
+ cred_collection = Metasploit ::Framework ::CredentialCollection . new (
30
+ blank_passwords : datastore [ 'BLANK_PASSWORDS' ] ,
31
+ pass_file : datastore [ 'PASS_FILE' ] ,
32
+ password : datastore [ 'PASSWORD' ] ,
33
+ user_file : datastore [ 'USER_FILE' ] ,
34
+ userpass_file : datastore [ 'USERPASS_FILE' ] ,
35
+ username : datastore [ 'USERNAME' ] ,
36
+ user_as_pass : datastore [ 'USER_AS_PASS' ] ,
37
+ )
78
38
79
- if res2 . get_cookies . include? ( 'ipsconnect' ) && res2 . get_cookies . include? ( 'coppa' )
80
- valid_creds = true
81
- end
39
+ scanner = Metasploit ::Framework ::LoginScanner ::IPBoard . new (
40
+ host : ip ,
41
+ port : rport ,
42
+ uri : normalize_uri ( target_uri . path ) ,
43
+ proxies : datastore [ "PROXIES" ] ,
44
+ cred_details : cred_collection ,
45
+ stop_on_success : datastore [ 'STOP_ON_SUCCESS' ] ,
46
+ connection_timeout : 5 ,
47
+ )
82
48
83
- # Inform the user if the user supplied credentials were valid or not
84
- if valid_creds
85
- print_good "#{ peer } Username: #{ user } and Password: #{ pass } are valid credentials!"
86
- register_creds ( user , pass , ip )
87
- return :next_user
88
- else
89
- vprint_error "#{ peer } Username: #{ user } and Password: #{ pass } are invalid credentials!"
90
- return nil
49
+ scanner . scan! do |result |
50
+ credential_data = result . to_h
51
+ credential_data . merge! (
52
+ module_fullname : self . fullname ,
53
+ workspace_id : myworkspace_id
54
+ )
55
+ case result . status
56
+ when Metasploit ::Model ::Login ::Status ::SUCCESSFUL
57
+ print_brute :level => :good , :ip => ip , :msg => "Success: '#{ result . credential } '"
58
+ credential_core = create_credential ( credential_data )
59
+ credential_data [ :core ] = credential_core
60
+ create_credential_login ( credential_data )
61
+ :next_user
62
+ when Metasploit ::Model ::Login ::Status ::UNABLE_TO_CONNECT
63
+ print_brute :level => :verror , :ip => ip , :msg => "Could not connect"
64
+ invalidate_login ( credential_data )
65
+ :abort
66
+ when Metasploit ::Model ::Login ::Status ::INCORRECT
67
+ print_brute :level => :verror , :ip => ip , :msg => "Failed: '#{ result . credential } ' #{ result . proof } "
68
+ invalidate_login ( credential_data )
91
69
end
92
-
93
- rescue ::Timeout ::Error
94
- print_error "#{ peer } Connection timed out while attempting to connect!"
95
- return :connection_error
96
-
97
- rescue ::Errno ::EPIPE
98
- print_error "#{ peer } Broken pipe error when connecting!"
99
- return :connection_error
100
70
end
101
- end
102
-
103
- def register_creds ( username , password , ipaddr )
104
- # Build service information
105
- service_data = {
106
- address : ipaddr ,
107
- port : datastore [ 'RPORT' ] ,
108
- service_name : 'http' ,
109
- protocol : 'tcp' ,
110
- workspace_id : myworkspace_id
111
- }
112
-
113
- # Build credential information
114
- credential_data = {
115
- origin_type : :service ,
116
- module_fullname : self . fullname ,
117
- private_data : password ,
118
- private_type : :password ,
119
- username : username ,
120
- workspace_id : myworkspace_id
121
- }
122
-
123
- credential_data . merge! ( service_data )
124
- credential_core = create_credential ( credential_data )
125
-
126
- # Assemble the options hash for creating the Metasploit::Credential::Login object
127
- login_data = {
128
- access_level : "user" ,
129
- core : credential_core ,
130
- last_attempted_at : DateTime . now ,
131
- status : Metasploit ::Model ::Login ::Status ::SUCCESSFUL ,
132
- workspace_id : myworkspace_id
133
- }
134
71
135
- login_data . merge! ( service_data )
136
- create_credential_login ( login_data )
137
72
end
138
73
139
74
end
0 commit comments