优酷土豆去视频广告(源码)

之前写的一个工具,好不好用我不知道,我自己用着挺好,编译环境VC6.0,原理是改HOST文件,不过还改了其他地方,可以看看源码,暂时支持XP,WIN7没写,代码可能有些乱,有兴趣的朋友可以自己改改。

  1     // guanggaoDlg.cpp : implementation file 



178     WIN32_FIND_DATA FindFileData;  

179       

180       

181   

182  

183       

184     void CGuanggaoDlg::OnButton1()   

185     {  

186     //屏蔽功能  

187     CopyFile("C:\\WINDOWS\\system32\\drivers\\etc\\hosts","C:\\WINDOWS\\system32\\drivers\\etc\\bak.hosts",TRUE);  

188         TCHAR lujing[MAX_PATH] = "C:\\Documents and Settings\\Administrator\\Application Data\\Macromedia\\Flash Player\\#SharedObjects\\";  

189         TCHAR lujing2[MAX_PATH] = "C:\\Documents and Settings\\Administrator\\Application Data\\Macromedia\\Flash Player\\#SharedObjects\\";  

190         TCHAR youku[MAX_PATH] = "\\static.youku.com";  

191         TCHAR tudou[MAX_PATH] = "\\js.tudouui.com";  

192         HANDLE hFist = FindFirstFile("C:\\Documents and Settings\\Administrator\\Application Data\\Macromedia\\Flash Player\\#SharedObjects\\*",&FindFileData);  

193         FindNextFile (hFist, &FindFileData);  

194         FindNextFile (hFist, &FindFileData);  

195         strcat(lujing,FindFileData.cFileName);  

196         strcat(lujing2,FindFileData.cFileName);  

197         LPSTR dedaoquanlujing = strcat(lujing,youku);  

198         LPSTR dedaoquanlujing2 = strcat(lujing2,tudou);  

199       

200         SHFILEOPSTRUCT filecaoz;  

201         ZeroMemory(&filecaoz,sizeof(filecaoz));  

202         filecaoz.wFunc = FO_DELETE;  

203         filecaoz.fFlags = FOF_NOCONFIRMATION|FOF_SIMPLEPROGRESS;  

204         filecaoz.hNameMappings = NULL;  

205         filecaoz.hwnd = NULL;  

206         filecaoz.lpszProgressTitle = NULL;  

207         filecaoz.pFrom = dedaoquanlujing;  

208         SHFileOperation(&filecaoz);  

209       

210         SHFILEOPSTRUCT filecaoz2;  

211         ZeroMemory(&filecaoz2,sizeof(filecaoz2));  

212         filecaoz.wFunc = FO_DELETE;  

213         filecaoz.fFlags = FOF_NOCONFIRMATION|FOF_SIMPLEPROGRESS;  

214         filecaoz.hNameMappings = NULL;  

215         filecaoz.hwnd = NULL;  

216         filecaoz.lpszProgressTitle = NULL;  

217         filecaoz.pFrom = dedaoquanlujing2;  

218         SHFileOperation(&filecaoz2);  

219       

220         SetFileAttributes(dedaoquanlujing,0);  

221         DeleteFile(dedaoquanlujing);  

222         DeleteFile(dedaoquanlujing2);  

223         HANDLE wenjian = CreateFile(dedaoquanlujing,GENERIC_WRITE|GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);  

224         HANDLE wenjian2 = CreateFile(dedaoquanlujing2,GENERIC_WRITE|GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);  

225         SetFileAttributes(dedaoquanlujing,0);  

226         SetFileAttributes(dedaoquanlujing2,0);  

227         CloseHandle(hFist);  

228         CloseHandle(wenjian);  

229         CloseHandle(wenjian2);  

230       

231     //HOST  

232         SetFileAttributes("C:\\WINDOWS\\system32\\drivers\\etc\\hosts",0);  

233         HANDLE wenjianjubing = CreateFile("C:\\WINDOWS\\system32\\drivers\\etc\\hosts",GENERIC_WRITE|GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);  

234           

235         //去优酷  

236         DWORD sizebuff = 0;  

237         char a1[] = {"#youku\r\n"};  

238         char a2[] = {"127.0.0.1 atm.youku.com\r\n"};  

239         char a3[] = {"127.0.0.1 Fvid.atm.youku.com\r\n"};  

240         char a4[] = {"127.0.0.1 html.atm.youku.com\r\n"};  

241         char a5[] = {"127.0.0.1 valb.atm.youku.com\r\n"};  

242         char a6[] = {"127.0.0.1 valf.atm.youku.com\r\n"};  

243         char a7[] = {"127.0.0.1 valo.atm.youku.com\r\n"};  

244         char a8[] = {"127.0.0.1 valp.atm.youku.com\r\n"};  

245         char a9[] = {"127.0.0.1 lstat.youku.com\r\n"};  

246         char a10[] = {"127.0.0.1 speed.lstat.youku.com\r\n"};  

247         char a11[] = {"127.0.0.1 urchin.lstat.youku.com\r\n"};  

248         char a12[] = {"127.0.0.1 stat.youku.com\r\n"};  

249         char a13[] = {"127.0.0.1 valc.atm.youku.com\r\n"};  

250         char a14[] = {"127.0.0.1 vid.atm.youku.com\r\n"};  

251         char a15[] = {"127.0.0.1 walp.atm.youku.com\r\n"};  

252         char a16[] = {"127.0.0.1 static.lstat.youku.com\r\n"};  

253         WriteFile(wenjianjubing,a1,sizeof(a1)-1,&sizebuff,NULL);  

254         WriteFile(wenjianjubing,a2,sizeof(a2)-1,&sizebuff,NULL);  

255         WriteFile(wenjianjubing,a3,sizeof(a3)-1,&sizebuff,NULL);  

256         WriteFile(wenjianjubing,a4,sizeof(a4)-1,&sizebuff,NULL);  

257         WriteFile(wenjianjubing,a5,sizeof(a5)-1,&sizebuff,NULL);  

258         WriteFile(wenjianjubing,a6,sizeof(a6)-1,&sizebuff,NULL);  

259         WriteFile(wenjianjubing,a7,sizeof(a7)-1,&sizebuff,NULL);  

260         WriteFile(wenjianjubing,a8,sizeof(a8)-1,&sizebuff,NULL);  

261         WriteFile(wenjianjubing,a9,sizeof(a9)-1,&sizebuff,NULL);  

262         WriteFile(wenjianjubing,a10,sizeof(a10)-1,&sizebuff,NULL);  

263         WriteFile(wenjianjubing,a11,sizeof(a11)-1,&sizebuff,NULL);  

264         WriteFile(wenjianjubing,a12,sizeof(a12)-1,&sizebuff,NULL);  

265         WriteFile(wenjianjubing,a13,sizeof(a13)-1,&sizebuff,NULL);  

266         WriteFile(wenjianjubing,a14,sizeof(a14)-1,&sizebuff,NULL);  

267         WriteFile(wenjianjubing,a15,sizeof(a15)-1,&sizebuff,NULL);  

268         WriteFile(wenjianjubing,a16,sizeof(a16)-1,&sizebuff,NULL);  

269       

270           

271     //去土豆  

272         char b0[] = {"#tudou\r\n"};  

273         char b1[]={"127.0.0.1 adextensioncontrol.tudou.com\r\n"};  

274         char b2[]={"127.0.0.1 iwstat.tudou.com\r\n"};  

275         char b3[]={"127.0.0.1 nstat.tudou.com\r\n"};  

276         char b4[]={"127.0.0.1 stats.tudou.com\r\n"};  

277         char b5[]={"127.0.0.1 *.p2v.tudou.com*\r\n"};  

278         char b6[]={"127.0.0.1 at-img1.tdimg.com\r\n"};  

279         char b7[]={"127.0.0.1 at-img2.tdimg.com\r\n"};  

280         char b8[]={"127.0.0.1 at-img3.tdimg.com\r\n"};  

281         char b9[]={"127.0.0.1 adplay.tudou.com\r\n"};  

282         char b10[]={"127.0.0.1 adcontrol.tudou.com\r\n"};  

283         char b11[]={"127.0.0.1 stat.tudou.com\r\n"};  

284         WriteFile(wenjianjubing,b0,sizeof(b0)-1,&sizebuff,NULL);  

285         WriteFile(wenjianjubing,b1,sizeof(b1)-1,&sizebuff,NULL);  

286         WriteFile(wenjianjubing,b2,sizeof(b2)-1,&sizebuff,NULL);  

287         WriteFile(wenjianjubing,b3,sizeof(b3)-1,&sizebuff,NULL);  

288         WriteFile(wenjianjubing,b4,sizeof(b4)-1,&sizebuff,NULL);  

289         WriteFile(wenjianjubing,b5,sizeof(b5)-1,&sizebuff,NULL);  

290         WriteFile(wenjianjubing,b6,sizeof(b6)-1,&sizebuff,NULL);  

291         WriteFile(wenjianjubing,b7,sizeof(b7)-1,&sizebuff,NULL);  

292         WriteFile(wenjianjubing,b8,sizeof(b8)-1,&sizebuff,NULL);  

293         WriteFile(wenjianjubing,b9,sizeof(b9)-1,&sizebuff,NULL);  

294         WriteFile(wenjianjubing,b10,sizeof(b10)-1,&sizebuff,NULL);  

295         WriteFile(wenjianjubing,b11,sizeof(b11)-1,&sizebuff,NULL);  

296         WriteFile(wenjianjubing,a15,sizeof(a15)-1,&sizebuff,NULL);  

297     //去酷6  

298         char c0[] = {"#ku6\r\n"};  

299         char c1[]={"127.0.0.1 1.allyes.com.cn\r\n"};  

300         char c2[]={"127.0.0.1 analytics.ku6.com\r\n"};  

301         char c3[]={"127.0.0.1 gug.ku6cdn.com\r\n"};  

302         char c4[]={"127.0.0.1 ku6.allyes.com\r\n"};  

303         char c5[]={"127.0.0.1 ku6afp.allyes.com\r\n"};  

304         char c6[]={"127.0.0.1 pq.stat.ku6.com\r\n"};  

305         char c7[]={"127.0.0.1 st.vq.ku6.cn\r\n"};  

306         char c8[]={"127.0.0.1 stat0.888.ku6.com\r\n"};  

307         char c9[]={"127.0.0.1 stat1.888.ku6.com\r\n"};  

308         char c10[]={"127.0.0.1 stat2.888.ku6.com\r\n"};  

309         char c11[]={"127.0.0.1 stat3.888.ku6.com\r\n"};  

310         char c12[]={"127.0.0.1 static.ku6.com\r\n"};  

311         char c13[]={"127.0.0.1 v0.stat.ku6.com\r\n"};  

312         char c14[]={"127.0.0.1 v1.stat.ku6.com\r\n"};  

313         char c15[]={"127.0.0.1 v2.stat.ku6.com\r\n"};  

314         char c16[]={"127.0.0.1 v3.stat.ku6.com\r\n"};  

315         WriteFile(wenjianjubing,c0,sizeof(c0)-1,&sizebuff,NULL);  

316         WriteFile(wenjianjubing,c1,sizeof(c1)-1,&sizebuff,NULL);  

317         WriteFile(wenjianjubing,c2,sizeof(c2)-1,&sizebuff,NULL);  

318         WriteFile(wenjianjubing,c3,sizeof(c3)-1,&sizebuff,NULL);  

319         WriteFile(wenjianjubing,c4,sizeof(c4)-1,&sizebuff,NULL);  

320         WriteFile(wenjianjubing,c5,sizeof(c5)-1,&sizebuff,NULL);  

321         WriteFile(wenjianjubing,c6,sizeof(c6)-1,&sizebuff,NULL);  

322         WriteFile(wenjianjubing,c7,sizeof(c7)-1,&sizebuff,NULL);  

323         WriteFile(wenjianjubing,c8,sizeof(c8)-1,&sizebuff,NULL);  

324         WriteFile(wenjianjubing,c9,sizeof(c9)-1,&sizebuff,NULL);  

325         WriteFile(wenjianjubing,c10,sizeof(c10)-1,&sizebuff,NULL);  

326         WriteFile(wenjianjubing,c11,sizeof(c11)-1,&sizebuff,NULL);  

327         WriteFile(wenjianjubing,c12,sizeof(c12)-1,&sizebuff,NULL);  

328         WriteFile(wenjianjubing,c13,sizeof(c13)-1,&sizebuff,NULL);  

329         WriteFile(wenjianjubing,c14,sizeof(c14)-1,&sizebuff,NULL);  

330         WriteFile(wenjianjubing,c15,sizeof(c15)-1,&sizebuff,NULL);  

331         WriteFile(wenjianjubing,c16,sizeof(c16)-1,&sizebuff,NULL);  

332     // //去奇艺广告  

333         char d0[] = {"#qiyi\r\n"};  

334         char d1[]={"127.0.0.1 afp.qiyi.com\r\n"};  

335         char d2[]={"127.0.0.1 focusbaiduafp.allyes.com\r\n"};  

336         WriteFile(wenjianjubing,d0,sizeof(d0)-1,&sizebuff,NULL);  

337         WriteFile(wenjianjubing,d1,sizeof(d1)-1,&sizebuff,NULL);  

338         WriteFile(wenjianjubing,d2,sizeof(d2)-1,&sizebuff,NULL);  

339       

340     //新浪视频  

341         char e0[] = {"#sina\r\n"};  

342         char e3[]={"127.0.0.1 dcads.sina.com.cn\r\n"};  

343         WriteFile(wenjianjubing,e0,sizeof(e0)-1,&sizebuff,NULL);  

344         WriteFile(wenjianjubing,e3,sizeof(e3)-1,&sizebuff,NULL);  

345       

346     //去PPTV  

347         char f0[] = {"#pptv\r\n"};  

348         char f4[]={"127.0.0.1 pp2.pptv.com\r\n"};  

349         WriteFile(wenjianjubing,f0,sizeof(f0)-1,&sizebuff,NULL);  

350         WriteFile(wenjianjubing,f4,sizeof(f4)-1,&sizebuff,NULL);  

351     //搜狐  

352         char g0[] = {"#sohu\r\n"};  

353         char g5[]={"127.0.0.1images.sohu.com\r\n"};  

354         WriteFile(wenjianjubing,g0,sizeof(g0)-1,&sizebuff,NULL);  

355         WriteFile(wenjianjubing,g5,sizeof(g5)-1,&sizebuff,NULL);  

356     //乐视  

357         char h0[] = {"#leshi\r\n"};  

358         char h6[]={"127.0.0.1 pro.letv.com\r\n"};  

359         WriteFile(wenjianjubing,h0,sizeof(h0)-1,&sizebuff,NULL);  

360         WriteFile(wenjianjubing,h6,sizeof(h6)-1,&sizebuff,NULL);  

361     //迅雷看看  

362         char j0[] = {"#xunlei\r\n"};  

363         char j1[]={"127.0.0.1 mcfg.sandai.net\r\n"};  

364         char j2[]={"127.0.0.1 biz5.sandai.net\r\n"};  

365         char j3[]={"127.0.0.1 server1.adpolestar.net\r\n"};  

366         char j4[]={"127.0.0.1 advstat.xunlei.com\r\n"};  

367         char j5[]={"127.0.0.1 mpv.sandai.net\r\n"};  

368         WriteFile(wenjianjubing,j0,sizeof(j0)-1,&sizebuff,NULL);  

369         WriteFile(wenjianjubing,j1,sizeof(j1)-1,&sizebuff,NULL);  

370         WriteFile(wenjianjubing,j2,sizeof(j2)-1,&sizebuff,NULL);  

371         WriteFile(wenjianjubing,j3,sizeof(j3)-1,&sizebuff,NULL);  

372         WriteFile(wenjianjubing,j3,sizeof(j3)-1,&sizebuff,NULL);  

373       

374     //QQ  

375     char qq1[]={"#qq\r\n"};  

376     char qq2[]={"127.0.0.1 adslvfile.qq.com\r\n"};  

377     char qq3[]={"127.0.0.1 adsfile.qq.com\r\n"};  

378     WriteFile(wenjianjubing,qq1,sizeof(qq1)-1,&sizebuff,NULL);  

379     WriteFile(wenjianjubing,qq2,sizeof(qq2)-1,&sizebuff,NULL);  

380     BOOL bWite = WriteFile(wenjianjubing,qq3,sizeof(qq3)-1,&sizebuff,NULL);  

381         if(bWite != 0)  

382         {  

383             AfxMessageBox("屏蔽成功!");  

384             SetFileAttributes("C:\\WINDOWS\\system32\\drivers\\etc\\hosts",1);  

385             system("echo y|cacls C:\\WINDOWS\\system32\\drivers\\etc\\hosts /g everyone:r");  

386             return;  

387         }  

388         else  

389         {  

390             AfxMessageBox("已经屏蔽!");  

391             return;  

392         }  

393           

394     }  

