Socket proxy source code

Source: Internet
Author: User
Tags htons
  1. # Include <winsock2.h>
  2. # Include <stdio. h>
  3. # Define proxy_version
  4. Int arid [] =
  5. {
  6. 1007225
  7. };
  8. Char szheadi [] =
  9. "Get http://www.5460.net/txl/liuyan/liuyanSql.pl? Nid = % d ";
  10. Char szheadii [] =
  11. "& Csid = 688939 & cname = % D5 % C2 % CC % Ce HTTP/1.1/R/N"
  12. "Accept: */R/N"
  13. "Referer: http://www.5460.net/txl/login/login.pl/r/n"
  14. "Accept-language: ZH-CN/R/N"
  15. "Accept-encoding: gzip, deflate/R/N"
  16. "User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)/R/N"
  17. "Host: www.5460.net/r/n"
  18. "Connection: keep-alive/R/N"
  19. # Ifdef proxy_version
  20. "Proxy-authorization: Basic eg9femp1omjvym8xodezmty =/R/N"
  21. # Endif
  22. "/R/N ";
  23. // "Cookie: nid = 2173606; pswd = wither/R/n/R/N ";
  24. Char MSG [4000];
  25. Bool sockinit ()
  26. {
  27. Wsadata;
  28. If (wsastartup (makeword (2, 0), & wsadata ))
  29. {
  30. Return false;
  31. }
  32. If (wsadata. wversion! = Makeword (2, 0 ))
  33. {
  34. Wsacleanup ();
  35. Return false;
  36. }
  37. Return true;
  38. }
  39. Int main (INT argc, char * argv [])
  40. {
  41. Sockinit ();
  42. Int SKT;
  43. Int Len;
  44. Struct sockaddr_in peer;
  45. Memset (& peer, 0, sizeof (PEER ));
  46. Peer. sin_family = af_inet;
  47. # Ifdef proxy_version
  48. Peer. sin_port = htons (80 );
  49. Peer. sin_addr.s_addr = inet_addr ("10.21.41.16 ");
  50. # Else
  51. Peer. sin_port = htons (80 );
  52. Peer. sin_addr.s_addr = inet_addr ("61.137.93.108 ");
  53. # Endif
  54. Char buff [1024*32];
  55. For (INT I = 0; I <1/* sizeof (arid)/sizeof (INT) */; I ++)
  56. {
  57. Int nid = arid [I];
  58. SKT = socket (af_inet, sock_stream, 0 );
  59. Len = connect (SKT, (struct sockaddr *) & peer, sizeof (PEER ));
  60. If (Len! = 0)
  61. {
  62. Closesocket (SKT );
  63. Continue;
  64. }
  65. Sprintf (MSG, szheadi, NID );
  66. Strcat (MSG, szheadii );
  67. Len = Send (SKT, MSG, sizeof (MSG)-1, 0 );
  68. If (LEN <= 0)
  69. {
  70. Closesocket (SKT );
  71. Continue;
  72. }
  73. Int Total = 0;
  74. For (;;)
  75. {
  76. Fd_set FDS;
  77. Fd_zero (& FDs );
  78. Fd_set (SKT, & FDs );
  79. Timeval TV;
  80. TV. TV _sec = 10;
  81. TV. TV _usec = 0;
  82. Len = select (0, & FDS, null, null, & TV );
  83. If (LEN <= 0)
  84. Break;
  85. Len = Recv (SKT, buff, sizeof (buff), 0 );
  86. Buff [Len] = '/0 ';
  87. Printf ("% s", buff );
  88. If (LEN <= 0)
  89. Break;
  90. Total + = Len;
  91. }
  92. Printf ("% d Recv: % d/N", NID, total );
  93. Closesocket (SKT );
  94. Sleep (500 );
  95. }
  96. Wsacleanup ();
  97. Return 0;
  98. }

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.