mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-22 17:46:37 +03:00
Alignment of UDF source code
This commit is contained in:
parent
49af0c43a5
commit
fa1357b40f
|
@ -37,7 +37,7 @@ fi
|
||||||
|
|
||||||
echo -e "\nPlease provide your MySQL root password"
|
echo -e "\nPlease provide your MySQL root password"
|
||||||
|
|
||||||
mysql -u ${USER} -P ${PORT} -p mysql < lib_mysqludf_sys.sql
|
mysql -h 127.0.0.1 -P ${PORT} -u ${USER} -p mysql < lib_mysqludf_sys.sql
|
||||||
|
|
||||||
if test $? -ne 0; then
|
if test $? -ne 0; then
|
||||||
echo "ERROR: unable to install the UDF"
|
echo "ERROR: unable to install the UDF"
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
|
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
|
||||||
#define DLLEXP __declspec(dllexport)
|
#define DLLEXP __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
|
@ -55,7 +56,7 @@ typedef long long longlong;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LIBVERSION "lib_mysqludf_sys version 0.0.3"
|
#define LIBVERSION "lib_mysqludf_sys version 0.0.4"
|
||||||
|
|
||||||
#ifdef __WIN__
|
#ifdef __WIN__
|
||||||
#define SETENV(name,value) SetEnvironmentVariable(name,value);
|
#define SETENV(name,value) SetEnvironmentVariable(name,value);
|
||||||
|
@ -446,7 +447,7 @@ char* sys_eval(
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), pipe) != NULL) {
|
while (fgets(line, sizeof(line), pipe) != NULL) {
|
||||||
linelen = strlen(line);
|
linelen = strlen(line);
|
||||||
result = realloc(result, outlen + linelen);
|
result = (char *)realloc(result, outlen + linelen);
|
||||||
strncpy(result + outlen, line, linelen);
|
strncpy(result + outlen, line, linelen);
|
||||||
outlen = outlen + linelen;
|
outlen = outlen + linelen;
|
||||||
}
|
}
|
||||||
|
@ -480,7 +481,6 @@ int sys_bineval(
|
||||||
UDF_INIT *initid
|
UDF_INIT *initid
|
||||||
, UDF_ARGS *args
|
, UDF_ARGS *args
|
||||||
){
|
){
|
||||||
int32 argv0_size;
|
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
|
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
|
||||||
|
@ -492,8 +492,7 @@ int sys_bineval(
|
||||||
pid_t pID;
|
pid_t pID;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
argv0_size = strlen(args->args[0]);
|
len = (size_t)strlen(args->args[0]);
|
||||||
len = (size_t)argv0_size;
|
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
|
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
|
||||||
// allocate a +rwx memory page
|
// allocate a +rwx memory page
|
||||||
|
@ -529,7 +528,22 @@ int sys_bineval(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
|
#if defined(_WIN64)
|
||||||
|
void __exec_payload(LPVOID);
|
||||||
|
|
||||||
|
DWORD WINAPI exec_payload(LPVOID lpParameter)
|
||||||
|
{
|
||||||
|
__try
|
||||||
|
{
|
||||||
|
__exec_payload(lpParameter);
|
||||||
|
}
|
||||||
|
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
||||||
DWORD WINAPI exec_payload(LPVOID lpParameter)
|
DWORD WINAPI exec_payload(LPVOID lpParameter)
|
||||||
{
|
{
|
||||||
__try
|
__try
|
||||||
|
@ -542,7 +556,6 @@ DWORD WINAPI exec_payload(LPVOID lpParameter)
|
||||||
}
|
}
|
||||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -48,29 +48,29 @@ PG_MODULE_MAGIC;
|
||||||
|
|
||||||
char *text_ptr_to_char_ptr(text *arg)
|
char *text_ptr_to_char_ptr(text *arg)
|
||||||
{
|
{
|
||||||
char *retVal;
|
char *retVal;
|
||||||
int arg_size = VARSIZE(arg) - VARHDRSZ;
|
int arg_size = VARSIZE(arg) - VARHDRSZ;
|
||||||
retVal = (char *)malloc(arg_size + 1);
|
retVal = (char *)malloc(arg_size + 1);
|
||||||
|
|
||||||
memcpy(retVal, VARDATA(arg), arg_size);
|
memcpy(retVal, VARDATA(arg), arg_size);
|
||||||
retVal[arg_size] = '\0';
|
retVal[arg_size] = '\0';
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
text *chr_ptr_to_text_ptr(char *arg)
|
text *chr_ptr_to_text_ptr(char *arg)
|
||||||
{
|
{
|
||||||
text *retVal;
|
text *retVal;
|
||||||
|
|
||||||
retVal = (text *)malloc(VARHDRSZ + strlen(arg));
|
retVal = (text *)malloc(VARHDRSZ + strlen(arg));
|
||||||
#ifdef SET_VARSIZE
|
#ifdef SET_VARSIZE
|
||||||
SET_VARSIZE(retVal, VARHDRSZ + strlen(arg));
|
SET_VARSIZE(retVal, VARHDRSZ + strlen(arg));
|
||||||
#else
|
#else
|
||||||
VARATT_SIZEP(retVal) = strlen(arg) + VARHDRSZ;
|
VARATT_SIZEP(retVal) = strlen(arg) + VARHDRSZ;
|
||||||
#endif
|
#endif
|
||||||
memcpy(VARDATA(retVal), arg, strlen(arg));
|
memcpy(VARDATA(retVal), arg, strlen(arg));
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_FUNCTION_INFO_V1(sys_exec);
|
PG_FUNCTION_INFO_V1(sys_exec);
|
||||||
|
|
|
@ -37,7 +37,7 @@ fi
|
||||||
|
|
||||||
echo -e "\nPlease provide your MySQL root password"
|
echo -e "\nPlease provide your MySQL root password"
|
||||||
|
|
||||||
mysql -u ${USER} -P ${PORT} -p mysql < lib_mysqludf_sys.sql
|
mysql -h 127.0.0.1 -P ${PORT} -u ${USER} -p mysql < lib_mysqludf_sys.sql
|
||||||
|
|
||||||
if test $? -ne 0; then
|
if test $? -ne 0; then
|
||||||
echo "ERROR: unable to install the UDF"
|
echo "ERROR: unable to install the UDF"
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
License along with this library; if not, write to the Free Software
|
License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
|
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
|
||||||
#define DLLEXP __declspec(dllexport)
|
#define DLLEXP __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
|
@ -55,7 +56,7 @@ typedef long long longlong;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LIBVERSION "lib_mysqludf_sys version 0.0.3"
|
#define LIBVERSION "lib_mysqludf_sys version 0.0.4"
|
||||||
|
|
||||||
#ifdef __WIN__
|
#ifdef __WIN__
|
||||||
#define SETENV(name,value) SetEnvironmentVariable(name,value);
|
#define SETENV(name,value) SetEnvironmentVariable(name,value);
|
||||||
|
@ -446,7 +447,7 @@ char* sys_eval(
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), pipe) != NULL) {
|
while (fgets(line, sizeof(line), pipe) != NULL) {
|
||||||
linelen = strlen(line);
|
linelen = strlen(line);
|
||||||
result = realloc(result, outlen + linelen);
|
result = (char *)realloc(result, outlen + linelen);
|
||||||
strncpy(result + outlen, line, linelen);
|
strncpy(result + outlen, line, linelen);
|
||||||
outlen = outlen + linelen;
|
outlen = outlen + linelen;
|
||||||
}
|
}
|
||||||
|
@ -480,7 +481,6 @@ int sys_bineval(
|
||||||
UDF_INIT *initid
|
UDF_INIT *initid
|
||||||
, UDF_ARGS *args
|
, UDF_ARGS *args
|
||||||
){
|
){
|
||||||
int32 argv0_size;
|
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
|
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
|
||||||
|
@ -492,8 +492,7 @@ int sys_bineval(
|
||||||
pid_t pID;
|
pid_t pID;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
argv0_size = strlen(args->args[0]);
|
len = (size_t)strlen(args->args[0]);
|
||||||
len = (size_t)argv0_size;
|
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
|
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
|
||||||
// allocate a +rwx memory page
|
// allocate a +rwx memory page
|
||||||
|
@ -529,7 +528,22 @@ int sys_bineval(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
|
#if defined(_WIN64)
|
||||||
|
void __exec_payload(LPVOID);
|
||||||
|
|
||||||
|
DWORD WINAPI exec_payload(LPVOID lpParameter)
|
||||||
|
{
|
||||||
|
__try
|
||||||
|
{
|
||||||
|
__exec_payload(lpParameter);
|
||||||
|
}
|
||||||
|
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
||||||
DWORD WINAPI exec_payload(LPVOID lpParameter)
|
DWORD WINAPI exec_payload(LPVOID lpParameter)
|
||||||
{
|
{
|
||||||
__try
|
__try
|
||||||
|
@ -542,7 +556,6 @@ DWORD WINAPI exec_payload(LPVOID lpParameter)
|
||||||
}
|
}
|
||||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -48,29 +48,29 @@ PG_MODULE_MAGIC;
|
||||||
|
|
||||||
char *text_ptr_to_char_ptr(text *arg)
|
char *text_ptr_to_char_ptr(text *arg)
|
||||||
{
|
{
|
||||||
char *retVal;
|
char *retVal;
|
||||||
int arg_size = VARSIZE(arg) - VARHDRSZ;
|
int arg_size = VARSIZE(arg) - VARHDRSZ;
|
||||||
retVal = (char *)malloc(arg_size + 1);
|
retVal = (char *)malloc(arg_size + 1);
|
||||||
|
|
||||||
memcpy(retVal, VARDATA(arg), arg_size);
|
memcpy(retVal, VARDATA(arg), arg_size);
|
||||||
retVal[arg_size] = '\0';
|
retVal[arg_size] = '\0';
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
text *chr_ptr_to_text_ptr(char *arg)
|
text *chr_ptr_to_text_ptr(char *arg)
|
||||||
{
|
{
|
||||||
text *retVal;
|
text *retVal;
|
||||||
|
|
||||||
retVal = (text *)malloc(VARHDRSZ + strlen(arg));
|
retVal = (text *)malloc(VARHDRSZ + strlen(arg));
|
||||||
#ifdef SET_VARSIZE
|
#ifdef SET_VARSIZE
|
||||||
SET_VARSIZE(retVal, VARHDRSZ + strlen(arg));
|
SET_VARSIZE(retVal, VARHDRSZ + strlen(arg));
|
||||||
#else
|
#else
|
||||||
VARATT_SIZEP(retVal) = strlen(arg) + VARHDRSZ;
|
VARATT_SIZEP(retVal) = strlen(arg) + VARHDRSZ;
|
||||||
#endif
|
#endif
|
||||||
memcpy(VARDATA(retVal), arg, strlen(arg));
|
memcpy(VARDATA(retVal), arg, strlen(arg));
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_FUNCTION_INFO_V1(sys_exec);
|
PG_FUNCTION_INFO_V1(sys_exec);
|
||||||
|
|
|
@ -56,7 +56,7 @@ typedef long long longlong;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LIBVERSION "lib_mysqludf_sys version 0.0.3"
|
#define LIBVERSION "lib_mysqludf_sys version 0.0.4"
|
||||||
|
|
||||||
#ifdef __WIN__
|
#ifdef __WIN__
|
||||||
#define SETENV(name,value) SetEnvironmentVariable(name,value);
|
#define SETENV(name,value) SetEnvironmentVariable(name,value);
|
||||||
|
@ -436,17 +436,18 @@ char* sys_eval(
|
||||||
, char *error
|
, char *error
|
||||||
){
|
){
|
||||||
FILE *pipe;
|
FILE *pipe;
|
||||||
char line[1024];
|
char *line;
|
||||||
unsigned long outlen, linelen;
|
unsigned long outlen, linelen;
|
||||||
|
|
||||||
result = malloc(1);
|
line = (char *)malloc(1024);
|
||||||
|
result = (char *)malloc(1);
|
||||||
outlen = 0;
|
outlen = 0;
|
||||||
|
|
||||||
pipe = popen(args->args[0], "r");
|
pipe = popen(args->args[0], "r");
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), pipe) != NULL) {
|
while (fgets(line, sizeof(line), pipe) != NULL) {
|
||||||
linelen = strlen(line);
|
linelen = strlen(line);
|
||||||
result = realloc(result, outlen + linelen);
|
result = (char *)realloc(result, outlen + linelen);
|
||||||
strncpy(result + outlen, line, linelen);
|
strncpy(result + outlen, line, linelen);
|
||||||
outlen = outlen + linelen;
|
outlen = outlen + linelen;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,29 +48,29 @@ PG_MODULE_MAGIC;
|
||||||
|
|
||||||
char *text_ptr_to_char_ptr(text *arg)
|
char *text_ptr_to_char_ptr(text *arg)
|
||||||
{
|
{
|
||||||
char *retVal;
|
char *retVal;
|
||||||
int arg_size = VARSIZE(arg) - VARHDRSZ;
|
int arg_size = VARSIZE(arg) - VARHDRSZ;
|
||||||
retVal = (char *)malloc(arg_size + 1);
|
retVal = (char *)malloc(arg_size + 1);
|
||||||
|
|
||||||
memcpy(retVal, VARDATA(arg), arg_size);
|
memcpy(retVal, VARDATA(arg), arg_size);
|
||||||
retVal[arg_size] = '\0';
|
retVal[arg_size] = '\0';
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
text *chr_ptr_to_text_ptr(char *arg)
|
text *chr_ptr_to_text_ptr(char *arg)
|
||||||
{
|
{
|
||||||
text *retVal;
|
text *retVal;
|
||||||
|
|
||||||
retVal = (text *)malloc(VARHDRSZ + strlen(arg));
|
retVal = (text *)malloc(VARHDRSZ + strlen(arg));
|
||||||
#ifdef SET_VARSIZE
|
#ifdef SET_VARSIZE
|
||||||
SET_VARSIZE(retVal, VARHDRSZ + strlen(arg));
|
SET_VARSIZE(retVal, VARHDRSZ + strlen(arg));
|
||||||
#else
|
#else
|
||||||
VARATT_SIZEP(retVal) = strlen(arg) + VARHDRSZ;
|
VARATT_SIZEP(retVal) = strlen(arg) + VARHDRSZ;
|
||||||
#endif
|
#endif
|
||||||
memcpy(VARDATA(retVal), arg, strlen(arg));
|
memcpy(VARDATA(retVal), arg, strlen(arg));
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
PG_FUNCTION_INFO_V1(sys_exec);
|
PG_FUNCTION_INFO_V1(sys_exec);
|
||||||
|
@ -108,7 +108,7 @@ extern DLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) {
|
||||||
char *command;
|
char *command;
|
||||||
char *result;
|
char *result;
|
||||||
FILE *pipe;
|
FILE *pipe;
|
||||||
char line[1024];
|
char *line;
|
||||||
int32 outlen, linelen;
|
int32 outlen, linelen;
|
||||||
|
|
||||||
command = text_ptr_to_char_ptr(argv0);
|
command = text_ptr_to_char_ptr(argv0);
|
||||||
|
@ -118,6 +118,7 @@ extern DLLIMPORT Datum sys_eval(PG_FUNCTION_ARGS) {
|
||||||
elog(NOTICE, "Command evaluated: %s", command);
|
elog(NOTICE, "Command evaluated: %s", command);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
line = (char *)malloc(1024);
|
||||||
result = (char *)malloc(1);
|
result = (char *)malloc(1);
|
||||||
outlen = 0;
|
outlen = 0;
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ typedef long long longlong;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LIBVERSION "lib_mysqludf_sys version 0.0.3"
|
#define LIBVERSION "lib_mysqludf_sys version 0.0.4"
|
||||||
|
|
||||||
#ifdef __WIN__
|
#ifdef __WIN__
|
||||||
#define SETENV(name,value) SetEnvironmentVariable(name,value);
|
#define SETENV(name,value) SetEnvironmentVariable(name,value);
|
||||||
|
@ -436,17 +436,18 @@ char* sys_eval(
|
||||||
, char *error
|
, char *error
|
||||||
){
|
){
|
||||||
FILE *pipe;
|
FILE *pipe;
|
||||||
char line[1024];
|
char *line;
|
||||||
unsigned long outlen, linelen;
|
unsigned long outlen, linelen;
|
||||||
|
|
||||||
result = malloc(1);
|
line = (char *)malloc(1024);
|
||||||
|
result = (char *)malloc(1);
|
||||||
outlen = 0;
|
outlen = 0;
|
||||||
|
|
||||||
pipe = popen(args->args[0], "r");
|
pipe = popen(args->args[0], "r");
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), pipe) != NULL) {
|
while (fgets(line, sizeof(line), pipe) != NULL) {
|
||||||
linelen = strlen(line);
|
linelen = strlen(line);
|
||||||
result = realloc(result, outlen + linelen);
|
result = (char *)realloc(result, outlen + linelen);
|
||||||
strncpy(result + outlen, line, linelen);
|
strncpy(result + outlen, line, linelen);
|
||||||
outlen = outlen + linelen;
|
outlen = outlen + linelen;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
PostgreSQL does not compile under Windows 64-bit.
|
Loading…
Reference in New Issue
Block a user