public STG send(STG message) { try { message.tokenApp = tokenApp; STG result = services.m_service(message); result.Print(); return(result); } catch { channelFactory.Abort(); throw; } }
public STG m_service(STG message) { message.Print(); STG response = new STG() { statut_op = false, info = message.info, data = new object[0] { }, operationname = message.operationname, tokenApp = "", tokenUser = message.tokenUser }; if (message.tokenApp != tokenApp) { response.statut_op = false; response.info = "Wrong tokenApp"; return(response); } if (message.operationname == "stopBruteForce") { BruteForce.StopBruteForce(message); response.statut_op = true; return(response); } if (message.operationname == "login") { response = auth.Login(message); return(response); } else if (message.operationname == "signup") { response = auth.Signup(message); return(response); } else if (message.operationname == "checkTokenUser") { string user = auth.VerifyTokenUser(message.tokenUser); response.statut_op = user != ""; if (response.statut_op) { response.data = new object[] { user }; } return(response); } else if (message.operationname == "logout") { response = auth.Logout(message); return(response); } // Verify token user string username = auth.VerifyTokenUser(message.tokenUser); if (username == "") { response.info = "Unknown token user"; return(response); } if (message.operationname == "bruteForce") { BruteForce workerObject = new BruteForce(message, username); Thread workerThread = new Thread(workerObject.BruteForceMessages); workerThread.Start(); while (!workerThread.IsAlive) { ; } response.statut_op = true; response.info = "started"; return(response); } else if (message.operationname == "result") { response = files.GetResult(message, username); return(response); } else if (message.operationname == "list") { response = files.GetAll(message, username); return(response); } return(response); }
static void Main(string[] args) { channelFactory = new ChannelFactory <IServices>("tcpConfig"); services = channelFactory.CreateChannel(); Console.WriteLine("Ready ?"); string action = Console.ReadLine(); string tokenUser = ""; Console.WriteLine("Endpoint = {0}", channelFactory.Endpoint.Address.ToString()); Console.WriteLine("('l' to login)"); Console.WriteLine("('o' to logout)"); Console.WriteLine("('s' to signup)"); Console.WriteLine("('c' to check token user)"); Console.WriteLine("('bf' to send file for bruteforce)"); Console.WriteLine("('r' to ask for file results)"); Console.WriteLine("('g' to get the list of your files)"); Console.WriteLine("('q' to quit)"); do { Console.WriteLine("\nChoose an action :"); action = Console.ReadLine(); if (action == "q") { continue; } STG message = new STG() { statut_op = true, info = "", data = new object[] { }, operationname = "", tokenApp = tokenApp, tokenUser = tokenUser }; if (action == "l") { Console.WriteLine("Login :"******"Password :"******"login"; message.data = new object[] { username, password }; } else if (action == "s") { Console.WriteLine("Username :"******"Email :"); string email = Console.ReadLine(); Console.WriteLine("Password :"******"signup"; message.data = new object[] { username, email, password }; } else if (action == "c") { message.operationname = "checkTokenUser"; } else if (action == "o") { message.operationname = "logout"; } else if (action == "bf") { String FileContent = null; Console.WriteLine("Insérer un document : "); OpenFileDialog ofd = new OpenFileDialog(); ofd.DefaultExt = ".txt"; //ofd.Filter = "Document texte (.txt)/*.txt"; ofd.ShowDialog(); string filename = ofd.FileName; Console.WriteLine("Document : " + filename); FileContent = File.ReadAllText(filename, Encoding.UTF8); Console.WriteLine("Content : " + FileContent); message.operationname = "bruteForce"; message.data = new object[] { Path.GetFileName(filename), FileContent }; } else if (action == "r") { Console.WriteLine("File :"); string file = Console.ReadLine(); message.operationname = "result"; message.data = new object[] { file }; } else if (action == "g") { message.operationname = "list"; message.data = new object[] { }; } try { STG result = services.m_service(message); if (result.operationname == "login") { tokenUser = result.tokenUser; } Console.WriteLine("\nResult :"); result.Print(); } catch { Console.WriteLine("\nError !"); channelFactory.Abort(); throw; } } while(action != "q"); }