1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| #include <stdio.h> #include <winsock2.h> #pragma comment( lib , "ws2_32" ) int main() { char Fs[1000]; char Js[1000];
WSADATA wsadata; SOCKET Socket; SOCKADDR_IN Local, to;
{ WSAStartup( 0x0202, &wsadata ); } Socket = socket( AF_INET, SOCK_STREAM, 0 ); if (!Socket) { return -1; }
Local.sin_family = AF_INET; Local.sin_port = htons(102); Local.sin_addr.S_un.S_addr = htonl(INADDR_ANY);
to.sin_family = AF_INET; to.sin_port = htons(80); to.sin_addr.S_un.S_addr = inet_addr("192.168.1.1");
if (bind(Socket, (SOCKADDR*)&Local, sizeof(Local)) == SOCKET_ERROR) { return -1; } if (connect(Socket, (SOCKADDR*)&to, sizeof(SOCKADDR)) == SOCKET_ERROR) { return -1; } { memset(Fs, 0, 1000); memset(Js, 0, 1000);
strcpy(Fs, "GET /userRpm/SysRebootRpm.htm?Reboot=%D6%D8%C6%F4%C2%B7%D3%C9%C6%F7 HTTP/1.1\r\n" ); strcat(Fs, "Host: 192.168.1.1\r\n" ); strcat(Fs, "Authorization: Basic YWRtaW46YWRtaW4=\r\n" ); strcat(Fs, "\r\n"); } if (send(Socket, Fs, strlen(Fs), 0) == SOCKET_ERROR) { return -1; } closesocket(Socket); WSACleanup(); return 0; }
|