拼接Url成功访问公司服务器



#include<iostream>
#include <stdio.h>
#include <windows.h>
#include <wininet.h>
#include <windows.h>
#include <stdlib.h>
#include<fstream>

#pragma comment(lib,"Wininet.lib")
#include <vector>
#include<string>
using namespace std; 

//long atol(char *s);

void creat_w( char input[64],unsigned long w[80])
{
   int i,j;unsigned long temp,temp1;
   for(i=0;i<16;i++)
          {
             j=4*i;
             w[i]=((long)input[j])<<24 |((long)input[1+j])<<16|((long)input[2+j])<<8|((long)input[3+j])<<0;

          }
   for(i=16;i<80;i++)
         {
             w[i]=w[i-16]^w[i-14]^w[i-8]^w[i-3];
             temp=w[i]<<1;
             temp1=w[i]>>31;
             w[i]=temp|temp1;

         }
   //return '0';
}

char ms_len(long a,char intput[64])
{
    unsigned long temp3,p1;  int i,j;
    temp3=0;
    p1=~(~temp3<<8);
    for(i=0;i<4;i++)
       {
          j=8*i;
          intput[63-i]=(char)((a&(p1<<j))>>j);

       }
	return '0';

}

//字符串插入函数  在字符串string 中查找 source , 找到后再 source之后插入字符串 destination, 找不到则返回 NULL
static char * insert_string (char * string, const char * source, char* destination )
{
    char* sk = strstr (string, source);
    if (sk == NULL) return NULL;
    //char* tmp;
    size_t size = strlen(string)+strlen(destination)+1;
    char* newstr = (char*)calloc (1, size);
    if (newstr == NULL) return NULL;  

    char* retstr = (char*)calloc (1, size);
    if (retstr == NULL)
    {
        free (newstr);
        return NULL;
    }
    _snprintf(newstr,size-1,"%s",string);
    sk = strstr (newstr, source);  

    int pos = 0;
    sk += strlen(source);  

    memcpy (retstr+pos, newstr, sk - newstr);
    pos += sk - newstr;  

    memcpy (retstr+pos, destination, strlen(destination));
    pos += strlen(destination);
    memcpy (retstr+pos, sk, strlen(sk));  

    free (newstr);
    return retstr;  

}  

