📄 config.pl
字号:
#!/usr/bin/perl################################################################################# config.pl ## WSH configuration script ## ## This file is part of WebShell which is distributed under the terms of the ## GNU General Public License v2.0 and is (c) copyright 2002,2003,2004 Alex ## Dyatlov <alex [at] gray-world.net> and Simon Castro <scastro [at] ## entreelibre.com>. See README and COPYING files for details or check ## http://gray-world.net ## ## VERSION 2.2.1 #################################################################################use strict;use File::Copy;my %CONF;# Default values$CONF{KEY} = "KEY";$CONF{INVERT} = 85;# Clientmy $f_cl_dir = "client";my $f_config = "$f_cl_dir/wsh-c.conf";my $f_client = "$f_cl_dir/wsh-c.pl";my $f_client_http = "$f_cl_dir/wsh-c-HTTP.pl";my $f_client_ssl = "$f_cl_dir/wsh-c-SSL.pl";# Servermy $f_sv_dir = "server";my $f_server = "$f_sv_dir/wsh-s.pl";my $f_server_c = "$f_sv_dir/wsh-s.c";my $f_server_j = "$f_sv_dir/WshServlet.java";print qq~ -- WSH configuration script --Use WSH client with SSL support?(Net::SSLeay module is required on the client box)~;$CONF{SSL} = yesorno();print qq~Enter <Key> value or press [enter] for default: '$CONF{KEY}'(letters, numbers, no spaces): ~;my $input = <STDIN>;chomp($input);$CONF{KEY} = $input if ($input !~ /^\s*$/s);die "Invalid <Key> value - '$CONF{KEY}'!\n" unless ($CONF{KEY} =~ /^[a-z0-9]+$/is);print "\nDo you want to encode data flow with Xor?\n";print "(no reason in Xor encoding if you are using SSL)\n";$CONF{ENCODE} = yesorno();if ($CONF{ENCODE}) { print "\nEnter <Xor byte> value or press [enter] for ". "default: '$CONF{INVERT}'\n(1..255): "; my $input = <STDIN>; chomp($input); $CONF{INVERT} = $input if ($input !~ /^\s*$/s); die "Invalid <Xor byte> value - $CONF{INVERT}!\n" if ($CONF{INVERT} < 1 || $CONF{INVERT} > 255);}print "\nIs target host running under Win32?\n";$CONF{WIN} = yesorno();# ssl ----------------------------------if ($CONF{SSL}) { copy($f_client_ssl, $f_client);} else { copy($f_client_http, $f_client);}# win ----------------------------------replace($f_config, 'win32\s+\d+', "win32\t\t$CONF{WIN}");replace($f_server, 'my \$win = [^;]+', "my \$win = $CONF{WIN}");replace($f_server_c, '#define WIN32_RUN\s+\d+', "#define WIN32_RUN $CONF{WIN}"); # encode -------------------------------replace($f_config, 'encode\s+\d+', "encode\t\t$CONF{ENCODE}");replace($f_server, 'my \$enc = [^;]+', "my \$enc = $CONF{ENCODE}");replace($f_server_c, '#define ENCODE\s+\d+', "#define ENCODE $CONF{ENCODE}"); replace($f_server_j, 'private final char Conf_XORED = [^;]+', "private final char Conf_XORED = $CONF{ENCODE}"); replace($f_config, 'invert\s+\d+', "invert\t\t$CONF{INVERT}") if ($CONF{ENCODE});replace($f_server, 'my \$invert = [^;]+', "my \$invert = $CONF{INVERT}") if ($CONF{ENCODE});replace($f_server_c, '#define INVERT\s+\d+', "#define INVERT $CONF{INVERT}"); replace($f_server_j, 'private final char Conf_XORVAL = [^;]+', "private final char Conf_XORVAL = $CONF{INVERT}"); # key ----------------------------------replace($f_server, '\$ENV{HTTP_X_KEY} eq \"[^"]+\"', "\$ENV{HTTP_X_KEY} eq \"$CONF{KEY}\"");replace($f_server_c, '#define KEY\s+\"[^"]+\"', "#define KEY \"$CONF{KEY}\""); replace($f_server_j, 'private final String Conf_XPASS\s?=\s?\"[^"]+\"', "private final String Conf_XPASS \"$CONF{KEY}\""); print qq~ -- done --Please, check "INSTALLATION" section in the README file.~;sub replace(@) { my $file = $_[0]; my $replace = $_[1]; my $with = $_[2]; open(F, $file) or die "Fail to read file $file: $!\n"; read(F, my $buf, -s $file); close(F); $buf =~ s/$replace/$with/; open(F, "> $file") or die "Fail to write file $file: $!\n"; print F $buf; close(F); return;}sub yesorno(@) { my $input; while ($input ne "y" && $input ne "n") { print "(y/n): "; $input = <STDIN>; chomp($input); } return ($input eq "y") ? 1 : 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -