easy_pow 0.1.0 → 0.1.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 +4 -4
- data/README.md +27 -1
- data/ext/easy_pow/ext.c +1 -1
- data/lib/easy_pow/version.rb +1 -1
- data/lib/easy_pow.rb +17 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5d3edfeecc053b3eb679c61b3f13275f7314b79
|
4
|
+
data.tar.gz: 2d8703ded833810fde651f5b2453225278459e14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ee458676351d953dfcafe8f9df9a245053d1dae9cb00144dd4acfb5a5ccdb476fa9bd5574330ceaf04f07edc9d978699f76c7c2388f2aba6799c2bec0cac384
|
7
|
+
data.tar.gz: 59efed38568017b7399d14693632c6483aed0c679f1a6e599c66ecacbebfbbbeea4884eb3af7930b78a19e9ea5a163a4bdf09ff9b1a63146aaff8c2261f7e18e
|
data/README.md
CHANGED
@@ -20,12 +20,38 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
+
### Solver
|
24
|
+
|
25
|
+
```
|
26
|
+
EasyPow.search_prefix(hash_type, prefix_bin, length, prefix, suffix = '', chars = '012...9ABC...Zabcd...z', parallel = true)
|
27
|
+
EasyPow.search_suffix(hash_type, suffix_bin, length, prefix, suffix = '', chars = '012...9ABC...Zabcd...z', parallel = true)
|
28
|
+
|
29
|
+
hash_type: :md5, :sha1, :sha224, :sha256, :sha384, :sha512
|
30
|
+
prefix_bin, suffix_bin: binary string of prefix or suffix (ex '0' * 24)
|
31
|
+
length: search string length ( except suffix and prefix length)
|
32
|
+
prefix: prefix string
|
33
|
+
suffix: suffix string
|
34
|
+
chars: search characters
|
35
|
+
parallel: use OpenMP
|
36
|
+
|
37
|
+
Example:
|
38
|
+
pry(main)> EasyPow.search_prefix(:md5, '1' * 24, 15, 'prefix', 'suffix', '0123456789')
|
39
|
+
=> "prefix200000000320050suffix"
|
40
|
+
pry(main)> Digest::MD5.hexdigest(_)
|
41
|
+
=> "ffffff75e679e4848069201dc511d302"
|
42
|
+
|
43
|
+
pry(main)> EasyPow.search_suffix(:sha256, '0' * 24, 15, 'prefix', 'suffix', '0123456789')
|
44
|
+
=> "prefix200000000637294suffix"
|
45
|
+
pry(main)> Digest::SHA256.hexdigest(_)
|
46
|
+
=> "54497d47f47496d82911a45f6bbfd4475f6d37502b9481006acbc9ca9a000000"
|
47
|
+
```
|
48
|
+
|
23
49
|
### Client
|
24
50
|
|
25
51
|
```ruby
|
26
52
|
require 'easy_pow'
|
27
53
|
TCPSocket.open('127.0.0.1', '1234') do |s|
|
28
|
-
|
54
|
+
EasyPow.solve(s)
|
29
55
|
end
|
30
56
|
```
|
31
57
|
|
data/ext/easy_pow/ext.c
CHANGED
@@ -165,7 +165,7 @@ void Init_ext()
|
|
165
165
|
{
|
166
166
|
VALUE module = rb_define_module("EasyPow");
|
167
167
|
rb_define_module_function(module, "search_md5_ext", search_md5, 7);
|
168
|
-
rb_define_module_function(module, "
|
168
|
+
rb_define_module_function(module, "search_sha1_ext", search_sha1, 7);
|
169
169
|
rb_define_module_function(module, "search_sha224_ext", search_sha224, 7);
|
170
170
|
rb_define_module_function(module, "search_sha256_ext", search_sha256, 7);
|
171
171
|
rb_define_module_function(module, "search_sha384_ext", search_sha384, 7);
|
data/lib/easy_pow/version.rb
CHANGED
data/lib/easy_pow.rb
CHANGED
@@ -54,13 +54,17 @@ module EasyPow
|
|
54
54
|
digest = Digest::SHA256.digest(prefix + input.rstrip).unpack("C*")
|
55
55
|
bits.times do |i|
|
56
56
|
if (digest[i / 8] >> (7 - i % 8) & 1) == 0
|
57
|
+
out_s.print "NG\n"
|
58
|
+
out_s.flush
|
57
59
|
return false
|
58
60
|
end
|
59
61
|
end
|
62
|
+
out_s.print "OK\n"
|
63
|
+
out_s.flush
|
60
64
|
return true
|
61
65
|
end
|
62
66
|
|
63
|
-
def
|
67
|
+
def solve_line(input)
|
64
68
|
if /The first (\d+)-bits of sha256\("(.{16})"/ =~ input
|
65
69
|
search_prefix('sha256', '1' * $1.to_i, 12, $2)[16..-1]
|
66
70
|
else
|
@@ -68,6 +72,17 @@ module EasyPow
|
|
68
72
|
end
|
69
73
|
end
|
70
74
|
|
75
|
+
def solve(socket = nil)
|
76
|
+
if socket.is_a?(String)
|
77
|
+
return self.solve_line(input)
|
78
|
+
else
|
79
|
+
line = socket.gets
|
80
|
+
socket.print solve_line(line) + "\n"
|
81
|
+
socket.flush
|
82
|
+
socket.gets == "OK\n"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
71
86
|
module_function :search_prefix, :search_suffix
|
72
|
-
module_function :easy_pow, :solve
|
87
|
+
module_function :easy_pow, :solve, :solve_line
|
73
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_pow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nomeaning
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
85
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.6.
|
86
|
+
rubygems_version: 2.6.11
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Simple PoW for CTF
|