forked from iagox86/poracle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Demo.rb
42 lines (34 loc) · 1.07 KB
/
Demo.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
##
# Demo.rb
# Created: February 10, 2013
# By: Ron Bowes
#
# A demo of how to use Poracle, that works against RemoteTestServer.
##
#
require 'httparty'
require './poracle'
class DemoModule
attr_reader :iv, :data, :blocksize
NAME = "DemoModule(tm)"
# This function should load @data, @iv, and @blocksize appropriately
def initialize()
@data = HTTParty.get("http://localhost:20222/encrypt").parsed_response
# Parse 'data' here
@data = [@data].pack("H*")
@iv = nil
@blocksize = 16
end
# This should make a decryption attempt and return true/false
def attempt_decrypt(data)
result = HTTParty.get("http://localhost:20222/decrypt/#{data.unpack("H*").pop}").parsed_response
# Match 'result' appropriately
return result !~ /Fail/
end
# Optionally define a character set, with the most common characters first
def character_set()
return ' eationsrlhdcumpfgybw.k:v-/,CT0SA;B#G2xI1PFWE)3(*M\'!LRDHN_"9UO54Vj87q$K6zJY%?Z+=@QX&|[]<>^{}'.chars.to_a
end
end
mod = DemoModule.new
puts "DECRYPTED: #{Poracle.decrypt(mod, mod.data, mod.iv, true)}"