Datenmuell Script

Aus Freiheit statt Angst!
Zur Navigation springen Zur Suche springen

Technischer Datenschutz


Maßnahmen

{{#ifeq:|Vorlage|

Diese Vorlage dient dazu, eine schnelle Navigation zwischen den Wikiseiten des Themas Technischer Datenschutz zu ermöglichen.

Nebenbei sortiert sie alles, was diese Vorlage verwendet automatisch in die Kategorie:Technischer Datenschutz ein. (Es sei denn es wird explizit ein Kategorie-Parameter übergeben)

}}


Das Original liegt auf http://www.cuneytyilmaz.com/prog/mtiptrav.pl.txt und ist unter "Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported" Lizenz freigegeben. Der Unterschied zu GPLv2 ist, dass *keine* kommerzielle Nutzung erlaubt ist.

http://creativecommons.org/licenses/by-nc-sa/3.0/

#!/usr/bin/perl -Tw
package multithreadediptraverse;
# cuneytyilmaz.com, December 2005
#
# this script creates random IP numbers and ports
# and tries to connect to these IPs
# aiming to generate as much traffic as possible
# it's meant to be anti-anti-democratic!
#
# if you don't know which human rights *you* have, see:
# http://www.un.org/Overview/rights.html
#
# the script is multithreaded and is a very quick solution,
# probably not the most efficient.
# it is using lots of memory, nevertheless it's running pretty fast!
#
# REMEMBER THIS: DON'T USE THIS SCRIPT IF YOU DON'T HAVE LOTS OF BANDWIDTH
# THIS SCRIPT IS PROVIDED AS-IS, NO RESPONSIBILITIES ARE TAKEN!
#
# this script is distributed under
# "Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported" License
# to see the full-text of the license please see:
# http://creativecommons.org/licenses/by-nc-sa/3.0/
#
# You are free:
#   * to Share — to copy, distribute and transmit the work
#   * to Remix — to adapt the work
#
# Under the following conditions:
# * Attribution. You must attribute the work in the manner specified by the author
#   or licensor (but not in any way that suggests that they endorse you or your use of the work).
# * Noncommercial. You may not use this work for commercial purposes.
# * Share Alike. If you alter, transform, or build upon this work, you may distribute
#   the resulting work only under the same or similar license to this one.
#
# if you have any suggestions or comments mail me at:
# progs-mtiptrav(insertthatmagiccharonemailaddresseshere)cuneytyilmaz.com
#
use strict;

use threads;
use threads::shared;
use Thread::Semaphore;
use IO::Socket;
use Fcntl;

my $threadcnt : shared = 0;
my $sem = new Thread::Semaphore(50);    # number of simultaneous connections

my ($i, $j, $k, $l);

# main loop
# alternatively use
# for my $dummy (1..1000)
while(1)
{
  # generate random IPs and check if they're allowed
  $i = 1 + int rand 253;
  $j = 1 + int rand 253;
  $k = 1 + int rand 253;
  $l = 1 + int rand 253;
  next unless(isValidIP($i, $j, $k, $l));
  # try to create a new thread, and detach it immediately
  $sem->down(1);
  threads->create(\&child, $i, $j, $k, $l)->detach();
}
# wait for all threads to finish (avoid "A thread exited while $n threads were running")
select(undef,undef,undef,rand 1) while($threadcnt>0);


# finds out if an IP number is valid,
# i.e. it should be neither blacklisted nor non-routable
sub isValidIP
{
  my($i,$j,$k,$l) = @_;
  # skip rfc1918 IPs
  if($i==10 || $i==172 && $j>=16 && $j<=31 || $i==192 && $j==168) { return 0 }
  # and other blacklisted IPs maybe...
  # elsif(...)
  else { return 1 }
}


sub child
{
  { lock($threadcnt); ++$threadcnt; }
  my $host = join ('.', @_);
  # unless we have root-rights don't use privileged ports; remember there's no port 0 ;-)
  my $port = ($> == 0 ? 1 + int rand 65534 : 1025 + int rand (65535-1025));
  # alternatively use a limited list of ports
  # my @portlist = qw(21 22 25 53 80 110 443);
  # $port = $portlist[rand @portlist];
  print "thread count: $threadcnt, thread id:".threads->self->tid.", connecting at $host:$port\n";

  my $remote = IO::Socket::INET->new(
    Proto    => 'tcp',
    PeerAddr => $host,
    PeerPort => $port,
    Timeout  => 5,
  );
#  print "Cannot connect to $host:$port\n" if(!$remote);
  print "Connected to $host:$port\n" if($remote);
  undef $remote;
  { lock($threadcnt); --$threadcnt; }
  $sem->up(1);
}