pin_drop 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9bde3f9cd4760aaf3cf38cdba18c187f35d23d3a
4
+ data.tar.gz: 2247352cfa3364b2b27b29571aa98cbf36263461
5
+ SHA512:
6
+ metadata.gz: 0694c47dd7af45102443cf070ab06512d72d788cece51b3273591f97c99cf502eb7c42a59eba1ef8047de89a9d714370baf9c0fb0b702b354707874574ca7a13
7
+ data.tar.gz: f94b43a63198db400fcbff74f8af04b446c5f4dc0b2b7a4189a224b57256b8a2a8698ddfc9a5244008160e34c0281d93d9e42b3ac30637734ee4ad1522e1122b
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pin_drop.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Andrew Hammond
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # PinDrop
2
+
3
+ Simple tool to estimate how strong a pin code is when subjected to a series of basic known patterns of human behavior. Out of the 10,0000 possible combinations of a 4 digit pin code, many can be guessed with ease. Based on patterns from http://www.datagenetics.com/blog/september32012/
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'pin_drop'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install pin_drop
18
+
19
+ ## Usage
20
+
21
+ Check a pin to seem how many guesses it might take to guess based on common patterns.
22
+
23
+ PinDrop::Cracker.crack_pin 1234 #=> 1
24
+
25
+ Get an array of all pin codes sorted by how common they are (most common/weak first).
26
+
27
+ PinDrop::Cracker.guesses #=> [1234,1111,0000,1212,7777,1004 ...]
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ desc "Open an irb session preloaded with this library"
4
+ task :console do
5
+ sh "irb -rubygems -I lib -r pin_drop.rb -r byebug"
6
+ end
data/lib/pin_drop.rb ADDED
@@ -0,0 +1,88 @@
1
+ require "pin_drop/version"
2
+
3
+ module PinDrop
4
+ class Cracker
5
+ def self.crack_pin(pin)
6
+ # http://www.datagenetics.com/blog/september32012/
7
+ guesses = self.guesses
8
+
9
+ i = 0
10
+ until guesses.empty?
11
+ guess = guesses.shift
12
+ i += 1
13
+ if guess == pin.to_s
14
+ puts "took #{i} guesses to guess #{pin}"
15
+ return i
16
+ end
17
+ end
18
+ end
19
+
20
+ def self.guesses
21
+ obvious = [1234,1111,0000,1212,7777,1004,2000,4444,2222,6969,9999,3333,5555,6666,1122,1313,8888,4321,2001,1010].map(&:to_s)
22
+ singlets = []
23
+ couplets = []
24
+ nineties = []
25
+ twothousands = []
26
+ starts_with_1 = []
27
+ starts_with_0 = []
28
+ ddmm_date = []
29
+ mmdd_date = []
30
+ mmyy_date = []
31
+ starts_with_2 = []
32
+ starts_with_3 = []
33
+ starts_with_4 = []
34
+ starts_with_5 = []
35
+ starts_with_7 = []
36
+ starts_with_6 = []
37
+ starts_with_8 = []
38
+ starts_with_9 = []
39
+ the_rest = []
40
+
41
+ (0..9999).each do |i|
42
+ str = i.to_s.rjust(4, '0')
43
+
44
+ if obvious.include? str
45
+ # already there
46
+ elsif str[0] == '1' && str[1] == '9'
47
+ nineties << str
48
+ elsif str[0] == '2' && str[1] == '0' && (str[2] == '1' || str[2] == '0')
49
+ twothousands << str
50
+ elsif str.chars.uniq.length === 1
51
+ singlets << str
52
+ elsif str[0] == str[2] && str[1] == str[3]
53
+ couplets << str
54
+ elsif str[0] == '1'
55
+ starts_with_1 << str
56
+ elsif str[0] == '0'
57
+ starts_with_0 << str
58
+ elsif str[0..1].to_i <= 31 && str[2..3].to_i <= 12
59
+ ddmm_date << str
60
+ elsif str[0..1].to_i <= 12 && str[2..3].to_i <= 31
61
+ mmdd_date << str
62
+ elsif str[0..1].to_i <= 12
63
+ mmyy_date << str
64
+ elsif str[0] == '2'
65
+ starts_with_2 << str
66
+ elsif str[0] == '3'
67
+ starts_with_3 << str
68
+ elsif str[0] == '4'
69
+ starts_with_4 << str
70
+ elsif str[0] == '5'
71
+ starts_with_5 << str
72
+ elsif str[0] == '7'
73
+ starts_with_7 << str
74
+ elsif str[0] == '6'
75
+ starts_with_6 << str
76
+ elsif str[0] == '8'
77
+ starts_with_8 << str
78
+ elsif str[0] == '9'
79
+ starts_with_9 << str
80
+ else
81
+ the_rest << str
82
+ end
83
+ end
84
+
85
+ obvious + singlets + couplets + nineties + twothousands + starts_with_1 + starts_with_0 + ddmm_date + mmdd_date + mmyy_date + starts_with_2 + starts_with_3 + starts_with_4 + starts_with_5 + starts_with_7 + starts_with_6 + starts_with_8 + starts_with_9 + the_rest
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,3 @@
1
+ module PinDrop
2
+ VERSION = "0.0.1"
3
+ end
data/pin_drop.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pin_drop/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pin_drop"
8
+ spec.version = PinDrop::VERSION
9
+ spec.authors = ["Andrew Hammond"]
10
+ spec.email = ["andrew@evertrue.com"]
11
+ spec.summary = %q{Tool for estimating how weak a pin code is.}
12
+ spec.description = %q{Tool for estimating how weak a pin code is.}
13
+ spec.homepage = "http://github.com/andrhamm"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "byebug"
24
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pin_drop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Hammond
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: byebug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Tool for estimating how weak a pin code is.
56
+ email:
57
+ - andrew@evertrue.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/pin_drop.rb
68
+ - lib/pin_drop/version.rb
69
+ - pin_drop.gemspec
70
+ homepage: http://github.com/andrhamm
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.2.0
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Tool for estimating how weak a pin code is.
94
+ test_files: []
95
+ has_rdoc: