@@ -21,7 +21,7 @@ def initialize
21
21
report successful logins.
22
22
} ,
23
23
'Author' => [ 'theLightCosine' ] ,
24
- 'References' =>
24
+ 'References' =>
25
25
[
26
26
[ 'CVE' , '1999-0502' ] # Weak password
27
27
] ,
@@ -39,31 +39,29 @@ def run_host(ip)
39
39
40
40
each_user_pass do |user , pass |
41
41
next if user . blank? or pass . blank?
42
- print_status "Trying #{ user } :#{ pass } "
42
+ print_status ( "Trying #{ user } :#{ pass } " )
43
43
result = do_login ( user , pass )
44
44
case result
45
45
when :success
46
- print_good "#{ ip } :#{ rport } Login Successful #{ user } :#{ pass } "
47
- report_auth_info (
48
- :host => rhost ,
49
- :port => datastore [ 'RPORT' ] ,
50
- :sname => 'pcanywhere_data' ,
51
- :user => user ,
52
- :pass => pass ,
53
- :source_type => "user_supplied" ,
54
- :active => true
46
+ print_good ( "#{ ip } :#{ rport } Login Successful #{ user } :#{ pass } " )
47
+ report_cred (
48
+ ip : rhost ,
49
+ port : datastore [ 'RPORT' ] ,
50
+ service_name : 'pcanywhere' ,
51
+ user : user ,
52
+ password : pass
55
53
)
56
54
return if datastore [ 'STOP_ON_SUCCESS' ]
57
- print_status " Waiting to Re-Negotiate Connection (this may take a minute)..."
55
+ print_status ( ' Waiting to Re-Negotiate Connection (this may take a minute)...' )
58
56
select ( nil , nil , nil , 40 )
59
57
connect
60
58
hsr = pca_handshake ( ip )
61
59
return if hsr == :handshake_failed
62
60
when :fail
63
- print_status "#{ ip } :#{ rport } Login Failure #{ user } :#{ pass } "
61
+ print_status ( "#{ ip } :#{ rport } Login Failure #{ user } :#{ pass } " )
64
62
when :reset
65
- print_status "#{ ip } :#{ rport } Login Failure #{ user } :#{ pass } "
66
- print_status " Connection Reset Attempting to reconnect in 1 second"
63
+ print_status ( "#{ ip } :#{ rport } Login Failure #{ user } :#{ pass } " )
64
+ print_status ( ' Connection reset attempting to reconnect in 1 second' )
67
65
select ( nil , nil , nil , 1 )
68
66
connect
69
67
hsr = pca_handshake ( ip )
@@ -73,6 +71,32 @@ def run_host(ip)
73
71
74
72
end
75
73
74
+ def report_cred ( opts )
75
+ service_data = {
76
+ address : opts [ :ip ] ,
77
+ port : opts [ :port ] ,
78
+ service_name : opts [ :service_name ] ,
79
+ protocol : 'tcp' ,
80
+ workspace_id : myworkspace_id
81
+ }
82
+
83
+ credential_data = {
84
+ origin_type : :service ,
85
+ module_fullname : fullname ,
86
+ username : opts [ :user ] ,
87
+ private_data : opts [ :password ] ,
88
+ private_type : :password
89
+ } . merge ( service_data )
90
+
91
+ login_data = {
92
+ core : create_credential ( credential_data ) ,
93
+ last_attempted_at : DateTime . now ,
94
+ status : Metasploit ::Model ::Login ::Status ::SUCCESSFUL
95
+ } . merge ( service_data )
96
+
97
+ create_credential_login ( login_data )
98
+ end
99
+
76
100
def do_login ( user , pass , nsock = self . sock )
77
101
# Check if we are already at a logon prompt
78
102
res = nsock . get_once ( -1 , 5 )
@@ -87,18 +111,18 @@ def do_login(user, pass, nsock=self.sock)
87
111
end
88
112
89
113
# Check if we are now at the password prompt
90
- unless res and res . include? " Enter password"
91
- print_error "Problem Sending Login: #{ res . inspect } "
114
+ unless res and res . include? ' Enter password'
115
+ print_error ( "Problem Sending Login: #{ res . inspect } " )
92
116
return :abort
93
117
end
94
118
95
119
epass = encryption_header ( encrypt ( pass ) )
96
120
nsock . put ( epass )
97
121
res = nsock . get_once ( -1 , 20 )
98
- if res . include? " Login unsuccessful"
122
+ if res . include? ' Login unsuccessful'
99
123
disconnect ( )
100
124
return :reset
101
- elsif res . include? " Invalid login"
125
+ elsif res . include? ' Invalid login'
102
126
return :fail
103
127
else
104
128
disconnect ( )
@@ -107,38 +131,38 @@ def do_login(user, pass, nsock=self.sock)
107
131
end
108
132
109
133
def pca_handshake ( ip , nsock = self . sock )
110
- print_status " Handshaking with the pcAnywhere service"
134
+ print_status ( ' Handshaking with the pcAnywhere service' )
111
135
nsock . put ( "\x00 \x00 \x00 \x00 " )
112
136
res = nsock . get_once ( -1 , 5 )
113
- unless res and res . include? " Please press <Enter>"
114
- print_error "Handshake(1) failed on Host #{ ip } aborting. ( Error: #{ res . inspect } )"
137
+ unless res and res . include? ' Please press <Enter>'
138
+ print_error ( "Handshake(1) failed on Host #{ ip } aborting. Error: #{ res . inspect } " )
115
139
return :handshake_failed
116
140
end
117
141
118
142
nsock . put ( "\x6F \x06 \xff " )
119
143
res = nsock . get_once ( -1 , 5 )
120
144
unless res and res . include? "\x78 \x02 \x1b \x61 "
121
- print_error "Handshake(2) failed on Host #{ ip } aborting. ( Error: #{ res . inspect } )"
145
+ print_error ( "Handshake(2) failed on Host #{ ip } aborting. Error: #{ res . inspect } " )
122
146
return :handshake_failed
123
147
end
124
148
125
149
nsock . put ( "\x6f \x61 \x00 \x09 \x00 \xfe \x00 \x00 \xff \xff \x00 \x00 \x00 \x00 " )
126
150
res = nsock . get_once ( -1 , 5 )
127
151
unless res and res == "\x1b \x62 \x00 \x02 \x00 \x00 \x00 "
128
- print_error "Handshake(3) failed on Host #{ ip } aborting. ( Error: #{ res . inspect } )"
152
+ print_error ( "Handshake(3) failed on Host #{ ip } aborting. Error: #{ res . inspect } " )
129
153
return :handshake_failed
130
154
end
131
155
132
156
nsock . put ( "\x6f \x62 \x01 \x02 \x00 \x00 \x00 " )
133
157
res = nsock . get_once ( -1 , 5 )
134
158
unless res and res . include? "\x00 \x7D \x08 "
135
- print_error "Handshake(4) failed on Host #{ ip } aborting. ( Error: #{ res . inspect } )"
159
+ print_error ( "Handshake(4) failed on Host #{ ip } aborting. Error: #{ res . inspect } " )
136
160
return :handshake_failed
137
161
end
138
162
139
163
res = nsock . get_once ( -1 , 5 ) unless pca_at_login? ( res )
140
164
unless pca_at_login? ( res )
141
- print_error "Handshake(5) failed on Host #{ ip } aborting. ( Error: #{ res . inspect } )"
165
+ print_error ( "Handshake(5) failed on Host #{ ip } aborting. Error: #{ res . inspect } " )
142
166
return :handshake_failed
143
167
end
144
168
end
0 commit comments