PDA

View Full Version : Secure FTP Action Plugin


Ulrich
08-19-2008, 04:05 PM
I am currently working on a plugin for secure FTP. You can use this plugin to connect to secure FTP servers with SSL.

For now, it has limited functionality, as this is work in progress. But you can already do the following:

Connect to servers using FTP with TLS/SSL, explicit mode
Connect to servers using FTP with TLS/SSL, implicit mode
Upload text or binary files
Download text or binary files
Disconnect from the server gracefully

Please note: This is for secure FTP servers (FTPS), not normal FTP servers communicating through a secure SSH tunnel!

Currently I have no directory navigation, listing, file renaming or removal - just upload and download, as written above. But these missing functions will be implemented in the near future.

The plugin is available as part of my Utilities package (http://www.mindquake.com.br/files/ams/UtilitiesSetup.exe). Documentation is included, but also available here (http://www.mindquake.com.br/files/ams/FTP2_Help.htm).

This plugin was tested against the free ZFTP Server (http://www.zftpserver.com/) and proved to work correctly with explicit and implicit TLS/SSL connections. Common, unsecure FTP connections are not supported - for those, please use the FTP plugin provided with AMS 7.0.

The plugin, in its current state, is free. I won't guarantee that latter versions with more functions will stay free as well. But if the current state of the action plugin is already enough to help you out in a commercial project, you may use it without problems.

Ulrich

jassing
08-19-2008, 07:52 PM
Ulrich-
Thanks for your work -- if you like; I can create an account on my server for you to test against.

i will be giving your plugin a go; as I am currently shelling out to do some ftp'ing in SUF8 for a clienit... not as clean as i would like...

-josh

Canter
08-19-2008, 09:03 PM
Thanks for your post. This is badly needed and I'm sure many will appreciate your efforts here.
:)

Dermot
08-19-2008, 09:14 PM
Excellent! thanks for sharing.

Ulrich
08-20-2008, 02:05 PM
I updated the FTP2 plugin to version 1.0.0.1. Changes since the release yesterday:


Functions renamed for better compatibility with the original AutoPlay "FTP" plugin:
FTP2.ConnectExplicit();
FTP2.ConnectImplicit();
FTP2.Disconnect();
FTP2.Upload();
FTP2.Download();
Some connection parameters are now boolean (as they should have been);
New function FTP2.ChangeDir();
New function FTP2.Delete();
New function FTP2.Rename();


It would nice to know if somebody was able to perform FTPS connections and file transfers with this plugin.
Here is a simple script which uses the available functions so far:

res = FTP2.ConnectImplicit("192.168.0.14", "admin", "password", 990, true, false);
if (res ~= 0) then
error = Application.GetLastError();
Dialog.Message("FTP2", "Could not establish FTPS connection. ("..error..")");
else
-- attempt secure file upload
filename = "file-" .. System.GetDate(DATE_FMT_ISO) .. System.GetTime(TIME_FMT_HOUR)..System.GetTime(TIME _FMT_MIN)..System.GetTime(TIME_FMT_SEC) .. ".test";
res = FTP2.Upload("D:\\TEMP\\sja.log", filename);
if (res ~= 0) then
error = Application.GetLastError();
Dialog.Message("FTP2", "Could not upload file. ("..error..")");
else
-- rename the remote file
res = FTP2.Rename(filename, "new-" .. filename);
if (res ~= 0) then
error = Application.GetLastError();
Dialog.Message("FTP2", "Could not rename file. ("..error..")");
else
-- attempt download of the renamed file
res = FTP2.Download("new-" .. filename, "D:\\TEMP\\down-" .. filename);
if (res ~= 0) then
error = Application.GetLastError();
Dialog.Message("FTP2", "Could not download file. ("..error..")");
else
-- delete the remote file
res = FTP2.Delete("new-" .. filename);
if (res ~= 0) then
error = Application.GetLastError();
Dialog.Message("FTP2", "Could not delete file. ("..error..")");
else
Dialog.Message("FTP2", "Done.");
end
end
end
end
FTP2.Disconnect();
end


Ulrich

Canter
08-20-2008, 02:21 PM
Well, AMS can't find the plugin, which I installed in the plugins directory. Using AMS7 (64 bit Vista, if that matters).

L Canter

Ulrich
08-20-2008, 02:37 PM
You should create a new folder for the plugin under ..\AutoPlay Media Studio 7.0\Plugins\Actions, and unzip the files there. Like C:\Program Files\AutoPlay Media Studio 7.0\Plugins\Actions\FTP2\.., for example. Did you do that? There should already exist folders for CDAudio, Clipboard, FTP and SQLite.

I just tested on a fresh install of AMS7 over Windows Vista (32 bits) and the plugin was found as expected.

Ulrich

ShadowUK
08-20-2008, 02:41 PM
Cool, I thought I could use this but my server is not FTPS.

Canter
08-20-2008, 02:44 PM
OK, I had just put it in the project folder , not the application, so it does now see the plugin. However, I do get the following error message:
Attempt to call field 'Open_FTP_SSL_Implicit' (a nil value)

Ulrich
08-20-2008, 02:49 PM
Canter, you are using the current version of the plugin with a function name used in the former release. Today Open_FTP_SSL_Implicit was renamed to ConnectImplicit, as I wrote earlier. Please check the help file and the example I provided here.

Ulrich

Canter
08-20-2008, 02:58 PM
Thanks - you were right about that, but now I get 12002 errors, can't connect - I"ve tried accessing 3 different FTP servers, all the same result.

Ulrich
08-20-2008, 03:22 PM
Are you absolutely sure that those were secure FTP servers? This plugin will not work with standard FTP servers without encrypted data exchange.

Here is a FTPS server, I'll leave it open for a couple of hours.

IP address: 74.86.188.83
Username: plugin
Password: ams70rocks
Protocol: Implicit SSL/TLS on port 990

Ulrich

Dermot
08-20-2008, 03:38 PM
Works perfectly for me using your test FTP server.

Canter
08-20-2008, 03:50 PM
That didn't work either - maybe I have something set wrong? Here is the debug trace output:

*** LOCATION: Page1 -> On Preload
[2]: Debug.ShowWindow(true);
[4]: result = FTP2.ConnectImplicit("74.86.188.83", "plugin", 'ams70rocks', 990, true, false);
TRACE: LastError = 0 ("Success.")
[5]: if (res ~= 0) then
[6]: error = Application.GetLastError();
[7]: Dialog.Message("FTP2", "Could not establish FTPS connection. ("..error..")");
TRACE: LastError = 0 ("Success.")
[40]: end

Ulrich
08-20-2008, 04:05 PM
[2]: Debug.ShowWindow(true);
[4]: result = FTP2.ConnectImplicit("74.86.188.83", "plugin", 'ams70rocks', 990, true, false);
TRACE: LastError = 0 ("Success.")
[5]: if (res ~= 0) then
[6]: error = Application.GetLastError();
[7]: Dialog.Message("FTP2", "Could not establish FTPS connection. ("..error..")");
TRACE: LastError = 0 ("Success.")
[40]: end

I see that you did connect to the server successfully. Your script is wrong: You set the answer of ConnectImplicit into result, and in the next line you compare variable res (which should be nil), instead of result, against 0.

The line with TRACE: LastError = 0 ("Success.") should alert you that the connection was made successfully.

Ulrich

Canter
08-20-2008, 04:13 PM
That's what I get for cutting and pasting.:wow
Sorry for the confusion - I was confused by the Success=0 but the not connected alert kept popping up.

So, looks good. Thanks again.


Larry

christhomas
09-02-2008, 04:07 PM
I'm having problems with the standard FTP plugin. The issue (a show stopper) is that I cannot reliably download large files, i.e. 1 gig to 5gig (only tested with 2.8gig file so far....)

Does your plugin have any issues with larger files in the gigabytes? If so, I could setup my FTP server with a secure connection. But there's not much point if it cannot handle 3,4 ,5 and up gig files.

Cheers

Chris Thomas
www.cg-academy.net

jassing
09-02-2008, 04:18 PM
I'm having problems with the standard FTP plugin. The issue (a show stopper) is that I cannot reliably download large files, i.e. 1 gig to 5gig (only tested with 2.8gig file so far....)

Does your plugin have any issues with larger files in the gigabytes? If so, I could setup my FTP server with a secure connection. But there's not much point if it cannot handle 3,4 ,5 and up gig files.

Cheers

Chris Thomas
www.cg-academy.net

FTP is relatively unreliable as it doesn't have a lot of built in packet-checks...

Can you reliably use ftp.exe to download these large files? if so, then it could be the plugin -- but I just did a 3 gig file (LAN) via the ftp plugin w/o issue...

christhomas
09-02-2008, 05:17 PM
Well, I don't really see much of an alternative. From what I understand, HTTP transfers are not as reliable, and are also slower. With smaller files i.e. 34mb the FTP plugin has been sterling. Its been downloading the files quickly and with a 100% success rate, and those both over a local test (from a windows PC to an FTP server running on a virtual linux box) and also over the internet.

The FTP server is a very well regarded one, and one with large file support. I've tested downloading the 2.8gig file from my Linux server using CuteFTP, and it seems to work fine. The server was giving me a bandwidth speed of 149mbits, and the downloaded .zip file was fine.

So, the problem does appear at this point to be with the FTP plugin. My guess is it simply cannot handle (correctly) files that are over 2gig (32bit file handles?).

Intrigued
09-02-2008, 05:53 PM
Thanks upeters.

christhomas
09-02-2008, 09:34 PM
Can anyone confirm (or not) if this plugin can handle downloading large files i.e. 2gb+ , ideally 4gb+

?

Cheers

CT

Ulrich
09-02-2008, 09:59 PM
I'll have to check. But as I still haven't managed to implement callbacks in this plugin, it probably isn't a good idea to use it in the current stage, as you won't have any idea how much of the data was already transferred. And I understood that you are able to transfer the huge files with the normal FTP plugin, just the callback function is showing a wrong amount, due to a variable overflow.

Ulrich

christhomas
09-02-2008, 10:16 PM
Hi, well, yes and no. One download off site, at a friends that was testing the manager for me did seem to download the file. He reported my manager had downloaded the 2.8gb file and had unzipped it correctly. However, he said the manager had then gone into a loop and was acting oddly (I've tested it with several 34mb files, like download 3 files in a batch, and it was fine). So it looks like the 2.8gb file freaked it out.....

However.. I've tested it locally earlier this evening. And it was problematical. I left it downloading, and came back to find it was still downloading, even though the (real) file size on my local disk was up to 5.6GB. Not good when the actual file is 2.8GB. It seems to have just not realized that the file was complete, and was just adding to it in a loop. I've tested downloading this same file using CuteFTP, and that worked perfectly.

I've tested the ItemInfo action of the FTP system, and its also broken i.e. its reporting a negative size for the 2.8gb file, in fact its reporting -1255mb, which is totally out of whack.

I've also considered using an externail open source FTP system. But thats just not viable. No way of getting any info back into AMS as to the download progress and so on. It would also basically require me to write a whole suite of wrappers to get what I really should be getting with AMS out of the box.

This looks like a show-stopper bug with the FTP plugin (a standard feature of AMS 7+). There is also another bug with the Download callback system that someone else has reported I guess. i.e. If you return FALSE to the Download action, its meant to abort the download (a useful feature). However, this does not work at all. So right now, the only way to abort a download is to disconnect from the server totally. Which is not ideal.

Looks like the FTP plugin needs some serious love from the AMS coders?