fiddlercore 문제 해결 방안, fidder 패키지, 핸드폰 앱 잡기
6586 단어 C#-net
//
X509Certificate2 oRootCert = CertMaker.GetRootCertificate();
//
X509Store certStore = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
//
certStore.Open(OpenFlags.ReadWrite);
try
{
//
certStore.Add(oRootCert);
}
finally
{
//
certStore.Close();
}
//
FiddlerApplication.oDefaultClientCertificate = oRootCert;
2. 보안 연결 솔 루 션 이 아 닙 니 다: 프 록 시 서버 만 들 기
// HTTPS , FiddlerCore HTTPS
// CERN 。
oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, oRootCert);
static Proxy oSecureEndpoint;
static string sSecureEndpointHostname = "localhost";
static int iSecureEndpointPort = 8888;
//
Fiddler.FiddlerApplication.SetAppDisplayName("FiddlerCoreDemoApp");
//
FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;
// http
int iPort = 8888;
Fiddler.CONFIG.IgnoreServerCertErrors = false;
Fiddler.CertMaker.createRootCert();
//
X509Certificate2 oRootCert = CertMaker.GetRootCertificate();
//
X509Store certStore = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
//
certStore.Open(OpenFlags.ReadWrite);
try
{
//
certStore.Add(oRootCert);
}
finally
{
//
certStore.Close();
}
//
FiddlerApplication.oDefaultClientCertificate = oRootCert;
//
CONFIG.IgnoreServerCertErrors = true;
//
CertMaker.trustRootCert();
// , 。。。 , , , 。
FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);
// ———— 1: https; 2:
// , http
// , windows ( true, http )
Fiddler.FiddlerApplication.Startup(iPort, true, true, true);
// HTTPS , FiddlerCore HTTPS
// CERN 。
oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, oRootCert);
txtlog.AppendText(" " + Environment.NewLine);
List oAllSessions = new List();
////
//Fiddler.FiddlerApplication.BeforeReturningError += FiddlerApplication_BeforeReturningError;
//
Fiddler.FiddlerApplication.BeforeRequest += delegate (Fiddler.Session oS)
{
//
Console.WriteLine("Before request for:\t" + oS.fullUrl);
// ,
// 。 FiddlerCore
// BeforeResponse ,
// 。
oS.bBufferResponse = true;
Monitor.Enter(oAllSessions);
oAllSessions.Add(oS);
Monitor.Exit(oAllSessions);
oS["X-AutoAuth"] = "(default)";
/* , 。
: BeforeRequest ,
Fiddler (pipeClient.LocalPort) ,
, ** ( , CONNECT)。
, https:// :7777 ,
Session list contains...
1 CONNECT http://localhost:7777
200 Request for httpS://" + sSecureEndpointHostname + ":" + iSecureEndpointPort.ToString() + " received. Your request was:
" + oS.oRequest.headers.ToString());
}
//if ((oS.oRequest.pipeClient.LocalPort == 8877) && (oS.hostname == "www.baidu.com"))
//{
// string url = oS.fullUrl;
// oS.utilCreateResponseAndBypassServer();
// oS.oResponse.headers.SetStatus(200, "Ok");
// oS.oResponse["Content-Type"] = "text/html; charset=UTF-8";
// oS.oResponse["Cache-Control"] = "private, max-age=0";
// oS.utilSetResponseBody("Request for httpS://" + sSecureEndpointHostname + ":" + iSecureEndpointPort.ToString() + " received. Your request was:
" + oS.oRequest.headers.ToString());
//}
};
/*
// , Fiddler 。
* , , ; , 。
//
// ,
Fiddler.FiddlerApplication.OnReadResponseBuffer += new EventHandler(FiddlerApplication_OnReadResponseBuffer);
*/
Fiddler.FiddlerApplication.BeforeResponse += delegate (Fiddler.Session oS)
{
oS.utilDecodeResponse();
string content = oS.GetResponseBodyAsString();
Regex rx = new Regex(@"^0{0,1}(13[4-9]|15[7-9]|15[0-2]|18[7-8])[0-9]{8}$");
if (textBox1.Text != "")
{
if (oS.fullUrl.IndexOf(textBox1.Text) > 0) {
txtlog.AppendText(" " + oS.GetResponseBodyAsString() + Environment.NewLine);
}
}
else {
txtlog.AppendText(" " + oS.GetResponseBodyAsString() + Environment.NewLine);
}
if (txtlog.Lines.Count() > 3000)
{
txtlog.Text = "";
txtlog.AppendText(" " + Environment.NewLine);
}
};