我需要查询Google的某项服务。我读到了这个答案:download csv from google insight for search
该问题的复制和粘贴代码为:
using (var client = new WebClient())
{
// TODO: put your real email and password in the request string
var response = client.DownloadString("https://www.google.com/accounts/ClientLogin?accountType=GOOGLE&Email=youraccount@gmail.com&Passwd=secret&service=trendspro&source=test-test-v1");
// The SID is the first line in the response
var sid = response.Split('\n')[0];
client.Headers.Add("Cookie", sid);
byte[] csv = client.DownloadData("http://www.google.com/insights/search/overviewReport?q=test&cmpt=q&content=1&export=2");
// TODO: do something with the downloaded csv file:
Console.WriteLine(Encoding.UTF8.GetString(csv));
File.WriteAllBytes("report.csv", csv);
}
我想知道在字符串中发送密码是安全还是可以抓取?
如果这不安全,应该怎么做?
答案 0 :(得分:2)
由于它使用https(不是普通的HTTP),因此它应该与大多数其他任何东西都可以在网上一样安全。一旦基础TLS连接建立,所有数据(包括URL)都会在加密通道上传输。
答案 1 :(得分:1)
这是“好消息,坏消息”的情况之一。
好消息:窃听者无法抓取密码(因为它是通过HTTPS发送的:加密的)。
坏消息:会话cookie可以被窃听者抓取(因为它是通过HTTP发送的:未加密)。正如Firesheep所证明的那样,让某人访问您的Google会话Cookie是危险的,因为它可以让攻击者访问您存储在Google上的电子邮件和其他内容。
如果您可以将http
网址更改为https
网址,则会更安全。