@@ -362,7 +362,6 @@ def load_password_vars(credentials = nil)
362
362
# Note, these special username/passwords should get deprecated
363
363
# some day. Note2: Don't use with SMB and FTP at the same time!
364
364
def translate_proto_datastores
365
- switched = false
366
365
[ 'SMBUser' , 'FTPUSER' ] . each do |u |
367
366
if datastore [ u ] and !datastore [ u ] . empty?
368
367
datastore [ 'USERNAME' ] = datastore [ u ]
@@ -547,6 +546,20 @@ def vprint_brute(opts={})
547
546
end
548
547
end
549
548
549
+ def vprint_status ( msg = '' )
550
+ print_brute :level => :vstatus
551
+ end
552
+
553
+ def vprint_error ( msg = '' )
554
+ print_brute :level => :verror
555
+ end
556
+
557
+ alias_method :vprint_bad , :vprint_error
558
+
559
+ def vprint_good ( msg = '' )
560
+ print_brute :level => :vgood
561
+ end
562
+
550
563
# Provides a consistant way to display messages about AuthBrute-mixed modules.
551
564
# Acceptable opts are fairly self-explanatory, but :level can be tricky.
552
565
#
@@ -568,10 +581,10 @@ def print_brute(opts={})
568
581
end
569
582
host_ip = opts [ :ip ] || opts [ :rhost ] || opts [ :host ] || ( rhost rescue nil ) || datastore [ 'RHOST' ]
570
583
host_port = opts [ :port ] || opts [ :rport ] || ( rport rescue nil ) || datastore [ 'RPORT' ]
571
- msg = opts [ :msg ] || opts [ :message ] || opts [ :legacy_msg ]
584
+ msg = opts [ :msg ] || opts [ :message ]
572
585
proto = opts [ :proto ] || opts [ :protocol ] || proto_from_fullname
573
586
574
- complete_message = build_brute_message ( host_ip , host_port , proto , msg , !! opts [ :legacy_msg ] )
587
+ complete_message = build_brute_message ( host_ip , host_port , proto , msg )
575
588
576
589
print_method = "print_#{ level } "
577
590
if self . respond_to? print_method
@@ -582,34 +595,24 @@ def print_brute(opts={})
582
595
end
583
596
584
597
# Depending on the non-nil elements, build up a standardized
585
- # auth_brute message, but support the old style used by
586
- # vprint_status and friends as well.
587
- def build_brute_message ( host_ip , host_port , proto , msg , legacy )
598
+ # auth_brute message.
599
+ def build_brute_message ( host_ip , host_port , proto , msg )
588
600
ip = host_ip . to_s . strip if host_ip
589
601
port = host_port . to_s . strip if host_port
590
602
complete_message = nil
591
- extracted_message = nil
592
- if legacy # TODO: This is all a workaround until I get a chance to get rid of the legacy messages
593
- old_msg = msg . to_s . strip
594
- msg_regex = /(#{ ip } )(:#{ port } )?(\s *-?\s *)(#{ proto . to_s } )?(\s *-?\s *)(.*)/ni
595
- if old_msg . match ( msg_regex ) and !old_msg . match ( msg_regex ) [ 6 ] . to_s . strip . empty?
596
- complete_message = ''
597
- unless ip . blank? && port . blank?
598
- complete_message << "#{ ip } :#{ rport } "
599
- else
600
- complete_message << ( old_msg . match ( msg_regex ) [ 4 ] || proto ) . to_s
601
- end
602
-
603
- complete_message << " - "
604
- progress = tried_over_total ( ip , port )
605
- complete_message << progress if progress
606
- complete_message << old_msg . match ( msg_regex ) [ 6 ] . to_s . strip
607
- else
608
- complete_message = msg . to_s . strip
609
- end
603
+ old_msg = msg . to_s . strip
604
+ msg_regex = /(#{ ip } )(:#{ port } )?(\s *-?\s *)(#{ proto . to_s } )?(\s *-?\s *)(.*)/ni
605
+ if old_msg . match ( msg_regex )
606
+ complete_message = msg . to_s . strip
610
607
else
611
608
complete_message = ''
612
- complete_message << "#{ proto . to_s . strip } - " if proto
609
+ unless ip . blank? && port . blank?
610
+ complete_message << "#{ ip } :#{ rport } "
611
+ else
612
+ complete_message << proto || 'Bruteforce'
613
+ end
614
+
615
+ complete_message << " - "
613
616
progress = tried_over_total ( ip , port )
614
617
complete_message << progress if progress
615
618
complete_message << msg . to_s . strip
@@ -657,23 +660,6 @@ def proto_from_fullname
657
660
File . split ( self . fullname ) . last . match ( /^(.*)_(login|auth|identify)/ ) [ 1 ] . upcase rescue nil
658
661
end
659
662
660
- # Legacy vprint
661
- def vprint_status ( msg = '' )
662
- print_brute :level => :vstatus , :legacy_msg => msg
663
- end
664
-
665
- # Legacy vprint
666
- def vprint_error ( msg = '' )
667
- print_brute :level => :verror , :legacy_msg => msg
668
- end
669
-
670
- alias_method :vprint_bad , :vprint_error
671
-
672
- # Legacy vprint
673
- def vprint_good ( msg = '' )
674
- print_brute :level => :vgood , :legacy_msg => msg
675
- end
676
-
677
663
# This method deletes the dictionary files if requested
678
664
def cleanup_files
679
665
path = datastore [ 'USERPASS_FILE' ]
0 commit comments