Advertisement
extrabeef

Untitled

Aug 1st, 2017
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. int main()
  2. {
  3. WSADATA wsaData;
  4. int iResult;
  5. DWORD dwError;
  6. SOCKET sock;
  7. struct hostent *remoteHost;
  8. struct sockaddr_in server;
  9. char host_name[] = "irc.chat.twitch.tv";
  10. struct in_addr addr;
  11.  
  12. char **pAlias;
  13. // Initialize Winsock
  14. iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
  15. if (iResult != 0) {
  16. printf("WSAStartup failed: %d\n", iResult);
  17. return 1;
  18. }
  19.  
  20. printf("Calling gethostbyname with %s\n", host_name);
  21. remoteHost = gethostbyname(host_name);
  22. if (!remoteHost)
  23. {
  24. printf("Failled to get %s(s) host by name... Error: %d\n", host_name, WSAGetLastError());
  25. getch();
  26. exit(1);
  27. }
  28. printf("Successfully retrieved host by name...\n");
  29. int i = 0;
  30. while (remoteHost->h_addr_list[i] != 0)
  31. {
  32. addr.s_addr = *(u_long *) remoteHost->h_addr_list[i++];
  33. printf("\tIP Address #%d: %s\n", i, inet_ntoa(addr));
  34. }
  35. char *ipaddr = inet_ntoa(addr);
  36. sock = socket(AF_INET, SOCK_STREAM, 0);
  37. if (sock == INVALID_SOCKET)
  38. {
  39. printf("Socket == Invalid_Socket...\n");
  40. getch();
  41. exit(1);
  42. }
  43.  
  44. printf("Gathered All IP Adresses... Using %s\n", ipaddr);
  45. ZeroMemory(&server, sizeof(&server));
  46. server.sin_addr.s_addr = inet_addr(ipaddr);
  47. server.sin_family = AF_INET;
  48. server.sin_port = htons(6667);
  49. if (connect(sock, (struct sockaddr *)&server, sizeof(server)) == 0)
  50. {
  51. printf("Connected to %s OR %s...\n", host_name, ipaddr);
  52. Sleep(2000);
  53. printf("Trying: PASS blockedforsecurity\nNICK ircbot");
  54. send(sock, "PASS blockedforsecurity\n", strlen("PASS blockedforsecurity") + 1, 0);
  55. send(sock, "NICK ircbot\n", strlen("ircbot") + 1, 0);
  56. int mret; char *rbuf;
  57. while (true)
  58. {
  59. ZeroMemory(&rbuf, sizeof(rbuf));
  60. mret = recv(sock, rbuf, sizeof(rbuf), 0);
  61. if (!mret)
  62. {
  63. printf("Connection broke...\n");
  64. getch();
  65. exit(1);
  66. }
  67. else
  68. {
  69. if(rbuf)
  70. printf("%s\n", rbuf);
  71. }
  72. Sleep(700);
  73. }
  74. }
  75. else
  76. {
  77. printf("Failed to connect!\n");
  78. }
  79. getch();
  80. return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement