peplum-john 0.2.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3557101f19534057d6928e39832552c6d3f752efc61ab5818f32dc12c4bf73fa
4
- data.tar.gz: 9f52968910d916f5f29066a21d68afa0d12b9e0e1839145d77c907e4ab485437
3
+ metadata.gz: 443f44c20876e1a8e0bb745fe6341a151851ce937e94c9f2c4e6a68d0bfc2197
4
+ data.tar.gz: 4c2ee91c1042307d95d927bcb6881d08714ef4326b80009ad61261e61c623d53
5
5
  SHA512:
6
- metadata.gz: 3dea930e2f89973e7bd90830352d709db0274aceb90daad387760c6f3e83df2422f488ed262c0a22aeb76993fc6c24e0639e959a3fa11f6e8e52a382b5ca210c
7
- data.tar.gz: 3bbf00ab6898ce84806a4dc92e082705ec1134ec32d656c4d7e2a861006cc86652a30074d8f38ede56680ac935f14cbd5cf26e2f1f5dbe1093e406e34ec38671
6
+ metadata.gz: c41fe68bac34af8e86831a28a93722dfe5f4f024872d602779af0bd32f5c3ccfa38f74980d939581be70946d2e4ab4aa72c2dcb5235ebca48edfbe96b07975f6
7
+ data.tar.gz: f629deee6ef6b5d03d632acd5026389dbfafac11ec36509ce68f79c94579588c7440a4af68968d44327b6c6334cc1efe120c57df2fbffd0c5299bb11c44e014d
data/examples/rest.rb CHANGED
@@ -28,8 +28,10 @@ request :post, 'instances', {
28
28
  objects: %w(
29
29
  6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090
30
30
  36f583dd16f4e1e201eb1e6f6d8e35a2ccb3bbe2658de46b4ffae7b0e9ed872e
31
+ c6b3e5102f268d17a60562720abeb625b0d3398289f46f51861f1bab3055e89d
32
+ b962ac55407c25c159c4c9f3764145e1ecc9ae6a37cf376e8bc98d31633e9a61
31
33
  ),
32
- max_workers: 2
34
+ max_workers: 4
33
35
  },
34
36
  payload: {
35
37
  format: 'raw-sha256'
@@ -40,6 +42,9 @@ request :post, 'instances', {
40
42
  instance_id = response_data['id']
41
43
 
42
44
  while sleep( 1 )
45
+ request :get, "instances/#{instance_id}/info/progress"
46
+ ap response_data
47
+
43
48
  # Continue looping while instance status is 'busy'.
44
49
  request :get, "instances/#{instance_id}"
45
50
  break if !response_data['busy']
data/examples/rpc.rb CHANGED
@@ -15,8 +15,10 @@ john.run(
15
15
  objects: %w(
16
16
  6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090
17
17
  36f583dd16f4e1e201eb1e6f6d8e35a2ccb3bbe2658de46b4ffae7b0e9ed872e
18
+ c6b3e5102f268d17a60562720abeb625b0d3398289f46f51861f1bab3055e89d
19
+ b962ac55407c25c159c4c9f3764145e1ecc9ae6a37cf376e8bc98d31633e9a61
18
20
  ),
19
- max_workers: 2
21
+ max_workers: 4
20
22
  },
21
23
  payload: {
22
24
  format: 'raw-sha256'
@@ -24,7 +26,10 @@ john.run(
24
26
  )
25
27
 
26
28
  # Waiting to complete.
27
- sleep 1 while john.running?
29
+ while john.running?
30
+ ap john.info.progress
31
+ sleep 1
32
+ end
28
33
 
29
34
  # Hooray!
30
35
  puts JSON.pretty_generate( john.generate_report.data )
@@ -8,10 +8,10 @@ class Application
8
8
  module Payload
9
9
 
10
10
  # For some reason doesn't work when specifying sane directories.
11
- HASHES_FILE = "hashes.#{Process.pid}.txt"
11
+ HASHES_FILE = "hashes.#{rand(99999)}.#{Process.pid}.txt"
12
12
  at_exit { FileUtils.rm_f HASHES_FILE }
13
13
 
14
- POT_FILE = "hashes.#{Process.pid}.pot"
14
+ POT_FILE = "hashes.#{rand(99999)}.#{Process.pid}.pot"
15
15
  at_exit { FileUtils.rm_f POT_FILE }
16
16
 
17
17
  JOHN = 'john-the-ripper'
@@ -85,7 +85,9 @@ module Payload
85
85
  end
86
86
  end
87
87
 
88
- _run options
88
+ r = _run( options )
89
+ John::Application.master.info.update r
90
+ r
89
91
  end
90
92
 
91
93
  # Distribute `objects` into `chunks` amount of groups, one for each worker.
@@ -119,15 +121,23 @@ module Payload
119
121
  end
120
122
 
121
123
  def _run( options )
122
- `#{executable} --no-log --pot=#{POT_FILE} --format=#{options['format']} #{HASHES_FILE} 2> /dev/null`
123
- `#{executable} --format=#{options['format']} #{HASHES_FILE} 2> /dev/null`
124
+ `#{executable} --no-log --session=#{Process.pid} --pot=#{POT_FILE} --format=#{options['format']} #{HASHES_FILE} 2> /dev/null`
125
+ self.report
126
+ end
124
127
 
128
+ def report
125
129
  results = {}
130
+
131
+ return results if !File.exists? POT_FILE
132
+
126
133
  File.open( POT_FILE , 'r' ) do |f|
127
- line = f.readline
128
- hash, password = line.split( '$' ).last.split( ':' )
129
- results[hash] = password.strip
134
+ while !f.eof?
135
+ line = f.readline
136
+ hash, password = line.split( '$' ).last.split( ':' )
137
+ results[hash] = password.strip
138
+ end
130
139
  end
140
+
131
141
  results
132
142
  end
133
143
 
@@ -0,0 +1,28 @@
1
+ module Peplum
2
+ class John
3
+ class Application
4
+ module Services
5
+
6
+ class Info
7
+
8
+ class <<self
9
+ def progress_data
10
+ @progress_data ||= {}
11
+ end
12
+ end
13
+
14
+ def progress
15
+ self.class.progress_data
16
+ end
17
+
18
+ def update( data )
19
+ self.class.progress_data.merge! Payload.merge( [self.class.progress_data, data] )
20
+ nil
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ module Peplum
2
+ class John
3
+ class Application
4
+ module Services
5
+ module RESTProxy
6
+ def self.registered( app )
7
+
8
+ app.get '/progress' do
9
+ instance_for( params[:instance] ) do |instance|
10
+ json instance.info.progress
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -11,6 +11,12 @@ class Application < Peplum::Application
11
11
  provision_memory 100 * 1024 * 1024
12
12
  provision_disk 100 * 1024 * 1024
13
13
 
14
+ require_relative "application/services/info"
15
+ instance_service_for :info, Services::Info
16
+
17
+ require_relative "application/services/rest_proxy"
18
+ rest_service_for :info, Services::RESTProxy
19
+
14
20
  def payload
15
21
  Payload
16
22
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Peplum
4
4
  class John
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peplum-john
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tasos Laskos
@@ -39,6 +39,8 @@ files:
39
39
  - lib/peplum/john.rb
40
40
  - lib/peplum/john/application.rb
41
41
  - lib/peplum/john/application/payload.rb
42
+ - lib/peplum/john/application/services/info.rb
43
+ - lib/peplum/john/application/services/rest_proxy.rb
42
44
  - lib/peplum/john/version.rb
43
45
  - peplum-john.gemspec
44
46
  homepage: http://ecsypno.com/