I've had a bit more than a passing thought about placing this under the "Snippets" or "Code" areas, but have shyed away so far. I had a similar need just last week, and took some Rot-13 and other similar code to roll my own into the following:
>less -x4 obf.pl
#!/usr/bin/perl
######################################################################
+######
# This utility can modify a "string file" as defined below to obfuscat
+e
# those strings using a modified rot-13 type algorithm. String inform
+ation
# is to be supplied via filenames, or piped from a file/process into t
+his
# script. All output is to stdout, suitable for piping into a resulta
+nt
# file.
#
# The string file is to contain passwords or snmp community strings
#
###
#
# Credits: Ideas taken from
# http://www.perlmonks.org/index.pl?node_id=385552
# Thanks to TZapper and Tachyon's posts
# http://search.cpan.org/author/JUERD/Crypt-Caesar-0.01/Caesar.pm
# http://search.cpan.org/author/AYRNIEU/Crypt-Rot13-0.6/Rot13.pm
# http://www.perlmonks.org/index.pl?node_id=421114
# Thanks to Tanktalus
#
So, for example, you could have a file test.dat like so:
> cat test.dat <p>
public public
private private
our-read 0uR3ad
our-write 0wR1t3
their-read th31read
their-write theirwrong
blah-blah blah-bl@h
foo-bar barfoobar
Then run the obf.pl script against it, with a rotation of 13:
> obf.pl 13 test.dat > t.1
> cat t.1
# Rotational distance was undefined, assuming 0
13
public }$oyvp
private }!v%n#r
our-read =$_@nq
our-write =&_>#@
their-read #u@>!rnq
their-write #urv!&!|{t
blah-blah oynu:oyMu
foo-bar on!s||on!
Using this code in actual expect or snmp scripts should be trival, though I've not gotten to that part in my own stuff yet :-)
-Scott L. Miller
|