On 11/11/22 10:10 AM, Bill Cole wrote:
From my bashrc...# type cidrcon cidrcon is a function cidrcon () { for a in $*; do echo $a; done | perl -e "use Net::CIDR::Lite; \$cidr = Net::CIDR::Lite->new(<>) ; \$_ = join (\"\n\",\$cidr->list) ; print \"\$_\n\";" }
Oh ... (minimally) obfuscated Perl one liner. N.B. My Perl is rusty. Let's try deobfuscating and interpreting.
use Net::CIDR::Lite;
Load the Net::CIDR::Lite module.
$cidr = Net::CIDR::Lite->new(<>);
Instantiate an instance of the Net::CIDR::Lite module. It also looks like you're reading from STDIN via "<>". Is that correct?I feel like that's a Perlish short cut to opening the STDIN. I have almost always used an "open" statement for such.
$_ = join ("\n",$cidr->list);
Set the unnamed variable to the output of the list output from the Net::CIDR::Lite object using new lines.
print "$_\n";
Print the unnamed variable with a trailing new line. I /think/. Am I close?
Obviously requires Perl and the Net::CIDR::Lite module. I do not recall why the implementation is so weird, but I've been using it for decades(!?)
The deobfuscated code doesn't seem weird to me.I suspect some of the weirdness comes from transforming it into a one liner and escaping things as necessary to pass it from shell to Perl.
I guess it may be a little weird that the cidrcon() shell function takes multiple parameters and prints each of them on a line to pass into Perl.
I wonder if it was easier / simpler to do -- what I call -- the rotation (from one line with multiple parameters to multiple lines with one parameter) in shell than to deal with them in Perl.
Thank you for sharing Bill. -- Your message has been waiting for me to read, analyze, assimilate, and reply. ;-)
-- Grant. . . . unix || die
smime.p7s
Description: S/MIME Cryptographic Signature