mirror of
https://github.com/cemu-project/idapython.git
synced 2024-11-28 03:54:18 +01:00
IDAPython 1.5.4
- fix for Python autorun script vulnerability reported by Greg MacManus - remove current directory from sys.path during initialization
This commit is contained in:
parent
06f0ff19d5
commit
0282e67982
10
CHANGES.txt
10
CHANGES.txt
@ -1,6 +1,16 @@
|
|||||||
Please see http://code.google.com/p/idapython/source/list for a detailed list of changes.
|
Please see http://code.google.com/p/idapython/source/list for a detailed list of changes.
|
||||||
|
|
||||||
|
|
||||||
|
Changes from version 1.5.3 to 1.5.4
|
||||||
|
------------------------------------
|
||||||
|
- fix for Python autorun script vulnerability reported by Greg MacManus
|
||||||
|
- remove current directory from sys.path during initialization
|
||||||
|
- added PyWraps sources. This will facilitate deployment, development and
|
||||||
|
debugging of IDAPython additions
|
||||||
|
- bugfix: op_t.is_reg() was buggy
|
||||||
|
- bugfix: build.py was putting duplicate files into the .zip
|
||||||
|
- bugfix: added back wrapped version of get_ascii_contents()
|
||||||
|
|
||||||
Changes from version 1.5.2 to 1.5.3
|
Changes from version 1.5.2 to 1.5.3
|
||||||
------------------------------------
|
------------------------------------
|
||||||
- IDA Pro 6.2 support
|
- IDA Pro 6.2 support
|
||||||
|
2
build.py
2
build.py
@ -36,7 +36,7 @@ else:
|
|||||||
# IDAPython version
|
# IDAPython version
|
||||||
VERSION_MAJOR = 1
|
VERSION_MAJOR = 1
|
||||||
VERSION_MINOR = 5
|
VERSION_MINOR = 5
|
||||||
VERSION_PATCH = 3
|
VERSION_PATCH = 4
|
||||||
|
|
||||||
# Determine Python version
|
# Determine Python version
|
||||||
PYTHON_MAJOR_VERSION = int(platform.python_version()[0])
|
PYTHON_MAJOR_VERSION = int(platform.python_version()[0])
|
||||||
|
32
python.cpp
32
python.cpp
@ -1265,6 +1265,29 @@ static int idaapi menu_installer_cb(void *, int code, va_list)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
// remove current directory (empty entry) from the sys.path
|
||||||
|
static void sanitize_path()
|
||||||
|
{
|
||||||
|
char buf[QMAXPATH];
|
||||||
|
qstrncpy(buf, Py_GetPath(), sizeof(buf));
|
||||||
|
char *ctx;
|
||||||
|
qstring newpath;
|
||||||
|
for ( char *d0 = qstrtok(buf, DELIMITER, &ctx);
|
||||||
|
d0 != NULL;
|
||||||
|
d0 = qstrtok(NULL, DELIMITER, &ctx) )
|
||||||
|
{
|
||||||
|
if ( d0[0] == '\0' )
|
||||||
|
// skip empty entry
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ( !newpath.empty() )
|
||||||
|
newpath.append(DELIMITER);
|
||||||
|
newpath.append(d0);
|
||||||
|
}
|
||||||
|
PySys_SetPath(newpath.begin());
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// Initialize the Python environment
|
// Initialize the Python environment
|
||||||
bool IDAPython_Init(void)
|
bool IDAPython_Init(void)
|
||||||
@ -1280,7 +1303,7 @@ bool IDAPython_Init(void)
|
|||||||
if ( !CheckScriptFiles() )
|
if ( !CheckScriptFiles() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char tmp[MAXSTR+64];
|
char tmp[QMAXPATH];
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
// Export symbols from libpython to resolve imported module deps
|
// Export symbols from libpython to resolve imported module deps
|
||||||
qsnprintf(tmp, sizeof(tmp), "libpython%d.%d.so.1",
|
qsnprintf(tmp, sizeof(tmp), "libpython%d.%d.so.1",
|
||||||
@ -1319,10 +1342,9 @@ bool IDAPython_Init(void)
|
|||||||
read_user_config_file("python.cfg", set_python_options, NULL);
|
read_user_config_file("python.cfg", set_python_options, NULL);
|
||||||
if ( g_alert_auto_scripts )
|
if ( g_alert_auto_scripts )
|
||||||
{
|
{
|
||||||
const char *autofn = pywraps_check_autoscripts();
|
if ( pywraps_check_autoscripts(tmp, sizeof(tmp))
|
||||||
if ( autofn != NULL
|
|
||||||
&& askyn_c(0, "HIDECANCEL\nTITLE IDAPython\nThe script '%s' was found in the current directory and will be automatically executed by Python.\n\n"
|
&& askyn_c(0, "HIDECANCEL\nTITLE IDAPython\nThe script '%s' was found in the current directory and will be automatically executed by Python.\n\n"
|
||||||
"Do you want to continue loading IDAPython?", autofn) == 0 )
|
"Do you want to continue loading IDAPython?", tmp) <= 0 )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1336,6 +1358,8 @@ bool IDAPython_Init(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sanitize_path();
|
||||||
|
|
||||||
// Enable multi-threading support
|
// Enable multi-threading support
|
||||||
if ( !PyEval_ThreadsInitialized() )
|
if ( !PyEval_ThreadsInitialized() )
|
||||||
PyEval_InitThreads();
|
PyEval_InitThreads();
|
||||||
|
@ -227,7 +227,7 @@ bool pywraps_nw_notify(int slot, ...);
|
|||||||
bool pywraps_nw_init();
|
bool pywraps_nw_init();
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
const char *pywraps_check_autoscripts();
|
bool pywraps_check_autoscripts(char *buf, size_t bufsize);
|
||||||
|
|
||||||
// [De]Initializes PyWraps
|
// [De]Initializes PyWraps
|
||||||
bool init_pywraps();
|
bool init_pywraps();
|
||||||
|
@ -94,28 +94,40 @@ struct py_timer_ctx_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
const char *pywraps_check_autoscripts()
|
bool pywraps_check_autoscripts(char *buf, size_t bufsize)
|
||||||
{
|
{
|
||||||
static const char *exts[] = {"py", "pyw", "pyc", "pyo"};
|
static const char *const exts[] =
|
||||||
|
{
|
||||||
|
"py",
|
||||||
|
"pyc",
|
||||||
|
"pyd",
|
||||||
|
"pyo",
|
||||||
|
"pyw",
|
||||||
|
};
|
||||||
|
|
||||||
static const char *fns[] =
|
static const char *const fns[] =
|
||||||
{
|
{
|
||||||
"swig_runtime_data" SWIG_RUNTIME_VERSION,
|
"swig_runtime_data" SWIG_RUNTIME_VERSION,
|
||||||
"sitecustomize",
|
"sitecustomize",
|
||||||
"usercustomize"
|
"usercustomize"
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t ifn=0; ifn < qnumber(fns); ++ifn )
|
for ( size_t ifn=0; ifn < qnumber(fns); ++ifn )
|
||||||
{
|
{
|
||||||
for ( size_t iext=0; iext < qnumber(exts); ++iext )
|
for ( size_t iext=0; iext < qnumber(exts); ++iext )
|
||||||
{
|
{
|
||||||
static char fn[QMAXPATH];
|
static char fn[QMAXPATH];
|
||||||
qsnprintf(fn, sizeof(fn), "%s.%s", fns[ifn], exts[iext]);
|
qsnprintf(buf, bufsize, "%s.%s", fns[ifn], exts[iext]);
|
||||||
if ( qfileexist(fn) )
|
if ( qfileexist(fn) )
|
||||||
return fn;
|
return true;
|
||||||
|
if ( qfileexist(fns[ifn]) )
|
||||||
|
{
|
||||||
|
qstrncpy(buf, fns[ifn], bufsize);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
@ -1289,28 +1289,40 @@ struct py_timer_ctx_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
const char *pywraps_check_autoscripts()
|
bool pywraps_check_autoscripts(char *buf, size_t bufsize)
|
||||||
{
|
{
|
||||||
static const char *exts[] = {"py", "pyw", "pyc", "pyo"};
|
static const char *const exts[] =
|
||||||
|
{
|
||||||
|
"py",
|
||||||
|
"pyc",
|
||||||
|
"pyd",
|
||||||
|
"pyo",
|
||||||
|
"pyw",
|
||||||
|
};
|
||||||
|
|
||||||
static const char *fns[] =
|
static const char *const fns[] =
|
||||||
{
|
{
|
||||||
"swig_runtime_data" SWIG_RUNTIME_VERSION,
|
"swig_runtime_data" SWIG_RUNTIME_VERSION,
|
||||||
"sitecustomize",
|
"sitecustomize",
|
||||||
"usercustomize"
|
"usercustomize"
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t ifn=0; ifn < qnumber(fns); ++ifn )
|
for ( size_t ifn=0; ifn < qnumber(fns); ++ifn )
|
||||||
{
|
{
|
||||||
for ( size_t iext=0; iext < qnumber(exts); ++iext )
|
for ( size_t iext=0; iext < qnumber(exts); ++iext )
|
||||||
{
|
{
|
||||||
static char fn[QMAXPATH];
|
static char fn[QMAXPATH];
|
||||||
qsnprintf(fn, sizeof(fn), "%s.%s", fns[ifn], exts[iext]);
|
qsnprintf(buf, bufsize, "%s.%s", fns[ifn], exts[iext]);
|
||||||
if ( qfileexist(fn) )
|
if ( qfileexist(fn) )
|
||||||
return fn;
|
return true;
|
||||||
|
if ( qfileexist(fns[ifn]) )
|
||||||
|
{
|
||||||
|
qstrncpy(buf, fns[ifn], bufsize);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user