Automate password access

 
Post new topic   Reply to topic    Aprelium Forum Index -> General Questions
View previous topic :: View next topic  
Author Message
warwound
-


Joined: 17 Mar 2005
Posts: 9
Location: UK

PostPosted: Thu Apr 28, 2005 8:56 pm    Post subject: Automate password access Reply with quote

I have a simple problem..

Some of my website folders are password protected - and this includes my online webcam stuff.
Accessing evrything with a browser works perfectly - i get a user/pass dialog to complete and that's it.

I have now written a program to access my webcam image from a mobile phone - i've written the program in MobileBASIC.
Of course access to the webcam image from my mobile is denied as the MobileBASIC environment doesn't work like a browser and prompt me for user/pass.

Here's the (edited) code within my program that attempts to access the webcam image:

Code:
sub updateImage
REM read and display remote image
open #1,"http://mywebsiteURL/image.jpg,"INPUT"
image$=""
trap done

readLoop:
get #1,byte%
image$=image$+chr$(byte%)
goto readLoop

done:
trap notOpen
close #1
notOpen:
REM debug if image open fails


I've tried variations of URL (format) to try to pass my username and password to Abyss webserver but they failed.
I tried
http://user:pass@mywebsiteURL
and also:
http://mywebsiteURL user=$$$ pass=$$$

MobileBASIC support forum is down and has been for ages so no luck for help there.
Can anyone help?
Or is this likely to be a problem for the MobileBASIC forum?

Thanks.

warwound.

PS My program works if i remove the password protection from the webcam folder.
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Fri Apr 29, 2005 4:28 pm    Post subject: Re: Automate password access Reply with quote

warwound,

It seems that MobileBasic does not know how to transform the URL:

http://user:pass@mywebsite/path

in a valid HTTP request.

Such a URL should result in the following HTTP request:

Code:

GET /path HTTP/1.1
Host: mywebsite
Authorization: Basic XXXXXXX



Where XXXXXXX is the value of Base64_encoding( "user:pass" ).
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
warwound
-


Joined: 17 Mar 2005
Posts: 9
Location: UK

PostPosted: Sat Apr 30, 2005 8:42 pm    Post subject: Reply with quote

Thanks for the reply.

Looks like i'll have to either abandon password protection on my webcam or write my webcam viewer in another language..

warwound.
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sun May 01, 2005 1:16 pm    Post subject: Reply with quote

warwound,

We have an idea: you create a small script (in PHP or Perl) that will take the password on the URL, validate it, and send back the image.

The URL will be something like http://yoursite/dir1/script.php?pass=thepassword

The MobileBasic won't have a problem with this URL.

If you want help writing this script, let us know. :-)
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Sun May 01, 2005 4:43 pm    Post subject: Reply with quote

aprelium wrote:
warwound,

We have an idea: you create a small script (in PHP or Perl) that will take the password on the URL, validate it, and send back the image.

The URL will be something like http://yoursite/dir1/script.php?pass=thepassword

The MobileBasic won't have a problem with this URL.

If you want help writing this script, let us know. :-)


Code:
<?PHP

if ($_GET['password']=="123456")
{
echo "<IMG SCR=/"webcam.jpg/">";
} else {
echo "Access Denied";
}
?>


This would give you access if you use: "file.php?password=123456"
Back to top View user's profile Send private message
Tim1681
-


Joined: 17 Jan 2005
Posts: 160
Location: Bristol, CT, USA

PostPosted: Sun May 01, 2005 4:58 pm    Post subject: Reply with quote

Just a kind of off topic question, is there anyway to have that PHP code check for multiple passwords?
Back to top View user's profile Send private message AIM Address
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Sun May 01, 2005 6:45 pm    Post subject: Reply with quote

Tim1681 wrote:
Just a kind of off topic question, is there anyway to have that PHP code check for multiple passwords?


Code:

<?PHP

$granted="Logged in!";

if ($_GET['password']=="pass1")
{
echo "$granted";
}
elseifif ($_GET['password']=="pass2")
{
echo "$granted";
}
else {
echo "Access Denied";
}
?>



If you need more than 2 passwords, just add some more "elseif" between the IF and the ELSE.
Back to top View user's profile Send private message
warwound
-


Joined: 17 Mar 2005
Posts: 9
Location: UK

PostPosted: Sun May 01, 2005 10:09 pm    Post subject: Reply with quote

Many thanks for the further help.
First obstacle was that MobileBASIC needs to open the JPG and read it byte by byte - HTML IMG SRC was no good.
Luckily a MobileBASIC sample - ImageServer.PHP - showed the way.
Here's ImageServer.PHP after i made a few edits..
Code:
<?PHP
if ($_GET['password']=="mypass")
{
$rawdata = $HTTP_RAW_POST_DATA;
$hi = ord($rawdata[0]);
$lo = ord($rawdata[1]);
$len = $hi * 256 + $lo;
#
//$fp = fopen(substr($rawdata,2,$len), "rb");
$fp = fopen("../protected/webcam/untitled.jpg", "rb");
if ($fp)
  fpassthru($fp);
}
?>

I don't understand the commented out line - '//$fp = fopen' etc - by the way. Looks like i could delete just about all of the original script and just keep the last few lines?

So i can leave the webcam folder password protected and the PHP script (not in a password protected folder) can gain access to it.
A quick re-write of my MobileBASIC program and all works well - or so it seemed...
Once running on my NGage, my program eats up the memory and grinds to a halt - a major memory leak as each new downloaded image is assigned new memory. Memory not being re-used or freed after use.
Taking into account the limits of the MobileBASIC language, and the fact that it's support forums have been down for quite a while - rumour is that MobileBASIC updates and support have come to an end - i've decided to shelve this project rather than waste any more time with it.
An alternative - MIDletPascal - looks very promising but i'm waiting for it to be updated so that it's midlets will work on my (Symbian) NGage.

Maybe it's time to learn Java??

warwound.

PS Thanks cmxflash but i already have a working (cracked) copy of YellowFTP!

;-)
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> General Questions All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group