string input_return(char* s1)
{
	ofstream outfile;
	outfile.open("myfile.txt");
	vector<char> v;
	//string text=s1;
	//string method="iss.getTalk";
	//appKey	ukundogckyf5kwbv2wmihaz5425xfc5wtfo4bqyp
	//appSecret	08bc1d6efbb937b51e71928fe5f54066
	//char szUrl[] = "http://117.121.49.45/service/iss?appkey=5rh55ljf6sijrmp4c23xyoaebccjojs4rekljoqu&appver=1&city=%E5%8C%97%E4%BA%AC%E5%B8%82&gps=39.97685%2C116.36043&history=&method=iss.getTalk&text=%E6%98%8E%E5%A4%A9%E7%9A%84%E5%A4%A9%E6%B0%94%EF%BC%9F&time=2015-03-18%2018%3A03%3A41&udid=54d59edc305273984f990823ee150fd1c25dc289&ver=2.0&voiceId=&scenario=&screen=&dpi=&viewid=0&appsig=E58C5622B7A9C79541E85F0EA71A6E172B812B73";
     // char szUrl[]="http://10.10.11.107/6F41015F89599D6C121BE289D6803F698C320354&appkey=ukundogckyf5kwbv2wmihaz5425xfc5wtfo4bqyp&method=iss.getTalk&text=%e4%bb%8a%e5%a4%a9%e5%a4%a9%e6%b0%94%e5%a6%82%e4%bd%95&ver=2.0&appsig=573B5655B56A7B729C704EB7BA19B23DFE906719&6F41015F89599D6C121BE289D6803F698C320354";
	//char szUrl[] = "http://117.121.49.45/service/iss?appkey=5rh55ljf6sijrmp4c23xyoaebccjojs4rekljoqu&appver=1&city=%E5%8C%97%E4%BA%AC%E5%B8%82&gps=39.97685%2C116.36043&history=&method=iss.getTalk&text=s1&time=2015-03-18%2018%3A03%3A41&udid=54d59edc305273984f990823ee150fd1c25dc289&ver=2.0&voiceId=&scenario=&screen=&dpi=&viewid=0&appsig=E58C5622B7A9C79541E85F0EA71A6E172B812B73";
	//  char szUrl[]="http://scv2.hivoice.cn/service/iss?appkey=F99AB60027FF379418DF6A094E83FA03723F92B7&method=iss.getTalk&appkey=test&ver=2.0&udid=124128941928&gps=33.90249,103.234723&appver=1.4.1.800&appsig=test&text=附近有什么好吃的";
	 // char szUrl[]="http://scv2.hivoice.cn/service/iss?4109A0F4790E67302889FFB6F3DF93AA&appkey=ukundogckyf5kwbv2wmihaz5425xfc5wtfo4bqyp&method=iss.getTalk&text=s1&ver=2.0&ver=2.0&appver=1.0.0&4109A0F4790E67302889FFB6F3DF93AA";
	 // char szUrl[]="http://scv2.hivoice.cn/service/iss?appkey=F99AB60027FF379418DF6A094E83FA03723F92B7&method=iss.getTalk&text=%e6%9d%a5%e4%b8%80%e9%a6%96%e6%ad%8c&ver=2.0&udid=8E67302889FFB6F3DF&appver=1.0.0&appsig=4109A0F4790E67302889FFB6F3DF93AA";
	 // char szUrl[]="http://scv2.hivoice.cn/ii.appkey=F99AB60027FF379418DF6A094E83FA03723F92B7&method=iss.getTalk&text=%e6%9d%a5%e4%b8%80%e9%a6%96%e6%ad%8c&ver=2.0&udid=8E67302889FFB6F3DF&appver=1.0.0&appsig=4109A0F4790E67302889FFB6F3DF93AA";
	  //char szUrl[]="http://scv2.hivoice.cn/service/iss?method=iss.getTalk&appkey=test&ver=2.0&udid=124128941928&gps=33.90249,103.234723&appver=1.4.1.800&appsig=test&text=附近有什么好吃的";
	 // char szUrl[]="http://scv2.hivoice.cn/service/iss?12794ca4422a63a21c8584bfb067b424&appKey=zjo6pne4fmgpiketi4c7be2dctjso36hjyaoppip&method=iss.getTalk&text=%e6%9d%a5%e4%b8%80%e9%a6%96%e6%ad%8c&ver=2.0&12794ca4422a63a21c8584bfb067b424&appsig=37356BB7900A7A8EF5865A40D4F5C4615876AAC7";
	  //char suUrl[]="http://scv2.hivoice.cn/service/08bc1d6efbb937b51e71928fe5f54066&appKey=ukundogckyf5kwbv2wmihaz5425xfc5wtfo4bqyp&method=iss.getTalk&text=%e6%9d%a5%e4%b8%80%e9%a6%96%e6%ad%8c&ver=2.0&udid=8E67302889FFB6F3DF&appver=1.0.0&appsig=4109A0F4790E67302889FFB6F3DF93AA&08bc1d6efbb937b51e71928fe5f54066";
	 //char szUrl[]="http://scv2.hivoice.cn/service/iss?08bc1d6efbb937b51e71928fe5f54066&appkey=zjo6pne4fmgpiketi4c7be2dctjso36hjyaoppip&method=iss.getTalk&text=&ver=2.0&08bc1d6efbb937b51e71928fe5f54066&appsig=FF7F6EAC33094241AEE59A578DA8FB9BAA98FD29";

	char szUrl[10000]="08bc1d6efbb937b51e71928fe5f54066&appkey=zjo6pne4fmgpiketi4c7be2dctjso36hjyaoppip&method=iss.getTalk&text=&ver=2.0&08bc1d6efbb937b51e71928fe5f54066";
	//printf("%s\n",insert_string (szUrl,"text=",s1));
	//szUrl=insert_string (szUrl,"text=",s1);
	//printf("hello\n");
	string lan=insert_string (szUrl,"text=",s1);   //在text后连接用户输入的数据
	string lan2="12794ca4422a63a21c8584bfb067b424&"+lan+"&12794ca4422a63a21c8584bfb067b424&";
	//printf("lan=======%s\n",lan);

	unsigned long H0=0x67452301,H1=0xefcdab89,H2=0x98badcfe,H3=0x10325476,H4=0xc3d2e1f0;
   unsigned long A,B,C,D,E,temp,temp1,temp2,temp3,k,f;int i,flag;unsigned long w[80];
   char input[64];
   long x;int n;
   //printf("input message:\n");
   //scanf("%s",input);
   n=strlen(input);
   if(n<57)
          {
                 x=n*8;
                 ms_len(x,input);
                 if(n==56)
                     for(i=n;i<60;i++)
                     input[i]=0;
                 else
                    {
                     input[n]=128;
                     for(i=n+1;i<60;i++)
                     input[i]=0;
                    }

          }

   creat_w(input,w);
   /*for(i=0;i<80;i++)
   printf("%lx,",w[i]);*/
   //printf("\n");
   A=H0;B=H1;C=H2;D=H3;E=H4;
   for(i=0;i<80;i++)
         {
               flag=i/20;
               switch(flag)
                  {
                   case 0: k=0x5a827999;f=(B&C)|(~B&D);break;
                   case 1: k=0x6ed9eba1;f=B^C^D;break;
                   case 2: k=0x8f1bbcdc;f=(B&C)|(B&D)|(C&D);break;
                   case 3: k=0xca62c1d6;f=B^C^D;break;
                  }
               /*printf("%lx,%lx\n",k,f); */
               temp1=A<<5;
               temp2=A>>27;
               temp3=temp1|temp2;
               temp=temp3+f+E+w[i]+k;
               E=D;
               D=C;

               temp1=B<<30;
               temp2=B>>2;
               C=temp1|temp2;
               B=A;
               A=temp;

              // printf("%lx,%lx,%lx,%lx,%lx\n",A,B,C,D,E);
         }
   H0=H0+A;
   H1=H1+B;
   H2=H2+C;
   H3=H3+D;
   H4=H4+E;

   //cout<<"H0="<<H0<<H1<<H2<<H3<<H4<<endl<<endl<<endl;

   string lan3=lan2+"appsig=";
   //longatol
   char a1[1000],a2[1000],a3[1000],a4[1000],a0[1000];
   sprintf(a0, "%u",H0);
   sprintf(a1, "%u",H1);
   sprintf(a2, "%u",H2);
   sprintf(a3, "%u",H3);
   sprintf(a4, "%u",H4);

   //string lan3;
   //strcpy(lan3,a0);
   string zhou0=a0;
   string zhou1=a1;
   string zhou2=a2;
   string zhou3=a3;
   string zhou4=a4;

   //cout<<a0<<a1<<a2<<a3<<a4<<endl<<endl<<endl;

   string lan4="http://scv2.hivoice.cn/service/iss?"+lan3+zhou0+zhou1+zhou2+zhou3+zhou4;
  // cout<<lan4<<endl;
   //strcpy(dst,src.c_str());
   strcpy(szUrl,lan4.c_str());

  // cout<<szUrl;
  // outfile<<szUrl<<endl;

	//char szUrl[]="http://scv2.hivoice.cn/service/iss?12794ca4422a63a21c8584bfb067b424&appKey=zjo6pne4fmgpiketi4c7be2dctjso36hjyaoppip&method=iss.getTalk&text=cout<<s1&ver=2.0&12794ca4422a63a21c8584bfb067b424&appsig=2462F8A6D6F2F34CBE707E98A6FB90AA85842039";
	 CHAR szAgent[] = "";
    HINTERNET hInternet1 =
        InternetOpen(NULL,INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,NULL);
    if (NULL == hInternet1)
     {
        InternetCloseHandle(hInternet1);
        return FALSE;
     }
    HINTERNET hInternet2 =InternetOpenUrl(hInternet1,szUrl,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE,NULL);
    if (NULL == hInternet2)
     {
        InternetCloseHandle(hInternet2);
        InternetCloseHandle(hInternet1);
        return FALSE;
     }
    DWORD dwMaxDataLength = 500;
    PBYTE pBuf = (PBYTE)malloc(dwMaxDataLength*sizeof(TCHAR));
    if (NULL == pBuf)
     {
        InternetCloseHandle(hInternet2);
        InternetCloseHandle(hInternet1);
        return FALSE;
     }
    DWORD dwReadDataLength = NULL;
    BOOL bRet = TRUE;
    do
    {
        ZeroMemory(pBuf,dwMaxDataLength*sizeof(TCHAR));
        bRet = InternetReadFile(hInternet2,pBuf,dwMaxDataLength,&dwReadDataLength);
        for (DWORD dw = 0;dw < dwReadDataLength;dw++)
         {
            v.push_back(pBuf[dw]);
         }
     } while (NULL != dwReadDataLength);

	//outfile<<szUrl<<endl;

    vector<char>::iterator i_j;
    for(i_j=v.begin(); i_j!=v.end(); i_j++)
	{
        //printf("%c",*i_j);
		outfile<<*(i_j);
	}
	//Sleep(100000);
	//outfile<<szUrl<<endl;
	outfile.close();
	return lan4;
}

int main()
{
	char s1[10000];
	cin>>s1;
	input_return(s1);
   // printf("%s\n",input_return(s1));
    return 0;
} 

时间: 2024-08-04 08:36:19

拼接Url成功访问公司服务器的相关文章

公司网络访问web服务器

一.准备工作:在eNsp中模拟公司访问web服务器,在模拟器中准备一台S5700交换机名为SW1,俩台S3700交换机分别名为SW2,SW3.三台PC机分别命名PC1,PC2,PC3.俩台Server,分别模拟web服务器跟dns服务器.一台Client,命名为Client1充当客户端 二.实验环境 设备 端口 连接设备 SW1 GE0/0/1 SW2 SW1 GE0/0/2 SW3 SW1 GE0/0/3 dns SW1 GE0/0/4 web SW2 Ethe0/0/1 SW1 SW2 Et

使用telnet访问某些服务器的端口,以测试可达性,为何有时要好几秒才能成功建立连接?

最近发现,在某些Freebsd服务器上使用telnet访问远程服务器端口,要好几秒才能建立成功连接.为何?今天下午终于搞清楚了.原来telnet在访问远程服务器时,默认启用了反向解析功能.而我们的dns没有配置dns反向解析.导致超时后才使用IP访问对方.这时只要使用-N参数就可以了,比如: telnet -N 192.100.0.1 80 很快建立连接. 其实很多其他服务器也是类似的,默认开启了反向解析功能.比如ssh,mysql. ssh,关闭dns反向解析: UseDNS no mysql

内网PC通过NAT server公网地址访问内部服务器时TCP三次握手不成功

公网地址访问内部服务器时TCP三次握手不成功   一.  背景 在上图所示的网络中,PC 及Server属不同LAN,都是zone trust.为了让Internet用户能够访问到Server,FW上部署了NatServer:nat server global A.B.C.D inside 192.168.51.M也就是将公网地址A.B.C.D映射到192.168.51.M.完成上述配置后,Internet用户能够通过A.B.C.D这个公网IP访问Server.但是内网的PC在访问Server的

HTTP协议详解以及URL具体访问过程

1.简介 1.1.HTTP协议是什么? 即超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议,所有的WWW文件都必须遵守这个标准.从网络参考模型来看,它是属于应用层.它规定了计算机通信网络中两台计算机之间进行通信所必须共同遵守的规定或规则,它允许将超文本标记语言(HTML)文档从Web服务器传送到客户端的浏览器. 简单的来说,它就是基于应用层一个规范一个标准!通讯双发都需要遵守这一准则,这就是http协议! 1.2.http简史

思科路由器实现出差员工访问公司内部网络远程访问VPN—Easy VPN

远程访问VPN-EasyVPN 1.       实验拓扑: 使用GNS3模拟器(版本号0.8.6)+c2691-advsecurityk9-mz.124-11.T2.bin +以太网交换机 2.       实验需求: a)       C1连接VMnet1和虚拟机Win7绑定一个网卡模仿Win7系统,C2连接VMnet8和虚拟机Win server2008绑定一个网卡模仿Win server 2008服务器 b)       使用Easy VPN让出差员工在任何地方都可以访问公司内网 c) 

Android通过get,post方式体访问http服务器

RT..我之前感觉Android网络通信很神奇,Magic...最近学习了网络知识,现在来总结一下怎么做 好了,就拿例子来说明原理. 说下这个Demo的用处: 1.用户可以访问一个网页 2.用户提交用户名和密码到Http服务器中,在Tomcat的控制台中显示出提交的内容. 先来介绍一下怎么访问网页 看代码 package com.hwb.service; import java.net.HttpURLConnection; import java.net.URL; import com.hwb.

Cisco路由器之Easy虚拟专用网(解决出差员工访问公司内网的问题)

博文大纲:一.在路由器上实现Easy 虚拟专用网需要配置什么?二.配置实例 前言:由于"Virtual Private Network"(请看首字母,就知道是什么咯)是敏\感词汇,所以在博文中使用它的中文名字"虚拟专用网"来代替. 在之前写过了Cisco路由器之IPSec 虚拟专用网:在Cisco的ASA防火墙上实现IPSec虚拟专用网.这两篇博文都是用于实现总公司和分公司之间建立虚拟专用网的,那么还有一种使用很多的情况,就是出差人员想要访问公司内网的资源呢?由于出

Cisco ASA防火墙之Easy虚拟专用网(解决出差员工访问公司内网的问题)

前言:上一篇博文写了Cisco路由器之Easy虚拟专用网(解决出差员工访问公司内网的问题),是基于公司网关设备是路由器的情况下,那么,如果是ASA防火墙的话,又该怎么配置呢?关于理论部分,在前面提到的博文链接中已经写的挺详细了,可以参考那篇博文的理论部分,这里就直接上配置了. 该博文关于虚拟专用网的理论知识点比较少,因为我之前写过好几篇虚拟专用网的博文了,所以关于原理方面不会重复写,若想了解原理,可以参考以下博文(路由器和防火墙的虚拟专用网原理类似,可参考): Cisco路由器之Easy虚拟专用

Cisco 路由器上配置Easy虚拟专用网(解决员工出差访问公司内网)

博文目录一.Easy 虚拟化专用网需要解决的问题是什么?二.如何在路由器上实现Easy 虚拟专用网?三.配置路由器上实现Easy 虚拟专用网 由于"Virtual Private Network"(请看首字母,就知道是什么咯)是敏\感词汇,所以在博文中使用它的中文名字"虚拟专用网"来代替. 在之前写过了Cisco路由器IPSec 虚拟专用网原理与详细配置:Cisco的ASA防火墙和路由器上实现IPSec虚拟专用网.这两篇博文都是用于实现总公司和分公司之间建立虚拟专用