- Titel:
- dm-crypt LUKS bruteforcing script
- Datum:
- 24. Januar 2009 11:01
- Aktionen:
-
- Seiten, die auf diesen Eintrag verweisen:
- Code:
-
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55 | #!/usr/bin/env ruby
#
# dm-crypt LUKS bruteforcing script
#
# Copyright 2009 by Rorschach (r0rschach@lavabit.com)
# Licence: GPL3
$VERBOSE=true
require 'open3'
$partition='/dev/sdXY'
$mapper='brute'
def error(msg)
puts " Error: #{msg}"
puts " Aborting now!"
exit 1
end
def check_if_correct(stderr,stdout)
return false if stderr.chomp.chomp == "Command failed: No key available with this passphrase."
return true if stdout =~ /^key\sslot\s\d\sunlocked\.$/
case stderr.chomp
when "Command failed: Device already exists"
error("#{$partition} is already unencrypted and mapped to #{$mapper}.")
when "Command failed: Can not access device"
error("Wheter #{$partition} does not exist or is already mapped to another device.")
else
error("An unknown error has occured:\n #{stderr.chomp}")
end
end
if ARGV[0]==nil
error("Not enough arguments!\n Usage: #{$0} dictionaryfile")
end
if not FileTest::exist?(ARGV[0])
error("#{ARGV[0]} doesn't exist.")
end
File.open(ARGV[0], "r").each_line do |password|
puts "Testing: #{password}"
Open3.popen3("sudo cryptsetup luksOpen #{$partition} #{$mapper}") do |stdin,stdout,stderr|
stdin.puts password.chomp
if check_if_correct(stderr.read,stdout.read)
puts "\n Correct password found: #{password.chomp}"
system("sudo cryptsetup remove #{$mapper}")
exit 0
end
end
end
puts "\n Haven't found the correct password."
exit 1
|