summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-09-05 22:53:24 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-09-05 22:53:24 (GMT)
commit1a85f36e0505d75a51ab7b7f2c5078da7ef6bd98 (patch)
treea9a7d542f0ed00f418b61122a27ec9f1927e646f /plugins
parent3d65cfcb6403d169b52045a9e5c242ad081539a7 (diff)
Made server connections easier while running analysis.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/pychrysalide/analysis/loaded.c90
1 files changed, 66 insertions, 24 deletions
diff --git a/plugins/pychrysalide/analysis/loaded.c b/plugins/pychrysalide/analysis/loaded.c
index 43e749c..ab00038 100644
--- a/plugins/pychrysalide/analysis/loaded.c
+++ b/plugins/pychrysalide/analysis/loaded.c
@@ -34,6 +34,7 @@
#include <analysis/loaded.h>
+#include <core/global.h>
#include "../access.h"
@@ -42,10 +43,10 @@
/* Lance l'analyse propre à l'élément chargé. */
-static PyObject *py_loaded_content_analyze(PyObject *, PyObject *);
+static PyObject *py_loaded_content_analyze(PyObject *, PyObject *, PyObject *);
/* Lance l'analyse de l'élément chargé et attend sa conclusion. */
-static PyObject *py_loaded_content_analyze_and_wait(PyObject *, PyObject *);
+static PyObject *py_loaded_content_analyze_and_wait(PyObject *, PyObject *, PyObject *);
/* Etablit une liste d'obscurcissements présents. */
static PyObject *py_loaded_content_detect_obfuscators(PyObject *, PyObject *);
@@ -62,6 +63,7 @@ static PyObject *py_loaded_content_get_content(PyObject *, void *);
* *
* Paramètres : self = contenu binaire à manipuler. *
* args = arguments fournis à l'appel. *
+* kwds = arguments de type key=val fournis. *
* *
* Description : Lance l'analyse propre à l'élément chargé. *
* *
@@ -71,20 +73,44 @@ static PyObject *py_loaded_content_get_content(PyObject *, void *);
* *
******************************************************************************/
-static PyObject *py_loaded_content_analyze(PyObject *self, PyObject *args)
+static PyObject *py_loaded_content_analyze(PyObject *self, PyObject *args, PyObject *kwds)
{
+ int connect; /* Connexion à la base ? */
int cache; /* Préparation de rendu ? */
int ret; /* Bilan de lecture des args. */
GLoadedContent *content; /* Version GLib de l'élément */
- cache = 0;
-
- ret = PyArg_ParseTuple(args, "|p", &cache);
+ static char *kwlist[] = { "connect", "cache", NULL };
+
+#define LOADED_CONTENT_ANALYZE_METHOD PYTHON_METHOD_DEF \
+( \
+ analyze, "$self, /, connect=bool, cache=False", \
+ METH_VARARGS | METH_KEYWORDS, py_loaded_content, \
+ "Start the analysis of the loaded binary and send an *analyzed* signal" \
+ " when done." \
+ "\n" \
+ "The *connect* parameter defines if connections to database servers" \
+ " (internal and/or remote) will be established. The default value" \
+ " depends on the running mode: if the analysis is run from the GUI," \
+ " the binary will get connected to servers; in batch mode, no" \
+ " connection will be made." \
+ "\n" \
+ "The *cache* parameter rules the build of the cache for rendering" \
+ " lines. The same behavior relative to the running mode applies." \
+ "\n" \
+ "All theses operations can be forced by providing True values as" \
+ " parameters." \
+)
+
+ connect = is_batch_mode() ? 0 : 1;
+ cache = is_batch_mode() ? 0 : 1;
+
+ ret = PyArg_ParseTupleAndKeywords(args, kwds, "|pp", kwlist, &connect, &cache);
if (!ret) return NULL;
content = G_LOADED_CONTENT(pygobject_get(self));
- g_loaded_content_analyze(content, cache);
+ g_loaded_content_analyze(content, connect, cache);
Py_RETURN_NONE;
@@ -95,6 +121,7 @@ static PyObject *py_loaded_content_analyze(PyObject *self, PyObject *args)
* *
* Paramètres : self = contenu binaire à manipuler. *
* args = arguments fournis à l'appel. *
+* kwds = arguments de type key=val fournis. *
* *
* Description : Lance l'analyse de l'élément chargé et attend sa conclusion. *
* *
@@ -104,25 +131,50 @@ static PyObject *py_loaded_content_analyze(PyObject *self, PyObject *args)
* *
******************************************************************************/
-static PyObject *py_loaded_content_analyze_and_wait(PyObject *self, PyObject *args)
+static PyObject *py_loaded_content_analyze_and_wait(PyObject *self, PyObject *args, PyObject *kwds)
{
PyObject *result; /* Bilan à retourner */
+ int connect; /* Connexion à la base ? */
int cache; /* Préparation de rendu ? */
int ret; /* Bilan de lecture des args. */
PyThreadState *_save; /* Sauvegarde de contexte */
GLoadedContent *content; /* Version GLib de l'élément */
bool status; /* Bilan de l'opération */
- cache = 0;
-
- ret = PyArg_ParseTuple(args, "|p", &cache);
+ static char *kwlist[] = { "connect", "cache", NULL };
+
+#define LOADED_CONTENT_ANALYZE_AND_WAIT_METHOD PYTHON_METHOD_DEF \
+( \
+ analyze_and_wait, "$self, /, connect=bool, cache=False", \
+ METH_VARARGS | METH_KEYWORDS, py_loaded_content, \
+ "Run the analysis of the loaded binary and wait for its completion." \
+ "\n" \
+ "The final analysis status is returned as boolean." \
+ "\n" \
+ "The *connect* parameter defines if connections to database servers" \
+ " (internal and/or remote) will be established. The default value" \
+ " depends on the running mode: if the analysis is run from the GUI," \
+ " the binary will get connected to servers; in batch mode, no" \
+ " connection will be made." \
+ "\n" \
+ "The *cache* parameter rules the build of the cache for rendering" \
+ " lines. The same behavior relative to the running mode applies." \
+ "\n" \
+ "All theses operations can be forced by providing True values as" \
+ " parameters." \
+)
+
+ connect = is_batch_mode() ? 0 : 1;
+ cache = is_batch_mode() ? 0 : 1;
+
+ ret = PyArg_ParseTupleAndKeywords(args, kwds, "|pp", kwlist, &connect, &cache);
if (!ret) return NULL;
content = G_LOADED_CONTENT(pygobject_get(self));
Py_UNBLOCK_THREADS;
- status = g_loaded_content_analyze_and_wait(content, cache);
+ status = g_loaded_content_analyze_and_wait(content, connect, cache);
Py_BLOCK_THREADS;
@@ -257,18 +309,8 @@ static PyObject *py_loaded_content_get_content(PyObject *self, void *closure)
PyTypeObject *get_python_loaded_content_type(void)
{
static PyMethodDef py_loaded_content_methods[] = {
- {
- "analyze", py_loaded_content_analyze,
- METH_VARARGS,
- "analyze($self, cache, /)\n--\n\nStart the analysis of the loaded binary and " \
- "send an \"analyzed\" signal when done."
- },
- {
- "analyze_and_wait", py_loaded_content_analyze_and_wait,
- METH_VARARGS,
- "analyze_and_wait($self, cache, /)\n--\n\nRun the analysis of the loaded binary and " \
- "wait for its completion."
- },
+ LOADED_CONTENT_ANALYZE_METHOD,
+ LOADED_CONTENT_ANALYZE_AND_WAIT_METHOD,
{
"detect_obfuscators", py_loaded_content_detect_obfuscators,
METH_VARARGS,