#!/usr/bin/perl use IO::Socket; #use CGI::Carp qw(fatalsToBrowser); # Setup my $email = "no-reply\@cryonhost.eu"; # Das Zeichen \ vor dem @ ist EXTREM WICHTIG!!! my $url = "http://kundenorder.cryoncom.com/kundenodr"; # Pfad zu Paket.cgi ohne den DATEINAMEN! my $telefon = "0"; # 1=Pflicht, 0=Optional my $mailprog = ""; # Sendmailpfad - LEER lassen wenn der Pfad automatisch erkannt werden soll. my $timeout = "35"; # Timeout my $IDNS = "1"; # 1=AN,0=AUS - IDN An/Aus (Umlaute) my $whois = "1"; # 1=Mit IO::Socket Modul - 0=Ohne Modul mit WHOIS my $command = "whois -h"; # Command für WHOIS ohne Modul my $version = "1.18"; # End # # Script: Resellerscript # Autor: Stefan Gipper (Stefanos) # Webseite: http://www.coder-world.de # E-Mail: support@coder-world.de # # read(STDIN, $input, $ENV{'CONTENT_LENGTH'});foreach $pair (split(/&/, $input)) {($name, $value) = split(/=/, $pair);$name =~ tr/+/ /;$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;$value =~ tr/+/ /;$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;$FORM{$name} = $value;}@vars = split(/&/, $ENV{QUERY_STRING});foreach $var (@vars) {($v,$i) = split(/=/, $var);$v =~ tr/+/ /;$v =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;$i =~ tr/+/ /;$i =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;$i =~ s///g;$INFO{$v} = $i;}if($FORM{'action'} ne ""){$action = $FORM{'action'};}else{$action = $INFO{'action'};} unless($mailprog){ foreach ("/usr/sbin/sendmail.postfix","/usr/bin/sendmail.postfix","/bin/sendmail.postfix","/sbin/sendmail.postfix","/bin/sendmail","/sbin/sendmail","/usr/lib/sendmail","/usr/bin/sendmail","/usr/share/sendmail","/usr/sbin/sendmail","/usr/bin/sendmail.restart","/etc/sendmail.cf","/etc/sendmail.cw","/usr/man/man8/sendmail.8","/var/qmail/bin/qmail-inject"){ if(-e $_ && -X _){ $mailprog = $_; last; } } } if($action eq "paket"){&paket;} if($action eq "aktiv"){&aktiv;} if($action eq "aktiv2"){&aktiv2;} if($action eq "bestellung"){&bestellung;} &index; sub index { print "Content-Type: text/html\n\n"; open(F,"); close(F); $temp =~ s/__paket__/$INFO{'paket'}/g; print $temp; exit; } sub paket { open(F,"){ s/[\n\r]//g; ($tld,$tldserver,$tldmatch,$vormark) = split(/\|/); $whois{$tld} = $tldserver; $match{$tld} = $tldmatch; $vormark{$tld} = $vormark; } close(F); $FORM{'paket'} = $INFO{'paket'} unless($FORM{'paket'}); $FORM{'end'} = $INFO{'end'} unless($FORM{'end'}); $domain = $INFO{'domain'} || $FORM{'domain'}; $domain =~ s/^http:\/\///g; $domain =~ s/^www\.//g; $domainbackup = $domain; if($IDNS == 1){ @dedomains = ("224","225","226","227","228","229","257","259","261","230","231","263","265","267","269","271","273","232","233","234","235","275","277","279","281","283","331","240","285","287","289","291","293","295","236","237","238","239","297","299","301","303","305","309","311","312","314","316","318","322","241","324","326","328","242","243","244","245","246","248","333","335","337","339","341","343","345","347","349","351","353","355","357","359","254","249","250","251","252","361","363","365","367","369","371","373","253","375","378","380","382"); foreach (@dedomains){ $idn .= chr($_); } $domain = idn($domain); } if($domain =~ /\.([\w\.]+)$/){ ($FORM{'end'}) = ($domain =~ m/(\.[\w\.]+)$/); $domain =~ s/(.+?)\.([\w\.]+)$/$1/; } $kk = $INFO{'kk'} || $FORM{'kk'}; if($kk == 1 && $domain ne ""){ $used = 3; }elsif($kk != 1){ $domain =~ tr/A-Z/a-z/; if($domain =~ /^[$idnA-Za-z0-9-]+$/ && $domain !~ /^-|-$|\.|\\|\// && length($domain) > 2 && length($domain) < 63){ $i = $FORM{'end'}; $i =~ s/^\.//g; $other = &whois($whois{$i},"$domain\.$i"); if($other =~ /^\*/ or length($domain) < 1) { $used = 1; }elsif($other =~ /$match{$i}/){ $used = 0; }else{ $used = 2; } }else{ $used = ""; } }else{ $domain =~ tr/A-Z/a-z/; if($domain =~ /^[$idnA-Za-z0-9-]+$/ && $domain !~ /^-|-$|\.|\\|\// && length($domain) >= 1 && length($domain) < 63){ $used= 0; }else{ $used = ""; } } if($used == 2){ open(F,"); close(F); }elsif($used eq "0"){ open(F,"); close(F); }elsif($used == 3){ open(F,"); close(F); }elsif($used eq ""){ open(F,"); close(F); $temp =~ s~<_e>~Abfrage der Domain ist nicht möglich oder Sie haben eine ungültige Domain eingegeben!~g; } $domainbackup .= $FORM{'end'} if($domainbackup !~ /$FORM{'end'}$/); $temp =~ s/<_domain>/$domainbackup/g; $temp =~ s/<_end>/$FORM{'end'}/g; $temp =~ s/<_kk>/$kk/g; if($FORM{'paket'} && $used eq "0" or $FORM{'paket'} && $used eq "3"){ if($kk){ print "Location: paket.cgi?domain=$domainbackup&kk=1&paketname=$FORM{'paket'}&action=bestellung\n\n"; }else{ print "Location: paket.cgi?domain=$domainbackup&paketname=$FORM{'paket'}&action=bestellung\n\n"; } }else{ $temp =~ s/__paket__/$FORM{'paket'}/g; print "Content-Type: text/html\n\n"; print $temp; } exit; } sub bestellung { open(F,"); close(F); if($INFO{'kk'} == 1){ $temp =~ s/<_kk>/Ja/g; }else{ $temp =~ s/<_kk>/Nein/g; } $temp =~ s/<_domain>/$INFO{'domain'}/g; $INFO{'paketname'} = ucfirst($INFO{'paketname'}); $temp =~ s/<_tarif>/$INFO{'paketname'}/g; print "Content-Type: text/html\n\n"; print $temp; exit; } sub aktiv { &error("Sie haben nicht über das Bestell-Formular bestellt!") if($FORM{'kk'} eq "" or $FORM{'tarif'} eq "" or $FORM{'domain'} eq ""); &error("Sie haben keinen Vor- oder Nachnamen eingetragen.") if($FORM{'Vorname'} eq "" or $FORM{'Nachname'} eq ""); &error("Sie haben Ihr Geburtsdatum nicht im Format TT.MM.JJJJ eingetragen!") if($FORM{'Geburtsdatum'} !~ /^\d\d\.\d\d\.\d\d\d\d$/ or $FORM{'Geburtsdatum'} eq ""); &error("Sie haben keine Strasse eingetragen.") unless($FORM{'Strasse'}); &error("Sie haben keine Hausnummer eingetragen.") unless($FORM{'Hausnr'}); &error("Sie haben keine Postleitzahl eingetragen.") unless($FORM{'Plz'}); &error("Sie haben keinen Wohnort eingetragen.") unless($FORM{'Ort'}); &error("Sie haben keine Bundesland eingetragen.") unless($FORM{'Bundesland'}); &error("Die E-Mailadresse stimmt nicht mit der Wiederholung überein!") if($FORM{'email'} ne $FORM{'email2'}); &error("Die E-Mailadresse ist falsch!") if($FORM{'email'} !~ /^([\w\-\.]+)(\@)([\w\-\.]+)(\.)(\w+)$/); &error("Die E-Mailadresse Wiederhholung ist falsch!") if($FORM{'email2'} !~ /^([\w\-\.]+)(\@)([\w\-\.]+)(\.)(\w+)$/); &error("Sie haben kein Telefonpasswort eingetragen oder dies ist nicht identisch mit der Wiederholung!") if($FORM{'passwort'} ne $FORM{'passwort2'} or $FORM{'passwort'} eq ""); if($telefon == 1){ &error("Sie haben keine gültige Telefonnummer (Festnetznummer) eingetragen.") unless($FORM{'Festnetz'}); } if($FORM{'nein'} == 2){ &error("Sie haben Ihre Kontonummer nicht eingetragen.") unless($FORM{'kto'}); &error("Sie haben keine Bankleitzahl eingetragen.") unless($FORM{'blz'}); &error("Sie haben Ihre Hausbank nicht eingetragen.") unless($FORM{'bankname'}); &error("Sie haben keinen Konto-Inhaber eingetragen.") unless($FORM{'inhaber'}); } &error("Sie haben unsere AGB nicht akzeptiert!") if($FORM{'agb'} != 1); open(F,"); close(F); if($FORM{'nein'} == 1){ $FORM{'nein'} = "Vorkasse (Überweisung)"; }elsif($FORM{'nein'} == 2){ $FORM{'nein'} = "Bankeinzug"; }elsif($FORM{'nein'} == 3){ $FORM{'nein'} = "Auf Rechnung"; }elsif($FORM{'nein'} == 4){ $FORM{'nein'} = "Paypal"; }elsif($FORM{'nein'} == 5){ $FORM{'nein'} = "Moneybookers"; }elsif($FORM{'nein'} == 6){ $FORM{'nein'} = "Moxmo.de"; } $ausgabe =~ s/<_ip>/$ENV{'REMOTE_ADDR'}/g; $ausgabe =~ s/<_domain>/$FORM{'domain'}/g; $ausgabe =~ s/<_domain2>/$FORM{'domain2'}/g; $ausgabe =~ s/<_kk>/$FORM{'kk'}/g; $ausgabe =~ s/<_authcode>/$FORM{'authcode'}/g; $ausgabe =~ s/<_tarif>/$FORM{'tarif'}/g; $ausgabe =~ s/<_IP>/$FORM{'IP'}/g; $ausgabe =~ s/<_HDD>/$FORM{'HDD'}/g; $ausgabe =~ s/<_RAM>/$FORM{'RAM'}/g; $ausgabe =~ s/<_Betriebssystem>/$FORM{'Betriebssystem'}/g; $ausgabe =~ s/<_Administration>/$FORM{'Administration'}/g; $ausgabe =~ s/<_Servicepack>/$FORM{'Servicepack'}/g; $ausgabe =~ s/<_Backupspace>/$FORM{'Backupspace'}/g; $ausgabe =~ s/<_Webresetter>/$FORM{'Webresetter'}/g; $ausgabe =~ s/<_ClamAV>/$FORM{'ClamAV'}/g; $ausgabe =~ s/<_radio>/$FORM{'radio'}/g; $ausgabe =~ s/<_Neukunde>/$FORM{'Neukunde'}/g; $ausgabe =~ s/<_Bestandskunde>/$FORM{'Bestandskunde'}/g; $ausgabe =~ s/<_Kundennummer>/$FORM{'Kundennummer'}/g; $ausgabe =~ s/<_Firma>/$FORM{'Firma'}/g; $ausgabe =~ s/<_Anrede>/$FORM{'Anrede'}/g; $ausgabe =~ s/<_Vorname>/$FORM{'Vorname'}/g; $ausgabe =~ s/<_Nachname>/$FORM{'Nachname'}/g; $ausgabe =~ s/<_Geburtsdatum>/$FORM{'Geburtsdatum'}/g; $ausgabe =~ s/<_Strasse>/$FORM{'Strasse'}/g; $ausgabe =~ s/<_Hausnr>/$FORM{'Hausnr'}/g; $ausgabe =~ s/<_Plz>/$FORM{'Plz'}/g; $ausgabe =~ s/<_Ort>/$FORM{'Ort'}/g; $ausgabe =~ s/<_Land>/$FORM{'Land'}/g; $ausgabe =~ s/<_Bundesland>/$FORM{'Bundesland'}/g; $ausgabe =~ s/<_Festnetz>/$FORM{'Festnetz'}/g; $ausgabe =~ s/<_Telefax>/$FORM{'Telefax'}/g; $ausgabe =~ s/<_Mobilfunk>/$FORM{'Mobilfunk'}/g; $ausgabe =~ s/<_email>/$FORM{'email'}/g; $ausgabe =~ s/<_passwort>/$FORM{'passwort'}/g; $ausgabe =~ s/<_Zahlungsweise>/$FORM{'Zahlungsweise'}/g; $ausgabe =~ s/<_zahlung>/$FORM{'zahlung'}/g; $ausgabe =~ s/<_nein>/$FORM{'nein'}/g; $ausgabe =~ s/<_kto>/$FORM{'kto'}/g; $ausgabe =~ s/<_blz>/$FORM{'blz'}/g; $ausgabe =~ s/<_bankname>/$FORM{'bankname'}/g; $ausgabe =~ s/<_inhaber>/$FORM{'inhaber'}/g; $ausgabe =~ s/<_paypal>/$FORM{'paypal'}/g; $ausgabe =~ s/<_moneybookers>/$FORM{'moneybookers'}/g; $ausgabe =~ s/<_agb>/$FORM{'agb'}/g; $ausgabe =~ s/<_mediacode>/$FORM{'mediacode'}/g; $ausgabe =~ s/<_geworben>/$FORM{'geworben'}/g; $ausgabe =~ s/<_Mitteilungen>/$FORM{'Mitteilungen'}/g; open (M,"| $mailprog -t") || die "Can't open Mail!"; print M "To: $FORM{'email'}\n"; print M "From: $email\n"; print M $ausgabe; close(M); open(F,"); close(F); $ausgabe =~ s/<_ip>/$ENV{'REMOTE_ADDR'}/g; $ausgabe =~ s/<_domain>/$FORM{'domain'}/g; $ausgabe =~ s/<_domain2>/$FORM{'domain2'}/g; $ausgabe =~ s/<_kk>/$FORM{'kk'}/g; $ausgabe =~ s/<_authcode>/$FORM{'authcode'}/g; $ausgabe =~ s/<_tarif>/$FORM{'tarif'}/g; $ausgabe =~ s/<_IP>/$FORM{'IP'}/g; $ausgabe =~ s/<_HDD>/$FORM{'HDD'}/g; $ausgabe =~ s/<_RAM>/$FORM{'RAM'}/g; $ausgabe =~ s/<_Betriebssystem>/$FORM{'Betriebssystem'}/g; $ausgabe =~ s/<_Administration>/$FORM{'Administration'}/g; $ausgabe =~ s/<_Servicepack>/$FORM{'Servicepack'}/g; $ausgabe =~ s/<_Backupspace>/$FORM{'Backupspace'}/g; $ausgabe =~ s/<_Webresetter>/$FORM{'Webresetter'}/g; $ausgabe =~ s/<_ClamAV>/$FORM{'ClamAV'}/g; $ausgabe =~ s/<_radio>/$FORM{'radio'}/g; $ausgabe =~ s/<_Neukunde>/$FORM{'Neukunde'}/g; $ausgabe =~ s/<_Bestandskunde>/$FORM{'Bestandskunde'}/g; $ausgabe =~ s/<_Kundennummer>/$FORM{'Kundennummer'}/g; $ausgabe =~ s/<_Firma>/$FORM{'Firma'}/g; $ausgabe =~ s/<_Anrede>/$FORM{'Anrede'}/g; $ausgabe =~ s/<_Vorname>/$FORM{'Vorname'}/g; $ausgabe =~ s/<_Nachname>/$FORM{'Nachname'}/g; $ausgabe =~ s/<_Geburtsdatum>/$FORM{'Geburtsdatum'}/g; $ausgabe =~ s/<_Strasse>/$FORM{'Strasse'}/g; $ausgabe =~ s/<_Hausnr>/$FORM{'Hausnr'}/g; $ausgabe =~ s/<_Plz>/$FORM{'Plz'}/g; $ausgabe =~ s/<_Ort>/$FORM{'Ort'}/g; $ausgabe =~ s/<_Land>/$FORM{'Land'}/g; $ausgabe =~ s/<_Bundesland>/$FORM{'Bundesland'}/g; $ausgabe =~ s/<_Festnetz>/$FORM{'Festnetz'}/g; $ausgabe =~ s/<_Telefax>/$FORM{'Telefax'}/g; $ausgabe =~ s/<_Mobilfunk>/$FORM{'Mobilfunk'}/g; $ausgabe =~ s/<_email>/$FORM{'email'}/g; $ausgabe =~ s/<_passwort>/$FORM{'passwort'}/g; $ausgabe =~ s/<_Zahlungsweise>/$FORM{'Zahlungsweise'}/g; $ausgabe =~ s/<_zahlung>/$FORM{'zahlung'}/g; $ausgabe =~ s/<_nein>/$FORM{'nein'}/g; $ausgabe =~ s/<_kto>/$FORM{'kto'}/g; $ausgabe =~ s/<_blz>/$FORM{'blz'}/g; $ausgabe =~ s/<_bankname>/$FORM{'bankname'}/g; $ausgabe =~ s/<_inhaber>/$FORM{'inhaber'}/g; $ausgabe =~ s/<_paypal>/$FORM{'paypal'}/g; $ausgabe =~ s/<_moneybookers>/$FORM{'moneybookers'}/g; $ausgabe =~ s/<_agb>/$FORM{'agb'}/g; $ausgabe =~ s/<_mediacode>/$FORM{'mediacode'}/g; $ausgabe =~ s/<_geworben>/$FORM{'geworben'}/g; $ausgabe =~ s/<_Mitteilungen>/$FORM{'Mitteilungen'}/g; open (M,"| $mailprog -t") || die "Can't open Mail!"; print M "To: $email\n"; print M "From: $email\n"; print M $ausgabe; close(M); open(F,"); close(F); $ausgabe =~ s/<_ip>/$ENV{'REMOTE_ADDR'}/g; $ausgabe =~ s/<_ip>/$ENV{'REMOTE_ADDR'}/g; $ausgabe =~ s/<_domain>/$FORM{'domain'}/g; $ausgabe =~ s/<_domain2>/$FORM{'domain2'}/g; $ausgabe =~ s/<_kk>/$FORM{'kk'}/g; $ausgabe =~ s/<_authcode>/$FORM{'authcode'}/g; $ausgabe =~ s/<_tarif>/$FORM{'tarif'}/g; $ausgabe =~ s/<_IP>/$FORM{'IP'}/g; $ausgabe =~ s/<_HDD>/$FORM{'HDD'}/g; $ausgabe =~ s/<_RAM>/$FORM{'RAM'}/g; $ausgabe =~ s/<_Betriebssystem>/$FORM{'Betriebssystem'}/g; $ausgabe =~ s/<_Administration>/$FORM{'Administration'}/g; $ausgabe =~ s/<_Servicepack>/$FORM{'Servicepack'}/g; $ausgabe =~ s/<_Backupspace>/$FORM{'Backupspace'}/g; $ausgabe =~ s/<_Webresetter>/$FORM{'Webresetter'}/g; $ausgabe =~ s/<_ClamAV>/$FORM{'ClamAV'}/g; $ausgabe =~ s/<_radio>/$FORM{'radio'}/g; $ausgabe =~ s/<_Neukunde>/$FORM{'Neukunde'}/g; $ausgabe =~ s/<_Bestandskunde>/$FORM{'Bestandskunde'}/g; $ausgabe =~ s/<_Kundennummer>/$FORM{'Kundennummer'}/g; $ausgabe =~ s/<_Firma>/$FORM{'Firma'}/g; $ausgabe =~ s/<_Anrede>/$FORM{'Anrede'}/g; $ausgabe =~ s/<_Vorname>/$FORM{'Vorname'}/g; $ausgabe =~ s/<_Nachname>/$FORM{'Nachname'}/g; $ausgabe =~ s/<_Geburtsdatum>/$FORM{'Geburtsdatum'}/g; $ausgabe =~ s/<_Strasse>/$FORM{'Strasse'}/g; $ausgabe =~ s/<_Hausnr>/$FORM{'Hausnr'}/g; $ausgabe =~ s/<_Plz>/$FORM{'Plz'}/g; $ausgabe =~ s/<_Ort>/$FORM{'Ort'}/g; $ausgabe =~ s/<_Land>/$FORM{'Land'}/g; $ausgabe =~ s/<_Bundesland>/$FORM{'Bundesland'}/g; $ausgabe =~ s/<_Festnetz>/$FORM{'Festnetz'}/g; $ausgabe =~ s/<_Telefax>/$FORM{'Telefax'}/g; $ausgabe =~ s/<_Mobilfunk>/$FORM{'Mobilfunk'}/g; $ausgabe =~ s/<_email>/$FORM{'email'}/g; $ausgabe =~ s/<_passwort>/$FORM{'passwort'}/g; $ausgabe =~ s/<_Zahlungsweise>/$FORM{'Zahlungsweise'}/g; $ausgabe =~ s/<_zahlung>/$FORM{'zahlung'}/g; $ausgabe =~ s/<_nein>/$FORM{'nein'}/g; $ausgabe =~ s/<_kto>/$FORM{'kto'}/g; $ausgabe =~ s/<_blz>/$FORM{'blz'}/g; $ausgabe =~ s/<_bankname>/$FORM{'bankname'}/g; $ausgabe =~ s/<_inhaber>/$FORM{'inhaber'}/g; $ausgabe =~ s/<_paypal>/$FORM{'paypal'}/g; $ausgabe =~ s/<_moneybookers>/$FORM{'moneybookers'}/g; $ausgabe =~ s/<_agb>/$FORM{'agb'}/g; $ausgabe =~ s/<_mediacode>/$FORM{'mediacode'}/g; $ausgabe =~ s/<_geworben>/$FORM{'geworben'}/g; $ausgabe =~ s/<_Mitteilungen>/$FORM{'Mitteilungen'}/g; print "Content-Type: text/html\n\n"; print $ausgabe; exit; } sub error { local($e) = @_; open(F,"); close(F); $temp =~ s/<_e>/$e/g; print "Content-Type: text/html\n\n"; print $temp; exit; } sub whois { local($server,$domain) = @_; local($m); if($whois == 1){ use IO::Socket; if($i eq "de"){ $x = new IO::Socket::INET (Timeout => $timeout,Proto => tcp,PeerAddr => $server,PeerPort => 43); if($x){ if($domain !~ /^xn--/){ # print $x " -T dn $domain\r\n"; print $x " -T st $domain\r\n"; }else{ if($IDNS == 1){ # print $x " -T ace,dn $domain\r\n"; print $x " -T st,ace $domain\r\n"; }else{ $domain = &iso2utf8($domain); # print $x " -T dn $domain\r\n"; print $x " -T st $domain\r\n"; } } $m .= join("",<$x>); close($x); } }elsif($i =~ /^com$|^net$|^org$|^tv$/){ #net $x = new IO::Socket::INET (Timeout => $timeout,Proto => tcp,PeerAddr => $server,PeerPort => 43); if($x){ print $x "$domain\r\n"; $m = join("",<$x>); close($x); ($server2) = grep(/Whois Server:/,$m); ($server2) = ($server2 =~ /Whois Server:\s*(\S+)/i); if($server2){ $x = new IO::Socket::INET (Timeout => $timeout,Proto => tcp,PeerAddr => $server2,PeerPort => 43); print $x "$domain\r\n"; $m .= join("",<$x>); close($x); 1 while $m =~ s/(.{100}[^\n])[ \-]/$1\n/g; }else{ $m .= join("",@output); } } }else{ $x = new IO::Socket::INET (Timeout => $timeout,Proto => tcp,PeerAddr => $server,PeerPort => 43); if($x){ print $x "$domain\r\n"; $m .= join("",<$x>); close($x); } } }else{ if($i eq "de"){ if($domain !~ /^xn--/){ # $m = `$command $server -- -T dn $domain`; $m = `$command $server -- -T st $domain`; }else{ if($IDNS == 1){ # $m = `$command $server -- -T ace,dn $domain`; $m = `$command $server -- -T st,ace $domain`; }else{ $domain = &iso2utf8($domain); # $m = `$command $server -- -T dn $domain`; $m = `$command $server -- -T st $domain`; } } }elsif($i =~ /^com$|^net$|^org$|^tv$/){ $m = `$command $server $domain`; ($server2) = grep(/Whois Server:/,$m); if($server2){ ($server2) = ($server2 =~ /Whois Server:\s*(\S+)/i); $m .= `$command $server2 $domain`; 1 while $m =~ s/(.{100}[^\n])[ \-]/$1\n/g; }else{ $m = join("",@output); } }else{ $m = `$command $server $domain`; } } $m = &utf82iso($m); #if($m =~ /Connection refused/ && $i eq "de" && $netsocks or !$m && $i eq "de" && $netsocks){ #if($m =~ /Connection refused/){ # foreach (@socks4){ # Proxy Support Net::SOCKS # } #} #} # if($m =~ /Connection refused/ or !$m && $i eq "de"){ # &error("$m
Socks4: $zsocks4
Socks5: $zsocks5 $serverx $server $domain $i"); # } $m =~ s/$domain/ /g; return($m); } sub utf82iso { my ($string) = @_; my %cache = (); $string =~ s/([\xc0-\xdf][\x80-\xbf])/$cache{$1} ||= decode_2byte_utf8($1)/eg; return $string; } sub decode_2byte_utf8 { my($a, $b) = split(//, $_[0]); return chr((((ord($a) & 0x1f) << 6) | (ord($b) & 0x3f) & 0xff)); } sub iso2mac { my($string) = @_; $string =~ tr/\xa0\xa1\xa4\xa5\xa7\xa8\xaa\xab\xac\xae\xaf\xb0\xb4\xb6\xb7\xb8\xba\xbb\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd1\xd2\xd3\xd4\xd6\xd8\xd9\xda\xdb\xdc\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xff/\xca\xc1\xdb\xb4\xa4\xac\xbb\xc7\xc2\xa8\xf8\xa1\xab\xa6\xe1\xfc\xbc\xc8\xc0\xcb\xe7\xe5\xcc\x80\x81\xae\x82\xe9\x83\xe6\xe8\xed\xea\xeb\xec\x84\xf1\xee\xef\x85\xaf\xf4\xf2\xf3\x86\xa7\x88\x87\x89\x8b\x8a\x8c\xbe\x8d\x8f\x8e\x90\x91\x93\x92\x94\x95\x96\x98\x97\x99\x9b\x9a\xd6\xbf\x9d\x9c\x9e\x9f\xd8/; return $string; } sub mac2iso { my ($string) = @_; $string =~ tr/\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa1\xa4\xa6\xa7\xa8\xab\xac\xae\xaf\xb4\xbb\xbc\xbe\xbf\xc0\xc1\xc2\xc7\xc8\xca\xcb\xcc\xd6\xd8\xdb\xe1\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf1\xf2\xf3\xf4\xf8\xfc/\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\xb0\xa7\xb6\xdf\xae\xb4\xa8\xc6\xd8\xa5\xaa\xba\xe6\xf8\xbf\xa1\xac\xab\xbb\xa0\xc0\xc3\xf7\xff\xa4\xb7\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\xd2\xda\xdb\xd9\xaf\xb8/; return $string; } sub iso2utf8 { my ($string) = @_; my %cache = (); $string =~ s/([\x80-\xff])/$cache{$1} ||= encode_iso($1)/eg; return $string; } sub encode_iso { my $iso = ord($_[0]); my $a = ((($iso & 0xc0) >> 6) | 0xc0); my $b = ($iso & 0x3f) | 0x80; return chr($a) . chr($b); } sub decode { local($encoded) = @_; $delim_pos = rindex($encoded, '-'); $decoded = (($delim_pos > length($punycode_prefix)) ? substr($encoded, length($punycode_prefix), ($delim_pos - length($punycode_prefix))) : ""); $deco_len = length($decoded); $enco_len = length($encoded); $is_first = true; $bias = $initial_bias; $idx = 0; $char = $initial_n; @encoded = split(//,$encoded); @decoded = split(//,$decoded); eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm(15); for($enco_idx = ($delim_pos) ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len){ for ($old_idx = $idx, $w = 1, $k = $base; 1 ; $k += $base){ $digit = &_decode_digit($encoded[$enco_idx++]); $idx += $digit * $w; $t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias)); last if($digit < $t); $w = int($w * ($base - $t)); } $bias = &_adapt($idx - $old_idx, $deco_len + 1, $is_first); $is_first = false; $char += ($idx / ($deco_len + 1)) % 256; $idx %= ($deco_len + 1); if($deco_len){ for($i = $deco_len; $i > $idx; $i--) { $decoded[$i] = $decoded[$i-1]; } } $decoded[$idx++] = chr($char); } }; return join("",@decoded); } sub encode { local($decoded) = @_; $deco_len = length($decoded); $codecount = 0; @decoded = split(//,$decoded); $encoded2 = $punycode_prefix; for($i = 0; $i < $deco_len; ++$i){ if($decoded[$i] =~ /[0-9a-zA-Z-]/){ $encoded2 .= $decoded[$i]; $codecount++; } } $encoded2 .= "-" if($codecount); $is_first = true; $cur_code = $initial_n; $bias = $initial_bias; $delta = 0; eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm(15); while($codecount < $deco_len){ for($i = 0, $next_code = $max_ucs; $i < $deco_len; $i++){ if(ord($decoded[$i]) >= $cur_code && ord($decoded[$i]) <= $next_code) { $next_code = ord($decoded[$i]); } } $delta += ($next_code - $cur_code) * ($codecount + 1); $cur_code = $next_code; for($i = 0; $i < $deco_len; $i++){ if(ord($decoded[$i]) < $cur_code){ $delta++; }elsif(ord($decoded[$i]) == $cur_code){ for($q = $delta, $k = $base; 1; $k += $base){ $t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : $k - $bias); last if($q < $t); $encoded2 .= &_encode_digit(int($t + (($q - $t) % ($base - $t)))); #ceil $q = ($q - $t) / ($base - $t); } $encoded2 .= &_encode_digit($q); $bias = &_adapt($delta, $codecount+1, $is_first); $codecount++; $delta = 0; $is_first = false; } } $delta++; $cur_code++; } }; return $encoded2; } sub _adapt{ local($delta,$npoints,$is_first) = @_; $delta = $is_first ? ($delta / $damp) : ($delta / 2); $delta += $delta / $npoints; for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base){ $delta = $delta / ($base - $tmin); } return $k + ($base - $tmin + 1) * $delta / ($delta + $skew); } sub _encode_digit { local($d) = @_; return chr($d + 22 + 75 * ($d < 26)); } sub _decode_digit { local($cp) = @_; $cp = ord($cp); return ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $base)); } sub idn { local($idnconvertdomain) = @_; @arr = (); $punycode_prefix = "xn--"; $invalid_ucs = 0x80000000; $max_ucs = 0x10ffff; $base = 36; $tmin = 1; $tmax = 26; $skew = 38; $damp = 700; $initial_bias = 72; $initial_n = 0x80; if($idnconvertdomain =~ /\@/){ ($email_pref,$idnconvertdomain) = split(/\@/,$idnconvertdomain,2); $email_pref .= "\@"; }else{ $email_pref = ""; } if($idnconvertdomain =~ /^\w+:\/\//){ ($email_pref, $idnconvertdomain, $auri) = ($url =~ m!(\w+)://(.*?)(/.*)!); } if($idnconvertdomain !~ /^$punycode_prefix/){ foreach (split(/\./,$idnconvertdomain)){ if($_ =~ /^[\w-]+$/){ push(@arr,"$_"); }else{ push(@arr,&encode("$_")); } } }else{ foreach (split(/\./,$idnconvertdomain)){ if($_ !~ /^$punycode_prefix/){ push(@arr,"$_"); }else{ push(@arr,&decode("$_")); } } } return $email_pref . join(".",@arr) . $auri; }