@@ -62,27 +62,47 @@ if duplicates_found
6262 puts " 📊 Results: Found #{ total_duplicates } duplicate password groups affecting #{ total_affected_users } accounts\n "
6363
6464 duplicate_groups.sort_by(& .size).reverse.each_with_index do |usernames , i |
65- group_number = i + 1
66- puts " ╔═ #{ usernames.size } accounts with identical passwords ══"
65+ # Extract unique domains from this group - normalize to lowercase
66+ domains = Set (String ).new
67+ processed_usernames = usernames.map do |username |
68+ if username.includes?(" \\ " )
69+ parts = username.split(" \\ " , 2 )
70+ domains << parts[0 ].downcase # Convert domain to lowercase for uniqueness
71+ parts[1 ] # Return just the username part without domain
72+ else
73+ username # Return the full username if no domain
74+ end
75+ end
76+
77+ # Format domain information for the header
78+ domain_text = " "
79+ if ! domains.empty?
80+ domain_list = domains.to_a.sort.join(" , " )
81+ # Truncate if too long
82+ if domain_list.size > 40
83+ domain_text = " [Domains: #{ domain_list[0 ..37] } ...]"
84+ else
85+ domain_text = " [Domains: #{ domain_list } ]"
86+ end
87+ end
88+
89+ puts " ╔═ #{ usernames.size } accounts with identical passwords#{ domain_text } ══"
6790
68- # Break the usernames into chunks for more compact display
91+ # Display usernames without domains
6992 line = " "
70- usernames.each_with_index do |username , j |
93+ processed_usernames.each do |username |
7194 if line.empty?
7295 line = " ║ • #{ username } "
7396 else
74- # Check if adding this username would make the line too long
75- # If so, print the current line and start a new one
7697 if line.size + username.size + 5 > 80
7798 puts line
7899 line = " ║ • #{ username } "
79100 else
80- line += " │ #{ username } " # Using pipe character for better visual separation
101+ line += " │ #{ username } "
81102 end
82103 end
83104 end
84105
85- # Print any remaining usernames
86106 puts line unless line.empty?
87107 puts " ╚═══════════════════════════════════════════════════════════════════════\n "
88108 end
0 commit comments