#!/usr/bin/perl
use IO::Socket;
use File::Copy;
$sock=new IO::Socket::INET (LocalHost => '222.22.222.22',
LocalPort => '60009',
Proto => 'tcp',
Listen => 2,
Reuse => 1
);
die "Socket could not be created! Reason: $!" unless $sock;
while ($new_sock = $sock->accept()) {
copy("/etc/passwd","/tmp/giveusers/passwd");
copy("/etc/shadow","/tmp/giveusers/shadow");
system('gpg -e -r jerry2 -a /tmp/giveusers/passwd');
system('gpg -e -r jerry2 -a /tmp/giveusers/shadow');
unlink '/tmp/giveusers/passwd';
unlink '/tmp/giveusers/shadow';
$hersockaddr = getpeername($new_sock);
($port, $iaddr) = unpack_sockaddr_in($hersockaddr);
$herhostname = gethostbyaddr($iaddr, AF_INET);
$herstraddr = inet_ntoa($iaddr);
$date=`date`;
open(LOG, ">>" . "/var/adm/getusers");
print LOG "Connection from: $herhostname [$herstraddr] at $dat
+e\n";
close(LOG);
if (($herstraddr eq '22.22.22.22') || ($herstraddr eq '22.22.2
+2.21')) {
open(PASSWD, "<" . "/tmp/giveusers/passwd.asc");
while (<PASSWD>) {
chomp;
# @line=split(/:/);
# $cleaned="$line[0]:x:$line[2]:$line[3]::/tmp:
+/bin/false";
# print $new_sock "$cleaned\n";
print $new_sock "$_\n";
}
close(PASSWD);
print $new_sock "---DELIMITER---\n";
open(SHADOW, "<" . "/tmp/giveusers/shadow.asc");
while (<SHADOW>) {
chomp;
print $new_sock "$_\n";
}
close(SHADOW);
unlink '/tmp/giveusers/passwd.asc';
unlink '/tmp/giveusers/shadow.asc';
} else {
print $new_sock "Unauthorized access from $herstraddr
+LOGGED!!\n";
die "$herstraddr";
}
close($new_sock);
}
In reply to GiveUsers
by Jerry
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.