使用tor c#更改IP地址

时间:2015-01-09 08:36:19

标签: c# windows tor

我想在x时间间隔使用TOR更改ip,在Windows平台上使用c#可以帮助我吗?

TIA。

我试过这段代码

public string Refresh()
{
    TcpClient client = new TcpClient("localhost", 9051);
    string response = string.Empty;
    string authenticate = MakeTcpRequest("AUTHENTICATE\r\n", client);
    if (authenticate.Equals("250"))
    {
        response = MakeTcpRequest("SIGNAL NEWNYM\r\n", client);
    }
    client.Close();
    return response;
}

public string MakeTcpRequest(string message, TcpClient client)
{
    client.ReceiveTimeout = 20000;
    client.SendTimeout = 20000;
    string proxyResponse = string.Empty;

    try
    {
        // Send message
        StreamWriter streamWriter = new StreamWriter(client.GetStream());
        streamWriter.Write(message);
        streamWriter.Flush();

        // Read response
        StreamReader streamReader = new StreamReader(client.GetStream());
        proxyResponse = streamReader.ReadToEnd();
    }
    catch (Exception ex)
    {
        // Ignore
    }

    return proxyResponse;
}

我得到514认证所需的错误

1 个答案:

答案 0 :(得分:0)

你的torrc是什么?没有它,帮助你是很棘手的。有关验证的示例,请参阅...

https://stem.torproject.org/faq.html#can-i-interact-with-tors-controller-interface-directly

更一般地说,如果你只是想以一定的间隔循环电路那么这就是MaxCircuitDirtiness torrc选项所做的......

https://www.torproject.org/docs/tor-manual.html.en#MaxCircuitDirtiness