Leser: 44
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
#!/usr/bin/perl use strict; use warnings; # History: # conray - 19.02.2010 : 19:31 UTC - initial version with ping (-p) # betterworld - 19.02.2010 : 19:44 UTC - minor changes # esskar - 19.02.2010 : 20:27 UTC - changes on ping, and dump myself command (-dump) # topeg - 19.02.2010 : 00:02 UTC - addded mirror # Kalle - 01.03.2010 - added technology assimilation automation use FindBin; use Net::Ping; #EierlegendeWollMilchSau.pl my $cmd = lc shift @ARGV; if ($cmd eq '-p' ) #ping { my $ip = shift @ARGV or die "No ip."; my @r = split(/\./, $ip); my $till = shift(@ARGV) || $r[3]; my $until = $till + 1; while ($r[3] < $until ) { $ip = join '.', @r; my $ping = Net::Ping->new('icmp', 1, 64 ); print "$ip " . ($ping->ping($ip) ? 'online' : 'offline') . "\n"; $r[3]++; } } elsif($cmd eq '-dump') { my $path = "$FindBin::Bin/$FindBin::Script"; open(my $myself, "< $path") or die "Unable to open myself ($path): $!"; while(<$myself>) { print $_; } close $myself; } elsif( $cmd eq '-devil' ) { print "So long, and thanks for all the fish.\n"; unlink $0 or die "Will not stop :'-(\n"; } elsif($cmd eq '-mirror') { my $fh=\*STDIN; my $file=shift; open($fh,'<',$file) || die("ERROR open $file ($!)") if($file); chomp($_) && print reverse($_)."\n" while(<$fh>); close($fh); } elsif($cmd eq '-assimilate') { my $newtechsource=shift @ARGV; my $borgtechnology; my $assimilationspace; my $newtechnology; my $biomemorycube; my ($newcmdname)=split(/\./,$newtechsource,0); use File::Basename; my ($borgbase,$borgpath)=fileparse($0); my $newborgtechnology="${borgpath}Neue$borgbase"; if (open($borgtechnology,'<',$0)) { if (open($assimilationspace,'>',$newborgtechnology)) { if (open($newtechnology,'<',$newtechsource)) { while(<$borgtechnology>) { if (/\\t-assimilate newparameter.pl\\t\\t/) { print $assimilationspace $_; print $assimilationspace " print \"\\t-$newcmdname\\t\\t assimilated weird stuff\\n\";\n"; } elsif (/^# elsif\(MORE\) \{ \}/) { my $thisline=$_; print "Assimiliere neue Technologie...\n"; print $assimilationspace "elsif(\$cmd eq \'-$newcmdname\')\n\{\n"; while(<$newtechnology>) { next if (/^#!|^use strict;|^use warnings;/); print $assimilationspace $_; } close($newtechnology); print $assimilationspace "\}\n$thisline"; } else { print $assimilationspace $_; } } close($borgtechnology); if (close($assimilationspace)) { print "Widerstand war zwecklos!\nNeue Technologie einsetzbar: Neue$borgbase -$newcmdname\n"; } else { print "Aktivierungssequenz ungültig. Assimilation abgebrochen.\n"; } } else { print "Neue Technologie kann nicht assimiliert werden. Abbruch der Assimilation\n"; } } else { print "Fluktuation im temporären Raum-/Zeitgefüge. Abbruch der Assimilation.\n"; } } else { print "Wo sind wir ? Es ist so....leise. Bring uns nach Hause!\n"; } } # elsif(MORE) { } <-- don't touch this else { print "usage: EierlegendeWollMilchSau.pl <parameters>\n\n"; print "parameters:\n"; print "\t-p <ip> [range]\t\ttrys to ping an ip or an range of ip addresses.\n"; print "\t-dump\t\t\tdumps itself to STDOUT\n"; print "\t-devil\t\t\tDon't try that\n"; print "\t-mirror [file]\t\t mirror file or STDIN\n"; print "\t-assimilate newparam.pl\t assimilate more perl code into this script\n"; print "\n"; exit 0; } __END__
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
#!/usr/bin/perl use strict; use warnings; # History: # conray - 19.02.2010 : 19:31 UTC - initial version with ping (-ping) # betterworld - 19.02.2010 : 19:44 UTC - minor changes # esskar - 19.02.2010 : 20:27 UTC - changes on ping, and dump myself command (-dump) # topeg - 19.02.2010 : 00:02 UTC - addded mirror # Kalle - 01.03.2010 - added technology assimilation automation # conray - 02.02.2010 21:07 - added Helpfunktion (-help) and changes on Ping-Parameter use FindBin; use Net::Ping; #EierlegendeWollMilchSau.pl my $cmd = lc shift @ARGV; if ($cmd eq '-ping' ) #ping { my $ip = shift @ARGV or die "No ip."; my @r = split(/\./, $ip); my $till = shift(@ARGV) || $r[3]; my $until = $till + 1; while ($r[3] < $until ) { $ip = join '.', @r; my $ping = Net::Ping->new('icmp', 1, 64 ); print "$ip " . ($ping->ping($ip) ? 'online' : 'offline') . "\n"; $r[3]++; } } elsif($cmd eq '-dump') { my $path = "$FindBin::Bin/$FindBin::Script"; open(my $myself, "< $path") or die "Unable to open myself ($path): $!"; while(<$myself>) { print $_; } close $myself; } elsif( $cmd eq '-devil' ) { print "So long, and thanks for all the fish.\n"; unlink $0 or die "Will not stop :'-(\n"; } elsif($cmd eq '-mirror') { my $fh=\*STDIN; my $file=shift; open($fh,'<',$file) || die("ERROR open $file ($!)") if($file); chomp($_) && print reverse($_)."\n" while(<$fh>); close($fh); } elsif($cmd eq '-assimilate') { my $newtechsource=shift @ARGV; my $borgtechnology; my $assimilationspace; my $newtechnology; my $biomemorycube; my ($newcmdname)=split(/\./,$newtechsource,0); use File::Basename; my ($borgbase,$borgpath)=fileparse($0); my $newborgtechnology="${borgpath}Neue$borgbase"; if (open($borgtechnology,'<',$0)) { if (open($assimilationspace,'>',$newborgtechnology)) { if (open($newtechnology,'<',$newtechsource)) { while(<$borgtechnology>) { if (/\\t-assimilate newparameter.pl\\t\\t/) { print $assimilationspace $_; print $assimilationspace " print \"\\t-$newcmdname\\t\\t assimilated weird stuff\\n\";\n"; } elsif (/^# elsif\(MORE\) \{ \}/) { my $thisline=$_; print "Assimiliere neue Technologie...\n"; print $assimilationspace "elsif(\$cmd eq \'-$newcmdname\')\n\{\n"; while(<$newtechnology>) { next if (/^#!|^use strict;|^use warnings;/); print $assimilationspace $_; } close($newtechnology); print $assimilationspace "\}\n$thisline"; } else { print $assimilationspace $_; } } close($borgtechnology); if (close($assimilationspace)) { print "Widerstand war zwecklos!\nNeue Technologie einsetzbar: Neue$borgbase -$newcmdname\n"; } else { print "Aktivierungssequenz ungültig. Assimilation abgebrochen.\n"; } } else { print "Neue Technologie kann nicht assimiliert werden. Abbruch der Assimilation\n"; } } else { print "Fluktuation im temporären Raum-/Zeitgefüge. Abbruch der Assimilation.\n"; } } else { print "Wo sind wir ? Es ist so....leise. Bring uns nach Hause!\n"; } } elsif($cmd eq '-help') { print "usage: EierlegendeWollMilchSau.pl <parameters>\n\n"; print "parameters:\n"; print "\t-ping <ip> [range]\t\ttrys to ping an ip or an range of ip addresses.\n"; print "\t-dump\t\t\tdumps itself to STDOUT\n"; print "\t-devil\t\t\tDon't try that\n"; print "\t-mirror [file]\t\t mirror file or STDIN\n"; print "\t-assimilate newparam.pl\t assimilate more perl code into this script\n"; print "\n"; } # elsif(MORE) { } <-- don't touch this else { print "Type ./EierlegendeMilchSau.pl -help for more informations \n"; exit 0; } __END__
2010-03-01T22:59:29 KalleCode (perl): (dl )1 2 3 4 5 6 7[...] my ($borgbase,$borgpath)=fileparse($0); [...] else { print "Wo sind wir ? Es ist so....leise. Bring uns nach Hause!\n"; } [...]
Quote[...]
Leider gabs ein Permission denied beim Versuch das Sourcefile zu unlinken und das neue pl umzubennen.
[...]
2010-03-03T00:15:09 murphyDurch Verwendung vonFindBin, was in dem Skript sowieso schon geladen ist, könnten die Borg hier die Zuverlässigkeit der Subraumverbindung zum Kollektiv verbessern ;-)
Quote[...]
Leider gabs ein Permission denied beim Versuch das Sourcefile zu unlinken und das neue pl umzubennen.
[...]
Ich dachte Widerstand sei zwecklos ;-) Man könnte sich ja zum Beispiel auch mitTie::File öffnen und den neuen Code in das entstehende virtuelle Array splicen — löschen kann man ein offenes Skript zwar nicht auf allen Betriebssystemen, aber modifizieren müsste man es können!
2010-03-03T08:52:54 Kalle[...]
Zumindest lese ich immer wieder, daß man FindBin benutzen solle, aber $0 kommt hier ja extrem praktisch.
Kann man sich darauf nicht verlassen ?
[...]
Quote[Tie::File]
Gute Idee, obwohl mir an sich nicht wirklich wohl wäre, zur Laufzeit ein Programm zu verändern. Zumindest bei Stapeldateien sollte man das tunlichst vermeiden :)
QuoteBei Perl dachte ich eigentlich, daß das ganze Sourcefile erstmal eingelesen wird und verstehe daher nicht, warum das überhaupt gelocked ist.
QuoteMeinst du da ist vielleicht nur ein Readlock drauf, um zu vermeiden, daß es beim Einlesen plötzlich gelöscht wird und man könnte es trotzdem noch schreibend öffnen ? hmm...vielleicht hing der Lock auch mit Optiperl zusammen oder mit den Bu..ääh features von Windows.
2010-03-03T12:11:31 murphyWenn das Skript aber korrekt mit dem Perlinterpreter verknüpft ist, im Pfad liegt und aus einem ganz anderen Arbeitsverzeichnis aufgerufen wird, kann es sein, dass in $0 einfach nur der Name des Skriptes steht, aber kein Pfad der relativ zum aktuellen Arbeitsverzeichnis auf das Skript zeigt.
open 0 or die $!; print <0>;
print __FILE__;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
#!/usr/bin/perl use strict; use warnings; # History: # conray - 19.02.2010 : 19:31 UTC - initial version with ping (-ping) # betterworld - 19.02.2010 : 19:44 UTC - minor changes # esskar - 19.02.2010 : 20:27 UTC - changes on ping, and dump myself command (-dump) # topeg - 19.02.2010 : 00:02 UTC - addded mirror # Kalle - 01.03.2010 - added technology assimilation automation # conray - 02.02.2010 21:07 - added Helpfunktion (-help) and changes on Ping-Parameter # conray - 03.02.2010 19:28 - added Password-Generator (-pwgen) use FindBin; use Net::Ping; #EierlegendeWollMilchSau.pl my $cmd = lc shift @ARGV; if ($cmd eq '-ping' ) #ping { my $ip = shift @ARGV or die "No ip."; my @r = split(/\./, $ip); my $till = shift(@ARGV) || $r[3]; my $until = $till + 1; while ($r[3] < $until ) { $ip = join '.', @r; my $ping = Net::Ping->new('icmp', 1, 64 ); print "$ip " . ($ping->ping($ip) ? 'online' : 'offline') . "\n"; $r[3]++; } } elsif($cmd eq '-dump') { my $path = "$FindBin::Bin/$FindBin::Script"; open(my $myself, "< $path") or die "Unable to open myself ($path): $!"; while(<$myself>) { print $_; } close $myself; } elsif( $cmd eq '-devil' ) { print "So long, and thanks for all the fish.\n"; unlink $0 or die "Will not stop :'-(\n"; } elsif($cmd eq '-mirror') { my $fh=\*STDIN; my $file=shift; open($fh,'<',$file) || die("ERROR open $file ($!)") if($file); chomp($_) && print reverse($_)."\n" while(<$fh>); close($fh); } elsif($cmd eq '-assimilate') { my $newtechsource=shift @ARGV; my $borgtechnology; my $assimilationspace; my $newtechnology; my $biomemorycube; my ($newcmdname)=split(/\./,$newtechsource,0); use File::Basename; my ($borgbase,$borgpath)=fileparse($0); my $newborgtechnology="${borgpath}Neue$borgbase"; if (open($borgtechnology,'<',$0)) { if (open($assimilationspace,'>',$newborgtechnology)) { if (open($newtechnology,'<',$newtechsource)) { while(<$borgtechnology>) { if (/\\t-assimilate newparameter.pl\\t\\t/) { print $assimilationspace $_; print $assimilationspace " print \"\\t-$newcmdname\\t\\t assimilated weird stuff\\n\";\n"; } elsif (/^# elsif\(MORE\) \{ \}/) { my $thisline=$_; print "Assimiliere neue Technologie...\n"; print $assimilationspace "elsif(\$cmd eq \'-$newcmdname\')\n\{\n"; while(<$newtechnology>) { next if (/^#!|^use strict;|^use warnings;/); print $assimilationspace $_; } close($newtechnology); print $assimilationspace "\}\n$thisline"; } else { print $assimilationspace $_; } } close($borgtechnology); if (close($assimilationspace)) { print "Widerstand war zwecklos!\nNeue Technologie einsetzbar: Neue$borgbase -$newcmdname\n"; } else { print "Aktivierungssequenz ungültig. Assimilation abgebrochen.\n"; } } else { print "Neue Technologie kann nicht assimiliert werden. Abbruch der Assimilation\n"; } } else { print "Fluktuation im temporären Raum-/Zeitgefüge. Abbruch der Assimilation.\n"; } } else { print "Wo sind wir ? Es ist so....leise. Bring uns nach Hause!\n"; } } elsif ($cmd eq '-pwgen') { print "How much positions your password should have?\n"; print "Note: Secure passwords have 10 positions as minimum \n"; my $input=<STDIN>; chomp $input; my @bletters = ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"); my @sletters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); my @numbers = ("1", "2", "3", "4", "5", "6", "7", "8", "9", "0"); my @special = ("!", "\.", "\$", "\%", "\&", "?", "\/", "\\", "\,", "-", "_", "\#", "\*", ":", "(", ")", "=", "+", "<", "§", "[", "]", "\;"); our $pw; while (length($pw) != $input) { my $n1 = int(rand(26)); my $n2 = int(rand(26)); my $n3 = int(rand(10)); my $n4 = int(rand(23)); my $z = int(rand(4)); if ($z == 0) { $pw = $pw . $bletters[$n1]; } elsif ($z == 1) { $pw = $pw . $sletters[$n2]; } elsif ($z == 2) { $pw = $pw . $numbers[$n3]; } elsif ($z == 3) { $pw = $pw . $special[$n4]; } else { print "There is bug"; exit; } } print "The generated Password is: $pw \n"; } elsif($cmd eq '-help') { print "usage: EierlegendeWollMilchSau.pl <parameters>\n\n"; print "parameters:\n"; print "\t-ping <ip> [range]\t\ttrys to ping an ip or an range of ip addresses.\n"; print "\t-dump\t\t\tdumps itself to STDOUT\n"; print "\t-devil\t\t\tDon't try that\n"; print "\t-mirror [file]\t\t mirror file or STDIN\n"; print "\t-assimilate newparam.pl\t assimilate more perl code into this script\n"; print "\t-pwgen generates an (secure) password\n"; print "\n"; } # elsif(MORE) { } <-- don't touch this else { print "Type ./EierlegendeMilchSau.pl -help for more informations \n"; exit 0; } __END__
shift @ARGV
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#! /usr/bin/perl use strict; use warnings; use Getopt::Long; my $had_action = 0; # sub routines # ############################ sub parse_options { GetOptions( 'ping' => \&do_ping, 'dump' => \&do_dump, # ... ) or exit 1; }; sub do_ping { # insert code for pinging } sub do_dump { # insert code for dumping } # ... # main program # ############################ parse_options(); __END__
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
#!/usr/bin/perl use strict; use warnings; # History: # conray - 19.02.2010 : 19:31 UTC - initial version with ping (-ping) # betterworld - 19.02.2010 : 19:44 UTC - minor changes # esskar - 19.02.2010 : 20:27 UTC - changes on ping, and dump myself command (-dump) # topeg - 19.02.2010 : 00:02 UTC - addded mirror # Kalle - 01.03.2010 - added technology assimilation automation # conray - 02.02.2010 21:07 - added Helpfunktion (-help) and changes on Ping-Parameter # conray - 03.02.2010 19:28 - added Password-Generator (-pwgen) use FindBin; use Net::Ping; #EierlegendeWollMilchSau.pl my $cmd = lc shift @ARGV; if ($cmd eq '-ping' ) #ping { my $ip = shift @ARGV or die "No ip."; my @r = split(/\./, $ip); my $till = shift(@ARGV) || $r[3]; my $until = $till + 1; while ($r[3] < $until ) { $ip = join '.', @r; my $ping = Net::Ping->new('icmp', 1, 64 ); print "$ip " . ($ping->ping($ip) ? 'online' : 'offline') . "\n"; $r[3]++; } } elsif($cmd eq '-dump') { my $path = "$FindBin::Bin/$FindBin::Script"; open(my $myself, "< $path") or die "Unable to open myself ($path): $!"; while(<$myself>) { print $_; } close $myself; } elsif( $cmd eq '-devil' ) { print "So long, and thanks for all the fish.\n"; unlink $0 or die "Will not stop :'-(\n"; } elsif($cmd eq '-mirror') { my $fh=\*STDIN; my $file=shift; open($fh,'<',$file) || die("ERROR open $file ($!)") if($file); chomp($_) && print reverse($_)."\n" while(<$fh>); close($fh); } elsif($cmd eq '-assimilate') { my $newtechsource=shift @ARGV; my $borgtechnology; my $assimilationspace; my $newtechnology; my ($newcmdname)=split(/\./,$newtechsource,0); use File::Basename; my ($borgbase,$borgpath)=fileparse($0); my $newborgtechnology="${borgpath}Neue$borgbase"; if (open($borgtechnology,'<',$0)) { if (open($assimilationspace,'>',$newborgtechnology)) { if (open($newtechnology,'<',$newtechsource)) { while(<$borgtechnology>) { if (/\\t-assimilate newparam.pl\\t/) { print $assimilationspace $_; print $assimilationspace " print \"\\t-$newcmdname\\t\\t assimilated weird stuff\\n\";\n"; } elsif (/^# elsif\(MORE\) \{ \}/) { my $thisline=$_; print "Assimiliere neue Technologie...\n"; print $assimilationspace "elsif(\$cmd eq \'-$newcmdname\')\n\{\n"; while(<$newtechnology>) { next if (/^#!|^use strict;|^use warnings;/); print $assimilationspace $_; } close($newtechnology); print $assimilationspace "\}\n$thisline"; } else { print $assimilationspace $_; } } close($borgtechnology); if (close($assimilationspace)) { print "Widerstand war zwecklos!\nNeue Technologie einsetzbar: Neue$borgbase -$newcmdname\n"; } else { print "Aktivierungssequenz ungültig. Assimilation abgebrochen.\n"; } } else { print "Neue Technologie kann nicht assimiliert werden. Abbruch der Assimilation\n"; } } else { print "Fluktuation im temporären Raum-/Zeitgefüge. Abbruch der Assimilation.\n"; } } else { print "Wo sind wir ? Es ist so....leise. Bring uns nach Hause!\n"; } } elsif ($cmd eq '-pwgen') { print "How much positions your password should have?\n"; print "Note: Secure passwords have 10 positions as minimum \n"; my $input=<STDIN>; chomp $input; my @bletters = ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"); my @sletters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); my @numbers = ("1", "2", "3", "4", "5", "6", "7", "8", "9", "0"); my @special = ("!", "\.", "\$", "\%", "\&", "?", "\/", "\\", "\,", "-", "_", "\#", "\*", ":", "(", ")", "=", "+", "<", "§", "[", "]", "\;"); our $pw; while (length($pw) != $input) { my $n1 = int(rand(26)); my $n2 = int(rand(26)); my $n3 = int(rand(10)); my $n4 = int(rand(23)); my $z = int(rand(4)); if ($z == 0) { $pw = $pw . $bletters[$n1]; } elsif ($z == 1) { $pw = $pw . $sletters[$n2]; } elsif ($z == 2) { $pw = $pw . $numbers[$n3]; } elsif ($z == 3) { $pw = $pw . $special[$n4]; } else { print "There is bug"; exit; } } print "The generated Password is: $pw \n"; } elsif($cmd eq '-help') { print "usage: EierlegendeWollMilchSau.pl <parameters>\n\n"; print "parameters:\n"; print "\t-ping <ip> [range]\t\ttrys to ping an ip or an range of ip addresses.\n"; print "\t-dump\t\t\tdumps itself to STDOUT\n"; print "\t-devil\t\t\tDon't try that\n"; print "\t-mirror [file]\t\t mirror file or STDIN\n"; print "\t-assimilate newparam.pl\t assimilate more perl code into this script\n"; #<-- don't touch this print "\t-pwgen generates an (secure) password\n"; print "\n"; } # elsif(MORE) { } <-- don't touch this else { print "Type ./EierlegendeMilchSau.pl -help for more informations \n"; exit 0; } __END__
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
#!/usr/bin/perl use strict; use warnings; # History: # conray - 19.02.2010 : 19:31 UTC - initial version with ping (-ping) # betterworld - 19.02.2010 : 19:44 UTC - minor changes # esskar - 19.02.2010 : 20:27 UTC - changes on ping, and dump myself command (-dump) # topeg - 19.02.2010 : 00:02 UTC - addded mirror # Kalle - 01.03.2010 - added technology assimilation automation # conray - 02.02.2010 21:07 - added Helpfunktion (-help) and changes on Ping-Parameter # conray - 03.02.2010 19:28 - added Password-Generator (-pwgen) #conray - 08.03.2010 21:35 - added print location (-whereami) use FindBin; use Net::Ping; #EierlegendeWollMilchSau.pl my $cmd = lc shift @ARGV; if ($cmd eq '-ping' ) #ping { my $ip = shift @ARGV or die "No ip."; my @r = split(/\./, $ip); my $till = shift(@ARGV) || $r[3]; my $until = $till + 1; while ($r[3] < $until ) { $ip = join '.', @r; my $ping = Net::Ping->new('icmp', 1, 64 ); print "$ip " . ($ping->ping($ip) ? 'online' : 'offline') . "\n"; $r[3]++; } } elsif($cmd eq '-dump') { my $path = "$FindBin::Bin/$FindBin::Script"; open(my $myself, "< $path") or die "Unable to open myself ($path): $!"; while(<$myself>) { print $_; } close $myself; } elsif( $cmd eq '-devil' ) { print "So long, and thanks for all the fish.\n"; unlink $0 or die "Will not stop :'-(\n"; } elsif($cmd eq '-mirror') { my $fh=\*STDIN; my $file=shift; open($fh,'<',$file) || die("ERROR open $file ($!)") if($file); chomp($_) && print reverse($_)."\n" while(<$fh>); close($fh); } elsif($cmd eq '-assimilate') { my $newtechsource=shift @ARGV; my $borgtechnology; my $assimilationspace; my $newtechnology; my ($newcmdname)=split(/\./,$newtechsource,0); use File::Basename; my ($borgbase,$borgpath)=fileparse($0); my $newborgtechnology="${borgpath}Neue$borgbase"; if (open($borgtechnology,'<',$0)) { if (open($assimilationspace,'>',$newborgtechnology)) { if (open($newtechnology,'<',$newtechsource)) { while(<$borgtechnology>) { if (/\\t-assimilate newparam.pl\\t/) { print $assimilationspace $_; print $assimilationspace " print \"\\t-$newcmdname\\t\\t assimilated weird stuff\\n\";\n"; } elsif (/^# elsif\(MORE\) \{ \}/) { my $thisline=$_; print "Assimiliere neue Technologie...\n"; print $assimilationspace "elsif(\$cmd eq \'-$newcmdname\')\n\{\n"; while(<$newtechnology>) { next if (/^#!|^use strict;|^use warnings;/); print $assimilationspace $_; } close($newtechnology); print $assimilationspace "\}\n$thisline"; } else { print $assimilationspace $_; } } close($borgtechnology); if (close($assimilationspace)) { print "Widerstand war zwecklos!\nNeue Technologie einsetzbar: Neue$borgbase -$newcmdname\n"; } else { print "Aktivierungssequenz ungültig. Assimilation abgebrochen.\n"; } } else { print "Neue Technologie kann nicht assimiliert werden. Abbruch der Assimilation\n"; } } else { print "Fluktuation im temporären Raum-/Zeitgefüge. Abbruch der Assimilation.\n"; } } else { print "Wo sind wir ? Es ist so....leise. Bring uns nach Hause!\n"; } } elsif ($cmd eq '-pwgen') { print "How much positions your password should have?\n"; print "Note: Secure passwords have 10 positions as minimum \n"; my $input=<STDIN>; chomp $input; my @bletters = ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"); my @sletters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); my @numbers = ("1", "2", "3", "4", "5", "6", "7", "8", "9", "0"); my @special = ("!", "\.", "\$", "\%", "\&", "?", "\/", "\\", "\,", "-", "_", "\#", "\*", ":", "(", ")", "=", "+", "<", "§", "[", "]", "\;"); our $pw; while (length($pw) != $input) { my $n1 = int(rand(26)); my $n2 = int(rand(26)); my $n3 = int(rand(10)); my $n4 = int(rand(23)); my $z = int(rand(4)); if ($z == 0) { $pw = $pw . $bletters[$n1]; } elsif ($z == 1) { $pw = $pw . $sletters[$n2]; } elsif ($z == 2) { $pw = $pw . $numbers[$n3]; } elsif ($z == 3) { $pw = $pw . $special[$n4]; } else { print "There is bug"; exit; } } print "The generated Password is: $pw \n"; } elsif($cmd eq '-help') { print "usage: EierlegendeWollMilchSau.pl <parameters>\n\n"; print "parameters:\n"; print "\t-ping <ip> [range]\t\ttrys to ping an ip or an range of ip addresses.\n"; print "\t-dump\t\t\tdumps itself to STDOUT\n"; print "\t-devil\t\t\tDon't try that\n"; print "\t-mirror [file]\t\t mirror file or STDIN\n"; print "\t-assimilate newparam.pl\t assimilate more perl code into this script\n"; #<-- don't touch this print "\t-pwgen generates an (secure) password\n"; print "\n"; } elseif ($cmd eq -whereami) { print __FILE__; } # elsif(MORE) { } <-- don't touch this else { print "Type ./EierlegendeMilchSau.pl -help for more informations \n"; exit 0; } __END__
print "$0\n";
perl -e '$/=undef; eval(<>)' snull.pl
Guest wer:-)Code: (dl )perl -e '$/=undef; eval(<>)' snull.pl
perl -e "$/=undef; eval(<>)" snull.pl
2010-03-04T02:08:00 murphydass ich zu sehr von meinen Erfahrungen mit Binärprogrammen beeinflusst war, wo man im Äquivalent zu $0 genau den zum Aufruf verwendeten Namen des Programmes vorfindet.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$ cat interp.c
#include <stdio.h>
#include <stdlib.h>
int
main (int argc, char *argv[])
{
for (int i=0; i<argc; i++) {
printf("%d: \"%s\"\n", i, argv[i]);
}
return 0;
}
$ cat script
#!/tmp/interp -blah
$ ./script eins zwei
0: "/tmp/interp"
1: "-blah"
2: "./script"
3: "eins"
4: "zwei"
$ ( exec -a null ./script eins zwei )
0: "/tmp/interp"
1: "-blah"
2: "/tmp/script"
3: "eins"
4: "zwei"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
#!/usr/bin/perl use strict; use warnings; # History: # conray - 19.02.2010 : 19:31 UTC - initial version with ping (-ping) # betterworld - 19.02.2010 : 19:44 UTC - minor changes # esskar - 19.02.2010 : 20:27 UTC - changes on ping, and dump myself command (-dump) # topeg - 19.02.2010 : 00:02 UTC - addded mirror # Kalle - 01.03.2010 - added technology assimilation automation # conray - 02.02.2010 21:07 - added Helpfunktion (-help) and changes on Ping-Parameter # conray - 03.02.2010 19:28 - added Password-Generator (-pwgen) #conray - 08.03.2010 21:35 - added print location (-whereami) use FindBin; use Net::Ping; #EierlegendeWollMilchSau.pl my $cmd = lc shift @ARGV; if ($cmd eq '-ping' ) #ping { my $ip = shift @ARGV or die "No ip."; my @r = split(/\./, $ip); my $till = shift(@ARGV) || $r[3]; my $until = $till + 1; while ($r[3] < $until ) { $ip = join '.', @r; my $ping = Net::Ping->new('icmp', 1, 64 ); print "$ip " . ($ping->ping($ip) ? 'online' : 'offline') . "\n"; $r[3]++; } } elsif($cmd eq '-dump') { my $path = "$FindBin::Bin/$FindBin::Script"; open(my $myself, "< $path") or die "Unable to open myself ($path): $!"; while(<$myself>) { print $_; } close $myself; } elsif( $cmd eq '-devil' ) { print "So long, and thanks for all the fish.\n"; unlink $0 or die "Will not stop :'-(\n"; } elsif($cmd eq '-mirror') { my $fh=\*STDIN; my $file=shift; open($fh,'<',$file) || die("ERROR open $file ($!)") if($file); chomp($_) && print reverse($_)."\n" while(<$fh>); close($fh); } elsif($cmd eq '-assimilate') { my $newtechsource=shift @ARGV; my $borgtechnology; my $assimilationspace; my $newtechnology; my ($newcmdname)=split(/\./,$newtechsource,0); use File::Basename; my ($borgbase,$borgpath)=fileparse($0); my $newborgtechnology="${borgpath}Neue$borgbase"; if (open($borgtechnology,'<',$0)) { if (open($assimilationspace,'>',$newborgtechnology)) { if (open($newtechnology,'<',$newtechsource)) { while(<$borgtechnology>) { if (/\\t-assimilate newparam.pl\\t/) { print $assimilationspace $_; print $assimilationspace " print \"\\t-$newcmdname\\t\\t assimilated weird stuff\\n\";\n"; } elsif (/^# elsif\(MORE\) \{ \}/) { my $thisline=$_; print "Assimiliere neue Technologie...\n"; print $assimilationspace "elsif(\$cmd eq \'-$newcmdname\')\n\{\n"; while(<$newtechnology>) { next if (/^#!|^use strict;|^use warnings;/); print $assimilationspace $_; } close($newtechnology); print $assimilationspace "\}\n$thisline"; } else { print $assimilationspace $_; } } close($borgtechnology); if (close($assimilationspace)) { print "Widerstand war zwecklos!\nNeue Technologie einsetzbar: Neue$borgbase -$newcmdname\n"; } else { print "Aktivierungssequenz ungültig. Assimilation abgebrochen.\n"; } } else { print "Neue Technologie kann nicht assimiliert werden. Abbruch der Assimilation\n"; } } else { print "Fluktuation im temporären Raum-/Zeitgefüge. Abbruch der Assimilation.\n"; } } else { print "Wo sind wir ? Es ist so....leise. Bring uns nach Hause!\n"; } } elsif ($cmd eq '-pwgen') { print "How much positions your password should have?\n"; print "Note: Secure passwords have 10 positions as minimum \n"; my $input=<STDIN>; chomp $input; my @bletters = ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"); my @sletters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); my @numbers = ("1", "2", "3", "4", "5", "6", "7", "8", "9", "0"); my @special = ("!", "\.", "\$", "\%", "\&", "?", "\/", "\\", "\,", "-", "_", "\#", "\*", ":", "(", ")", "=", "+", "<", "§", "[", "]", "\;"); our $pw; while (length($pw) != $input) { my $n1 = int(rand(26)); my $n2 = int(rand(26)); my $n3 = int(rand(10)); my $n4 = int(rand(23)); my $z = int(rand(4)); if ($z == 0) { $pw = $pw . $bletters[$n1]; } elsif ($z == 1) { $pw = $pw . $sletters[$n2]; } elsif ($z == 2) { $pw = $pw . $numbers[$n3]; } elsif ($z == 3) { $pw = $pw . $special[$n4]; } else { print "There is bug"; exit; } } print "The generated Password is: $pw \n"; } elsif($cmd eq '-help') { print "usage: EierlegendeWollMilchSau.pl <parameters>\n\n"; print "parameters:\n"; print "\t-ping <ip> [range]\t\ttrys to ping an ip or an range of ip addresses.\n"; print "\t-dump\t\t\tdumps itself to STDOUT\n"; print "\t-devil\t\t\tDon't try that\n"; print "\t-mirror [file]\t\t mirror file or STDIN\n"; print "\t-assimilate newparam.pl\t assimilate more perl code into this script\n"; #<-- don't touch this print "\t-pwgen generates an (secure) password\n"; print "\n"; } elsif ($cmd eq '-whereami') { print __FILE__; } # elsif(MORE) { } <-- don't touch this else { print "Type ./EierlegendeMilchSau.pl -help for more informations \n"; exit 0; } __END__
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/usr/bin/perl
use strict;
use warnings;
# History:
# conray - 19.02.2010 : 19:31 UTC - initial version with ping (-ping)
# betterworld - 19.02.2010 : 19:44 UTC - minor changes
# esskar - 19.02.2010 : 20:27 UTC - changes on ping, and dump myself command (-dump)
# topeg - 19.02.2010 : 00:02 UTC - addded mirror
# Kalle - 01.03.2010 - added technology assimilation automation
# conray - 02.02.2010 21:07 - added Helpfunktion (-help) and changes on Ping-Parameter
# conray - 03.02.2010 19:28 - added Password-Generator (-pwgen)
#conray - 08.03.2010 21:35 - added print location (-whereami)
#steferbo - 08.03.2010 23:10 - added get country from ip (-get_country)
use FindBin;
use Net::Ping;
#EierlegendeWollMilchSau.pl
my $cmd = lc shift @ARGV;
if ($cmd eq '-ping' ) #ping
{
my $ip = shift @ARGV
or die "No ip.";
my @r = split(/\./, $ip);
my $till = shift(@ARGV) || $r[3];
my $until = $till + 1;
while ($r[3] < $until )
{
$ip = join '.', @r;
my $ping = Net::Ping->new('icmp', 1, 64 );
print "$ip " . ($ping->ping($ip) ? 'online' : 'offline') . "\n";
$r[3]++;
}
}
elsif($cmd eq '-dump')
{
my $path = "$FindBin::Bin/$FindBin::Script";
open(my $myself, "< $path") or die "Unable to open myself ($path): $!";
while(<$myself>) { print $_; }
close $myself;
}
elsif( $cmd eq '-devil' )
{
print "So long, and thanks for all the fish.\n";
unlink $0 or die "Will not stop :'-(\n";
}
elsif($cmd eq '-mirror')
{
my $fh=\*STDIN;
my $file=shift;
open($fh,'<',$file) || die("ERROR open $file ($!)") if($file);
chomp($_) && print reverse($_)."\n" while(<$fh>);
close($fh);
}
elsif($cmd eq '-assimilate')
{
my $newtechsource=shift @ARGV;
my $borgtechnology;
my $assimilationspace;
my $newtechnology;
my ($newcmdname)=split(/\./,$newtechsource,0);
use File::Basename;
my ($borgbase,$borgpath)=fileparse($0);
my $newborgtechnology="${borgpath}Neue$borgbase";
if (open($borgtechnology,'<',$0)) {
if (open($assimilationspace,'>',$newborgtechnology)) {
if (open($newtechnology,'<',$newtechsource)) {
while(<$borgtechnology>) {
if (/\\t-assimilate newparam.pl\\t/) {
print $assimilationspace $_;
print $assimilationspace " print \"\\t-$newcmdname\\t\\t assimilated weird stuff\\n\";\n";
}
elsif (/^# elsif\(MORE\) \{ \}/) {
my $thisline=$_;
print "Assimiliere neue Technologie...\n";
print $assimilationspace "elsif(\$cmd eq \'-$newcmdname\')\n\{\n";
while(<$newtechnology>) {
next if (/^#!|^use strict;|^use warnings;/);
print $assimilationspace $_;
}
close($newtechnology);
print $assimilationspace "\}\n$thisline";
}
else {
print $assimilationspace $_;
}
}
close($borgtechnology);
if (close($assimilationspace)) {
print "Widerstand war zwecklos!\nNeue Technologie einsetzbar: Neue$borgbase -$newcmdname\n";
}
else {
print "Aktivierungssequenz ungültig. Assimilation abgebrochen.\n";
}
}
else {
print "Neue Technologie kann nicht assimiliert werden. Abbruch der Assimilation\n";
}
}
else {
print "Fluktuation im temporären Raum-/Zeitgefüge. Abbruch der Assimilation.\n";
}
}
else {
print "Wo sind wir ? Es ist so....leise. Bring uns nach Hause!\n";
}
}
elsif ($cmd eq '-pwgen')
{
print "How much positions your password should have?\n";
print "Note: Secure passwords have 10 positions as minimum \n";
my $input=<STDIN>;
chomp $input;
my @bletters = ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
my @sletters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
my @numbers = ("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
my @special = ("!", "\.", "\$", "\%", "\&", "?", "\/", "\\", "\,", "-", "_", "\#", "\*", ":", "(", ")", "=", "+", "<", "§", "[", "]", "\;");
our $pw;
while (length($pw) != $input) {
my $n1 = int(rand(26));
my $n2 = int(rand(26));
my $n3 = int(rand(10));
my $n4 = int(rand(23));
my $z = int(rand(4));
if ($z == 0) {
$pw = $pw . $bletters[$n1]; }
elsif ($z == 1) {
$pw = $pw . $sletters[$n2]; }
elsif ($z == 2) {
$pw = $pw . $numbers[$n3]; }
elsif ($z == 3) {
$pw = $pw . $special[$n4]; }
else {
print "There is bug";
exit; }
}
print "The generated Password is: $pw \n";
}
elsif($cmd eq '-help')
{
print "usage: EierlegendeWollMilchSau.pl <parameters>\n\n";
print "parameters:\n";
print "\t-ping <ip> [range]\t\ttrys to ping an ip or an range of ip addresses.\n";
print "\t-dump\t\t\tdumps itself to STDOUT\n";
print "\t-devil\t\t\tDon't try that\n";
print "\t-mirror [file]\t\t mirror file or STDIN\n";
print "\t-assimilate newparam.pl\t assimilate more perl code into this script\n"; #<-- don't touch this
print "\t-get_country\t\t assimilated weird stuff\n";
print "\t-pwgen generates an (secure) password\n";
print "\t-get_country <ip> \t single-host 32bit decimal\n";
print "\n";
}
elsif ($cmd eq '-whereami') {
print __FILE__;
}
elsif($cmd eq '-get_country')
{
my $ip = shift @ARGV;
my $line=""; my $country=""; my $out="IP: $ip is non-registered";
my $whois="http://www.utrace.de/whois/";
my $hol=$whois.$ip;
my $html=stuff($hol);
$html =~ s/<([^>]|\n)*>//mig;
$html =~ s/ //mig;
(my @text)=split(/\n/,$html);
foreach $line (@text){
if( $line =~ /country:/ig ){
$line =~ s/\s//ig;
(my $nix, $country)=split(/:/,$line);
$out="IP: $ip has country-code: $country";
goto ELMS;
} # end if
} # end foeach
ELMS:
print $out;
sub stuff {
use LWP::UserAgent;
use HTTP::Cookies;
my $url=shift;
my $agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.18) EierlegendeMilchSau/1.0.0";
my $cookie = HTTP::Cookies->new;
my $req = HTTP::Request->new(GET => $url);
$req->header('Referer', '');
$req->header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
$req->header('Accept-Language', 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3');
$req->header('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7');
$req->header('Keep-Alive', '115');
$req->header('Cache-Control', 'max-age=0');
my $browser = LWP::UserAgent->new;
$browser -> agent($agent);
$browser -> cookie_jar($cookie);
my $res = $browser->request($req);
my $stuff = $res->content;
return ($stuff);
}# end sub stuff
}
# elsif(MORE) { } <-- don't touch this
else
{
print "Type ./EierlegendeMilchSau.pl -help for more informations \n";
exit 0;
}
__END__
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
#!/usr/bin/perl use strict; use warnings; # History: # conray - 19.02.2010 : 19:31 UTC - initial version with ping (-ping) # betterworld - 19.02.2010 : 19:44 UTC - minor changes # esskar - 19.02.2010 : 20:27 UTC - changes on ping, and dump myself command (-dump) # topeg - 19.02.2010 : 00:02 UTC - addded mirror # Kalle - 01.03.2010 - added technology assimilation automation # conray - 02.02.2010 21:07 - added Helpfunktion (-help) and changes on Ping-Parameter # conray - 03.02.2010 19:28 - added Password-Generator (-pwgen) #conray - 08.03.2010 21:35 - added print location (-whereami) #steferbo - 08.03.2010 23:10 - added get country from ip (-get_country) use FindBin; use Net::Ping; #EierlegendeWollMilchSau.pl my $cmd = lc shift @ARGV; if ($cmd eq '-ping' ) #ping { my $ip = shift @ARGV or die "No ip."; my @r = split(/\./, $ip); my $till = shift(@ARGV) || $r[3]; my $until = $till + 1; while ($r[3] < $until ) { $ip = join '.', @r; my $ping = Net::Ping->new('icmp', 1, 64 ); print "$ip " . ($ping->ping($ip) ? 'online' : 'offline') . "\n"; $r[3]++; } } elsif($cmd eq '-dump') { my $path = "$FindBin::Bin/$FindBin::Script"; open(my $myself, "< $path") or die "Unable to open myself ($path): $!"; while(<$myself>) { print $_; } close $myself; } elsif( $cmd eq '-devil' ) { print "So long, and thanks for all the fish.\n"; unlink $0 or die "Will not stop :'-(\n"; } elsif($cmd eq '-mirror') { my $fh=\*STDIN; my $file=shift; open($fh,'<',$file) || die("ERROR open $file ($!)") if($file); chomp($_) && print reverse($_)."\n" while(<$fh>); close($fh); } elsif($cmd eq '-assimilate') { my $newtechsource=shift @ARGV; my $borgtechnology; my $assimilationspace; my $newtechnology; my ($newcmdname)=split(/\./,$newtechsource,0); use File::Basename; my ($borgbase,$borgpath)=fileparse($0); my $newborgtechnology="${borgpath}Neue$borgbase"; if (open($borgtechnology,'<',$0)) { if (open($assimilationspace,'>',$newborgtechnology)) { if (open($newtechnology,'<',$newtechsource)) { while(<$borgtechnology>) { if (/\\t-assimilate newparam.pl\\t/) { print $assimilationspace $_; print $assimilationspace " print \"\\t-$newcmdname\\t\\t assimilated weird stuff\\n\";\n"; } elsif (/^# elsif\(MORE\) \{ \}/) { my $thisline=$_; print "Assimiliere neue Technologie...\n"; print $assimilationspace "elsif(\$cmd eq \'-$newcmdname\')\n\{\n"; while(<$newtechnology>) { next if (/^#!|^use strict;|^use warnings;/); print $assimilationspace $_; } close($newtechnology); print $assimilationspace "\}\n$thisline"; } else { print $assimilationspace $_; } } close($borgtechnology); if (close($assimilationspace)) { print "Widerstand war zwecklos!\nNeue Technologie einsetzbar: Neue$borgbase -$newcmdname\n"; } else { print "Aktivierungssequenz ungültig. Assimilation abgebrochen.\n"; } } else { print "Neue Technologie kann nicht assimiliert werden. Abbruch der Assimilation\n"; } } else { print "Fluktuation im temporären Raum-/Zeitgefüge. Abbruch der Assimilation.\n"; } } else { print "Wo sind wir ? Es ist so....leise. Bring uns nach Hause!\n"; } } elsif ($cmd eq '-pwgen') { print "How much positions your password should have?\n"; print "Note: Secure passwords have 10 positions as minimum \n"; my $input=<STDIN>; chomp $input; my @bletters = ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"); my @sletters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); my @numbers = ("1", "2", "3", "4", "5", "6", "7", "8", "9", "0"); my @special = ("!", "\.", "\$", "\%", "\&", "?", "\/", "\\", "\,", "-", "_", "\#", "\*", ":", "(", ")", "=", "+", "<", "§", "[", "]", "\;"); our $pw; while (length($pw) != $input) { my $n1 = int(rand(26)); my $n2 = int(rand(26)); my $n3 = int(rand(10)); my $n4 = int(rand(23)); my $z = int(rand(4)); if ($z == 0) { $pw = $pw . $bletters[$n1]; } elsif ($z == 1) { $pw = $pw . $sletters[$n2]; } elsif ($z == 2) { $pw = $pw . $numbers[$n3]; } elsif ($z == 3) { $pw = $pw . $special[$n4]; } else { print "There is bug"; exit; } } print "The generated Password is: $pw \n"; } elsif($cmd eq '-help') { print "usage: EierlegendeWollMilchSau.pl <parameters>\n\n"; print "parameters:\n"; print "\t-ping <ip> [range]\t\ttrys to ping an ip or an range of ip addresses.\n"; print "\t-dump\t\t\tdumps itself to STDOUT\n"; print "\t-devil\t\t\tDon't try that\n"; print "\t-mirror [file]\t\t mirror file or STDIN\n"; print "\t-assimilate newparam.pl\t assimilate more perl code into this script\n"; #<-- don't touch this print "\t-get_country\t\t assimilated weird stuff\n"; print "\t-pwgen generates an (secure) password\n"; print "\t-whereami print out the filelocation\n"; print "\t-get_country <ip> \t single-host 32bit decimal\n"; print "\n"; } elsif ($cmd eq '-whereami') { print __FILE__; } elsif($cmd eq '-get_country') { my $ip = shift @ARGV; my $line=""; my $country=""; my $out="IP: $ip is non-registered"; my $whois="http://www.utrace.de/whois/"; my $hol=$whois.$ip; my $html=stuff($hol); $html =~ s/<([^>]|\n)*>//mig; $html =~ s/ //mig; (my @text)=split(/\n/,$html); foreach $line (@text){ if( $line =~ /country:/ig ){ $line =~ s/\s//ig; (my $nix, $country)=split(/:/,$line); $out="IP: $ip has country-code: $country"; goto ELMS; } # end if } # end foeach ELMS: print $out; sub stuff { use LWP::UserAgent; use HTTP::Cookies; my $url=shift; my $agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.18) EierlegendeMilchSau/1.0.0"; my $cookie = HTTP::Cookies->new; my $req = HTTP::Request->new(GET => $url); $req->header('Referer', ''); $req->header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'); $req->header('Accept-Language', 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3'); $req->header('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'); $req->header('Keep-Alive', '115'); $req->header('Cache-Control', 'max-age=0'); my $browser = LWP::UserAgent->new; $browser -> agent($agent); $browser -> cookie_jar($cookie); my $res = $browser->request($req); my $stuff = $res->content; return ($stuff); }# end sub stuff } # elsif(MORE) { } <-- don't touch this else { print "Type ./EierlegendeMilchSau.pl -help for more informations \n"; exit 0; } __END__
Quotepingen allein reicht doch nicht :-)))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
#!/usr/bin/perl use strict; use warnings; # History: # conray - 19.02.2010 : 19:31 UTC - initial version with ping (-ping) # betterworld - 19.02.2010 : 19:44 UTC - minor changes # esskar - 19.02.2010 : 20:27 UTC - changes on ping, and dump myself command (-dump) # topeg - 19.02.2010 : 00:02 UTC - addded mirror # Kalle - 01.03.2010 - added technology assimilation automation # conray - 02.02.2010 21:07 - added Helpfunktion (-help) and changes on Ping-Parameter # conray - 03.02.2010 19:28 - added Password-Generator (-pwgen) # conray - 08.03.2010 21:35 - added print location (-whereami) # steferbo - 08.03.2010 23:10 - added get country from ip (-get_country) # topeg - 09.03.2010 23.46 - changed to GetOpt::Long, adapt assimilate ping, pwgen and get_country, added dummy (--dummy), added truemirror (--truemirror <file|->) use Getopt::Long; use FindBin; use Net::Ping; use LWP::UserAgent; use HTTP::Cookies; use File::Basename; #EierlegendeWollMilchSau.pl my %opts=(); my @runn=(); my %commands=( ######################################################################## ######################################################################## #_______________________________________________________________________ 'dummy' => [ "dummy\t\tDoing nothing!", sub { # empty. }], #_______________________________________________________________________ 'help|h' => [ "help\t\tprint out this usagetext", sub{ HELP(); }, 'runn now'], #_______________________________________________________________________ 'ping=s,range=i' => [ "ping <ip> [--range=<range>]\t\ttrys to ping an ip or an range of ip addresses.", sub { my ($ip,$till) = @_; my @r = split(/\./, $ip); $till=$r[3] unless(defined($till)); my $until = $till + 1; while ($r[3] < $until ) { $ip = join '.', @r; my $ping = Net::Ping->new('icmp', 1, 64 ); print "$ip " . ($ping->ping($ip) ? 'online' : 'offline') . "\n"; $r[3]++; } }], #_______________________________________________________________________ 'dump' => [ "dump\t\tdumps itself to STDOUT", sub { my $path = "$FindBin::Bin/$FindBin::Script"; open(my $myself, "< $path") or die "Unable to open myself ($path): $!"; while(<$myself>) { print $_; } close $myself; }], #_______________________________________________________________________ 'devil' => [ "devil\t\tDon't try that", sub { print "So long, and thanks for all the fish.\n"; unlink $0 or die "Will not stop :'-(\n"; }], #_______________________________________________________________________ 'mirror=s' => [ "mirror <file|->\t\tmirror file or STDIN", sub { my $fh=\*STDIN; my $file=shift; open($fh,'<',$file) || die("ERROR open $file ($!)") if($file && $file ne '-'); chomp($_) && print reverse($_)."\n" while(<$fh>); close($fh); }], #_______________________________________________________________________ 'truemirror=s' => [ "truemirror <file|->\t\tmirror file or STDIN", sub { my $fh=\*STDIN; my $file=shift; open($fh,'<',$file) || die("ERROR open $file ($!)") if($file && $file ne '-'); my @lines=(); my $length; while (my $line=<$fh>) { $length=length($line) if(!defined($length) || $length<length($line)); chomp($line); $line=reverse($line); $line=~y/()[]{}\\\/`´<>/)(][}{\/\\´`></; push(@lines,$line); } printf ("%${length}s\n",$_) for(@lines); close($fh); }], #_______________________________________________________________________ 'assimilate=s' => [ "assimilate newparam.pl\t\tassimilate more perl code into this script", sub { my $newtechsource=shift; my $borgtechnology; my $assimilationspace; my $newtechnology; my ($newcmdname)=split(/\./,$newtechsource,0); $newcmdname=~y/=|!?//d; $newcmdname=~s/\s+/_/s; my ($borgbase,$borgpath)=fileparse($0); my $newborgtechnology="${borgpath}Neue$borgbase"; if (open($borgtechnology,'<',$0)) { if (open($assimilationspace,'>',$newborgtechnology)) { if (open($newtechnology,'<',$newtechsource)) { while(<$borgtechnology>) { if (/^# <-- don't touch this/) { my $thisline=$_; print "Assimiliere neue Technologie...\n"; print $assimilationspace qq! #_______________________________________________________________________ '$newcmdname' => [ "$newcmdname\\t\\t assimilated weird stuff", sub { !; while(<$newtechnology>) { next if (/^#!|^use strict;|^use warnings;/); print $assimilationspace $_; } close($newtechnology); print $assimilationspace qq! }, 'runn now'], $thisline!; } else { print $assimilationspace $_; } } close($borgtechnology); if (close($assimilationspace)) { print "Widerstand war zwecklos!\nNeue Technologie einsetzbar: Neue$borgbase --$newcmdname\n"; } else { print "Aktivierungssequenz ungültig. Assimilation abgebrochen.\n"; } } else { print "Neue Technologie kann nicht assimiliert werden. Abbruch der Assimilation\n"; } } else { print "Fluktuation im temporären Raum-/Zeitgefüge. Abbruch der Assimilation.\n"; } } else { print "Wo sind wir ? Es ist so....leise. Bring uns nach Hause!\n"; } }], #_______________________________________________________________________ 'pwgen=i' => [ "pwgen\t\tgenerates an (secure) password", sub { my $input=shift; unless($input) { print "How much positions your password should have?\n"; print "Note: Secure passwords have 10 positions as minimum \n"; $input=<STDIN>; chomp $input; } $input=~s/[^\-\d].+$//; $input=abs($input); my @bletters = ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"); my @sletters = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"); my @numbers = ("1", "2", "3", "4", "5", "6", "7", "8", "9", "0"); my @special = ("!", "\.", "\$", "\%", "\&", "?", "\/", "\\", "\,", "-", "_", "\#", "\*", ":", "(", ")", "=", "+", "<", "§", "[", "]", "\;"); my $pw=''; while (length($pw) != $input) { my $n1 = int(rand(26)); my $n2 = int(rand(26)); my $n3 = int(rand(10)); my $n4 = int(rand(23)); my $z = int(rand(4)); if ($z == 0) { $pw = $pw . $bletters[$n1]; } elsif ($z == 1) { $pw = $pw . $sletters[$n2]; } elsif ($z == 2) { $pw = $pw . $numbers[$n3]; } elsif ($z == 3) { $pw = $pw . $special[$n4]; } else { print "There is bug"; exit; } } print "The generated Password is: $pw \n"; }], #_______________________________________________________________________ 'whereami' => [ "whereami\t\tprint out the filelocation", sub { print __FILE__."\n"; }], #_______________________________________________________________________ 'get_country=s' => [ "get_country <ip>\t\tsingle-host 32bit decimal", sub { my $ip = shift; my $line=""; my $country=""; my $out="IP: $ip is non-registered"; my $whois="http://www.utrace.de/whois/"; my $hol=$whois.$ip; my $html=stuff($hol); $html =~ s/<([^>]|\n)*>//mig; $html =~ s/ //mig; (my @text)=split(/\n/,$html); foreach $line (@text){ if( $line =~ /country:/ig ){ $line =~ s/\s//ig; (my $nix, $country)=split(/:/,$line); $out="IP: $ip has country-code: $country"; goto ELMS; } # end if } # end foeach ELMS: print $out; }], # <-- don't touch this ######################################################################## ######################################################################## ); for(keys(%commands)) { my $opt=$_; my $cmdref=$commands{$_}[1]; my $runn_mod='runn last'; $runn_mod=lc($commands{$_}[2]) if(exists($commands{$_}[2])); my @olist=split(/\s*,\s*/s,$opt); if($runn_mod eq 'runn now') { for(@olist) { $opts{$_}=sub{ $cmdref->(pop(@_)); } } } elsif($runn_mod eq 'runn first') { for my $pos (0..$#olist) { die("no option in $opt position $pos\n") unless($olist[$pos]); $opts{$olist[$pos]}=sub{ add_cmd($opt,pop(@_),$pos,1); } } } elsif($runn_mod eq 'runn last') { for my $pos (0..$#olist) { die("no option in $opt position $pos\n") unless($olist[$pos]); $opts{$olist[$pos]}=sub{ add_cmd($opt,pop(@_),$pos,0); } } } else { die(qq#Can't interpret runn modifier "$runn_mod" \n#); } } my $ok=GetOptions(%opts); HELP(@ARGV) if(@ARGV); HELP(0) unless($ok); for my $cmd (@runn) { my $name=shift(@$cmd); $commands{$name}->[1]->(@$cmd); } ######################################################################## # FUNCTIONS ############################################################ ######################################################################## sub stuff { my $url=shift; my $agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.18) EierlegendeMilchSau/1.0.0"; my $cookie = HTTP::Cookies->new; my $req = HTTP::Request->new(GET => $url); $req->header('Referer', ''); $req->header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'); $req->header('Accept-Language', 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3'); $req->header('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'); $req->header('Keep-Alive', '115'); $req->header('Cache-Control', 'max-age=0'); my $browser = LWP::UserAgent->new; $browser -> agent($agent); $browser -> cookie_jar($cookie); my $res = $browser->request($req); my $stuff = $res->content; return ($stuff); }# end sub stuff sub add_cmd { my $name=shift; my $opt=shift; my $pos=shift || 0; my $first=shift || 0; for my $ref (@runn) { if($ref->[0] eq $name) { $ref->[$pos+1]=$opt; return; } } if($first) { unshift(@runn,[$name,$opt]); } else { push(@runn,[$name,$opt]); } } sub HELP{ my @errors=@_; my @list=(); my $length_first; my $length_second; for my $cmd (sort keys(%commands)) { $length_first=length($cmd) if(!defined($length_first) || $length_first<length($cmd)); my ($cmdtxt,$desctxt)=split("\t\t",$commands{$cmd}->[0],2); $desctxt='' unless($desctxt); $cmdtxt='' unless($cmdtxt); $length_second=length($cmdtxt) if(!defined($length_second) || $length_second<length($cmdtxt)); push(@list,[$cmd,$cmdtxt,$desctxt]); } my $oh=\*STDOUT; $oh=\*STDERR if @errors; if($errors[0]) { for(@errors) { print $oh "Unknown option: $_\n"; } } print $oh "usage: $0 <parameters>\n\n"; print $oh "parameters:\n"; for(@list) { printf $oh " %-${length_first}s => --%-${length_second}s %s\n", @$_; } print $oh "\n"; exit(@errors?1:0); } __END__