phoenix_password 1.1.0 → 1.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7429ba7459dcd2b4b309516ad63da99f76d3d296
4
- data.tar.gz: c92da9f74996bb727193d87ba8c3733f2cb07f5f
3
+ metadata.gz: 8a7b71057052d23dac1b6cb3125b6fcc70502f62
4
+ data.tar.gz: d2db106b5cfa6e84821989bc366975636007cbf3
5
5
  SHA512:
6
- metadata.gz: 3c766082ad076343dad9b382e798dc38313360b41a097c01dca8b8c743cd548d9fc2a58e5acc16cbaf6288863e76da977500d311c735d9c3424c6ecc10b8abb9
7
- data.tar.gz: 9bcd73a84b9327bd71f8025a22e3293bb1869bf915f0b6ce3d5aeb311be9d38536fd853d9868fd7c6488b52e66dd73a9e551e8c77fd143c262d749866a9c0fde
6
+ metadata.gz: c5d5e50eccecc17feefd7e5a6aac81b34726c4faf4fc0c07b7e621c1d5d03215afcb7680bad7a1196b6760ae93ff5f56d1fd367f19b9149f7e9e60d56c488a9d
7
+ data.tar.gz: '08b578bec86750a01ecc64fc54c15b8fe798c3953b60509581af5b9fd7042e86bd02603e8775426b61acbae47715fcead31a48e4902fd50ea8abeace11d192b0'
data/README.md CHANGED
@@ -119,6 +119,11 @@ c)Create a checkpoint table in the phoenix_password database as follows
119
119
 
120
120
  create table checkpoint ( id int not null auto_increment primary key,combination varchar(200) not null,chars_used varchar(255) not null,i bigint unsigned not null);
121
121
 
122
+ d)Insert a row in the checkpoint table
123
+
124
+ insert into checkpoint (combination,chars_used,i) values ('000000','00000',0);
125
+
126
+
122
127
  You can customize the settings if you want but you must change the phoenix_password.rb file accordingly.
123
128
 
124
129
 
@@ -153,7 +158,9 @@ If you are dealing with an odd number of total combinations say 11^6=1771561 usi
153
158
  **Restore**
154
159
 
155
160
  ```ruby
156
- PhoenixPassword.new(:restore=>true,:restore_cmb=>7)
161
+ PhoenixPassword.new(:restore=>true)
162
+
163
+ PhoenixPassword.new(:restore=>true,:checkpoint=>true,:check_fraction=>4)
157
164
 
158
165
  PhoenixPassword.new(:restore=>true,:restore_cmb=>7,:checkpoint=>true,:check_cmb=>7,:check_fraction=>4)
159
166
  ```
@@ -213,11 +220,12 @@ Set extra characters to be used one at a time if the initial characters,minimum
213
220
  Note that when etxra_chars are used only combinations that include them will be written to file.
214
221
 
215
222
  ```ruby
216
- :type=>("matching" or "unique")
223
+ :type=>("matching","unique","all")
217
224
  ```
218
225
  Sets which type of combinations to be generated.
219
226
  Matching: Characters repeating them selves any number of times xx or xxx
220
227
  Unique:Characters are different in every position xz or xzx
228
+ All: Creates all possible combinations, note that you can't use any rules when using "all".
221
229
 
222
230
  ```ruby
223
231
  :match_limit=> 2 (:optional)
data/lib/file_size.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  module FileSize
2
2
 
3
-
4
3
  def get_size(data)
5
4
  bytes=data[:combinations]*(data[:cmb_length]+1)
6
5
  kilo_bytes=bytes/1000.0
@@ -352,9 +351,16 @@ module FileSize
352
351
  return (possible_combinations-matches)-single_combs
353
352
  end
354
353
  end
355
- else
354
+ elsif data[:type]=='matching'
356
355
  return matches-old_matches if !data[:extra_chars].nil?
357
356
  return matches
357
+ else
358
+ if data[:extra_chars]
359
+ remainder = (base ** data[:cmb_length]).-(old_base**data[:cmb_length])
360
+ return remainder
361
+ else
362
+ return base ** data[:cmb_length]
363
+ end
358
364
  end
359
365
  return 0
360
366
  end
@@ -480,7 +486,11 @@ module FileSize
480
486
  end
481
487
  end
482
488
  end
483
- puts "Possible #{data[:type]} combinations #{poss_combs}."
489
+ if data[:type] == 'all'
490
+ puts "All possible combinations #{poss_combs}."
491
+ else
492
+ puts "Possible #{data[:type]} combinations #{poss_combs}."
493
+ end
484
494
  size_string="File size:"
485
495
  file_size.each do |key,value|
486
496
  next if value == 0
@@ -89,6 +89,47 @@ class PhoenixPassword
89
89
  end
90
90
  end
91
91
 
92
+ #Added for all
93
+ def add_all_combinations(data)
94
+
95
+ combinations=[]
96
+ combination=data[:combination]
97
+ characters=data[:characters]
98
+ if data[:extra_chars].nil? || data[:iteration] == 0
99
+ combinations.<<(combination.join())
100
+ if combination.last != characters.first
101
+ reverse_comb=combination.reverse
102
+ combinations.<<(reverse_comb.join())
103
+
104
+ reverse_comb.pop
105
+ reverse_compare=reverse_comb
106
+ reverse_comb=reverse_comb.join()
107
+ characters.each do |char|
108
+ next if char == characters.first
109
+ combinations.<<("%s%s"%[reverse_comb,char])
110
+
111
+ end
112
+ end
113
+
114
+ else
115
+ combinations << combination.join() if combination.include?(characters.last)
116
+ if combination.last != characters.first
117
+ reverse_comb=combination.reverse
118
+ reverse_comb.pop
119
+ reverse_compare=reverse_comb
120
+ reverse_comb=reverse_comb.join
121
+ if reverse_comb.include?(characters.last)
122
+ characters.each do |char|
123
+ combinations.<<("%s%s"%[reverse_comb,char])
124
+ end
125
+ else
126
+ combinations.<<("%s%s"%[reverse_comb,characters.last])
127
+ end
128
+ end
129
+ end
130
+ return combinations
131
+ end
132
+
92
133
  def generate_combinations(data)
93
134
  characters=data[:characters]
94
135
  if !data[:extra_chars].nil?
@@ -141,9 +182,15 @@ class PhoenixPassword
141
182
  y+=1
142
183
  end
143
184
 
144
- combinations=add_combinations({:combination=>combination,:extra_chars=>data[:extra_chars],
145
- :characters=>characters,:cmb_length=>data[:cmb_length],:type=>data[:type]})
146
- yield(combinations) if combinations.length >= 1
185
+ if @type == 'all'
186
+ yield(add_all_combinations({:combination=>combination,:extra_chars=>data[:extra_chars],
187
+ :characters=>characters,:cmb_length=>data[:cmb_length]}))
188
+ else
189
+ combinations=add_combinations({:combination=>combination,:extra_chars=>data[:extra_chars],
190
+ :characters=>characters,:cmb_length=>data[:cmb_length],:type=>data[:type]})
191
+ yield(combinations) if combinations.length >= 1
192
+ end
193
+
147
194
 
148
195
  z=combination_length-1
149
196
  while 1 < z
@@ -245,6 +292,44 @@ class PhoenixPassword
245
292
  return combinations
246
293
  end
247
294
 
295
+ def all_combinations(info)
296
+ data={:characters=>info[:characters],:cmb_length=>info[:cmb_length],:type=>info[:type]}
297
+ unless info[:extra_chars].nil?
298
+ data[:extra_chars]=info[:extra_chars]
299
+ end
300
+
301
+ create_file(info) if !info[:piped] && @fh.nil?
302
+
303
+ char_sum=data[:characters].length
304
+ total_characters=data[:characters].length
305
+ unless data[:extra_chars].nil?
306
+ total_characters=data[:characters].length+data[:extra_chars].length
307
+ data[:iteration]=0
308
+ if info[:skip_first] || !info[:piped]
309
+ data[:iteration] +=1
310
+ char_sum +=1
311
+ end
312
+ end
313
+
314
+ all=0
315
+ begin
316
+ generate_combinations(data) do |combinations|
317
+ combinations.each do |combination|
318
+ if info[:piped]
319
+ puts combination
320
+ else
321
+ @fh.puts(combination)
322
+ end
323
+ all +=1
324
+ end
325
+ end
326
+ data[:iteration]+=1 unless data[:iteration].nil?
327
+ char_sum +=1
328
+ rescue => e
329
+ raise
330
+ end while char_sum <= total_characters
331
+ return all
332
+ end
248
333
  def matching_combinations(info)
249
334
  data={:characters=>info[:characters],:cmb_length=>info[:cmb_length],:type=>info[:type]}
250
335
  unless info[:extra_chars].nil?
@@ -420,9 +505,11 @@ class PhoenixPassword
420
505
  dataB[:cmb_length] = data[:cmb_length][i]
421
506
  dataB[:characters]=data[:characters].clone
422
507
  if data[:type] == 'unique'
423
- unique_combinations(dataB)
508
+ unique_combinations(dataB)
424
509
  elsif data[:type] == 'matching'
425
- matching_combinations(dataB)
510
+ matching_combinations(dataB)
511
+ elsif @type == 'all'
512
+ all_combinations(dataB)
426
513
  end
427
514
  i+=1
428
515
  end
@@ -449,6 +536,14 @@ class PhoenixPassword
449
536
  data[:write_cmbs]=data[:cmb_length].clone
450
537
  multi_length(data)
451
538
  end
539
+ when "all"
540
+ if data[:cmb_length].length == 1
541
+ data[:cmb_length]=data[:cmb_length].first
542
+ all_combinations(data)
543
+ else
544
+ data[:write_cmbs]=data[:cmb_length].clone
545
+ multi_length(data)
546
+ end
452
547
  else
453
548
  puts "Invalid combination type"
454
549
  exit
@@ -1,3 +1,3 @@
1
1
  class PhoenixPassword
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phoenix_password
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spiros Avlonitis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-24 00:00:00.000000000 Z
11
+ date: 2017-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler