Ich verzweifel hier noch an regexp... Wär cool wenn mir einer mal unter die Arme greifen könnte, denn regexp nur anhand komischer netzbeispiele lernen is zu hoch für mich...
Im moment lade ich mit meinem Script mails per pop3 direkt in ein array,
ich will in diesen mails nach bestimmten Wörtern suchen lassen und dann den wert nach diesen Schlüsselwörtern nen Key zuweisen damit ich ne nette ausgabe der Werte erstellen lassen kann...
Das Script liegt hier: http://mindfuck.gotd...udas/botinfo.pl
Und so sehen die Mails aus die ankommen: http://mindfuck.gotd.../judas/mail.txt
Hoffe mir kann da einer helfen
thx im vorraus
Perl Pro gesucht!
Themenstarter
m1ndfuck
, 02. Feb. 2007 13:48 Uhr
#2
Geschrieben 02. Feb. 2007 - 14:52 Uhr
Also des Problem ist zB bei dem Port Ausdruck das ^port bedeutet, dass die Zeile mit port beginnt, deswegen findet der das nicht.
Dieser Code liefert als Ausgabe:
port: 6060
#!/usr/bin/perl my $string = " * Connects to "key.bihsecurity.com" on port 6060 (TCP)."; $ircdport = $1 if ($string =~ m/ports+(.*)s/i); print "port: $ircdport n";
Dieser Code liefert als Ausgabe:
port: 6060
Ich versteh die Frage nicht
#3
Geschrieben 02. Feb. 2007 - 15:45 Uhr
ah das is schoma ein anfang
Der string ist allerdings dynamisch, d.H der server wechselt natürlich wie alle anderen werte bei jeder email...
d.h ich muss also alles zwischen
Connects to "
und
" on port
einlesen...
haste dafür noch ein beispiel? am besten direkt in meinem code
mail addy+pass stimmt, kannst es ruhig mal zum test ausführen...[/code]
Der string ist allerdings dynamisch, d.H der server wechselt natürlich wie alle anderen werte bei jeder email...
d.h ich muss also alles zwischen
Connects to "
und
" on port
einlesen...
haste dafür noch ein beispiel? am besten direkt in meinem code
#!/usr/bin/perl ########################################### use Mail::POP3Client; my $host = "post.strato.de"; my $user = "test@kaarst-holzbuettgen.de"; my $pw = "gehaim"; my $timeout = '30'; ############################################ system(clear); my $pop3; $pop3 = Mail::POP3Client->new( HOST => $host, USER => $user, AUTH_MODE => 'PASS', DEBUG => '0', PASSWORD => $pw, TIMEOUT => $timeout ); my $status = $pop3->State(); if ( $status =~ /AUTHORIZATION/i ) { die("AUTH_ERRROR $user"); } if ( $status =~ /DEAD/i ) { die("CONNECTION_ERROR $host"); } my $nom; # number of messages $nom = $pop3->Count(); if ($nom > 0) { print "$nom Mails - "; my $boxsize =$pop3->Size(); print "Mailbox size: $boxsize bytesn-------------------------------------------n"; my $msgno; for ($msgno = 1; $msgno <= $nom; $msgno++) { my $subject; my $from; my $date; my @Lines = $pop3->Head($msgno); my $x; for ($x = 0; $x <= $#Lines; $x++) { $ircd = $1 if ($Lines[$x] =~ /Connects to "(.*)"/); $ircdport = $1 if ($Lines[$x] =~ m/^ports+(.*)/i); $botname = $1 if ($Lines[$x] =~ m/^nicknames+(.*)/i); $botident = $1 if ($Lines[$x] =~ m/^usernames+(.*)/i); $botchan = $1 if ($Lines[$x] =~ m/^Channels+(.*)/i); $botumode = $1 if ($Lines[$x] =~ m/^Usermodes+(.*)/i); $botmutex = $1 if ($Lines[$x] =~ m/^Mutexs+(.*)/i); $botchanpass = $1 if ($Lines[$x] =~ m/^Passwords+(.*)/i); $botfile = $1 if ($Lines[$x] =~ m/^Createss+(.*)/i); $botmd5 = $1 if ($Lines[$x] =~ m/^MD54s+(.*)/i); } unless (defined $ircd) { $ircd = "No IRC Connection!";} unless (defined $ircdport) { $ircdport = "No Port set!";} print "nNr. $msgno nFilename: $botfile nMD5-Hash: $botmd5 nServer: $ircd nPort: $ircdport nBotnick: $botname nBotident: $botident nChannel: $botchan nChannel-Password: $botchanpass nUsermode: $botumode nMutex Handle: $botmutex nn---n"; @Lines = $pop3->Body($msgno); for ($x = 0; $x <= $#Lines; $x++) { # print $Lines[$x]; } }} else { print "Sorry, no Mailnn"; } $pop3->Close(); my $string_time = localtime; my $name = getpwuid $<; if (!defined($name)) { $name = "UID: $<"; } print "n-----------------------------------------------------------nAutomatically generated at ${string_time} by ${name}nJudasBot by Mindfuck (c)2007 - bawtmaster@gmail.comnn";
mail addy+pass stimmt, kannst es ruhig mal zum test ausführen...[/code]
#4
Geschrieben 02. Feb. 2007 - 16:24 Uhr
so hier der code sollte funzen
#!/usr/bin/perl ########################################### use Mail::POP3Client; my $host = "post.strato.de"; my $user = "test@kaarst-holzbuettgen.de"; my $pw = "gehaim"; my $timeout = '30'; ############################################ system(clear); my $pop3; $pop3 = Mail::POP3Client->new( HOST => $host, USER => $user, AUTH_MODE => 'PASS', DEBUG => '0', PASSWORD => $pw, TIMEOUT => $timeout ); my $status = $pop3->State(); if ( $status =~ /AUTHORIZATION/i ) { die("AUTH_ERRROR $user"); } if ( $status =~ /DEAD/i ) { die("CONNECTION_ERROR $host"); } my $nom; # number of messages $nom = $pop3->Count(); if ($nom > 0) { print "$nom Mails - "; my $boxsize =$pop3->Size(); print "Mailbox size: $boxsize bytesn-------------------------------------------n"; my $msgno; for ($msgno = 1; $msgno <= $nom; $msgno++) { my $subject; my $from; my $date; my @Lines = $pop3->Body($msgno); my $x; for ($x = 0; $x <= $#Lines; $x++) { $ircd = $1 if ($Lines[$x] =~ m/Connects to "(.*)"/i); $ircdport = $1 if ($Lines[$x] =~ m/ports+(.*)s/i); $botname = $1 if ($Lines[$x] =~ m/nicknames+(.*)[.]+/i); $botident = $1 if ($Lines[$x] =~ m/usernames+(.*)[.]+/i); $botchan = $1 if ($Lines[$x] =~ m/Channels+(.*)[.]+/i); $botumode = $1 if ($Lines[$x] =~ m/Usermodesforsusers.*s+(.*)/i); $botmutex = $1 if ($Lines[$x] =~ m/Mutexs+(.*)[.]+/i); $botchanpass = $1 if ($Lines[$x] =~ m/Passwords+(.*)[.]+/i); $botfile = $1 if ($Lines[$x] =~ m/Createssfiles(.*)[.]+/i); $botmd5 = $1 if ($Lines[$x] =~ m/MD5shash:s+(.*)[.]+/i); } unless (defined $ircd) { $ircd = "No IRC Connection!";} unless (defined $ircdport) { $ircdport = "No Port set!";} print "nNr. $msgno nFilename: $botfile nMD5-Hash: $botmd5 nServer: $ircd nPort: $ircdport nBotnick: $botname nBotident: $botident nChannel: $botchan nChannel-Password: $botchanpass nUsermode: $botumode nMutex Handle: $botmutex nn---n"; @Lines = $pop3->Body($msgno); for ($x = 0; $x <= $#Lines; $x++) { # print $Lines[$x]; } }} else { print "Sorry, no Mailnn"; } $pop3->Close(); my $string_time = localtime; my $name = getpwuid $<; if (!defined($name)) { $name = "UID: $<"; } print "n-----------------------------------------------------------nAutomatically generated at ${string_time} by ${name}nJudasBot by Mindfuck (c)2007 - bawtmaster@gmail.comnn";
Ich versteh die Frage nicht
1 Besucher lesen dieses Thema
Mitglieder: 0, Gäste: 1, unsichtbare Mitglieder: 0