mirror of
https://github.com/hashcat/hashcat.git
synced 2025-07-23 06:58:31 +00:00
Merge pull request #4080 from lakiw/4079-radmin3_to_hashcat
Updated radmin3_to_hashcat.pl to support multiple users
This commit is contained in:
commit
2ac3fd2053
@ -48,6 +48,8 @@
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use utf8;
|
use utf8;
|
||||||
|
use Encode;
|
||||||
|
use Encode::Guess;
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -93,16 +95,69 @@ if (! open ($fh, "<", $file_name))
|
|||||||
|
|
||||||
binmode ($fh);
|
binmode ($fh);
|
||||||
|
|
||||||
my $file_content = "";
|
# Strip out any leading info from the registry file or the registry dumping program
|
||||||
|
# Then break up the registry keys into an array so each one can be processed if there are multiple
|
||||||
|
# Radmin users
|
||||||
|
my @sections;
|
||||||
|
my $current_section = '';
|
||||||
|
|
||||||
{
|
{
|
||||||
local $/ = undef;
|
local $/; # Enable slurp mode
|
||||||
|
my $file_info = <$fh>;
|
||||||
|
|
||||||
$file_content = <$fh>;
|
# Registry dumps are often UTF-16LE, but some programs might dump
|
||||||
|
# it as a different format
|
||||||
|
my $enc = guess_encoding($file_info, qw/ ascii cp1252 iso-8859-1 utf-8 UTF-16LE /);
|
||||||
|
|
||||||
|
# Decode using the encoding detected
|
||||||
|
$file_info = decode($enc->name, $file_info);
|
||||||
|
|
||||||
|
# Split lines, handling both Unix and Windows line endings
|
||||||
|
my @lines = split /\r?\n/, $file_info;
|
||||||
|
|
||||||
|
# Read the file line by line
|
||||||
|
foreach my $line (@lines) {
|
||||||
|
chomp $line;
|
||||||
|
|
||||||
|
# Check if the line is a section header
|
||||||
|
if ($line =~ /^\[HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Radmin\\v3\.0\\Server\\Parameters\\Radmin Security\\/) {
|
||||||
|
# If we already have a section, push it to the array
|
||||||
|
if ($current_section) {
|
||||||
|
push @sections, $current_section;
|
||||||
}
|
}
|
||||||
|
|
||||||
close ($fh);
|
# Start a new section with the header
|
||||||
|
$current_section = "$line\n";
|
||||||
|
}
|
||||||
|
elsif ($current_section) {
|
||||||
|
# If we are in a section, continue adding lines to it
|
||||||
|
if ($line =~ /^\[.*\]$/) {
|
||||||
|
# New section starts, save the current one
|
||||||
|
push @sections, $current_section;
|
||||||
|
$current_section = '';
|
||||||
|
} else {
|
||||||
|
# Add data to the current section
|
||||||
|
$current_section .= "$line\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Push the last section if there was one
|
||||||
|
if ($current_section) {
|
||||||
|
push @sections, $current_section;
|
||||||
|
}
|
||||||
|
close $fh;
|
||||||
|
|
||||||
|
if (!@sections) {
|
||||||
|
print STDERR "ERROR: Did not find any Radmin users in the file'\n";
|
||||||
|
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Loop over the data
|
||||||
|
my $file_content = '';
|
||||||
|
while($file_content=shift(@sections)) {
|
||||||
|
|
||||||
if (length ($file_content) < 5 + 0) # replace 0 with minimum expected length
|
if (length ($file_content) < 5 + 0) # replace 0 with minimum expected length
|
||||||
{
|
{
|
||||||
@ -143,9 +198,6 @@ if ($file_content_len < 2 + 1 + 2 + 1 + 2 + 32 + 2 + 256 + 2 + 256) # replace wi
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# loop over the data:
|
|
||||||
|
|
||||||
my $user = "";
|
my $user = "";
|
||||||
my $salt = "";
|
my $salt = "";
|
||||||
my $verifier = "";
|
my $verifier = "";
|
||||||
@ -287,3 +339,4 @@ print sprintf ("\$radmin3\$%s*%s*%s\n",
|
|||||||
$user,
|
$user,
|
||||||
$salt,
|
$salt,
|
||||||
$verifier);
|
$verifier);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user