Home: Need a Custom or Prewritten Perl Program?: I Need a Programmer for Freelance Work:
Honeyd Perl script



luckyray12
New User

Apr 5, 2009, 6:09 PM


Views: 9678
Honeyd Perl script

Hello, Need to hire someone that will write Perl script to work with Honeyd Honeypot. I need to elaborate on an pre existing script that emulates a Cisco router. What I need done is for this router to be able to let you log in with default username(cisco) and password(cisco) and let the attacker be able to do a "show run" and get the configs off this router. This is the current code.

#!/usr/bin/perl
#

$HOST="bps-pc8";
$DOMAIN="bps.e-technik.uni-kassel.de";
$LOG="/var/log/honeyd/cisco.log";

# Don't echo Will Echo Will Surpress Go Ahead
$return = pack('ccccccccc', 255, 254, 1, 255, 251, 1, 255, 251, 3);
syswrite STDOUT, $return, 9;


$string=
"Welcome to $HOST.$DOMAIN cisco router!\r
PLEASE LOG OFF IF YOU ARE NOT AUTHORIZED TO USE\r
THIS SYSTEM!\r
\r
Users (authorized or unauthorized) have no explicit or\r
implicit expectation of privacy. Any or all uses of this\r
system may be monitored, inspected, copied, intercepted,\r
audited, recorded, and disclosed to authorized site.\r
By using this system, the user consents to such\r
monitoring, interception, recording, copying, auditing,\r
inspection, and disclosure at the discretion of authorized\r
site.\r
\r
\r
\r
User Access Verification\r
";

syswrite STDOUT, $string;

$count = 0;
while ($count < 3) {
do {
$count++;
syswrite STDOUT, "\r\n";
$word = read_word("Username: ", 1);
} while (!$word && $count < 3);
if ($count >= 3 && !$word) {
exit;
}
$password = read_word("Password: ", 0);
if (!$password) {
syswrite STDOUT, "% Login invalid\r\n";
} else {
#syswrite STDERR, "Attempted login: $word/$password";
`/bin/echo "$HOST Attempted login: $word/$password" >> $LOG`;
syswrite STDOUT, "% Access denied\r\n";
}
}

exit;

sub read_word {
local $prompt = shift;
local $echo = shift;
local $word;

syswrite STDOUT, "$prompt";

$word = "";
$alarmed = 0;
eval {
local $SIG{ALRM} = sub { $alarmed = 1; die; };
alarm 30;
$finished = 0;
do {
$nread = sysread STDIN, $buffer, 1;
die unless $nread;
if (ord($buffer) == 0) {
; #ignore
} elsif (ord($buffer) == 255) {
sysread STDIN, $buffer, 2;
} elsif (ord($buffer) == 13 || ord($buffer) == 10) {
syswrite STDOUT, "\r\n" if $echo;
$finished = 1;
} else {
syswrite STDOUT, $buffer, 1 if $echo;
$word = $word.$buffer;
}
} while (!$finished);
alarm 0;
};
syswrite STDOUT, "\r\n" if $alarmed || ! $echo;
if ($alarmed) {
syswrite STDOUT, "% $prompt timeout expired!\r\n";
return (0);
}

return ($word);
}