class SpeedPwn::Generator

The Generator class takes a SpeedTouch SSID part (the last 6 characters) and returns an Array containing the possible default passwords for it. This code is based on the following resources:

Note that unlike other tools this particular one only supports SpeedTouch routers since BT Home hubs are not used in The Netherlands.

@!attribute [r] identifier

@return [String]

Constants

CHARACTERS

@return [Array]

WEEKS

@return [Array]

YEARS

@return [Array]

Attributes

identifier[R]

Public Class Methods

new(identifier) click to toggle source

@param [String] identifier The last 6 characters of the SSID.

# File lib/speedpwn/generator.rb, line 37
def initialize(identifier)
  @identifier = identifier
  @digest     = OpenSSL::Digest::SHA1.new
end

Public Instance Methods

count()
Alias for: size
finish_batch(&block) click to toggle source

Sets the block to call whenever a week (= batch) has been processed.

@param [Proc] block

# File lib/speedpwn/generator.rb, line 47
def finish_batch(&block)
  @finish_batch = block
end
generate() click to toggle source

Generates the passwords and returns them as an Array of Strings.

@return [Array]

# File lib/speedpwn/generator.rb, line 56
def generate
  passwords  = []
  batch_size = character_combinations.size

  YEARS.each do |year|
    WEEKS.each do |week|
      character_combinations.each do |combo|
        found = generate_password(year, week, combo)

        passwords << found if found
      end

      @finish_batch.call(batch_size) if @finish_batch
    end
  end

  return passwords
end
size() click to toggle source

Returns the amount of iterations to run.

@return [Numeric]

# File lib/speedpwn/generator.rb, line 80
def size
  return YEARS.size * WEEKS.size * character_combinations.size
end
Also aliased as: count

Private Instance Methods

character_combinations() click to toggle source

@return [Array]

# File lib/speedpwn/generator.rb, line 109
def character_combinations
  @combinations ||= CHARACTERS.permutation(3).map do |group|
    group.map { |char| char.ord.to_s(16) }.join('')
  end

  return @combinations
end
generate_password(year, week, combo) click to toggle source

@param [String] year @param [String] week @param [String] combo @return [String]

# File lib/speedpwn/generator.rb, line 94
def generate_password(year, week, combo)
  found  = nil
  serial = "CP#{year}#{week}#{combo}".upcase
  hash   = @digest.hexdigest(serial).upcase

  if hash[-6..-1] == identifier
    found = hash[0..9]
  end

  return found
end