tags:

views:

30

answers:

4

I would like to call a swf file which takes some parameters, but I do not want those parameters to visible on the client (let's say a secret authentication token or something like that).

I thought I would write a simple PHP proxy script like this:

header('Content-type: application/x-shockwave-flash');
readfile('http://path/to/swf/file.swf?here=are&some=parameters');

And then simply to do

<embed src="/path/to/php/proxy.php'/>

But the flash parameters don't seem to be making it to the swf. Is something like this possible?

A: 

GET parameters don't work that way. They only work through the web. Can your SWF file accept parameters through some other method such as POST?

The best way would be to encrypt them but almost anything you do will likely require changing the Flash to accept some other kind of input.

Cfreak
Of course they work this way. readfile is making a request over HTTP just like a web browser, and if I put the url with the query string directly into my browser, it works just fine.
blockhead
No, they don't. You're accessing the SWF through the filesystem, not the web server.
Ignacio Vazquez-Abrams
I've updated my post so that it's clearer that it's using HTTP
blockhead
From the documention: "Reads a file and writes it to the output buffer." - I have not found any information about a HTTP request on the documentation page... it uses fopen which could emulate file access over HTTP...
Hippo
If you put readfile('http://www.google.com'); in to a php script, you will see google's home page. Convinced?
blockhead
Warning: readfile(google.com): failed to open stream: No such file or directory in no_it_doesnt.php on line 3 - so no I'm not convinced. Put http:// on it, it does but default is to look at the filesystem. Also IMHO this is one of PHP's worst design decisions to mix reading from file systems or URLs.
Cfreak
The point is, if you have an http:// there, it uses HTTP. I could have easily used cURL to do the same thing. That's not at all my point. I just choice to use readfile because it's one line instead of 5.
blockhead
And twice you didn't do it and everyone pointed out that it won't work that way.
Cfreak
you are reading the file over http to the output buffer... the swf reads the GET parameters when it is *executed* not when it loaded from the server/file system... thats the reason why readfile will not work, because the parameters aren't there when you embedded into the webpage...
Hippo
A: 

There is no way to start a flash movie with any parameters that are not invisible to the user. (You always could use Firebug or something similar.)
Easiest approach would be to recieve the data from the server after starting the movie and encrypt the communication between them.

Hippo
No good, although not trivial, ajax code can be clearly seen in the JS debugger...
Sean Farrell
thats why you should encrypt it... ;-)
Hippo
A: 

The way you are doing it the parameters are not being sent as part of the GET request so Flash never sees them.

There is no straight forward way of doing what you want, but your best bet is to re-generate the auth token for the user each time they log-in, and even rotate the token after each call you make to the server.

The real thing is that you can't hide anything from a sniffer (like Fiddler/WireShark/Charles) so a dynamic token is probably the only way to go (resorting to HTTPS/AMF and anything palliative for securing the transport layer will just be an extra, as your primary token would still be in the clear.)

gonchuki
A: 

Think again what you are doing. You are reading a swf file from disk and serves it to the user. I wonder why the file system takes the added "parameters" without error. Then the flash gets executed on the users machine. Where are the arguments, now? You did not send them to the user, did you? You did not modify the flash file, did you? So yea, you are basically out of luck... You are only doing the same thing a web server does, only slower.

What you can do though, use a cross site scripting approach. Send out the frame HTML with a randomly generated "pass phrase". You store the "pass phrase" somewhere, like a database. Then use code such as:

<embed src="/path/to/php/proxy.php?pass=dfkhslrufbeuip'/>

Only ever serve the file if it is a valid pass phrase.

Ok the flash is not protected, the user can still "save as" and play it alone. But at least you don't have the trouble of someone hogging your bandwidth from a different site...

Sean Farrell
Actually you could pass the pass phase to flash too and let flash authenticate against your server. (In the flash app.) But my AS knowledge is not sufficient here...
Sean Farrell
I'm not reading an swf file from disk. I'm reading it over HTTP.
blockhead