Stories
Slash Boxes
Comments

SoylentNews is people

Journal by fliptop

The iGuard IP250E requires cookies for authentication. Modifying Part 3's script is pretty simple. Below are just the additional code chunks. Whole script is available here.

use HTML::Form;
use HTTP::Cookies;

Add these to your includes.

my $ua = LWP::UserAgent->new;
$ua->cookie_jar(HTTP::Cookies->new(file => "/tmp/iguard-ip250e.txt", autosave => 1));
$ua->agent("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.13) Gecko/2009080317 Fedora/3.0.13-1.fc10 Firefox/3.0.13");

Here we tell our useragent object where to store any cookies.

my $uri = 'http://192.168.1.243/image.cgi';
my $res = $ua->request(HTTP::Request->new(GET => $uri));
my $status = $res->status_line;
printf LOG "unable to process initial cookie request, status code is: %s", $status
  unless $status eq '200 OK' || $status eq '302 Found';

my ($form) = HTML::Form->parse($res);
print LOG "form: ", Dumper($form) if DEBUG;

$form->value('$login_un' => 'username');
$form->value('$login_pw' => 'password');

On the iGuard IP250E, there's a simple login form returned if you request image.cgi We parse the form and assign the username/password params.

$res = $ua->request($form->click);
$status = $res->status_line;
printf LOG "unable to submit username/password, status code is: %s", $status
  unless $status eq '200 OK' || $status eq '302 Found';

$uri = 'http://192.168.1.243/showimg_pda.cgi?cam=1';

my $im = Image::Magick->new();

Submit the form by issuing click. The URI showimg_pda.cgi?cam=1 is the way to return just the image from the iGuard. The rest of the code is the same.

 

Post Comment

Edit Comment You are not logged in. You can log in now using the convenient form below, or Create an Account, or post as Anonymous Coward.

Public Terminal

Anonymous Coward [ Create an Account ]

Use the Preview Button! Check those URLs!


Logged-in users aren't forced to preview their comments. Create an Account!

Allowed HTML
<b|i|p|br|a|ol|ul|li|dl|dt|dd|em|strong|tt|blockquote|div|ecode|quote|sup|sub|abbr|sarc|sarcasm|user|spoiler|del>

URLs
<URL:http://example.com/> will auto-link a URL

Important Stuff

  • Please try to keep posts on topic.
  • Try to reply to other people's comments instead of starting new threads.
  • Read other people's messages before posting your own to avoid simply duplicating what has already been said.
  • Use a clear subject that describes what your message is about.
  • Offtopic, Inflammatory, Inappropriate, Illegal, or Offensive comments might be moderated. (You can read everything, even moderated posts, by adjusting your threshold on the User Preferences Page)
  • If you want replies to your comments sent to you, consider logging in or creating an account.

If you are having a problem with accounts or comment posting, please yell for help.