Advertisement
Guest User

for_qweqwe_by_anonym_alex_tkachenko

a guest
Aug 12th, 2011
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 4.40 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. use LWP::UserAgent;
  4. use HTTP::Cookies;
  5. use URI::Escape;
  6. use Encode qw/from_to/;
  7. use POSIX qw/strftime/;
  8. use JSON;
  9.  
  10. $mail = '';
  11. $pass = '';
  12. $noteid = '';
  13.  
  14. $browser = LWP::UserAgent->new;
  15. $cookie = HTTP::Cookies->new( file => 'cookies.cookies', autosave => 1, );
  16. $browser->cookie_jar($cookie);
  17.  
  18. sub str_replace {
  19.     my $replace_this = shift;
  20.     my $with_this  = shift;
  21.     my $string   = shift;
  22.    
  23.     my $length = length($string);
  24.     my $target = length($replace_this);
  25.    
  26.     for(my $i=0; $i<$length - $target + 1; $i++) {
  27.         if(substr($string,$i,$target) eq $replace_this) {
  28.             $string = substr($string,0,$i) . $with_this . substr($string,$i+$target);
  29.             return $string;
  30.         }
  31.     }
  32.     return $string;
  33. }
  34.  
  35.  
  36. print "\nStarted\n";
  37.  
  38. $login = $browser->get("http://login.vk.com/?act=login&email=$mail&pass=$pass")->as_string;
  39.  
  40. if($login =~ /reg/){
  41.     print "Auth fail\n";
  42.     exit(1);
  43. } else {
  44.     print "[*] Auth done\n";
  45. }
  46.  
  47.  
  48. print "[*] Parsing inbox...\n";
  49.  
  50. $inbox = $browser->get("http://vkontakte.ru/mail?section=inbox")->as_string;
  51.  
  52. if($inbox =~ /mail_summary">(.*) ([0-9]+) (.*)<\/span>/){
  53.     $inbox = $2;
  54. } else {
  55.     print "[fail]\n";
  56.     exit(1);
  57. }
  58.  
  59.  
  60. print "[*] Parsing outbox...\n";
  61.  
  62. $outbox = $browser->get("http://vkontakte.ru/mail?section=outbox")->as_string;
  63.  
  64. if($outbox =~ /mail_summary">(.*) ([0-9]+) (.*)<\/span>/){
  65.     $outbox = $2;
  66. } else {
  67.     print "[fail]";
  68.     exit(1);
  69. }
  70.  
  71. $intin = int($inbox);
  72. $intout = int($outbox);
  73. $total = $intin + $intout;
  74.  
  75.  
  76. print "[*] Parsing feed2...\n";
  77.  
  78. $feed2 = $browser->get("http://vkontakte.ru/feed2.php")->content;
  79. $json = JSON->new->allow_nonref;
  80.  
  81. $perl_scalar = $json->decode( $feed2 );
  82.  
  83.  
  84. if (defined($perl_scalar->{friends}->{count})){
  85.     $friends = $perl_scalar->{friends}->{count};
  86. }else{
  87.     $friends = "some error";
  88. }
  89.  
  90. if (defined($perl_scalar->{messages}->{count})){
  91.     $new_msg = $perl_scalar->{messages}->{count};
  92. }else{
  93.     $new_msg = "some error";
  94. }
  95.  
  96. if (defined($perl_scalar->{gifts}->{count})){
  97.     $gifts = $perl_scalar->{gifts}->{count};
  98. }else{
  99.     $gifts = "some error";
  100. }
  101.  
  102. if (defined($perl_scalar->{events}->{count})){
  103.     $events = $perl_scalar->{events}->{count};
  104. }else{
  105.     $events = "some error";
  106. }
  107.  
  108. if (defined($perl_scalar->{groups}->{count})){
  109.     $groups = $perl_scalar->{groups}->{count};
  110. }else{
  111.     $groups = "some error";
  112. }
  113.  
  114.  
  115. print "[*] Parsing payments...\n";
  116.  
  117. $votes = $browser->get("http://vkontakte.ru/payments.php")->as_string;
  118.  
  119. if($votes =~ /window.userBalance = '(.*)';/){
  120.     $votes = $1;
  121.     $money = $browser->get("http://vkontakte.ru/payments.php")->as_string;
  122.     if($money =~ /window.userMoney = '(.*)';/) {
  123.         $money = $1;
  124.     }
  125. }
  126.  
  127.  
  128. $all_friends = $browser->get("http://vkontakte.ru/friends?section=all")->as_string;
  129.  
  130. if($all_friends =~ /friends_summary">(.*) ([0-9]+) (.*)<\/div>/){
  131.     $all_friends = $2;
  132. }
  133.  
  134.  
  135. $time = strftime('%H:%M', localtime);
  136.  
  137. $title = "Умная заметка на Perl ($time)";
  138. $text = "
  139. {|
  140. |-
  141. ! Zametka (v.1.0)
  142. !
  143. |-
  144. | Всего друзей
  145. | $all_friends
  146. |-
  147. | Заявок в друзья
  148. | $friends
  149. |-
  150. | Личных сообщений
  151. | $total
  152. |-
  153. | Входящих
  154. | $inbox
  155. |-
  156. | Исходящих
  157. | $outbox
  158. |-
  159. | Новых сообщений
  160. | $new_msg
  161. |-
  162. | Новых подарков
  163. | $gifts
  164. |-
  165. | Приглашений на встречи
  166. | $events
  167. |-
  168. | Приглашений в группы
  169. | $groups
  170. |-
  171. | Количество голосов
  172. | $votes
  173. |-
  174. | Количество рублей
  175. | $money
  176. |-
  177. | Время последнего обновления скрипта
  178. | <b>$time</b>
  179. |}";
  180.  
  181. print "[*] Fetching action link...";
  182.  
  183. $editnote = $browser->get("http://m.vkontakte.ru/editnote$noteid")->as_string;
  184.  
  185. if($editnote =~ /action="(.*)"/) {
  186.     $link1 = "http://m.vkontakte.ru$1";
  187.     $link = str_replace('amp;', '', $link1);
  188.     $link = str_replace('amp;', '', $link);
  189.     $link = str_replace('amp;', '', $link);
  190.     print "[ok]\n";
  191. } else {
  192.     print "[fail]";
  193.     exit(0);
  194. }
  195.  
  196. print "[*] Updating note...";
  197.  
  198. $result = $browser->post($link, Content => "title=$title&post=$text")->as_string;
  199.  
  200. if($result =~ /\?m=3/) {
  201.     print "[ok]\n\n";
  202. } else {
  203.     print "[fail]\n";
  204. }
  205.  
  206. print "
  207. All friends : $all_friends
  208. New friends : $friends
  209. Total messages : $total
  210. Messages in inbox : $inbox
  211. Messages in outbox : $outbox
  212. New messages : $new_msg
  213. New gifts : $gifts
  214. New invite events : $events
  215. Vote : $votes
  216. Money : $money
  217. New invite groups : $groups\n\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement