Created
July 17, 2017 09:40
-
-
Save tqkve/e7020f730b917266ad7d4714f0c6c9dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "stdafx.h" | |
| #include <stdio.h> | |
| #include <winsock2.h> | |
| #include <Ws2tcpip.h> | |
| #include <string> | |
| #pragma comment (lib,"ws2_32.lib") | |
| /* | |
| vd thuat toan nen': | |
| goc': abacadae (8byte) | |
| max char = a (4 lan xuat hien) | |
| bang nen (1byte-8bit):1 0 1 0 1 0 1 0 | |
| sau khi nen': b c d e (4byte) | |
| goc:a b a c a d a e | |
| exploit: abacadaebbbbbbb => them b vao cho chac chan b la maxchar | |
| bang nen 010000001111111 => ky tu thu 2 trong mau tin goc la b | |
| lap di lap lai du het cac ky tu trong tap ky tu cua ban tin goc: | |
| */ | |
| int _tmain(int argc, _TCHAR* argv[]) | |
| { | |
| const char base64chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; | |
| int recvbuflen = 4096; | |
| char recvbuf[4096] = ""; | |
| char recvbuf2[4096]=""; | |
| char e[1600]; | |
| memset(e, 0, 1600); | |
| int iResult; | |
| WSADATA wsaData; | |
| char payl[100]; | |
| SOCKET ConnectSocket = INVALID_SOCKET; | |
| struct sockaddr_in clientService; | |
| clientService.sin_family = AF_INET; | |
| clientService.sin_addr.s_addr = inet_addr("139.59.227.253"); //tower1.svattt.org | |
| clientService.sin_port = htons(31331); | |
| for (int i = 0; i < 65; i++) | |
| { | |
| iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); | |
| ConnectSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); | |
| iResult = connect(ConnectSocket, (SOCKADDR*)&clientService, sizeof(clientService)); | |
| iResult = recv(ConnectSocket, recvbuf, recvbuflen, 0); | |
| if (iResult > 0) | |
| printf("%s\n",recvbuf); | |
| memset(recvbuf, 0, 4096); | |
| memset(payl, base64chars[i], 100); | |
| send(ConnectSocket, payl, 100, 0); | |
| printf("%c\n", base64chars[i]); | |
| memset(recvbuf2, 0, 4096); | |
| int n = 0; | |
| do | |
| { | |
| iResult = recv(ConnectSocket, recvbuf, recvbuflen, 0); | |
| if (iResult > 0) | |
| { | |
| memcpy(recvbuf2 + n, recvbuf, iResult); | |
| n += iResult; | |
| } | |
| //printf("%d\n", iResult); | |
| memset(recvbuf, 0, 4096); | |
| } | |
| while (iResult != -1 && iResult!=0); | |
| printf("recv %d\n", n); | |
| /*for (int i = 0; i < n; i++) | |
| printf("%c", recvbuf2[i]);*/ | |
| memset(recvbuf, 0, 4096); | |
| int j = 0; | |
| /*for (size_t i = 38; i < 1600; i++) | |
| { | |
| printf("%c ", recvbuf2[i]); | |
| } | |
| system("Pause");*/ | |
| // POC_LENGTH =1024 => base64 cua POC_LENGTH co do dai 1368 | |
| // 1368/8=171 | |
| // in ra kieu string 2 kytu 1 byte nen do dai cua bang map = 171x2 = 342 | |
| //342 +38 la do dai header | |
| for (int k = 38; k < 380; k +=2) | |
| { | |
| char a[3] = ""; | |
| a[2] = 0; | |
| memcpy(a, &recvbuf2[k], 2); | |
| //printf("%s ", a); | |
| int offset = std::stoi(a,0,16); | |
| //printf("%x ", offset); | |
| for (int n = 0; n < 8; n++) | |
| { | |
| //o dau co bit = 1 o do co byte base64chars[i] | |
| if (offset & 0x80) e[j] = base64chars[i]; | |
| offset = offset << 1; | |
| j++; | |
| } | |
| } | |
| printf("\n"); | |
| closesocket(ConnectSocket); | |
| WSACleanup(); | |
| } | |
| //in base64 cua file poc ra | |
| for (size_t i = 0; i < 1368; i++) | |
| { | |
| printf("%c", e[i]); | |
| } | |
| printf("\n"); | |
| system("Pause"); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment