Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

Commit

Permalink
Land #80, lots of @OJ PRs
Browse files Browse the repository at this point in the history
This lands:

#69
#70
#75
#77
#78

All have been tested sufficiently, and once this lands, the binaries as
well as the library and module updates represented by
rapid7/metasploit-framework#3122 will also land.
  • Loading branch information
Tod Beardsley committed Mar 19, 2014
2 parents bc2b93d + c608308 commit 5addac7
Show file tree
Hide file tree
Showing 20 changed files with 1,402 additions and 176 deletions.
6 changes: 3 additions & 3 deletions Makefile
Expand Up @@ -8,8 +8,8 @@ framework_dir = ../metasploit-framework/
# Change me if you want to build openssl and libpcap somewhere else
build_tmp = posix-meterp-build-tmp


BIONIC=$(PWD)/source/bionic
ROOT=$(basename $(CURDIR:%/=%))
BIONIC=$(ROOT)/source/bionic
LIBC=$(BIONIC)/libc
LIBM=$(BIONIC)/libm
COMPILED=$(BIONIC)/compiled
Expand Down Expand Up @@ -94,7 +94,7 @@ $(COMPILED):
mkdir $(COMPILED)/

$(COMPILED)/libc.so: $(COMPILED)
(cd source/bionic/libc && ARCH=x86 TOP=${PWD} jam)
(cd source/bionic/libc && ARCH=x86 TOP=${ROOT} jam)
(cd source/bionic/libc/out/x86/ && $(MAKE) -f Makefile.msf && [ -f libbionic.so ])
cp source/bionic/libc/out/x86/libbionic.so $(COMPILED)/libc.so

Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -84,6 +84,7 @@ You will need:
- gcc-multilib, if you're building on a 64-bit machine
- jam
- wget
- flex

Meterpreter requires libpcap-1.1.1 and OpenSSL 0.9.8o sources, which it
will download automatically during the build process. If for some
Expand Down
55 changes: 55 additions & 0 deletions source/common/core.c
Expand Up @@ -213,6 +213,61 @@ Packet *packet_create( PacketTlvType type, LPCSTR method )
return packet;
}

/*!
* @brief Create a packet that is used to contain a subgroup.
* @returns An instance of a packet to use as a group container.
* @remarks Group packets can be used to arbitrarily nest groupings prior to
* sending the packet to the client.
*/
Packet* packet_create_group()
{
Packet* packet = NULL;
do
{
if (!(packet = (Packet*)malloc(sizeof(Packet))))
{
break;
}

memset(packet, 0, sizeof(Packet));

// we don't need to worry about the TLV header at this point
// so we'll ignore it

// Initialize the payload to be blank
packet->payload = NULL;
packet->payloadLength = 0;

return packet;
} while (0);

if (packet)
{
free(packet);
}
return NULL;
}

/*!
* @brief Add a group packet to the parent packet.
* @param packet Pointer to the container packet that the group is to be added to.
* @param type The type of group packet being added.
* @param groupPacket the packet containing the group data (created by `packet_create_group`).
* @returns Indication of success or failure.
* @remarks The function calls `packet_destroy` on the `groupPacket` if adding the packet succeeds.
*/
DWORD packet_add_group(Packet* packet, TlvType type, Packet* groupPacket)
{
DWORD result = packet_add_tlv_raw(packet, type, groupPacket->payload, groupPacket->payloadLength);
if (result == ERROR_SUCCESS)
{
packet_destroy(groupPacket);
return ERROR_SUCCESS;
}

return result;
}

/*!
* @brief Create a response packet from a request.
* @details Create a response packet from a request, referencing the requestors
Expand Down
2 changes: 2 additions & 0 deletions source/common/core.h
Expand Up @@ -206,9 +206,11 @@ typedef struct
*/
LINKAGE Packet *packet_create(PacketTlvType type, LPCSTR method);
LINKAGE Packet *packet_create_response(Packet *packet);
LINKAGE Packet* packet_create_group();
LINKAGE Packet *packet_duplicate(Packet *packet);
LINKAGE VOID packet_destroy(Packet *packet);

LINKAGE DWORD packet_add_group(Packet* packet, TlvType type, Packet* groupPacket);
LINKAGE DWORD packet_add_tlv_string(Packet *packet, TlvType type, LPCSTR str);
LINKAGE DWORD packet_add_tlv_wstring(Packet *packet, TlvType type, LPCWSTR str);
LINKAGE DWORD packet_add_tlv_uint(Packet *packet, TlvType type, UINT val);
Expand Down
37 changes: 2 additions & 35 deletions source/extensions/extapi/adsi.c
Expand Up @@ -3,48 +3,15 @@
* @brief Definitions for ADSI functionality.
*/
#include "extapi.h"
#include "wshelpers.h"
#include "adsi.h"
#include "adsi_interface.h"

/*! @brief The default page size to use when no page size is specified */
#define DEFAULT_PAGE_SIZE 1000

/*!
* @brief Helper function that converts an ASCII string to a wide char string.
* @param lpValue ASCII string to convert.
* @param lpwValue Target memory for the converted string.
* @remark \c lpwValue must be freed by the caller using `free`.
* @returns Indication of success or failure.
*/
DWORD to_wide_string(LPSTR lpValue, LPWSTR* lpwValue)
{
size_t charsCopied = 0;
DWORD valueLength;
DWORD dwResult;

do
{
if (lpValue == NULL)
{
BREAK_WITH_ERROR("[EXTAPI ADSI] Value parameter missing", ERROR_INVALID_PARAMETER);
}

valueLength = lstrlenA(lpValue);
*lpwValue = (LPWSTR)malloc(sizeof(WCHAR)* (lstrlenA(lpValue) + 1));
if (*lpwValue == NULL)
{
BREAK_WITH_ERROR("[EXTAPI ADSI] Unable to allocate memory", ERROR_OUTOFMEMORY);
}

mbstowcs_s(&charsCopied, *lpwValue, valueLength + 1, lpValue, valueLength);
dwResult = ERROR_SUCCESS;
} while (0);

return dwResult;
}

/*!
* @brief Enumerate all the users in AD.
* @brief Perform an ASDI query against a domain.
* @param remote Pointer to the \c Remote instance.
* @param packet Pointer to the incoming \c Packet instance.
* @returns Indication of success or failure.
Expand Down
2 changes: 0 additions & 2 deletions source/extensions/extapi/adsi.h
Expand Up @@ -5,8 +5,6 @@
#ifndef _METERPRETER_SOURCE_EXTENSION_EXTAPI_ADSI_H
#define _METERPRETER_SOURCE_EXTENSION_EXTAPI_ADSI_H

//DWORD request_adsi_user_enum(Remote *remote, Packet *packet);
//DWORD request_adsi_computer_enum(Remote *remote, Packet *packet);
DWORD request_adsi_domain_query(Remote *remote, Packet *packet);

#endif

0 comments on commit 5addac7

Please sign in to comment.