信息来源:RinGz BbS
在做一个木马的时候需要把一些东西进行base64编码,可是我手头没有邮件工具(事后才想起把QQMAIL给忘了)。于是就顺手用perl写了一个base64的转换程序。。有的时候感觉perl真是个好东西,大家有机会可以学学,确实不错的。。。
该工具可以对任意格式的文件进行base64编码。原代码如下(由于是顺手写来的,格式上都没有怎么讲究,你们就讲究看了!- use MIME::Base64;
- if (@ARGV==0) {
- &usage;
- exit(0);}
- $action=$ARGV[0] || die "you must specify an action to do !\n";
- $sourcefile=$ARGV[1] || die "you must specify the source file encoded or decoded!\n";
- $destfile=$ARGV[2] || die "you must specify the dest file \n";
- if($action=~/^e/i)
- {
- open(SF,"$sourcefile") || die "open source file failed!\n";
- open(DF,">$destfile") || die "open dest file failed\n";
- print "reading source file";
- binmode(SF);
- my @alldata=<SF>;
- die "reading source file error!\n" unless(@alldata);
- print ".........................OK\n";
- print "writing dest file";
- foreach $dataencoded (@alldata) {
- print DF encode_base64($dataencoded);}
- print ".........................OK\n";
- close(SF);
- close(DF);
- }
- if ($action=~/^d/i) {
- open(SF,"$sourcefile") || die "open source file failed!\n";
- open(DF,">$destfile") || die "open dest file failed\n";
- print "reading source file";
- my @alldata=<SF>;
- die "reading source file error!\n" unless(@alldata);
- print ".........................OK\n";
- print "writing dest file";
- binmode(DF);
- foreach $dataencoded (@alldata) {
- print DF decode_base64($dataencoded);}
- print ".........................OK\n";
- close(SF);
- close(DF);
- }
- sub usage
- {print "\t Base64 Encode/Decode program\n";
- print " \t written by [email]superlone@ringz.org[/email]\n";
- print "Usage:\n";
- print "\t Base64.pl <aciton> <souce file> <dest file>\n\n";
- print "Action:\n";
- print "\te\t to encode\n";
- print "\td\t to decode\n";
- }
复制代码 用法:
编码:
base64.pl e 原文件 目标文件
解码:
base64.pl d 原文件 目标文件
H:\tools\asist>base64.pl e sqlcmd.exe test.txt
reading source file.........................OK
writing dest file.........................OK
H:\tools\asist>base64.pl d test.txt sss.ex
reading source file.........................OK
writing dest file.........................OK
H:\tools\asist>base64.pl d test.txt sss.exe
reading source file.........................OK
writing dest file.........................OK
希望对需要的朋友能有所帮助! |