fiddlercore 类库应用- 检查客户端调用的服务接口内容.
来源:互联网 发布:金盾软件硬件参数 编辑:程序博客网 时间:2024/06/07 05:41
fiddlercore是.NET类库,你可以加入到.NET框架和单框架的应用。 也可以应用到Managed C++公共运行时语言程序中.本次是在 Managed C++ 程序中应用的。 fiddlercore可以捕获和修改HTTP和HTTPS流量就像Fiddler一样,但没有Fiddler的UI。
fiddlercore主要特点
HTTP和HTTPS流量捕获和修改。
强大的内容过滤和修改的对象模型。
存储和重载网络流量。
我主要的目的是抓取到某个应用程序内部所有的服务请求. 以检测各个服务状态,各个服务接口请求的状态, 请求接口的url格式, 请求包体,返回包体等内容,这样辅助部署实施人员能够排查出应用程序问题,并通过服务的状态,参数解决掉问题. 比如,可能某个服务关闭当掉,客户端请求就是返回500以上服务内部错误的code值, 400 为服务拒绝客户端请求,客户端请求参数不正确等错误code值, 200 为请求正确的code。
下面是 应用代码. 初始化.
System::String^ m_CliIp = gcnew System::String("NoSAZ");
Fiddler::FiddlerApplication::SetAppDisplayName("FiddlerCoreDemoApp");
EventReceiver^ pR = gcnew EventReceiver;
pR->pTestDlg= this;
Fiddler::FiddlerApplication::OnNotification += gcnew EventHandler<NotificationEventArgs^>(pR,&EventReceiver::OnNotification);
Fiddler::FiddlerApplication::Log->OnLogString += gcnew EventHandler<LogEventArgs^>(pR,&EventReceiver::Log_OnLogString);
Fiddler::FiddlerApplication::BeforeRequest += gcnew SessionStateHandler(pR,&EventReceiver::BeforeRequest);
Fiddler::FiddlerApplication::BeforeResponse += gcnew SessionStateHandler(pR,&EventReceiver::BeforeResponse);
Fiddler::FiddlerApplication::AfterSessionComplete += gcnew SessionStateHandler(pR,&EventReceiver::AfterSessionComplete);
Fiddler::CONFIG::IgnoreServerCertErrors = false;
int iPort = 8877;
Fiddler::FiddlerApplication::Startup(iPort, Fiddler::FiddlerCoreStartupFlags::Default);
Fiddler::FiddlerApplication::Log->LogFormat("Created endpoint listening on port {0}", iPort);
Fiddler::FiddlerApplication::Log->LogFormat("Starting with settings: [{0}]", Fiddler::FiddlerCoreStartupFlags::Default);
Fiddler::FiddlerApplication::Log->LogFormat("Gateway: {0}", CONFIG::UpstreamGateway.ToString());
System::String^ sSecureEndpointHostname = gcnew System::String("localhost");
int iSecureEndpointPort = 7777;
GlobalObjects::oSecureEndpoint
= Fiddler::FiddlerApplication::CreateProxyEndpoint(iSecureEndpointPort, true, "localhost");
if (GlobalObjects::oSecureEndpoint)
{
Fiddler::FiddlerApplication::Log->LogFormat("开始监控 HTTP 过程 .");
}
// 抓取过程
public ref struct ArgsReceiver
{
String^ Argsstrurl;
String^ ArgsMethod;
int^ Argsosid;
SessionStates^ Argsss;
};
public ref struct EventReceiver
{
public:
class CTest001Dlg* pTestDlg;
void OnNotification(System::Object^ sender, Fiddler::NotificationEventArgs^ e)
{
Console::WriteLine("OnNotification");
}
void Log_OnLogString(System::Object^ sender, Fiddler::LogEventArgs ^e)
{
pTestDlg->AddMessage(e->LogString);
}
void BeforeRequest(Fiddler::Session^ os)//, Fiddler::Session os(Fiddler::Session os)
{
}
void BeforeResponse(Fiddler::Session^ os)//, Fiddler::Session os(Fiddler::Session os)
{
}
void AfterSessionComplete(Fiddler::Session^ os)//, Fiddler::Session os(Fiddler::Session os)
{
String^ strClientName = os->LocalProcess;
int index = strClientName->LastIndexOf("ezjcj3");
if(index > -1)//判断是ezjcj3发出的请求
{
// 将数据发送道list列表中
pTestDlg->AddReqToList(os);
}
}
};
显示部分
void CTest001Dlg::AddReqToList(Fiddler::Session^ os)
{
try
{
//list列表中显示
int icount = m_listurl.GetItemCount();
int ^ osid = os->id; // 请求ID
System::String^ sid = osid->ToString("G");
char* ch1 = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(sid);
int nRow = m_listurl.InsertItem(icount, CString(ch1));//插入行
String^ strMet = os->oRequest->headers->HTTPMethod;
char* ch2 = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(strMet);
m_listurl.SetItemText(nRow, 1, CString(ch2));//设置数据
String^ strurl = os->fullUrl;// 整个请求路径
ch2 = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(strurl);
m_listurl.SetItemText(nRow, 2, CString(ch2));//设置数据
String^ strSt = os->oResponse->headers->HTTPResponseStatus;// 最终状态
ch2 = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(strSt);
m_listurl.SetItemText(nRow, 3, CString(ch2));//设置数据
String^ strtype = os->oResponse->MIMEType;// 最终状态
ch2 = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(strtype);
m_listurl.SetItemText(nRow,4, CString(ch2));//设置数据
System::String^ strPath = gcnew String(m_strExePath);
String^ sFilename1 = System::String::Format("{0}{1}{2}{3}",strPath,"fiddler_log\\",sid,".txt");
os->SaveResponse(sFilename1,FALSE); // 保存返回内容
}
catch(...)
{
}
}
- fiddlercore 类库应用- 检查客户端调用的服务接口内容.
- osgi学习笔记4之 web客户端调用已发布的接口服务
- 基于FiddlerCore的.Net二次开发
- 微信多客户端导致重复调用服务接口问题
- 调用应用服务器的接口
- 关于Webservice接口的Java客户端调用
- WebService客户端调用接口的方法
- 获取调用接口的客户端ip地址
- webservice接口客户端调用
- WCF客户端调用服务
- 客户端调用SOAP服务
- 使用AXIS的CALL调用服务接口
- python调用wcf服务 实现网站对客户端的调用
- 使用FiddlerCore来测试你的WebAPI
- 检查粘贴的内容
- Python调用服务接口
- js调用web服务的接口和调用后台方法
- WebService应用之客户端 Ksoap 库调用
- LeetCode Balanced Binary Tree
- Wireshark实战分析之ARP协议(一)
- java内部类
- Android 数据保存之SharedPreferences
- C# 属性
- fiddlercore 类库应用- 检查客户端调用的服务接口内容.
- LabVIEW-水仙花数
- IIS与ASP.NET Development Server
- Linux网络编程入门 (转载)
- socket编程的select模型
- 应聘时最漂亮的回答!
- 13.1 打印基础
- 资料
- shellapi