Created
January 14, 2021 20:17
-
-
Save rsmudge/30867c1661aba56bed84bf8361ec5041 to your computer and use it in GitHub Desktop.
import creds from a file with mimikatz output.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import mimikatz creds from a file. | |
# go to View -> Script Console | |
# load this script | |
# type importcreds /path/to/file.txt | |
sub process { | |
if ($luser eq "(null)" || $luser eq "") { | |
return; | |
} | |
else if ([$luser endsWith: '$']) { | |
println("$luser ( $+ $domain $+ ) rejected because computer account"); | |
return; | |
} | |
else if ($lpass eq "" && $lhash eq "") { | |
println("$luser ( $+ $domain $+ ) rejected because empty hash/password fields"); | |
return; | |
} | |
else if ($lpass eq "(null)" && $lhash eq "") { | |
println("$luser ( $+ $domain $+ ) rejected because empty hash/password fields"); | |
return; | |
} | |
println("ADD $luser ( $+ $ldomain $+ ): ' $+ $lpass $+ ' and ' $+ $lhash $+ '"); | |
if ($lpass ne "(null)" && $lpass ne "") { | |
credential_add($luser, $lpass, $ldomain, "mimikatz-imported", ""); | |
} | |
if ($lhash ne "") { | |
credential_add($luser, $lhash, $ldomain, "mimikatz-imported", ""); | |
} | |
} | |
sub parsefile { | |
local('$handle $luser $lpass $ldomain $key'); | |
$handle = openf($1); | |
while $temp (readln($handle)) { | |
$key = strrep($temp, " ", "", "\t", ""); | |
if ($key ismatch ".Username:(.*?)") { | |
$luser = matched()[0]; | |
} | |
else if ($key ismatch ".Password:(.*?)") { | |
$lpass = matched()[0]; | |
} | |
else if ($key ismatch ".Domain:(.*?)") { | |
$ldomain = matched()[0]; | |
process(\$luser, \$lpass, \$lhash, \$ldomain); | |
($lpass, $luser, $lhash, $ldomain) = $null; | |
} | |
else if ($key ismatch ".NTLM:(.*?)") { | |
$lhash = matched()[0]; | |
} | |
} | |
closef($temp); | |
} | |
command importcreds { | |
parsefile($1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment