-
Notifications
You must be signed in to change notification settings - Fork 155
/
Copy pathmain.aardio
144 lines (128 loc) · 3.71 KB
/
main.aardio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import win.ui;
/*DSG{{*/
mainForm = win.form(text="WechatVideoSniffer";right=959;bottom=591)
mainForm.add(
btnClear={cls="button";text="清空列表";left=797;top=540;right=889;bottom=580;z=5};
btnCopyUrl={cls="button";text="复制链接";left=797;top=177;right=889;bottom=211;z=6};
btnDown={cls="button";text="下载选中";left=794;top=120;right=885;bottom=157;z=4};
btnSniffer={cls="button";text="监听";left=794;top=14;right=885;bottom=51;z=1};
btnStop={cls="button";text="停止";left=794;top=70;right=885;bottom=107;z=2};
listview={cls="listview";left=17;top=15;right=787;bottom=584;edge=1;hscroll=1;z=3}
)
/*}}*/
import dotNet
import win.clip
mainForm.listview.insertColumn( "URL",-1 )
dotNet.reference({
"FiddlerCore4" = $"res\FiddlerCore4.dll";
"CertMaker" = $"res\CertMaker.dll";
"BCMakeCert" = $"res\BCMakeCert.dll";
"BasicFormatsForCore" = $"res\BasicFormatsForCore.dll"
})
var FiddlerCore4 = dotNet.load("FiddlerCore4")
Fiddler = FiddlerCore4.import("Fiddler")
InstallCertificate = function(){
if(!Fiddler.CertMaker.rootCertExists()){
if(!Fiddler.CertMaker.createRootCert()){
return false;
}
if(Fiddler.CertMaker.trustRootCert()){
return false;
}
}
return true;
}
UninstallCertificate = function(){
if(Fiddler.CertMaker.rootCertExists()){
if(!Fiddler.CertMaker.removeFiddlerGeneratedCerts(true)){
return false;
}
}
return true;
}
// 视频链接过滤规则
var urls = {}
filterUrl = function(url){
if(string.find(url,"^https\:\/\/finder<mp>*\.video\.qq\.com\/251\/20302\/") or string.find(url,"mpvideo\.qpic\.cn") ){
// 去除无用链接格式
if(!!string.match(url,"token=\w+")){
if(!urls[url]){
urls[url] = true
return true;
}
}
}
return false;
}
AttachListening = function(){
Fiddler.FiddlerApplication.BeforeRequest = function(s){
s.bBufferResponse = false;
if(filterUrl(s.fullUrl)){
mainForm.listview.addItem( {s.fullUrl} )
}
}
/*
Fiddler.FiddlerApplication.BeforeResponse = function(s){
if(string.startWith(s.fullUrl,"https://finder.video.qq.com")){
mainForm.listview.addItem( {s.fullUrl} )
}
}
*/
}
StartupFiddlerCore = function(){
Fiddler.FiddlerApplication.Startup(9898,Fiddler.FiddlerCoreStartupFlags.Default | Fiddler.FiddlerCoreStartupFlags.RegisterAsSystemProxy | Fiddler.FiddlerCoreStartupFlags.AllowRemoteClients)
}
UninstallFiddler = function(){
if(Fiddler.FiddlerApplication.IsStarted()){
Fiddler.FiddlerApplication.Shutdown();
}
}
mainForm.btnSniffer.oncommand = function(id,event){
InstallCertificate()
AttachListening()
StartupFiddlerCore()
mainForm.btnSniffer.disabled = true
}
mainForm.btnStop.oncommand = function(id,event){
UninstallCertificate()
UninstallFiddler()
mainForm.btnSniffer.disabled = false
}
mainForm.btnClear.oncommand = function(id,event){
mainForm.listview.clear()
urls = {}
}
mainForm.btnDown.oncommand = function(id,event){
var index = mainForm.listview.selIndex
if(index>0){
var url = mainForm.listview.getItemText(index,1,10240)
mainForm.btnDown.text = "下载中"
mainForm.btnDown.disabled = true
thread.invokeAndWait(
function(url){
import inet.httpFile
math.randomize()
var remoteFile = inet.httpFile( url,"/download/" + string.random(6) + ".mp4" )
remoteFile.test()
remoteFile.download()
remoteFile.close()
},url
)
mainForm.msgbox("下载完成")
mainForm.btnDown.text = "下载选中"
mainForm.btnDown.disabled = false
}
}
mainForm.onClose = function(hwnd,message,wParam,lParam){
//UninstallCertificate()
UninstallFiddler()
}
mainForm.btnCopyUrl.oncommand = function(id,event){
var index = mainForm.listview.selIndex
if(index>0){
var url = mainForm.listview.getItemText(index,1,10240)
win.clip.write(url)
}
}
mainForm.show();
return win.loopMessage();