Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Module : DH Tools
- # Version : 0.3
- # (C) Doddy Hackman 2016
- package DH_Tools;
- use LWP::UserAgent;
- use Try::Tiny;
- use File::Basename;
- use URI::Split qw(uri_split uri_join);
- use Digest::MD5;
- use IO::Socket;
- my @agents = (
- 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0',
- 'Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14',
- 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36',
- 'Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0',
- 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.8pre) Gecko/20070928 Firefox/2.0.0.7 Navigator/9.0RC1',
- 'Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))',
- 'Mozilla/5.0 (Windows NT 6.0; rv:2.0) Gecko/20100101 Firefox/4.0 Opera 12.14',
- 'Mozilla/5.0 (Windows; U; Windows NT 6.1; tr-TR) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27'
- );
- my $timeout = "10";
- sub new {
- my $class = shift;
- my $self = {};
- bless $self,$class;
- return $self;
- }
- sub toma {
- my ($self,$page) = @_;
- my $contenido = "";
- if($page ne "") {
- try {
- my $nave = LWP::UserAgent->new;
- $nave->agent( $agents[ rand @agents ] );
- $nave->timeout($timeout);
- $contenido = $nave->get($page)->content;
- } catch {
- $contenido = "Error";
- };
- } else {
- $contenido = "Error";
- }
- return $contenido;
- }
- sub tomar {
- my ($self,$page, $params ) = @_;
- my $contenido = "";
- if($page ne "" and $params ne "") {
- try {
- my $nave = LWP::UserAgent->new;
- $nave->agent( $agents[ rand @agents ] );
- $nave->timeout($timeout);
- $contenido = $nave->post( $page, [ %{$params} ] )->content;
- } catch {
- $contenido = "Error";
- };
- } else {
- $contenido = "Error";
- }
- return $contenido;
- }
- sub savefile {
- my ($self,$filename,$text) = @_;
- my $response = 0;
- if($filename ne "" and $text ne "") {
- try {
- open( SAVE, ">>" . $filename );
- print SAVE $text . "\n";
- close SAVE;
- $response = 1;
- } catch {
- $response = 0;
- };
- } else {
- $response = 0;
- }
- return $response;
- }
- sub console {
- my ($self,$command) = @_;
- my $response = "";
- if($command ne "") {
- try {
- $response = `$command`;
- } catch {
- $response = "Error";
- };
- } else {
- $response = "Error";
- }
- return $response;
- }
- sub http_fingerprinting {
- my ($self,$page,$option) = @_;
- my $response = "";
- if($page ne "") {
- my $nave = LWP::UserAgent->new;
- $nave->agent( $agents[ rand @agents ] );
- $nave->timeout($timeout);
- my $code = $nave->get($page);
- if($option eq "single") {
- $response = $response . "[+] Date : " . $code->header('date');
- $response = $response . "\n[+] Server : " . $code->header('server');
- $response = $response . "\n[+] Connection : " . $code->header('connection');
- $response = $response . "\n[+] Content-Type : " . $code->header('content-type');
- } elsif($option eq "full") {
- $response = $code->headers()->as_string();
- } else {
- $response = $code->headers()->as_string();
- }
- } else {
- $response = "Error";
- }
- return $response;
- }
- sub get_response_code {
- my ($self,$page) = @_;
- my $contenido = "";
- if($page ne "") {
- try {
- my $nave = LWP::UserAgent->new;
- $nave->agent( $agents[ rand @agents ] );
- $nave->timeout($timeout);
- $contenido = $nave->get($page)->code;
- } catch {
- $contenido = "Error";
- };
- } else {
- $contenido = "Error";
- }
- return $contenido;
- }
- sub repes {
- my ($self,@array_to_clean) = @_;
- my @limpio;
- foreach $line (@array_to_clean) {
- push @limpio, $line unless $repe{$line}++;
- }
- return @limpio;
- }
- sub cortar {
- my ($self,@array_to_cut) = @_;
- my @limpio;
- foreach $line (@array_to_cut) {
- if($line=~/(.*?)=(.*?)/) {
- my($parte_uno,$parte_dos) = ($1,$2);
- my $url_ready = $parte_uno . "=";
- push(@limpio,$url_ready);
- }
- }
- return @limpio;
- }
- sub regex {
- my ($self,$code,$deaca,$hastaaca) = @_;
- my $response = "";
- if($code ne "" and $deaca ne "" and $hastaaca ne "") {
- if($code=~/$deaca(.*?)$hastaaca/) {
- $response = $1;
- } else {
- $response = "";
- }
- } else {
- $response = "";
- }
- return $response;
- }
- sub download {
- my ($self,$url,$filename) = @_;
- my $response = 0;
- if($url ne "" and $filename ne "") {
- try {
- my $nave = LWP::UserAgent->new;
- $nave->agent( $agents[ rand @agents ] );
- $nave->timeout($timeout);
- if ($nave->mirror($url,$filename)) {
- if (-f $filename) {
- $response = 1;
- } else {
- $response = 0;
- }
- } else {
- $response = 0;
- }
- } catch {
- $response = 0;
- };
- } else {
- $response = 0;
- }
- return $response;
- }
- sub get_filename_by_url {
- my ($self,$page) = @_;
- my $filename = "";
- if($page ne "") {
- my ($scheme, $auth, $path, $query, $frag) = uri_split($page);
- $filename = basename($path);
- } else {
- $filename = "";
- }
- return $filename;
- }
- sub url_split {
- my ($self,$page,$option) = @_;
- my $response = "";
- if($page ne "" and $option ne "") {
- my ($scheme, $auth, $path, $query, $frag) = uri_split($page);
- if($option eq "scheme") {
- $response = $scheme;
- } elsif($option eq "auth") {
- $response = $auth;
- } elsif($option eq "path") {
- $response = $path;
- } elsif($option eq "query") {
- $response = $query;
- } elsif($option eq "frag") {
- $response = $frag;
- } else {
- $response = $page;
- }
- } else {
- $response = "";
- }
- return $response;
- }
- sub md5_encode {
- my ($self,$text) = @_;
- my $response = "";
- if($text ne "") {
- $md5 = Digest::MD5->new;
- $md5->add($text);
- $response = $md5->hexdigest;
- } else {
- $response = "Error";
- }
- return $response;
- }
- sub md5_file_encode {
- my ($self,$filename) = @_;
- my $response = "";
- if(-f $filename) {
- open FILE, "$filename";
- my $md5 = Digest::MD5->new;
- $md5->addfile (*FILE);
- $response = $md5->hexdigest;
- close (FILE);
- } else {
- $response = "Error";
- }
- return $response;
- }
- sub get_ip {
- my ($self,$hostname) = @_;
- my $response = "";
- if($hostname ne "") {
- try {
- my $handle_socket = gethostbyname($hostname);
- $response = inet_ntoa($handle_socket);
- } catch {
- $response = "Error";
- };
- } else {
- $response = "Error";
- }
- return $response;
- }
- sub destroy
- {
- my $self=shift;
- }
- 1;
- # The End ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement