• 管理员
    了解作者
  • Visual C++
    开发工具
  • 116KB
    文件大小
  • zip
    文件格式
  • 1
    收藏次数
  • 10 积分
    下载积分
  • 2380
    下载次数
  • 2001-01-07 15:19
    上传日期
小型HTTP代理程序
proxy.zip
  • res
  • HTTPDOC.ICO
    1.1KB
  • MAINFRM.ICO
    1.1KB
  • HTTPSVR.RC2
    399B
  • LOGFILE.ICO
    4.7KB
  • IMAGES.BMP
    3.1KB
  • PersonalProxy.rc2
    405B
  • PersonalProxy.ico
    1.1KB
  • SMIMAGES.BMP
    886B
  • resource
  • Debug
  • PersonalProxy.exe
    128.1KB
  • HTTPSVR.ncb
    105KB
  • StdAfx.h
    1KB
  • PersonalProxy.h
    1.4KB
  • www.pudn.com.txt
    218B
  • PersonalProxyDlg.cpp
    6.8KB
  • HTTPSVR.opt
    52.5KB
  • httpsvr.plg
    2.7KB
  • PersonalProxy.cpp
    2.1KB
  • PersonalProxy.opt
    52.5KB
  • PersonalProxyDlg.h
    1.6KB
  • PersonalProxy.ncb
    225KB
  • default Log 20000502.hsl
    2.1KB
  • PersonalProxy.dsp
    4.4KB
  • PersonalProxy.dsw
    761B
  • resource.h
    1KB
  • PersonalProxy.rc
    6.3KB
  • PersonalProxy.aps
    35.7KB
  • WorkingThread.cpp
    21KB
  • StdAfx.cpp
    215B
  • PersonalProxy.plg
    1.1KB
  • WorkingThread.h
    2.8KB
  • PersonalProxy.clw
    2KB
内容介绍
/* * File name: WorkingThread.cpp * Version: 1.0.0.2 * Programmer: A.George * Organization: * Date(start): 5.23.2000 * Date(finish): * Description: Working thread. */ #include "stdafx.h" #include "WorkingThread.h" #include "winsock.h" #include <stdio.h> #include <io.h> #include <afxinet.h rel='nofollow' onclick='return false;'> #define SITEBASE "g:\\ag\\personalproxy" ///////////////////////////////////////////////////////////////////////////// int g_nConnectionCount; HANDLE g_hConnectionCount; unsigned long g_ulIpRefused[100]; int g_nRefused; GLOBAL globalInfo; ///////////////////////////////////////////////////////////////////////////// int (*ProcessCommand)(SOCKET sck, char* pszCommand, char* buf); ///////////////////////////////////////////////////////////////////////////// BYTE Table(BYTE ot) { if(ot>=0 && ot<=25)return 'A' + ot; else if(ot>=26 && ot<=51)return 'a' + (ot-26); else if(ot>=52 && ot<=61)return '0' + (ot-52); else if(ot==62)return '+'; else if(ot==63)return '/'; else return '='; } void Base64(char* pszSource, char* pszCode) { BYTE ot; int i; i=0; while(pszSource[i]) { ot = (0xFC & pszSource[i])>>2; *pszCode = Table(ot); i++; pszCode++; if(!pszSource[i]) { ot = (0x03 & pszSource[i-1])<<4; *pszCode = Table(ot); pszCode++; break; } ot = (0x03 & pszSource[i-1])<<4 | (0xF0 & pszSource[i])>>4; *pszCode = Table(ot); pszCode++; i++; if(!pszSource[i]) { ot = (0x0F & pszSource[i-1])<<2; *pszCode = Table(ot); pszCode++; break; } ot = (0x0F & pszSource[i-1])<<2 | (0xC0 & pszSource[i])>>6; *pszCode = Table(ot); pszCode++; ot = 0x3F & pszSource[i]; *pszCode = Table(ot), i++; pszCode++; } *pszCode = NULL; } BYTE GetSixBits(char* pszStr, int& i) { char c; while(1) { if(i>=strlen(pszStr))break; c = pszStr[i++]; if(isupper(c)) return c-'A'; else if(islower(c)) return c-'a'+26; else if(isdigit(c)) return c-'0'+52; else if(c=='+') return 62; else if(c=='/') return 63; else if(c=='=') return 0; } return 0; } void Unbase64(char* pszText, char* pszCode) { int nLen, i; BYTE bySixBits0, bySixBits1, bySixBits2, bySixBits3, c; nLen = strlen(pszCode); for(i=0; i<nLen; ) { bySixBits0 = GetSixBits(pszCode, i); if(i<nLen)bySixBits1 = GetSixBits(pszCode, i); if(i<nLen)bySixBits2 = GetSixBits(pszCode, i); if(i<nLen)bySixBits3 = GetSixBits(pszCode, i); c = bySixBits0<<2 | bySixBits1>>4; *pszText = c; pszText++; c = bySixBits1<<4 | bySixBits2>>2; *pszText = c; pszText++; c = bySixBits2<<6 | bySixBits3; *pszText = c; pszText++; } *pszText = NULL; } DWORD RecvHeader(SOCKET socket, char *buf, DWORD dwSize, HTTPHEADER* pHeader) { char * pEnd, *pSize, *pType, *pLocation; int nRet, nTotal; memset(pHeader, 0, sizeof(HTTPHEADER)); nTotal = 0; do{ nRet = recv(socket, buf+nTotal, dwSize-nTotal, 0); if(nRet==SOCKET_ERROR)return SOCKET_ERROR; nTotal += nRet; buf[nRet] = NULL; pEnd = strstr(buf, "\r\n\r\n"); if(pEnd) { pSize = strstr(buf, "Content-length: "); if(pSize)sscanf(pSize+16, "%ud", &(pHeader->dwContSize)); else pHeader->dwContSize = -1; if(DWORD(pEnd-buf+4)<dwSize) pHeader->pContBegin = pEnd+4; else pHeader->pContBegin = NULL; sscanf(buf, "HTTP/%d.%d %d %s", &pHeader->nVerMajor, &pHeader->nVerMinor, &pHeader->dwHttpStatus, pHeader->pszStatus); pType = strstr(buf, "Content-type: "); if(pType)sscanf(pType+14, "%s", &(pHeader->pszType)); pLocation = strstr(buf, "Location: "); if(pLocation)sscanf(pLocation+10, "s", &(pHeader->pszLocation)); return nTotal; } }while(!pEnd && nRet); return nTotal; } int RecvRequest(SOCKET sck, char * buf, DWORD dwSize, REQUESTHEADER * pRequestHeader) { char * pEnd, pszCode[32], pszText[32], *pAuthorization, *pRange, *pSize; int iRet; DWORD nTotal; pRequestHeader->dwFlag = REQUEST_UNAUTHORIZED; memset(buf, 0, dwSize); nTotal = 0; do{ iRet = recv(sck, buf+nTotal, dwSize-nTotal-1, 0); if(iRet==SOCKET_ERROR) { return SOCKET_ERROR; } nTotal += iRet; buf[nTotal] = NULL; pEnd = strstr(buf, "\r\n\r\n"); if(pEnd) { pAuthorization = strstr(buf, "Proxy-Authorization: "); if(!pAuthorization) { pRequestHeader->pszUserPass[0] = NULL; return 0; } sscanf(pAuthorization+21, "%*s%s", pszCode); Unbase64(pszText, pszCode); if(strcmp(pszText, "user:ag")) { strcpy(pRequestHeader->pszUserPass, pszText); return 0; } else pRequestHeader->dwFlag = 0; pRequestHeader->pszAuthBegin = pAuthorization; pRequestHeader->pszAuthEnd = strstr(pAuthorization, "\r\n")+2; pRequestHeader->pszVirtualRes = strstr(buf, "GET "); //"http://www.personalproxy.com/"); if(pRequestHeader->pszVirtualRes) { if(!strncmp(pRequestHeader->pszVirtualRes+4, "http://www.personalproxy.com", 28)) { pRequestHeader->dwFlag |= VIRTUAL_RESOURCE; sscanf(pRequestHeader->pszVirtualRes+4, "%s", pRequestHeader->pszUrl); } } pRange = strstr(buf, "RANGE: bytes"); if(pRange) { pRange = strstr(pRange, "="); if(pRange) { sscanf(pRange+1, "%d", &pRequestHeader->dwRange); pRequestHeader->dwFlag |= PARTIAL_CONTENT; } } pSize = strstr(buf, "Content-Length: "); if(pSize) { sscanf(pSize+16, "%d", &pRequestHeader->dwContSize); } else pRequestHeader->dwContSize = 0; pRequestHeader->pszContBegin = pEnd+4; return nTotal; } }while(!pEnd && iRet); return 0; } void UnCh(char* pszStr) { char pszLine[512]; int i, j, nLen; BYTE b1, b2; i=0; j=0; nLen = strlen(pszStr); while(i<nLen) { if(pszStr[i]=='%') { i++; sscanf(pszStr+i, "%2X", &b1); i += 2; } else { pszLine[j++] = pszStr[i++]; continue; } if(i>=nLen) { pszLine[j++] = b1; break; } if(pszStr[i]=='%') { i++; sscanf(pszStr+i, "%2X", &b2); i += 2; pszLine[j++] = b2; pszLine[j++] = b1; } else { pszLine[j++] = b1; pszLine[j++] = pszStr[i++]; } } pszLine[j]=0; strcpy(pszStr, pszLine); } void ContentType(char* pszFile, char* pszType) { char drive[4], dir[MAX_PATH], fname[MAX_PATH], ext[16]; _splitpath(pszFile, drive, dir, fname, ext); _strlwr(ext); if(strstr(pszFile, "multipart")) strcpy(pszType, "multipart/mixed"); else if(!*ext) strcpy(pszType, "text/html"); else if(!strcmp(ext, ".jpg")) strcpy(pszType, "image/jpeg"); else if(!strcmp(ext, ".jpeg")) strcpy(pszType, "image/gif"); else if(!strcmp(ext, ".htm")) strcpy(pszType, "text/html"); else if(!strcmp(ext, ".html")) strcpy(pszType, "text/html"); else if(!strcmp(ext, ".zip")) strcpy(pszType, "application/x-compressed"); else if(!strcmp(ext, ".mpeg")) strcpy(pszType, "video/mpeg"); else strcpy(pszType, "application/octet-stream"); } void HttpService(char * pszUrl, SOCKET sck, char* buf, REQUESTHEADER* pRequestHeader) { CString strServer, strObject; DWORD dwService, dwSize, dwFileLen; unsigned short nPort; int iRet; char pszFile[512], pszLine[512], pszType[16]; char pszCommand[128], *pQuestionMark; FILE* pFileContent; AfxParseURL(pszUrl, dwService, strServer, strObject, nPort); if(strObject=="/") sprintf(pszFile, "%s%s", SITEBASE, "\\VirtualPage.html"); else sprintf(pszFile, "%s%s", SITEBASE, strObject); UnCh(pszFile); // dwService 3 // nPort 80 // + strObject {"/count.dll?a=1&b=2"} // + strServer {"www.ms.com"} // + this 0x0012fe74 {CTryDlg hWnd=0x01460920} if(strstr(pszFile, "myextension")) { pQuestionMark = strstr(pszFile, "?"); if(pQuestionMark) { strcpy(pszCommand, pQuestionMark+1); *pQuestionMark = NULL; } else * pszCommand = NULL; HMODULE hModule = LoadLibrary(pszFile); if(!hModule) { OUTPU
评论
    相关推荐
    • 修补http代理
      修补http代理
    • qq http 代理服务器
      如果网关限制了qq可以通过qq代理服务器进行上qq
    • HTTP代理服务器代码
      每客户单线程实现http 代理服务器,参考网络资源,用VC6.0编写,满足网络程序设计课程的实验要求。
    • http代理测试器
      查看网上代理是否还能正常使用 包含源代码
    • 自动代理HTTP服务器
      是不是还要每次调节IP地址???在这你不用了 安装后 点击会自动代理
    • http代理
      NULL 博文链接:https://angrycoder.iteye.com/blog/1682007
    • HTTP Web 代理服务器
      本来想到网上下载一个代理器的,就发现一个可以用,而且很简单,所以花了一些时间做了这个,vc6开发的,基于CAsyncSocket,可以修改http的头信息,易于理解。
    • http代理http代理http代理http代理
      http代理源代码http代理http代理http代理http代理http代理
    • 智能HTTP代理
      支持全自动获取网页中的代理信息,自动在线扫描可用代理。国内外都可以一键代理,非常方便。
    • HTTP代理
      HTTP代理HTTP代理