Class: Snackhack2::PhishingTlds
- Inherits:
-
PhishingData
- Object
- PhishingData
- Snackhack2::PhishingTlds
- Defined in:
- lib/snackhack2/phishing_tlds.rb
Instance Attribute Summary collapse
-
#site ⇒ Object
Returns the value of attribute site.
Instance Method Summary collapse
- #add_tlds(list) ⇒ Object
- #change_tld(no_tld: true) ⇒ Object
- #check_domains(array: true) ⇒ Object
- #combosquatting ⇒ Object
- #idn_homograph ⇒ Object
-
#initialize ⇒ PhishingTlds
constructor
A new instance of PhishingTlds.
- #remove_letters(array_out: true) ⇒ Object
Methods inherited from PhishingData
Constructor Details
#initialize ⇒ PhishingTlds
Returns a new instance of PhishingTlds.
87 88 89 |
# File 'lib/snackhack2/phishing_tlds.rb', line 87 def initialize @site = site end |
Instance Attribute Details
#site ⇒ Object
Returns the value of attribute site.
86 87 88 |
# File 'lib/snackhack2/phishing_tlds.rb', line 86 def site @site end |
Instance Method Details
#add_tlds(list) ⇒ Object
197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/snackhack2/phishing_tlds.rb', line 197 def add_tlds(list) # takes the newly created domains (list) # and adds the tlds (domains) to the newly created # ones. o = [] list.each do |rr| domains.each do |dd| o << "#{rr}#{dd}" end end o end |
#change_tld(no_tld: true) ⇒ Object
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/snackhack2/phishing_tlds.rb', line 243 def change_tld(no_tld: true) # This method will take the inputted site in @site and # remove the TLDs and add a new TLDs to the domain. # its uses the 'domain' method in the PhishingData class # which has an array of a bunch of different tlds. # if the @site does not have a tlds if no_tld new_domains = [] # loop through the tlds domains.each do |d| # combine the inputed @site # and the tlds new_domains << "#{@site}#{d}" end new_domains else # If the @site does have a TLDs. # this is where the final results # are stored. list_of_domains = [] # removes .com, .org, etc ds = remove_tlds # join the elements together with . ds = ds.join(".") # loops through the tlds domains.each do |tlds| # adds the new domains to the array list_of_domains << "#{ds}#{tlds}" #ds + tlds end list_of_domains end end |
#check_domains(array: true) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/snackhack2/phishing_tlds.rb', line 112 def check_domains(array: true) # The function of this method is to # check if the given domains are valid or not. # By valid I mean resolvable and active. # if domains is set to true, this array will hold the domains domains_out = [] # build the list of domains generated_tlds = change_tld valid_domains = [] not_valid_domains = [] generated_tlds.each do |domain| # if array is true; add the domains to array if array domains_out << domain else # if array is false print out the domains puts domain end domains_out if array end end |
#combosquatting ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/snackhack2/phishing_tlds.rb', line 209 def combosquatting # where the generated domains will be located. results = [] # get the domain_keywords array from the PhishingData class. keywords = domain_keywords prefixes = ["-", ".", "--"] ds = remove_tlds # this will generate the 'new_domain' with the keywords # as a prefix prefixes.each do |pre| ds.each do |domain| keywords.each do |key| new_domain = "#{key}#{pre}#{domain}" results << new_domain end end end suffixes = ["-", ".", "--"] # this will generate the 'new_domain' with the keywords # as a suffixes suffixes.each do |suf| ds.each do |domain| keywords.each do |key| new_domain = "#{domain}#{suf}#{key}" results << new_domain end end end # adds the tlds to the newly created domains add_tlds(results) end |
#idn_homograph ⇒ Object
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/snackhack2/phishing_tlds.rb', line 282 def idn_homograph letters = { "o" => ["0", "О", "ó", "о","ο","օ","ȯ","ọ","ỏ","ơ","ó","ö"], "i" => ["1","ı", "ỉ", "і", "í", "ï"], "a" => ["а","α", "ạ"], "h" => ["н", "һ", "ĥ"], "c" => ["с"], "I" => "l", "e" => ["е", "℮", "ё", "ė", "ẹ"], "b" => [ "þ", "в", "B" ], "g" => [ "ɢ"], "l" => ["Ɩ", "Ι"], "m" => ["m", "ʍ", "м"], "t" => ["т", "ţ"], "p" => ["р"], "y" => ["у", "ý"], "k" => ["ķ"], "d" => ["ɗ"], "z" => ["ź","ʐ", "ż"], "s" => ["ś", "ṣ"], "u" => ["ų", "υ", "ս","ü","ú","ù"], "n" => ["ń", "ñ"], "r" => ["ɾ", "R", "r", "ʀ", "Ի", "Ꮢ", "ᚱ", "R", "r"], "ll" => ["ǁ"], "q" => ["զ"], "j" => ["ј", "ʝ"], "v" => ["ν", "ѵ"], "x" => ["х" "ҳ"] } tlds = @site.split(".") # removes the tlds tlds.pop # joins back the rest of the site tlds = tlds.join(".") new_domains = [] letters.each do |k, v| tlds.split(//).each do |letter| # if the letter elements # are qual to the key vlaue # located in the letters hash if letter.eql?(k) # find the key and replace it # the v ( idn ) if v.kind_of?(Array) # detct if the v ( value ) # is an array. If it is # then it will "randomly" pick an element v = v.sample end new_domains << tlds.gsub(k, v) end end end add_tlds(new_domains) end |
#remove_letters(array_out: true) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/snackhack2/phishing_tlds.rb', line 138 def remove_letters(array_out: true) # This method will remove letters that # occur more than once. For example: # google.com would become goggle.com # store the letter count in a hash. letter_count = {} ds = remove_tlds # Creates an array with each character being # stored in a element. It will loop through the array # and figure out the number of occurrences for each character ds.shift.split(//).each do |letter| if letter_count.has_key?(letter) letter_count[letter] += 1 else letter_count[letter] = 1 end end # After it creates the hash with the character and # the number of time it cocures. This method # will loop through the hash and check to see # if the value is greater than 1. If it is then the key ( the letter) # is added to the array named 'letters_with_more_than_one' letters_with_more_than_one = [] letter_count.each do |key, value| if value > 1 letters_with_more_than_one << key end end ds = remove_tlds new_ds = ds.shift # the final array with the duplicates letters removed remove_letters_out = [] # Loops through the 'letters_with_more_than_one' # array and uses 'sub' to remove the occurence # of one of the letters letters_with_more_than_one.each do |l| # removes only first character ( l ) remove_letters_out << new_ds.sub(l, "") # removes ALL chracters ( l ) remove_letters_out << new_ds.gsub(l, "") end # add tldds to the created list domains_with_tlds = add_tlds(remove_letters_out) if array_out domains_with_tlds else # will print the contents of the array # instead of returning the array domains_with_tlds.each { |a| puts a } end end |