Debian Codegraph @

src/samples/metadata_from_clearkey.rb

raw
1 #!/usr/bin/env ruby
2 #
3 # Dislocker -- enables to read/write on BitLocker encrypted partitions under
4 # Linux
5 # Copyright (C) 2012-2013 Romain Coltel, Hervé Schauer Consultants
6 #
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 # USA.
21 #
22
23 # $LOAD_PATH.unshift '@libdir@'
24 require '../libdislocker'
25
26
27 if ARGV.empty? or ARGV.length < 1
28 puts "Usage: #{$0} <volume path> [<offset> [<block>]]"
29 exit 1
30 end
31
32 volume = ARGV[0]
33 offset = 0
34 block = 0
35
36 if ARGV.length > 1
37 offset = ARGV[1].to_i
38 end
39
40 if ARGV.length > 2
41 block = ARGV[2]
42 end
43
44 dismeta = Dislocker::Metadata.new volume, offset, block
45
46 disaccess = Dislocker::Accesses.new(dismeta)
47
48 if dismeta.has_clearkey?
49 disaccess.vmk_from_clearkey
50
51 fvek = disaccess.fvek
52 puts ". FVEK found:"
53 puts fvek
54 else
55 puts "No clear key found, use another decryption mean."
56 end