Page 1 of 2

[Script] Auto Downloader

Posted: Fri Jan 20, 2017 12:22 am
by Doctor_Arsenic

Code: Select all

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//			Tribes Auto-Downloader script by Dr.Arsenic
//
//
//	* What it does: If the server you connect to has a client side file that you need to download to play,
//			this script will ask the server where to download the file and open up a window where
//			you can download the file.
//
//
//                     (1-19-2017 Date of Project Start) 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$AutoDownloaderVersion = "0.12 BETA";
$AutoDownloaderPopupTime = 5; // seconds to exit before window change
$AutoPopupHTMLWindows = true;

function onConnectionError(%client, %manager, %errorString)
{

	%serverName = $serverName;
	%url = $serverFileURL;

	$AutoLoaderExportInfo = "Server: "@$serverName@" - "@%errorString;
	$AutoLoaderExportURL = %URL;
	$AutoLoaderExportSpace = "-------------------------------------------------";

	export("AutoLoaderExport*","temp\\ConnectionErrorLog.log",true);


	$AutoLoaderExport = "";
	$AutoLoaderExportURL = "";
	$AutoLoaderExportSpace = "";

   if(%manager == 2048)
   {
   }
   else
   {
      Quickstart();
      $errorString = "Connection to server error:\n" @ %errorString;

	if($AutoPopupHTMLWindows) {
		if(%URL != "-1" && %URL != "") {
			$errorString = "<jc><f1>-= Auto Downloader v<f2>"@$AutoDownloaderVersion@"<f1> =-\n\n"@%serverName@" wants to send you to URL\n(<f2>"@%url@"<f1>)\n\n<f3>Exit this menu to cancel.";
			Schedule("AutoDownloader::HTMLOpen(\""@ %URL @"\");",$AutoDownloaderPopupTime);
		}
	}

      GuiPushDialog(MainWindow, "gui\\MessageDialog.gui");
      schedule("Control::setValue(MessageDialogTextFormat, $errorString);", 0);
   }
}

function AutoDownloader::HTMLOpen(%url)
{
	if(isObject(MessageDialogGUI))
	{
		HTMLOpen(%url);
	}
}

Put this in your AutoExec.cs to install. Server hosts define $Server::FileURL in your mod or config.

WHAT IT DOES:
-If you are unable to join a server because of invalid mission file (missing .ted file), bad version, or because of missing model (.dts) files, this script will auto send you to the server's file URL to get the missing files.
-You will be able to view the URL in Tribes, and have the option to stop before the HTML window actually pops up.


DISCLAIMER: I still need to add client crash protection, so use this with trusted servers only.

Re: [Script] Auto Downloader

Posted: Fri Jan 20, 2017 10:28 am
by perrinoia
function onConnectionError displays an error message with a close button (dialog box).

I suggest adding a download link to the dialog box.

I'm not entirely sure how to do that...

Here's my best guess:

First, append $Server::fileURL to the error message so the player knows what they are clicking on:

Code: Select all

	$errorString = sprintf("Connection to server error:\n%1\n\nDownload client-side content:\n%2", %error, $Server::fileURL);
Then, edit instant FearGuiFormattedText "MessageDialogTextFormat" in MessageDialog.gui.cs:

Code: Select all

					consoleCommand = "HTMLOpen($Server::fileURL);";
I think that might work... But I don't know for sure, cause it's text, not a button... Perhaps you'll need to add a button. I don't know.

If it doesn't work, it might be due to the fact that the error message dialog box is scheduled, and $Server::fileURL is deleted during the delay. I dunno.

Re: [Script] Auto Downloader

Posted: Fri Jan 20, 2017 11:43 am
by Doctor_Arsenic
Im getting hazy on remembering certain functuons. There is a gui popup function, once you push the popup the you can use Control::setValue to a specific message (if i remember correctly)

Re: [Script] Auto Downloader

Posted: Fri Jan 20, 2017 12:06 pm
by perrinoia
Yes. It's in your script.

Code: Select all

      GuiPushDialog(MainWindow, "gui\\MessageDialog.gui");
      $errorString = "Connection to server error:\n" @ %errorString;
      schedule("Control::setValue(MessageDialogTextFormat, $errorString);", 0);

I'm not sure why that's scheduled for 0 seconds... I wonder if this will work, instead:

Code: Select all

      GuiPushDialog(MainWindow, "gui\\MessageDialog.gui");
      Control::setValue(MessageDialogTextFormat, sprintf("Connection to server error:\n%1\n\nDownload client-side files:\n%2", %errorString, $Server::fileURL));

Re: [Script] Auto Downloader

Posted: Fri Jan 20, 2017 1:13 pm
by Doctor_Arsenic
It schedules to prevent a crash, net kick has to be done the same way. Ill hop on and update some more today

Re: [Script] Auto Downloader

Posted: Fri Jan 20, 2017 4:13 pm
by S_hift
Fuckin aye you did it man! I'm guessing this works similar to the meat spin exploit lol but in a good way this time.

I'm gonna start working on maps using opencall 3 terrains and maybe even make my own terrains and ted lighting maps. Omg this is amazing bro

Re: [Script] Auto Downloader

Posted: Fri Jan 20, 2017 6:12 pm
by Doctor_Arsenic
As per your request, and yeah it uses the function HTMLOpen. I will work with you to make sure it is compatible with the clientside stuff you make, and hopefully add a decent level of universality to the script as well (which I don't think will be very difficult anyway)

Re: [Script] Auto Downloader

Posted: Fri Jan 20, 2017 7:34 pm
by perrinoia
The problem is, this script is client side, and obviously exploitable by server hosts.

So, first, clients have to know to download this script, before this script can assist them in downloading map files.

It would probably be a good idea to make this script only work with trusted servers.

Or, you can simply use the same exploit you abused before, but for good instead of evil.

Re: [Script] Auto Downloader

Posted: Fri Jan 20, 2017 7:38 pm
by Doctor_Arsenic
Just updated the script. It now allows you to view the URL, and gives you the option to exit out before being sent to the site.


And yes added protection from exploits will come next, I would more worry about them trying to client crash you with a <image.bmp> than them sending you to a bad website. I just made it so that you can see the URL and opt out if you want before it sends you there.

So the only exploit that I see off the top of my head would be client crashes (and that just means I need to install a couple string checks to get rid of "exploity" text being sent to your popup window via $Server::FileURL)

Re: [Script] Auto Downloader

Posted: Fri Jan 20, 2017 10:32 pm
by perrinoia
That's easy.
Character Encoding Chart
Classification Included characters
Non-ASCII characters Includes the entire “top half” of the ISO-Latin set 80-FF hex (128-255 decimal.)
Reserved characters ; / ? : @ = & (does not include blank space)
Unsafe characters Includes the blank/empty space and " < > # % { } | \ ^ ~ [ ] `
2 more rows
(Please) Stop Using Unsafe Characters in URLs | Perishable Press
https://perishablepress.com/stop-using- ... s-in-urls/