Advertisement
Quantumzblue

Test upload

Mar 29th, 2015
690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.62 KB | None | 0 0
  1. use strict;
  2. use warnings;
  3. use Data::Dumper;
  4. use HTTP::Request::Common;
  5. use LWP::UserAgent;
  6. #trianing time handle
  7. $| = 1;
  8. #========================= Make browser ==================================
  9. my $browser = LWP::UserAgent->new(
  10. agent => '  Mozilla/5.0 (Windows NT 6.3; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0',
  11. max_redirect => 1,
  12. timeout => 2000,
  13.                             );
  14.  # =======================================================================
  15.  
  16. sub main # 12.255.4 => 1
  17. {
  18.  # Maybe use @browser->is_online  to make the automatic data injection
  19.  
  20.  #======================== Setting day before post ============================
  21. my @months = qw(01 02 03 04 05 06 07 08 09 10 11 12 );
  22. my @days =   qw(06 0 01 02 03 04 05);
  23. #my $url = 'http://192.168.1.49/admin/configdivers.htm';  # I hope All electronic carte are the same IP ....
  24. my $url = 'http://192.168.1.49/admin/configdivers.htm';
  25. my $url1 = 'http://192.168.1.49/admin/configequipments.htm';
  26. #my $url = 'http://localhost/post';
  27. #my $url1 = 'http://localhost/post';
  28. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
  29. my $thisyear = $year +1900-2000;
  30. my $thishour = '';
  31. my $thisminut = '';
  32. my $thisday = '';
  33.  #===============Setting date and time data for send   ===============
  34.  
  35. if ($hour <= 9)
  36. {
  37. $thishour = '0'."$hour";
  38. }
  39. else {
  40.  
  41.     $thishour = "$hour";
  42. }
  43. if ($min <= 9){
  44.     $thisminut ='0'."$min";
  45. }
  46. else{
  47.     $thisminut ="$min";
  48. }
  49. if($mday <= 9)  {
  50. $thisday = '0'."$mday";
  51.                 }
  52. else            {
  53. $thisday = "$mday";
  54.                 }
  55.  
  56.  #======================================================================
  57. my $ua=LWP::UserAgent->new();
  58. $file = 'Stb3Web-1-27.bin';
  59.   print "Version: StbWeb 1-3.1 \n";
  60. my $request = HTTP::Request->new(POST 'http://192.168.1.49/mpfsupload', Content_Type => 'application/octet-stream', Content => [file_0 => ['Stb3Web-1-27.bin']]);
  61. my $response = $browser->request($request);
  62. print $response->error_as_HTML . "\n" if $response->is_error;
  63. print "$request \n "
  64. my $res = $ua->post(
  65.                   'http://192.168.1.49/mpfsupload',
  66.                   Content_Type => 'application/octet-stream',
  67.                   Content =>[
  68.                     fn => ["$file" => $file],
  69.                
  70.                   ],
  71.                 );
  72. print "Upload complete!\n"
  73.                                     }#end sub
  74. #my $connectionstatus = $browser->is_online;
  75. #=========================check connection Madafaka !!! ==================
  76. #if ($connectionstatus == 0)
  77. #                       {
  78. #sleep(1);
  79. #print "[!] Aucun de connection \r";
  80.  
  81. #       }# End unless while loop
  82. #else
  83. #{
  84. #   print "[+]Connection avec la carte d'electronique \n";
  85. # main();
  86. #}#end else
  87.  
  88. main();
  89. sleep(2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement