mirror of
https://github.com/trustedsec/ELFLoader
synced 2026-06-08 17:56:51 +00:00
Added getOSName function to internal API
This commit is contained in:
+9
-2
@@ -1,6 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include "beacon_api.h"
|
||||
@@ -8,8 +9,14 @@
|
||||
int run_uname(void){
|
||||
struct utsname values;
|
||||
int retcode = 0;
|
||||
retcode = uname(&values);
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "%s %s %s %s %s\n", values.sysname, values.nodename, values.release, values.version, values.machine);
|
||||
char* osversion = getOSName();
|
||||
if (strcmp("lin", osversion)==0){
|
||||
retcode = uname(&values);
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "%s %s %s %s %s\n", values.sysname, values.nodename, values.release, values.version, values.machine);
|
||||
}
|
||||
else{
|
||||
BeaconPrintf(CALLBACK_OUTPUT, "Not supported\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,4 +55,5 @@ uint32_t swap_endianess(uint32_t indata);
|
||||
|
||||
char* BeaconGetOutputData(int *outsize);
|
||||
char** getEnviron(void);
|
||||
char* getOSName(void);
|
||||
#endif
|
||||
|
||||
@@ -13,8 +13,8 @@ typedef struct beacon_function{
|
||||
void* function;
|
||||
} beacon_function_t;
|
||||
|
||||
extern beacon_function_t BeaconInternalMapping[17];
|
||||
#define BEACONINTERNALMAPPINGCOUNT 16
|
||||
extern beacon_function_t BeaconInternalMapping[18];
|
||||
#define BEACONINTERNALMAPPINGCOUNT 17
|
||||
|
||||
void* internalFunctionLookup(char* symbolName);
|
||||
/* Structures as is in beacon.h */
|
||||
@@ -63,4 +63,5 @@ uint32_t swap_endianess(uint32_t indata);
|
||||
|
||||
char* BeaconGetOutputData(int *outsize);
|
||||
char** getEnviron(void);
|
||||
char* getOSName(void);
|
||||
#endif
|
||||
|
||||
@@ -33,7 +33,7 @@ extern char** environ;
|
||||
|
||||
/* Data Parsing */
|
||||
|
||||
beacon_function_t BeaconInternalMapping[17] = {
|
||||
beacon_function_t BeaconInternalMapping[18] = {
|
||||
{"BeaconDataParse", (void*)BeaconDataParse},
|
||||
{"BeaconDataInt", (void*)BeaconDataInt},
|
||||
{"BeaconDataShort", (void*)BeaconDataShort},
|
||||
@@ -49,7 +49,8 @@ beacon_function_t BeaconInternalMapping[17] = {
|
||||
{"BeaconPrintf", (void*)BeaconPrintf},
|
||||
{"BeaconOutput", (void*)BeaconOutput},
|
||||
{"BeaconIsAdmin", (void*)BeaconIsAdmin},
|
||||
{"getEnviron", (void*)getEnviron}
|
||||
{"getEnviron", (void*)getEnviron},
|
||||
{"getOSName", (void*)getOSName}
|
||||
};
|
||||
|
||||
|
||||
@@ -57,6 +58,20 @@ char** getEnviron(void){
|
||||
return environ;
|
||||
}
|
||||
|
||||
char* getOSName(void){
|
||||
#ifdef __APPLE__
|
||||
return "apple";
|
||||
#elif __FreeBSD__
|
||||
return "freebsd";
|
||||
#elif __OpenBSD__
|
||||
return "openbsd";
|
||||
#elif __linux__
|
||||
return "lin";
|
||||
#else
|
||||
return "unk";
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
/* A hacky compatible dlsym function for use on windows systems.
|
||||
* TODO: Implement a internal function lookup function for all OS's that
|
||||
|
||||
Reference in New Issue
Block a user