#!/usr/bin/perl # Skrypt do wysyłania smsów przez www.miastoplusa.pl # # (c) 2002-2003 Przemysław Frasunek # Piotr Kassin # # Licencja GNU # # Wersja z 23/07/2003 use LWP::UserAgent; use HTTP::Cookies; if (@ARGV < 1) { print "Użycie: $0 [wiadomość]\n"; print "Przykład: $0 venglin xxx 601062409 \"masa yo yo\"\n"; print "Jeśli nie podasz wiadomości jako argumentu, to program "; print "wczyta ją z stdin.\n"; exit 0; } if (@ARGV < 2) { ($username, $haslo, $telefon) = @ARGV; print "Wklepaj wiadomość i pacnij enter\n\n"; $wiadomosc = ; } else { ($username, $haslo, $telefon, $wiadomosc) = @ARGV; } $dir=$ENV{'HOME'}; if ($telefon !~ /^[0-9]{9}$/) { open(PLIK, "$dir/.miasto") || die "Nie ma ksiazki"; while ($dane = ) { @ktos = split(" ", $dane); $ksiazka{$ktos[0]} = $ktos[1]; if ($telefon =~ /lista/) { print "$ktos[0] \t\t $ktos[1]\n"; } } close PLIK; if ($telefon =~ /lista/) { exit 0; } print "Ksiazka: $telefon - "; $telefon=$ksiazka{"$telefon"}; print "$telefon\n"; } if ($telefon !~ /^(5|6)(0|9)[0-9]{7}$/) { print "Zły format numeru.\n"; exit 1; } $ua = new LWP::UserAgent; #$ua->proxy('http','http://192.168.111.100:3128/'); $cookie = new HTTP::Cookies; $ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)'); $req = new HTTP::Request GET => 'http://www.miastoplusa.pl/login.jsp'; $res = $ua->request($req); $cookie->extract_cookies($res); if (!$res->is_success) { print "$username -> $telefon: Błąd HTTP (main).\n"; exit 1; } $req = new HTTP::Request POST => 'http://www.miastoplusa.pl/auth/LoginCitizen.do'; $req->content_type('application/x-www-form-urlencoded'); $req->content("login=$username&password=$haslo"); $cookie->add_cookie_header($req); $res = $ua->request($req); if (!$res->is_success) { print "$username -> $telefon: Błąd HTTP (login).\n"; #exit 1; } $req = new HTTP::Request POST => 'http://www.miastoplusa.pl/m/kontaktor/SendMessage.do'; $req->content_type('application/x-www-form-urlencoded'); $req->content("msg=$wiadomosc&r=1&phone=$telefon"); $cookie->add_cookie_header($req); $res = $ua->request($req); if (!$res->is_success) { print "$username -> $telefon: Błąd HTTP (lub autoryzacji).\n"; exit 1; } if ($res->content !~ /Wiadomość została wysłana/) { print "$username -> $telefon: Błąd bramki.\n"; exit 1; } exit 0;