C++实现优酷土豆去视频广告的方法

   2015-06-23 0
核心提示:这篇文章主要介绍了C++实现优酷土豆去视频广告的方法,实例分析了C++实现屏蔽功能的相关技巧,需要的朋友可以参考下

本文实例讲述了C++实现优酷土豆去视频广告的方法。分享给大家供大家参考。具体分析如下:

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

// guanggaoDlg.cpp : implementation file 
WIN32_FIND_DATA FindFileData; 
void CGuanggaoDlg::OnButton1()  
{ 
//屏蔽功能 
CopyFile("C:\\WINDOWS\\system32\\drivers\\etc\\hosts","C:\\WINDOWS\\system32\\drivers\\etc\\bak.hosts",TRUE); 
    TCHAR lujing[MAX_PATH] = "C:\\Documents and Settings\\Administrator\\Application Data\\Macromedia\\Flash Player\\#SharedObjects\\"; 
    TCHAR lujing2[MAX_PATH] = "C:\\Documents and Settings\\Administrator\\Application Data\\Macromedia\\Flash Player\\#SharedObjects\\"; 
    TCHAR youku[MAX_PATH] = "\\static.youku.com"; 
    TCHAR tudou[MAX_PATH] = "\\js.tudouui.com"; 
    HANDLE hFist = FindFirstFile("C:\\Documents and Settings\\Administrator\\Application Data\\Macromedia\\Flash Player\\#SharedObjects\\*",&FindFileData); 
    FindNextFile (hFist, &FindFileData); 
    FindNextFile (hFist, &FindFileData); 
    strcat(lujing,FindFileData.cFileName); 
    strcat(lujing2,FindFileData.cFileName); 
    LPSTR dedaoquanlujing = strcat(lujing,youku); 
    LPSTR dedaoquanlujing2 = strcat(lujing2,tudou); 
    SHFILEOPSTRUCT filecaoz; 
    ZeroMemory(&filecaoz,sizeof(filecaoz)); 
    filecaoz.wFunc = FO_DELETE; 
    filecaoz.fFlags = FOF_NOCONFIRMATION|FOF_SIMPLEPROGRESS; 
    filecaoz.hNameMappings = NULL; 
    filecaoz.hwnd = NULL; 
    filecaoz.lpszProgressTitle = NULL; 
    filecaoz.pFrom = dedaoquanlujing; 
    SHFileOperation(&filecaoz); 
    SHFILEOPSTRUCT filecaoz2; 
    ZeroMemory(&filecaoz2,sizeof(filecaoz2)); 
    filecaoz.wFunc = FO_DELETE; 
    filecaoz.fFlags = FOF_NOCONFIRMATION|FOF_SIMPLEPROGRESS; 
    filecaoz.hNameMappings = NULL; 
    filecaoz.hwnd = NULL; 
    filecaoz.lpszProgressTitle = NULL; 
    filecaoz.pFrom = dedaoquanlujing2; 
    SHFileOperation(&filecaoz2); 
    SetFileAttributes(dedaoquanlujing,0); 
    DeleteFile(dedaoquanlujing); 
    DeleteFile(dedaoquanlujing2); 
    HANDLE wenjian = CreateFile(dedaoquanlujing,GENERIC_WRITE|GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); 
    HANDLE wenjian2 = CreateFile(dedaoquanlujing2,GENERIC_WRITE|GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); 
    SetFileAttributes(dedaoquanlujing,0); 
    SetFileAttributes(dedaoquanlujing2,0); 
    CloseHandle(hFist); 
    CloseHandle(wenjian); 
    CloseHandle(wenjian2); 
  //HOST 
    SetFileAttributes("C:\\WINDOWS\\system32\\drivers\\etc\\hosts",0); 
    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); 
    //去优酷 
    DWORD sizebuff = 0; 
    char a1[] = {"#youku\r\n"}; 
    char a2[] = {"127.0.0.1 atm.youku.com\r\n"}; 
    char a3[] = {"127.0.0.1 Fvid.atm.youku.com\r\n"}; 
    char a4[] = {"127.0.0.1 html.atm.youku.com\r\n"}; 
    char a5[] = {"127.0.0.1 valb.atm.youku.com\r\n"}; 
    char a6[] = {"127.0.0.1 valf.atm.youku.com\r\n"}; 
    char a7[] = {"127.0.0.1 valo.atm.youku.com\r\n"}; 
    char a8[] = {"127.0.0.1 valp.atm.youku.com\r\n"}; 
    char a9[] = {"127.0.0.1 lstat.youku.com\r\n"}; 
    char a10[] = {"127.0.0.1 speed.lstat.youku.com\r\n"}; 
    char a11[] = {"127.0.0.1 urchin.lstat.youku.com\r\n"}; 
    char a12[] = {"127.0.0.1 stat.youku.com\r\n"}; 
    char a13[] = {"127.0.0.1 valc.atm.youku.com\r\n"}; 
    char a14[] = {"127.0.0.1 vid.atm.youku.com\r\n"}; 
    char a15[] = {"127.0.0.1 walp.atm.youku.com\r\n"}; 
    char a16[] = {"127.0.0.1 static.lstat.youku.com\r\n"}; 
    WriteFile(wenjianjubing,a1,sizeof(a1)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a2,sizeof(a2)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a3,sizeof(a3)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a4,sizeof(a4)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a5,sizeof(a5)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a6,sizeof(a6)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a7,sizeof(a7)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a8,sizeof(a8)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a9,sizeof(a9)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a10,sizeof(a10)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a11,sizeof(a11)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a12,sizeof(a12)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a13,sizeof(a13)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a14,sizeof(a14)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a15,sizeof(a15)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a16,sizeof(a16)-1,&sizebuff,NULL); 
  //去土豆 
    char b0[] = {"#tudou\r\n"}; 
    char b1[]={"127.0.0.1 adextensioncontrol.tudou.com\r\n"}; 
    char b2[]={"127.0.0.1 iwstat.tudou.com\r\n"}; 
    char b3[]={"127.0.0.1 nstat.tudou.com\r\n"}; 
    char b4[]={"127.0.0.1 stats.tudou.com\r\n"}; 
    char b5[]={"127.0.0.1 *.p2v.tudou.com*\r\n"}; 
    char b6[]={"127.0.0.1 at-img1.tdimg.com\r\n"}; 
    char b7[]={"127.0.0.1 at-img2.tdimg.com\r\n"}; 
    char b8[]={"127.0.0.1 at-img3.tdimg.com\r\n"}; 
    char b9[]={"127.0.0.1 adplay.tudou.com\r\n"}; 
    char b10[]={"127.0.0.1 adcontrol.tudou.com\r\n"}; 
    char b11[]={"127.0.0.1 stat.tudou.com\r\n"}; 
    WriteFile(wenjianjubing,b0,sizeof(b0)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,b1,sizeof(b1)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,b2,sizeof(b2)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,b3,sizeof(b3)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,b4,sizeof(b4)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,b5,sizeof(b5)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,b6,sizeof(b6)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,b7,sizeof(b7)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,b8,sizeof(b8)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,b9,sizeof(b9)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,b10,sizeof(b10)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,b11,sizeof(b11)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,a15,sizeof(a15)-1,&sizebuff,NULL); 
  //去酷6 
    char c0[] = {"#ku6\r\n"}; 
    char c1[]={"127.0.0.1 1.allyes.com.cn\r\n"}; 
    char c2[]={"127.0.0.1 analytics.ku6.com\r\n"}; 
    char c3[]={"127.0.0.1 gug.ku6cdn.com\r\n"}; 
    char c4[]={"127.0.0.1 ku6.allyes.com\r\n"}; 
    char c5[]={"127.0.0.1 ku6afp.allyes.com\r\n"}; 
    char c6[]={"127.0.0.1 pq.stat.ku6.com\r\n"}; 
    char c7[]={"127.0.0.1 st.vq.ku6.cn\r\n"}; 
    char c8[]={"127.0.0.1 stat0.888.ku6.com\r\n"}; 
    char c9[]={"127.0.0.1 stat1.888.ku6.com\r\n"}; 
    char c10[]={"127.0.0.1 stat2.888.ku6.com\r\n"}; 
    char c11[]={"127.0.0.1 stat3.888.ku6.com\r\n"}; 
    char c12[]={"127.0.0.1 static.ku6.com\r\n"}; 
    char c13[]={"127.0.0.1 v0.stat.ku6.com\r\n"}; 
    char c14[]={"127.0.0.1 v1.stat.ku6.com\r\n"}; 
    char c15[]={"127.0.0.1 v2.stat.ku6.com\r\n"}; 
    char c16[]={"127.0.0.1 v3.stat.ku6.com\r\n"}; 
    WriteFile(wenjianjubing,c0,sizeof(c0)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c1,sizeof(c1)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c2,sizeof(c2)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c3,sizeof(c3)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c4,sizeof(c4)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c5,sizeof(c5)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c6,sizeof(c6)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c7,sizeof(c7)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c8,sizeof(c8)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c9,sizeof(c9)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c10,sizeof(c10)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c11,sizeof(c11)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c12,sizeof(c12)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c13,sizeof(c13)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c14,sizeof(c14)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c15,sizeof(c15)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,c16,sizeof(c16)-1,&sizebuff,NULL); 
  // //去奇艺广告 
    char d0[] = {"#qiyi\r\n"}; 
    char d1[]={"127.0.0.1 afp.qiyi.com\r\n"}; 
    char d2[]={"127.0.0.1 focusbaiduafp.allyes.com\r\n"}; 
    WriteFile(wenjianjubing,d0,sizeof(d0)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,d1,sizeof(d1)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,d2,sizeof(d2)-1,&sizebuff,NULL); 
  //新浪视频 
    char e0[] = {"#sina\r\n"}; 
    char e3[]={"127.0.0.1 dcads.sina.com.cn\r\n"}; 
    WriteFile(wenjianjubing,e0,sizeof(e0)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,e3,sizeof(e3)-1,&sizebuff,NULL); 
  //去PPTV 
    char f0[] = {"#pptv\r\n"}; 
    char f4[]={"127.0.0.1 pp2.pptv.com\r\n"}; 
    WriteFile(wenjianjubing,f0,sizeof(f0)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,f4,sizeof(f4)-1,&sizebuff,NULL); 
  //搜狐 
    char g0[] = {"#sohu\r\n"}; 
    char g5[]={"127.0.0.1images.sohu.com\r\n"}; 
    WriteFile(wenjianjubing,g0,sizeof(g0)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,g5,sizeof(g5)-1,&sizebuff,NULL); 
  //乐视 
    char h0[] = {"#leshi\r\n"}; 
    char h6[]={"127.0.0.1 pro.letv.com\r\n"}; 
    WriteFile(wenjianjubing,h0,sizeof(h0)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,h6,sizeof(h6)-1,&sizebuff,NULL); 
  //迅雷看看 
    char j0[] = {"#xunlei\r\n"}; 
    char j1[]={"127.0.0.1 mcfg.sandai.net\r\n"}; 
    char j2[]={"127.0.0.1 biz5.sandai.net\r\n"}; 
    char j3[]={"127.0.0.1 server1.adpolestar.net\r\n"}; 
    char j4[]={"127.0.0.1 advstat.xunlei.com\r\n"}; 
    char j5[]={"127.0.0.1 mpv.sandai.net\r\n"}; 
    WriteFile(wenjianjubing,j0,sizeof(j0)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,j1,sizeof(j1)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,j2,sizeof(j2)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,j3,sizeof(j3)-1,&sizebuff,NULL); 
    WriteFile(wenjianjubing,j3,sizeof(j3)-1,&sizebuff,NULL); 
  //QQ 
  char qq1[]={"#qq\r\n"}; 
  char qq2[]={"127.0.0.1 adslvfile.qq.com\r\n"}; 
  char qq3[]={"127.0.0.1 adsfile.qq.com\r\n"}; 
  WriteFile(wenjianjubing,qq1,sizeof(qq1)-1,&sizebuff,NULL); 
  WriteFile(wenjianjubing,qq2,sizeof(qq2)-1,&sizebuff,NULL); 
  BOOL bWite = WriteFile(wenjianjubing,qq3,sizeof(qq3)-1,&sizebuff,NULL); 
    if(bWite != 0) 
    { 
      AfxMessageBox("屏蔽成功!"); 
      SetFileAttributes("C:\\WINDOWS\\system32\\drivers\\etc\\hosts",1); 
      system("echo y|cacls C:\\WINDOWS\\system32\\drivers\\etc\\hosts /g everyone:r"); 
      return; 
    } 
    else 
    { 
      AfxMessageBox("已经屏蔽!"); 
      return; 
    } 
  } 
  void CGuanggaoDlg::OnButton2()  
  { 
  //恢复 
    TCHAR lujing[MAX_PATH] = "C:\\Documents and Settings\\Administrator\\Application Data\\Macromedia\\Flash Player\\#SharedObjects\\"; 
    TCHAR lujing2[MAX_PATH] = "C:\\Documents and Settings\\Administrator\\Application Data\\Macromedia\\Flash Player\\#SharedObjects\\"; 
    TCHAR mingche2[MAX_PATH] = "\\static.youku.com"; 
    TCHAR tudou[MAX_PATH] = "\\js.tudouui.com"; 
    HANDLE hFist2 = FindFirstFile("C:\\Documents and Settings\\Administrator\\Application Data\\Macromedia\\Flash Player\\#SharedObjects\\*",&FindFileData); 
    FindNextFile (hFist2, &FindFileData); 
    FindNextFile (hFist2, &FindFileData); 
    strcat(lujing,FindFileData.cFileName); 
    strcat(lujing2,FindFileData.cFileName); 
    LPSTR dedaoquanlujing = strcat(lujing,mingche2); 
    LPSTR dedaoquanlujing2 = strcat(lujing2,tudou); 
    DeleteFile(dedaoquanlujing); 
    DeleteFile(dedaoquanlujing2); 
    CloseHandle(hFist2); 
    system("echo y|cacls C:\\WINDOWS\\system32\\drivers\\etc\\hosts /g everyone:f"); 
    SetFileAttributes("C:\\WINDOWS\\system32\\drivers\\etc\\hosts",0); 
    BOOL bCpy = CopyFile("C:\\WINDOWS\\system32\\drivers\\etc\\bak.hosts","C:\\WINDOWS\\system32\\drivers\\etc\\hosts",FALSE); 
    if(bCpy != 0) 
    { 
      AfxMessageBox("恢复成功!"); 
      return; 
    } 
    else 
    { 
      AfxMessageBox("恢复失败!"); 
      return; 
    } 
  } 
  void CGuanggaoDlg::OnButton3()  
  { 
    //优酷测试 
    ShellExecute(NULL,"open","http://www.youku.com",NULL,NULL,SW_SHOWNORMAL); 
  }

希望本文所述对大家的C++程序设计有所帮助。

 
标签: C++ 视频 广告
反对 0举报 0 评论 0
 

免责声明:本文仅代表作者个人观点,与乐学笔记(本网)无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
    本网站有部分内容均转载自其它媒体,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责,若因作品内容、知识产权、版权和其他问题,请及时提供相关证明等材料并与我们留言联系,本网站将在规定时间内给予删除等相关处理.

  • Aurelius vs mORMot vs EntityDAC Delphi 的
    Aurelius vs mORMot vs EntityDAC   Delphi 的 ORM框架:http://www.tmssoftware.com/site/aurelius.asp#product-buy-onlinehttps://synopse.info/fossil/wiki/Synopse+OpenSourcehttps://www.devart.com/entitydac/download.htmlkbmMW  http://www.compo
    02-09
  • 【Ruby】Mac gem的一些坑
    前言自上一次升级MacOS系统后出现jekyll无法构建的问题,当时处理半天。谁知道最近又升级了MacOS,荒废博客多时,今天吝啬写了一篇准备发布,构建报错,问题重新。还是记录下,以防下次升级出问题。问题描述安装jekyll静态博客需要在Ruby环境下运行,于是参照
    02-09
  • iOS oc 调用 swift
    如股票oc要调用swift里面的代码 需要包含固定这个头文件项目名称 LiqunSwiftDemo-Swift.h         #ProjectName#-Swift.h固定的写法swift 目的 是取代oc 但是 不会完全取代 只是前端的替换LiqunSwiftDemo-Swift 点进去 可以看到 所有的swift代码 都产生
    02-09
  • objective-c NSTimer 定时器
    -(void)initTimer{//时间间隔NSTimeInterval timeInterval =3.0 ;//定时器repeats 表示是否需要重复,NO为只重复一次NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:timeInterval target:self selector:@selector(mobileAnimation) userInfo:nil
    02-09
  • Objective-C  日记③ 字符串
    Objective-C 日记③ 字符串
    一、创建字符串、类方法   公式创建NSString  +(id) stringWithFormat:(NSString *) format,……;eg:  NSString *height;  height=[NSString stringWithFormat:@"高度是: %d 长度: %d",10,20];得到的字符串:“高度是: 10 长度: 20” 注意:  省
    02-09
  • Objective-C KVC机制
    Objective-C KVC机制http://blog.csdn.net/omegayy/article/details/7381301全部推翻重写一个版本,这是我在公司内做技术分享的文档总结,对结构、条理做了更清晰的调整。 1.    基本概念MODEL主要是英文文档里面经常出现的一些概念,讲解一下,方便英文
    02-09
  • objective-c 加号 减号 - +
    “加号代表static”是错误的说法,可能跟你那样表达的人其实意思是:“前置加号的方法相当于Java 里面的静态方法”。在Oc中,方法分为类方法和实例方法。前置加号(+)的方法为类方法,这类方法是可以直接用类名来调用的,它的作用主要是创建一个实例。有人把
    02-09
  • Objective-C  日记①
    Objective-C 日记①
    1、Xcode的.m扩展名表示文件含有Object-C代码,C以.c文件,C++以.cpp文件2、头文件声明:C使用:#include,O-C使用#import(当然你也可以使用#include) 3、输出方式:  C:printf("",参数);  O-C:NSLog(@"",参数); 4、布尔类型  C:bool 具有true
    02-09
  • ASP.NET MVC 操作AD 获取域服务器当前用户姓
    #region 根据当前登录域账号 获取AD用户姓名和所在OU目录/// summary/// 根据当前登录域账号 获取AD用户姓名和所在OU目录/// /summary/// param name="searchUser"要搜索的当前用户名/param/// param name="paths"out返回该用户所在OU目录/param/// param nam
    02-09
  • swift和OC - 拆分数组 和 拆分字符串
    1. 拆分数组 /// 根据 数组 截取 指定个数返回 多个数组的集合func splitArray( array: [Date], withSubSize subSize: Int) - [[Date]] {//数组将被拆分成指定长度数组的个数let count = array.count% subSize == 0 ? (array.count/ subSize) : (array.count
    02-08
点击排行