Skip to content

Commit a5cfad7

Browse files
author
iagox86
committed
Major update: re-named most of the files, added a README.md file, and added a decryption module. This change breaks compatibility with previous versions, unfortunately.
1 parent 0b21db6 commit a5cfad7

File tree

7 files changed

+323
-341
lines changed

7 files changed

+323
-341
lines changed

Demo.rb

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# encoding: ASCII-8BIT
2+
13
##
24
# Demo.rb
35
# Created: February 10, 2013
@@ -7,36 +9,36 @@
79
##
810
#
911
require 'httparty'
10-
require './poracle'
11-
12-
class DemoModule
13-
attr_reader :iv, :data, :blocksize
14-
15-
NAME = "DemoModule(tm)"
16-
17-
# This function should load @data, @iv, and @blocksize appropriately
18-
def initialize()
19-
@data = HTTParty.get("http://localhost:20222/encrypt").parsed_response
20-
# Parse 'data' here
21-
@data = [@data].pack("H*")
22-
@iv = nil
23-
@blocksize = 16
24-
end
25-
26-
# This should make a decryption attempt and return true/false
27-
def attempt_decrypt(data)
28-
result = HTTParty.get("http://localhost:20222/decrypt/#{data.unpack("H*").pop}").parsed_response
29-
30-
# Match 'result' appropriately
31-
return result !~ /Fail/
32-
end
33-
34-
# Optionally define a character set, with the most common characters first
35-
def character_set()
36-
return ' eationsrlhdcumpfgybw.k:v-/,CT0SA;B#G2xI1PFWE)3(*M\'!LRDHN_"9UO54Vj87q$K6zJY%?Z+=@QX&|[]<>^{}'.chars.to_a
37-
end
38-
end
12+
require './Poracle'
13+
14+
BLOCKSIZE = 16
3915

40-
mod = DemoModule.new
41-
puts "DECRYPTED: #{Poracle.decrypt(mod, mod.data, mod.iv, true)}"
16+
poracle = Poracle.new(BLOCKSIZE, true) do |data|
17+
url = "http://localhost:20222/decrypt/#{data.unpack('H*').pop()}"
18+
result = HTTParty.get(url)
19+
20+
# Return
21+
result.parsed_response !~ /Fail/
22+
end
4223

24+
data = HTTParty.get("http://localhost:20222/encrypt").parsed_response
25+
print "Trying to decrypt: %s" % data
26+
27+
result = poracle.decrypt([data].pack('H*'))
28+
puts("-----------------------------")
29+
puts("Decryption result")
30+
puts("-----------------------------")
31+
puts result
32+
puts("-----------------------------")
33+
puts()
34+
35+
data = "The most merciful thing in the world, I think, is the inability of the human mind to correlate all its contents."
36+
print "Trying to encrypt: %s" % data
37+
result = poracle.encrypt(data)
38+
39+
puts("-----------------------------")
40+
puts("Encrypted string")
41+
puts("-----------------------------")
42+
puts result.unpack('H*')
43+
puts("-----------------------------")
44+
puts()

DoTests.rb

Lines changed: 0 additions & 111 deletions
This file was deleted.

LocalTestModule.rb

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)