import win;
import web.json;
import myplu.fiddler;
import wsock.tcp.asynHttpServer;
import console;
function getIp(){
import inet.adapter;
import sys.networkCards;
for networkCard in ..sys.networkCards.each("PCI"){
for adptInfo in ..inet.adapter.each() {
if(tostring(networkCard.adapterName) == tostring(adptInfo.adapterName)){
return adptInfo.ipAddressList.ipAddress ;
}
}
}
}
var fetch_cache = {};
var filter_urls = {};
myplu.fiddler.fiddlerApplication.BeforeResponse = function (s) {
var url = s.fullUrl;
var ft = table.find(filter_urls,function(v,index){
return string.find(url,"@@"+v);
});
if(ft){
table.push(fetch_cache,{url=url;
method=s.RequestMethod;
responseCode=s.responseCode;
requestHeaders=myplu.fiddler.getHeaders(s.RequestHeaders);
responseHeaders=myplu.fiddler.getHeaders(s.ResponseHeaders);
requestBody=s.GetRequestBodyAsString();
responseBody=s.GetResponseBodyAsString();});
}
}
var httpServer = wsock.tcp.asynHttpServer();
// http服务器处理,接收前端消息
httpServer.run(function(response,request,session){
response.headers["Access-Control-Allow-Origin"] = "*";
response.headers["Access-Control-Allow-Headers"] = "*";
response.contentType = "application/json; charset=utf-8";
select(request.path) {
case "/filterUrl" {
var data = request.query("rule");
if(!data){
data = request.postData();
}
filter_urls = web.json.parse(data);
response.write({state="ok";msg="filter updated";data=filter_urls});
}
case "/startFetch" {
if(!myplu.fiddler.fiddlerApplication.IsStarted()){
myplu.fiddler.startup(0);
response.write({state="ok";msg="service started";poxy=getIp() +":"+ tostring(myplu.fiddler.fiddlerApplication.oProxy.ListenPort)});
}else{
response.write({state="ok";msg="start success"});
}
}
case "/stopFetch" {
myplu.fiddler.stop();
response.write({state="ok";msg="stop success"});
}
case "/fetch" {
var data = request.postData();
table.push(fetch_cache,data);
response.write({state="ok";msg="fetch success"});
}
case "/getMsg" {
try{
if(#fetch_cache){
var data = table.pop(fetch_cache);
response.write(data);
}else{
response.write({});
}
}
catch(e){
response.write({});
}
}
case "/clearMsg" {
fetch_cache = {};
response.write({state="ok";msg="clear success"});
}
case "/quit" {
win.quitMessage();
response.write({state="ok";msg="Exited"});
}
else {
var data = `%s<br/>
Url:%s<br/>
Method:%s<br/>
<br/>
`
var res = string.format(data, "更新嗅探规则,需要抓取的url列表", httpServer.getUrl("filterUrl")+`?rule=["https://www.xxx.com/xxx"]`, "GET")
res += string.format(data, "启动嗅探服务", httpServer.getUrl("startFetch"), "GET")
res += string.format(data, "停止嗅探服务", httpServer.getUrl("stopFetch"), "GET")
res += string.format(data, "获取一条嗅探消息", httpServer.getUrl("getMsg"), "GET")
res += string.format(data, "清理嗅探结果队列", httpServer.getUrl("clearMsg"), "GET")
res += string.format(data, "停止服务,结束进程", httpServer.getUrl("quit"), "GET")
response.contentType = "text/html; charset=utf-8";
response.write(res);
}
}
});
httpServer.start("0.0.0.0",8888);
win.loopMessage();
myplu.fiddler.stop();
httpServer.stop();
aardio后台进程
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 本文主要介绍,如何在Ubuntu远程连接服务器、远程启动进程、远程启动后台进程、远程启动后台图形化进程的常规方法。...
- 6.管理进程状态 当程序运行为进程后,我们希望进程能够停止,此时可以使用kill,killall,pkill命令对...
- 管理进程状态 当程序运行为进程后,如果希望停止进程,怎么办呢? 那么此时我们可以使用linux的kill命令对进程...
- 我相信不少人有这个需求,但是每次命令记不住啊,怎么办?还能怎么办,好记性不如烂笔头,脑子记不住,就写下来啊 一、为...