395       

396     void CGuanggaoDlg::OnButton2()   

397     {  

398     //恢复  

399         TCHAR lujing[MAX_PATH] = "C:\\Documents and Settings\\Administrator\\Application Data\\Macromedia\\Flash Player\\#SharedObjects\\";  

400         TCHAR lujing2[MAX_PATH] = "C:\\Documents and Settings\\Administrator\\Application Data\\Macromedia\\Flash Player\\#SharedObjects\\";  

401         TCHAR mingche2[MAX_PATH] = "\\static.youku.com";  

402         TCHAR tudou[MAX_PATH] = "\\js.tudouui.com";  

403         HANDLE hFist2 = FindFirstFile("C:\\Documents and Settings\\Administrator\\Application Data\\Macromedia\\Flash Player\\#SharedObjects\\*",&FindFileData);  

404         FindNextFile (hFist2, &FindFileData);  

405         FindNextFile (hFist2, &FindFileData);  

406         strcat(lujing,FindFileData.cFileName);  

407         strcat(lujing2,FindFileData.cFileName);  

408         LPSTR dedaoquanlujing = strcat(lujing,mingche2);  

409         LPSTR dedaoquanlujing2 = strcat(lujing2,tudou);  

410         DeleteFile(dedaoquanlujing);  

411         DeleteFile(dedaoquanlujing2);  

412         CloseHandle(hFist2);  

413         system("echo y|cacls C:\\WINDOWS\\system32\\drivers\\etc\\hosts /g everyone:f");  

414         SetFileAttributes("C:\\WINDOWS\\system32\\drivers\\etc\\hosts",0);  

415         BOOL bCpy = CopyFile("C:\\WINDOWS\\system32\\drivers\\etc\\bak.hosts","C:\\WINDOWS\\system32\\drivers\\etc\\hosts",FALSE);  

416         if(bCpy != 0)  

417         {  

418             AfxMessageBox("恢复成功!");  

419             return;  

420         }  

421         else  

422         {  

423             AfxMessageBox("恢复失败!");  

424             return;  

425         }  

426       

427     }  

428       

429     void CGuanggaoDlg::OnButton3()   

430     {  

431         //优酷测试  

432         ShellExecute(NULL,"open","http://www.youku.com",NULL,NULL,SW_SHOWNORMAL);  

433     }  

 

你可能感兴趣的:(源码)