App-Hack-Exe

 view release on metacpan or  search on metacpan

lib/App/Hack/Exe.pm  view on Meta::CPAN


=head1 NAME

App::Hack::Exe - An animated terminal app that pretends to hack a website, just
like in the movies

=head1 SYNOPSIS

    require App::Hack::Exe;

    my $he = App::Hack::Exe->new;

    # Run the script
    $he->run('yahoo.com');

=head1 DESCRIPTION

This is a flashy animated script that simulates a "hacking program", as often
seen in movies.

=cut

use constant {
    DEFAULTS => {
        get_ipv4 => 1,
        get_ipv6 => 1,
        no_delay => 0,
        ports => [qw/ 143 993 587 456 25 587 993 80 /],
        proxies => [qw/ BEL AUS JAP CHI NOR FIN UKR /],
    },
    # Original ASCII art by Jan (janbrennen@github)
    # Source: https://github.com/janbrennen/rice/blob/master/hack.exe.c
    DEMON => <<'EOD',
          .                                                      .
        .n                   .                 .                  n.
  .   .dP                  dP                   9b                 9b.    .
 4    qXb         .       dX                     Xb       .        dXp     t
dX.    9Xb      .dXb    __                         __    dXb.     dXP     .Xb
9XXb._       _.dXXXXb dXXXXbo.                 .odXXXXb dXXXXb._       _.dXXP
 9XXXXXXXXXXXXXXXXXXXVXXXXXXXXOo.           .oOXXXXXXXXVXXXXXXXXXXXXXXXXXXXP
  `9XXXXXXXXXXXXXXXXXXXXX'~   ~`OOO8b   d8OOO'~   ~`XXXXXXXXXXXXXXXXXXXXXP'
    `9XXXXXXXXXXXP' `9XX'   DIE    `98v8P'  HUMAN   `XXP' `9XXXXXXXXXXXP'
        ~~~~~~~       9X.          .db|db.          .XP       ~~~~~~~
                        )b.  .dbo.dP'`v'`9b.odb.  .dX(
                      ,dXXXXXXXXXXXb     dXXXXXXXXXXXb.
                     dXXXXXXXXXXXP'   .   `9XXXXXXXXXXXb
                    dXXXXXXXXXXXXb   d|b   dXXXXXXXXXXXXb
                    9XXb'   `XXXXXb.dX|Xb.dXXXXX'   `dXXP
                     `'      9XXXXXX(   )XXXXXXP      `'
                              XXXX X.`v'.X XXXX
                              XP^X'`b   d'`X^XX
                              X. 9  `   '  P )X
                              `b  `       '  d'
                               `             '
EOD
    # Float; Number of seconds to display "loading" animation for
    DOTS_DURATION => 1,
    # Int; Number of characters to draw each "loading" animation line
    # 77 = Width of demon
    DOTS_WIDTH => 77,
    # ANSI escape codes for cursor manipulation
    MEMORIZE_CURSOR => "\e\x{37}",
    RECALL_CURSOR => "\e\x{38}",
};

use Carp qw/ croak /;
use Socket 1.95 qw/
    AF_INET
    AF_INET6
    NI_NUMERICHOST
    NI_NUMERICSERV
    getaddrinfo
    getnameinfo
/;
use Term::ANSIColor qw/ color colored /;
use Time::HiRes qw/ sleep /;

use fields qw/
    get_ipv4
    get_ipv6
    no_delay
    ports
    proxies
/;

=head1 CONSTRUCTOR

=head2 C<new()>

    my $he = App::Hack::Exe->new( %options )

This method constructs a new L<App::Hack::Exe> object and returns it. Key/value
pair arguments may be provided to set up the initial state. The following
options are recognized:

   KEY              DEFAULT
   -----------      -----------
   get_ipv4         1
   get_ipv6         1
   no_delay         0
   ports            [143, 993, 587, 456, 25, 587, 993, 80]
   proxies          [qw/ BEL AUS JAP CHI NOR FIN UKR /]

=over

=item get_ipv4, get_ipv6 (int)

Print out this number of IPv4 and IPv6 addresses for the host name,
respectively.

=item no_delay (bool)

Print out all text at once, instead of simulating delays (e.g. network lag).

=item ports (arrayref)

Set the port numbers for the simulation. Ports are arbitrary strings.

=item proxies (arrayref)

Set the proxy names for the simulation. Proxy names are arbitrary strings.



( run in 2.505 seconds using v1.01-cache-2.11-cpan-cdf2f3d4e48 )