Created
May 15, 2023 00:52
-
-
Save ckxng/4ebbe5dc7ffc5d26ea32051517186f50 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/perl -wT | |
use strict; | |
use warnings; | |
%ENV = (); | |
$ENV{'PATH'} = '/bin:/usr/bin'; | |
sub untaintfp { | |
my $keyfp = shift or die "untaintfp missing parameter: keyfp\n"; | |
my $utkeyfp = ''; | |
if($keyfp =~ /^(0x[a-zA-Z0-9]+)$/) { | |
$utkeyfp = $1; | |
} else { | |
die "exportkey: invalid fingerprint\n"; | |
} | |
} | |
sub exportkey { | |
my $keyfp = shift or die "exportkey: missing parameter: keyfp\n"; | |
my $utkeyfp = untaintfp $keyfp; | |
my $output = `gpg -a --export ${utkeyfp}`; | |
open KEYF, ">pub-${utkeyfp}.asc" or die "exportkey: unable to open file pub-${utkeyfp}.asc\n"; | |
printf KEYF "%s\n", $output; | |
close KEYF; | |
} | |
exportkey $_ while(<DATA>); | |
__DATA__ | |
0x00112233445566778899AABBCCDDEEFF00112233 | |
0x44556677889900AABBCCDDEEFF00112233445566 | |
0x778899AABBCCDDEEFF00112233445566778899AA | |
0xEC32B8C8E90430080D5A8402B30A183EF47041FE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment