Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* external_controls by Flammrock, used for download all external controls here : http://batch-external-controls.site88.net/list.php */
- /* Under MIT/X11 licence. */
- /*
- The MIT License (MIT)
- Copyright (c) 2016 Flammrock
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Net;
- using System.IO;
- namespace get
- {
- class Program
- {
- static void Main(string[] args)
- {
- ConsoleColor oldFGcolor = Console.ForegroundColor;
- if (args.Length == 0)
- {
- Console.Write("[");
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write("ERROR");
- Console.ForegroundColor = oldFGcolor;
- Console.Write("] : ");
- Console.WriteLine("Veuillez indiquer le nom d'une commande externe !");
- Console.ReadKey();
- Environment.Exit(0);
- }
- else if ( args[0]=="/?" )
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write("------- Aide Commande externe 'Get' -------\n");
- Console.ForegroundColor = oldFGcolor;
- Console.Write("get /? : ");
- Console.ForegroundColor = ConsoleColor.Blue;
- Console.Write("Affiche l'aide et la liste des commandes.\n");
- Console.ForegroundColor = oldFGcolor;
- Console.Write("get <commande_externe> : ");
- Console.ForegroundColor = ConsoleColor.Blue;
- Console.Write("Permet de télécharger n'importe quel commande externe.\n");
- Console.Write(" Exemple : get SockeT_full\n");
- Console.ForegroundColor = oldFGcolor;
- Console.Write("get /list : ");
- Console.ForegroundColor = ConsoleColor.Blue;
- Console.Write("Permet d'afficher la liste des commandes externes.\n");
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write("------- 'Get' a été créé par Flammrock -------\n");
- Console.ForegroundColor = oldFGcolor;
- Console.Write("\n");
- }
- else if (args[0] == "/list")
- {
- Console.Write("Connexion sur le serveur en cours...\n");
- try
- {
- string temp = Path.GetTempPath();
- WebClient wc = new WebClient();
- wc.DownloadFile("http://batch-external-controls.site88.net/external_controls/list.external_controls.php", temp + "list.external_controls.php");
- wc.Dispose();
- int counter = 0;
- string line;
- string file_list = temp + "list.external_controls.php";
- StreamReader file = new StreamReader(file_list);
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write("------- Liste des commandes externes disponibles :\n");
- Console.ForegroundColor = oldFGcolor;
- Console.ForegroundColor = ConsoleColor.Blue;
- while ((line = file.ReadLine()) != null)
- {
- Console.WriteLine(line);
- counter++;
- }
- Console.ForegroundColor = ConsoleColor.Red;
- file.Close();
- File.Delete(file_list);
- Console.Write("\n");
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write("{0}", counter);
- Console.ForegroundColor = oldFGcolor;
- Console.Write(" commande externe disponible sur le serveur !\n\n");
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write("--------------------------------------------------\n");
- Console.ForegroundColor = oldFGcolor;
- }
- catch
- {
- Console.Write("\n[");
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write("ERROR");
- Console.ForegroundColor = oldFGcolor;
- Console.Write("] : ");
- Console.WriteLine("Erreur de connexion sur le serveur ! Veuillez réessayer !");
- Console.ReadKey();
- }
- }
- else
- {
- Console.Write("Recherche de \"");
- Console.ForegroundColor = ConsoleColor.Blue;
- Console.Write(args[0]);
- Console.ForegroundColor = oldFGcolor;
- Console.Write("\" sur le serveur...\n");
- string _url = "http://batch-external-controls.site88.net/external_controls/" + args[0] + ".php";
- if ( CheckUrl(_url)=="OK" )
- {
- Console.Write("\"");
- Console.ForegroundColor = ConsoleColor.Blue;
- Console.Write(args[0]);
- Console.ForegroundColor = oldFGcolor;
- Console.Write("\" existe\n");
- try
- {
- WebClient wc = new WebClient();
- wc.DownloadFile("http://batch-external-controls.site88.net/external_controls/" + args[0] + ".exe", args[0]+".exe");
- wc.Dispose();
- Console.Write("Téléchargement terminé !");
- }
- catch
- {
- try
- {
- WebClient wc = new WebClient();
- wc.DownloadFile("http://batch-external-controls.site88.net/external_controls/" + args[0] + ".bat", args[0] + ".bat");
- wc.Dispose();
- Console.Write("Téléchargement terminé !");
- }
- catch
- {
- Console.Write("[");
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write("ERROR");
- Console.ForegroundColor = oldFGcolor;
- Console.Write("] : ");
- Console.WriteLine("Erreur lors du téléchargement !");
- Console.ReadKey();
- }
- }
- }
- else
- {
- Console.Write("[");
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write("ERROR");
- Console.ForegroundColor = oldFGcolor;
- Console.Write("] : ");
- Console.WriteLine("Cette commande externe n'existe pas !");
- Console.ReadKey();
- }
- Console.ReadKey();
- }
- }
- static string CheckUrl(string myUrl)
- {
- HttpWebRequest _Request;
- HttpWebResponse _Response;
- string message = "";
- if (myUrl != "")
- {
- try
- {
- _Request = (HttpWebRequest)WebRequest.Create(myUrl);
- _Request.AllowAutoRedirect = false;
- _Response = (HttpWebResponse)_Request.GetResponse();
- message = _Response.StatusCode.ToString();
- }
- catch (System.Net.WebException ex)
- {
- if (ex.Response != null)
- {
- message = (((HttpWebResponse)ex.Response).StatusCode).ToString();
- }
- else
- message = ex.Message;
- }
- catch (System.UriFormatException ex1)
- {
- message = ex1.Message;
- }
- }
- return message;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement