password_crack 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9476219e1055065a8a0862f233c947157dc53d50
4
+ data.tar.gz: 4c1c13302540965646f0a754860673dcb5889b2c
5
+ SHA512:
6
+ metadata.gz: 81542c0f8620a5dc637e14b3fa262e4c32a5b09f0bee729dc864baec25dd68b637517a1b6d683b86676236d3713332e8e4ac1c5e03fe6b1d9a5bdefd7eef1d03
7
+ data.tar.gz: 440f3198452cc6818b160bc1039af350a87dc196cc50bfed5588613d6eb099a9112c35b0989f674035a12c96be475342bb92cac347c82be246897fbc4a019c7c
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://gems.ruby-china.org'
2
+
3
+ # Specify your gem's dependencies in password_crack.gemspec
4
+ gemspec
5
+
6
+ gem 'mechanize'
7
+ gem 'seven_zip_ruby'
8
+ gem 'trollop'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Jhon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # PasswordCrack
2
+
3
+ crack password by dicts,
4
+ suppert single thread md5 crack now
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'password_crack'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install password_crack
21
+
22
+ ## Usage
23
+
24
+
25
+ ```ruby
26
+ md5Password = 'e10adc3949ba59abbe56e057f20f883e'
27
+ cracker = PasswordCrack::Md5Cracker.new
28
+ dict_name = 'week_password_sample' #all dict names:see https://github.com/luaxlou/week_password/tree/master/dicts
29
+ result = cracker.crack md5Password,dict_name
30
+ expect(result).to eq('123456')
31
+
32
+ md516Password = '49ba59abbe56e057'
33
+ result = cracker.crack md516Password,dict_name
34
+ expect(result).to eq('123456')
35
+
36
+ ```
37
+
38
+ ## Command Line Usage
39
+
40
+ ```bash
41
+ $ password_crack
42
+ creack passwrod by dicts
43
+
44
+ Usage:
45
+ password_crack <crypted_password> [options]
46
+ Example:
47
+ password_crack e10adc3949ba59abbe56e057f20f883e
48
+ where [options] are:
49
+ -d, --dict=<s> dict name (default: week_password_sample)
50
+ -c, --crypt=<s> crypt type (default: md5)
51
+ -h, --help Show this message
52
+
53
+
54
+ ```
55
+
56
+ ## Contributing
57
+
58
+ Bug reports and pull requests are welcome on GitHub at https://github.com/luaxlou/password_crack. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
59
+
60
+
61
+ ## License
62
+
63
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
64
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+ require "bundler/setup"
3
+ require "password_crack"
4
+ require 'trollop'
5
+
6
+ program = 'password_crack'
7
+
8
+
9
+
10
+ crypted_password = ARGV[0]
11
+
12
+ if !crypted_password
13
+ ARGV[0] ='-h'
14
+
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+ opts = Trollop::options do
22
+ banner <<-EOS
23
+ creack passwrod by dicts
24
+
25
+ Usage:
26
+ #{program} <crypted_password> [options]
27
+ Example:
28
+ #{program} e10adc3949ba59abbe56e057f20f883e
29
+ where [options] are:
30
+ EOS
31
+ opt :dict, "dict name",:default=>'week_password_sample'
32
+ opt :crypt, "crypt type ",:default=>'md5'
33
+ end
34
+
35
+
36
+ c = PasswordCrack::Cracker.new
37
+
38
+ result = c.crack crypted_password,opts.dict,opts.crypt
39
+ p "crack success! result is:#{result}" if result
40
+
41
+ p "crack failed! now password matched!" if !result
@@ -0,0 +1,218 @@
1
+ require "password_crack/version"
2
+ require 'tmpdir'
3
+ require 'mechanize'
4
+ require 'seven_zip_ruby'
5
+
6
+ module PasswordCrack
7
+
8
+ DICT_DOWNLOAD_FOLDER = 'https://github.com/luaxlou/week_password/raw/master/dicts/'
9
+
10
+
11
+ class Cracker
12
+
13
+ def crack crypted_password,dict_name='week_password_sample',crypt_type='md5'
14
+
15
+ case crypt_type
16
+
17
+ when 'md5'
18
+ c = Md5Cracker.new
19
+
20
+ return c.crack crypted_password,dict_name
21
+
22
+ end
23
+
24
+
25
+ end
26
+
27
+
28
+
29
+ end
30
+
31
+
32
+ class Md5Cracker
33
+
34
+
35
+ #all dict names:see https://github.com/luaxlou/week_password/tree/master/dicts
36
+ def crack md5Password,dict_name='week_password_sample'
37
+
38
+ iMd516 = (md5Password.length==16)
39
+
40
+ d = Dict.new dict_name,'md5'
41
+ File.open(d.create).each_line() do |l|
42
+
43
+ (md5,pass) = l.split "\t"
44
+
45
+ pass.chomp!
46
+
47
+ md5 =md5[8..23] if iMd516
48
+
49
+ return pass if md5 == md5Password
50
+
51
+ end
52
+
53
+ return nil
54
+
55
+ end
56
+
57
+
58
+
59
+ end
60
+
61
+
62
+ class Dict
63
+
64
+ def initialize dict_name,dict_type=nil
65
+
66
+ dict_name = dict_name+ '.txt'
67
+
68
+ dict_name = dict_name + '.' + dict_type if dict_type
69
+
70
+ @dict_name = dict_name
71
+ @dict_path= Dir.tmpdir
72
+ @dict_filename = dict_name +'.7z'
73
+ @dict_filename_timestamp = @dict_filename +'.timestamp'
74
+
75
+ @client = Mechanize.new
76
+
77
+ end
78
+
79
+ public
80
+
81
+ def update
82
+
83
+ load
84
+ end
85
+
86
+ def clean
87
+
88
+ delete dict_7z_pathname
89
+ delete dict_timestamp_pathname
90
+ delete dict_pathname
91
+ end
92
+
93
+
94
+
95
+ def load
96
+ if local_timestamp < server_timestamp
97
+
98
+ download_and_unpack
99
+
100
+ end
101
+
102
+
103
+ end
104
+
105
+ def create
106
+
107
+ pathname = dict_pathname
108
+
109
+ load if !File.exists? pathname
110
+
111
+ pathname
112
+ end
113
+
114
+
115
+
116
+
117
+ private
118
+
119
+ def dict_pathname
120
+
121
+ @dict_path+'/'+@dict_filename.gsub(/\.7z/,'')
122
+
123
+ end
124
+
125
+
126
+ def dict_7z_pathname
127
+
128
+ @dict_path+'/'+@dict_filename
129
+
130
+ end
131
+
132
+
133
+ def dict_timestamp_pathname
134
+
135
+ @dict_path+'/'+@dict_filename_timestamp
136
+
137
+ end
138
+
139
+
140
+
141
+ def dict_download_url
142
+
143
+ DICT_DOWNLOAD_FOLDER+'/'+@dict_filename
144
+
145
+ end
146
+
147
+ def dict_timestamp_download_url
148
+
149
+ DICT_DOWNLOAD_FOLDER+'/'+@dict_filename_timestamp
150
+
151
+ end
152
+
153
+ def local_timestamp
154
+ t = read dict_timestamp_pathname
155
+
156
+ return 0 if ( !t)
157
+
158
+ t.to_i
159
+
160
+ end
161
+
162
+ def server_timestamp
163
+ t =download dict_timestamp_download_url
164
+ t.to_i
165
+ end
166
+
167
+ def download_and_unpack
168
+ write dict_7z_pathname,download(dict_download_url)
169
+ unpack
170
+ write dict_timestamp_pathname, server_timestamp
171
+
172
+ end
173
+
174
+ def download url
175
+
176
+ r = @client.get(url)
177
+
178
+ r.body
179
+ end
180
+
181
+ def unpack
182
+ File.open(dict_7z_pathname, "rb") do |file|
183
+ SevenZipRuby::Reader.extract_all(file, @dict_path)
184
+ delete file.path
185
+ p 'create new file:' +dict_pathname
186
+ end
187
+ end
188
+
189
+ def read pathname
190
+ return nil unless File.exists? pathname
191
+ File.read pathname
192
+
193
+ end
194
+
195
+
196
+ def delete pathname
197
+
198
+ if File.exists? pathname
199
+
200
+ File.delete pathname
201
+ p 'delete file:'+pathname
202
+ end
203
+
204
+
205
+ end
206
+
207
+
208
+ def write pathname,content
209
+ File.write pathname,content
210
+ p 'create new file: '+pathname
211
+
212
+ end
213
+
214
+
215
+
216
+ end
217
+
218
+ end
@@ -0,0 +1,3 @@
1
+ module PasswordCrack
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'password_crack/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "password_crack"
8
+ spec.version = PasswordCrack::VERSION
9
+ spec.authors = ["luax"]
10
+ spec.email = ["luax@qq.com"]
11
+
12
+ spec.summary = "crack password by dict"
13
+ spec.description = "it's easy to crack password by dict"
14
+ spec.homepage = "https://github.com/luaxlou/password_crack"
15
+ spec.license = "MIT"
16
+
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.executables = ['password_crack']
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: password_crack
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - luax
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-04 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
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: it's easy to crack password by dict
56
+ email:
57
+ - luax@qq.com
58
+ executables:
59
+ - password_crack
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - CODE_OF_CONDUCT.md
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - bin/password_crack
72
+ - lib/password_crack.rb
73
+ - lib/password_crack/version.rb
74
+ - password_crack.gemspec
75
+ homepage: https://github.com/luaxlou/password_crack
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.4.8
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: crack password by dict
99
+ test_files: []