Home
Home Page
In detail about Robots.txt
Safe programming on PHP
We write elementary rassylhhik
Use of HTML-tables for a conclusion of diagrams
What is dorvei? Whether Banjat for them?
How to learn{find out} on what searches find my site in search machines?
Cunnings of tabulared design. (we form a framework of the table)
The guest book on PHP
BB-codes
We hide counters
Use of patterns of design in ASP.NET
RSS the generator
Search optimization of a site
Metatags
Optimization for MSN
We
Cookies - fresh rolls
Superdynamical webs - interfaces
Links
 

We write elementary rassylhhik

LWP + HTTP::Request::Common + HTML:: Parser


As considers Larri Uol - one of the greatest qualities of any progrmmista is his  laziness.

It agree. Our channels have bothered, has bothered to pay money for three lines of the text, and the most important-

Has bothered to load iksy and a Netscape what free-of-charge to send sms.


Well that this laziest Uol has invented perl, and ostal`ye linivcy - the module.


To business.

The problem  - to send sms from the command line not loading a browser.

At successful performance - broadcasting unlimited dispatch (a spam a reluctance it to name) sms.


1. We search for a suitable resource of dispatch. Repeatedly we send sms to different operators,

We note time of delivery and reliability.

2. We look at system of safety of a resource and who gives a gate.

It was essentially important for me gate Kievstara since on him  I send more often

They have protected in total and page in the best way (.gif not razberesh though would listen to opinions).


On first two items{points} I vnimani was involved with a resource of "Telecom" http://telecom.com.ua <http: // www.internet-technologies.ru/? url=http%3A%2F%2Ftelecom.com.ua>

He not only very quickly delivers sms on Kievstar but there fat the inscription shined

" The software for a gate is given by the company " Kievstar GSM " ".

At me already handles were combed.

Fluently having familiarized with the form (razljadyvaja html) - any barrier. Three parameters of search:


1. Number{Room} of the addressee, in the form to_addr.

2. "Nutcracker" - whether accepts phone kirilicu, in the form dcs.

3. Actually @ text sms, in the form new_body.


The form without superfluous entrails:



<form name=sms method = "post" action = "/cgi-bin/sms/sms.pl " onsubmit = " return SendForm () ">

<input type=text name=to_addr> <input type=radio value=1 name=dcs onClick=setLen (this.value)>

<input type=radio value=0 name=dcs checked onClick=setLen (this.value)>

<textarea name=new_body cols=40 rows=4 wrap=virtual onChange=checkLen (document.forms [0]) onKeyUp=checkLen (document.forms [0])> </textarea>

<input type=hidden name=kfY value ='KLHNcbbv7pPXg7Frdjl9V8SS7bGRDHyOS6bvX3gV '>

<! - <input type=hidden name=no_spam value ='YLIQc4jXJZeAdvrtQHoQ '>->

</form>


Really all so is simple? And here I see two more not clear parameters

With pometochko hidden: one of them changed the value with each loading and

That name that value absolutely magnificent names a cat normal had

The person in a normal status never would think up.

The second - type zakomentirovannyj no_spam - from supervision and last name we judge:

"Have thrown" in us digital podpisju!

Means attack " in a forehead " will fail.


The algorithm is simple:

We empty page, we assort, we get values dynamically changed{changeable}

Parameters of the signature as that khesh and the signature. We write the letter to the friend,

To it  atachim the same parameters. We thrust to the server and let chews.

With shout - " there Is no barrier to patriots! " Has got from CPANa and has grinded HTML:: Parser.


That turns out...



*!/usr/bin/perl

warn " Loading... nn ";


* Modules


use strict;

use warnings;

use LWP;

use HTTP::Request::Common;

use HTML:: Parser;


* Constants: 1-n the address of a page with the form, 2-n adress the script.


use constant SMS_CENTER => ' http: // telecom.com.ua/smsgate / ';

use constant SMS_SCRIPT => ' http: // telecom.com.ua/cgi-bin/sms/sms.pl ';


*************************** Reception of the data for sending KOI8-ru ***************


print " Kyiv Star 067XXXXXXXn

        UMC 050XXXXXXXn

        Goblin Telecom 039XXXXXXn

        WellCOM 068XXXXXn

        Phone number poluchatelja:n ";

my $to_addr = <STDIN>; chomp ($to_addr); $to_addr = ' 0000000000 ' unless $to_addr;


Whether print " the addressee kirilicu Distinguishes? (0 - No) (1 - Yes) n ";

my $dcs = <STDIN>; chomp ($dcs); $dcs = 0 unless $dcs;


print " the Text soobhhenija:n ";

my $new_body = <STDIN>; chomp ($new_body);

$new_body = ' test message from LWP ' unless $new_body;


************************ Sending the data on ************* server



************** Parameters such as a browser (thanks perl.dp.ua:) ******************


my @ns_headers = (

        ' User-Agent ' => ' Mozilla/4.76 [ru] (Win98; U) ',

        'Accept' => ' image/gif, image/x-xbitmap, image/jpeg,

        image/pjpeg, image/png, */* ',

        ' Accept-Charset ' => ' koi8-ru, *, utf-8 ',

        ' Accept-Language ' => ' en-US ',

);


************************ Connection to ************* server

$ | =1; *** we disconnect buffering

my $ua = LWP:: UserAgent-> new;

$ua-> agent (@ns_headers, push {$ ua-> requests_redirectable}, ' POST ');


****** We follow new page with the form *********


my $request = HTTP::Request-> new (GET => SMS_CENTER);

my $parser = HTML:: Parser-> new (api_version => 3); *** new object razborhhika


************* Adjustment razborhhika


*** The name khehsha and his  value here understands. Function start will engage in it

my ($hash_name, $hash) = $parser-> handler (start => *start, ' tagname, attr '); *** as attributes of function are passed a name tega and his  value


*** Value of the digital signature - function hidden

my $cifer = $parser-> handler (comment => *hidden, ' tagname '); ** here we need only a name tega


my $response = $ua-> request ($request, sub {$parser-> parse (shift)}); *** we receive page and it is passed razborhhiku

$parser-> eof; *** razborhhik it is not necessary any more


    die $response-> status_line unless $response-> is_success; *** we "die" if there is no answer



system (' clear '); *** we clear the screen

print " the data Are received... n

        Number{Room} of the addressee: $to_addrn

        Reception kirilicy: $dcsn

        The message: $new_bodyn

        The data khehsha: $hash_name = $hashn

        The signature: $cifernn

    ";


*********** We fill the form ***************


$request = POST (SMS_SCRIPT,

        Content => [

            to_addr => $to_addr,

            dcs => $dcs,

            new_body => $new_body,

            $hash_name => $hash,

            no_spam => $cifer

],

        Referer => SMS_CENTER

);

    $response = $ua-> request ($request); ********** It is sent on the server

    die $response-> status_line unless $response-> is_success; *** if there is no answer - leave



print $response-> content; ***** it is received (for debugging) the answer of the server





************************ functions *****************

******** All functions are transparent if the description will be necessary.


sub start {

    my ($tag, $attr) = _;

    if ($tag eq ' input ') {

        return unless $attr-> {type};

        if ($attr-> {type} eq ' hidden ') {

        $hash_name = $ attr-> {name};

        $hash = $attr-> {value};

        return;

}

}


}

sub hidden {

    my ($tag) = _;

    if ($tag = ~ m / (input type=hidden name=no_spam value = ') (w +) (' *)/i) {

        $cifer = $2;

        return;

}

}


Well and toward the end I shall say, that dl I other "animals" have connected all this business through CGI with an opportunity of dispatch up to 30 subscribers at once, have laid out on a server at office, all are happy and pleased to such freebie.


At once I warn, in the same place costs{stands} vychisljalka IP so without a normal masquerade all the same will fail to send more than 5 sms. And this server khrenoven`ko sends on numbers{rooms} UMC (a gate all taki Kievstarovskij). So take others and hollow. By the way at UMC all is realized not more difficultly than at "Telecom". Draw conclusions:)


Success.