Ejemplo n.º 1
0
int
WSAAPI
Hookedbind(
  SOCKET s,
  const struct sockaddr *name,
  int namelen
  )
{
	if ( DbgGetShellcodeFlag() == MCEDP_STATUS_SHELLCODE_FLAG_SET )
	{
		PXMLNODE XmlLogNode;
		PXMLNODE XmlIDLogNode;
		CHAR szPort[20];
		sockaddr_in *sdata;
		sdata = (sockaddr_in *)name;

		XmlIDLogNode = mxmlNewElement( XmlShellcode, "row");
		// type
		XmlLogNode = mxmlNewElement( XmlIDLogNode, "type");
		mxmlNewText( XmlLogNode, 0, "6");
		// bind
		XmlLogNode = mxmlNewElement( XmlIDLogNode, "bind_ip");
		mxmlNewText( XmlLogNode, 0, inet_ntoa(sdata->sin_addr));
		XmlLogNode = mxmlNewElement( XmlIDLogNode, "bind_port");
		mxmlNewText( XmlLogNode, 0, itoa(htons(sdata->sin_port),szPort, 10));
		// save
		SaveXml( XmlLog );
	}

	return (bind_(s, name, namelen));
}
Ejemplo n.º 2
0
int
WSAAPI
Hookedlisten(
	SOCKET s,
	int backlog
	)
{
	if ( DbgGetShellcodeFlag() == MCEDP_STATUS_SHELLCODE_FLAG_SET )
	{
		PXMLNODE XmlLogNode;
		PXMLNODE XmlIDLogNode;

		XmlIDLogNode = mxmlNewElement( XmlShellcode, "row");
		// type
		XmlLogNode = mxmlNewElement( XmlIDLogNode, "type");
		mxmlNewText( XmlLogNode, 0, "5");
		// listen
		XmlLogNode = mxmlNewElement( XmlIDLogNode, "listen_desc");
		mxmlNewText( XmlLogNode, 0, "Shellcode attemp to listen on a port (possibly on previously bind address).");
		// save
		SaveXml( XmlLog );
	}

	return (listen_( s,backlog ));
}
Ejemplo n.º 3
0
int command(
	char *nBI, 
	char *command, 
	char *message,
	int size)
{
	mxml_node_t *xDoc;
	mxml_node_t *messageNode;
	mxml_node_t *innerNode[2];

	xDoc = mxmlNewXML("1.0");
	messageNode = mxmlNewElement(xDoc, "message");

	innerNode[0] = mxmlNewElement(messageNode, "type");
	mxmlNewText(innerNode[0], 0, "Command");

	innerNode[1] = mxmlNewElement(messageNode, "Command");
	mxmlNewText(innerNode[1], 0, command);

	mxmlSaveString (xDoc, message, size, MXML_NO_CALLBACK);

	mxmlDelete(xDoc);

	return 0;
}
Ejemplo n.º 4
0
int logInMessage(
	char *nBI, 
	char *name, 
	char *hostName, 
	char *message,
	int size)
{
	mxml_node_t *xDoc;
	mxml_node_t *messageNode;
	mxml_node_t *innerNode[4];

	xDoc = mxmlNewXML("1.0");
	messageNode = mxmlNewElement(xDoc, "message");

	innerNode[0] = mxmlNewElement(messageNode, "type");
	mxmlNewText(innerNode[0], 0, "Login");

	innerNode[1] = mxmlNewElement(messageNode, "nBI");
	mxmlNewText(innerNode[1], 0, nBi);

	innerNode[2] = mxmlNewElement(messageNode, "name");
	mxmlNewText(innerNode[2], 0, name);

	innerNode[3] = mxmlNewElement(messageNode, "hostName");
	mxmlNewText(innerNode[3], 0, hostName);

	mxmlSaveString (xDoc, message, size, MXML_NO_CALLBACK);

	mxmlDelete(xDoc);

	return 0;
}
Ejemplo n.º 5
0
int backup_extract_transfer_complete( mxml_node_t *node, char **msg_out, int *method_id)
{
	mxml_node_t *tree_m, *b, *n;

	tree_m = mxmlLoadString(NULL, CWMP_TRANSFER_COMPLETE_MESSAGE, MXML_NO_CALLBACK);
	if (!tree_m) goto error;

	b = mxmlFindElement(node, node, "command_key", NULL, NULL, MXML_DESCEND);
	if (!b) goto error;
	n = mxmlFindElement(tree_m, tree_m, "CommandKey", NULL, NULL, MXML_DESCEND);
	if (!n) goto error;
	n = mxmlNewText(n, 0, b->child->value.text.string);
	if (!n) goto error;

	b = mxmlFindElement(node, node, "fault_code", NULL, NULL, MXML_DESCEND);
	if (!b) goto error;
	n = mxmlFindElement(tree_m, tree_m, "FaultCode", NULL, NULL, MXML_DESCEND);
	if (!n) goto error;
	n = mxmlNewText(n, 0, b->child->value.text.string);
	if (!n) goto error;

	b = mxmlFindElement(node, node, "fault_string", NULL, NULL, MXML_DESCEND);
	if (!b) goto error;
	if (b->child && b->child->type == MXML_TEXT && b->child->value.text.string) {
		n = mxmlFindElement(tree_m, tree_m, "FaultString", NULL, NULL, MXML_DESCEND);
		if (!n) goto error;
		char *c = xml_get_value_with_whitespace(b->child);
		n = mxmlNewText(n, 0, c);
		free(c);
		if (!n) goto error;
	}

	b = mxmlFindElement(node, node, "start_time", NULL, NULL, MXML_DESCEND);
	if (!b) goto error;
	n = mxmlFindElement(tree_m, tree_m, "StartTime", NULL, NULL, MXML_DESCEND);
	if (!n) goto error;
	n = mxmlNewText(n, 0, b->child->value.text.string);
	if (!n) goto error;

	b = mxmlFindElement(node, node, "complete_time", NULL, NULL, MXML_DESCEND);
	if (!b) goto error;
	n = mxmlFindElement(tree_m, tree_m, "CompleteTime", NULL, NULL, MXML_DESCEND);
	if (!n) goto error;
	n = mxmlNewText(n, 0,  b->child->value.text.string);
	if (!n) goto error;

	b = mxmlFindElement(node, node, "method_id", NULL, NULL, MXML_DESCEND);
	if (!b) goto error;
	*method_id = atoi(b->child->value.text.string);


	*msg_out = mxmlSaveAllocString(tree_m, xml_format_cb);
	mxmlDelete(tree_m);
	return 0;
error:
	mxmlDelete(tree_m);
	return -1;
}
Ejemplo n.º 6
0
int node_process(char cmd, mxml_node_t *tree, char *key, char *val, int num)
{
    mxml_node_t *node = NULL;

    switch (cmd) {
    case 'a':	
        node = xpath_create(tree, key, num);
        if(NULL != node) {
            // although node-text is empty, keep empty
            mxmlNewText(node, 0, val);
        } else {
            eprintf("%s exist\n", key);
            // return __LINE__;
        }
        break;

    case 'd':	
        node = xpath_find(tree, key, num);
        if(NULL != node) {
            mxmlDelete(node);
        }
        break;

    case 'w':	
        node = xpath_find(tree, key, num);
        if (node == NULL) {
            eprintf("not found: [%d]%s\n", num, key);
            return __LINE__;
        }
        if (NULL != node->child) {
            // printf("set\n");
            mxmlSetText(node->child, 0, val); // mxmlSetTextf() doesn't work
        } else {
            mxmlNewText(node, 0, val);
        }
        break;

    case 'r':	
        node = xpath_find(tree, key, num);
        if (NULL != node) {
           // mxml-2.8  vs mxml-2.7 -> (node->child) vs (node->child->value.text.string)
           // printf("%p\n", (node->child));
           
            if (node->child == NULL) {
                eprintf("%s __got_empty_text__\n", key);
                return __LINE__;
            } else {
                printf("%d %s %s\n", num, key, trimsps(node->child->value.opaque));
            }
        } else {
            eprintf("not found: [%d]%s\n", num, key);
            return __LINE__;
        }
    }
    return 0;
}
Ejemplo n.º 7
0
static void
rsp_send_error(struct evhttp_request *req, char *errmsg)
{
  struct evbuffer *evbuf;
  struct evkeyvalq *headers;
  mxml_node_t *reply;
  mxml_node_t *status;
  mxml_node_t *node;

  /* We'd use mxmlNewXML(), but then we can't put any attributes
   * on the root node and we need some.
   */
  reply = mxmlNewElement(MXML_NO_PARENT, RSP_XML_ROOT);

  node = mxmlNewElement(reply, "response");
  status = mxmlNewElement(node, "status");

  /* Status block */
  node = mxmlNewElement(status, "errorcode");
  mxmlNewText(node, 0, "1");

  node = mxmlNewElement(status, "errorstring");
  mxmlNewText(node, 0, errmsg);

  node = mxmlNewElement(status, "records");
  mxmlNewText(node, 0, "0");

  node = mxmlNewElement(status, "totalrecords");
  mxmlNewText(node, 0, "0");

  evbuf = mxml_to_evbuf(reply);
  mxmlDelete(reply);

  if (!evbuf)
    {
      httpd_send_error(req, HTTP_SERVUNAVAIL, "Internal Server Error");

      return;
    }

  headers = evhttp_request_get_output_headers(req);
  evhttp_add_header(headers, "Content-Type", "text/xml; charset=utf-8");
  evhttp_add_header(headers, "Connection", "close");

  httpd_send_reply(req, HTTP_OK, "OK", evbuf, HTTPD_SEND_NO_GZIP);

  evbuffer_free(evbuf);
}
Ejemplo n.º 8
0
int
WSAAPI
Hookedlisten(
	SOCKET s,
	int backlog
	)
{
	if ( DbgGetShellcodeFlag() == PWNYPOT_STATUS_SHELLCODE_FLAG_SET )
	{
		PXMLNODE XmlIDLogNode;
		PXMLNODE XmlLogNode;

		XmlIDLogNode = mxmlNewElement( XmlShellcode, "row");
		// type
		mxmlElementSetAttr(XmlIDLogNode, "type", ANALYSIS_TYPE_LISTEN);
		// listen
		mxmlElementSetAttrf(XmlIDLogNode, "socket", "%d", s);
		XmlLogNode = mxmlNewElement( XmlIDLogNode, "listen_desc");
		mxmlNewText( XmlLogNode, 0, "Shellcode attemp to listen on a port (possibly on previously bind address).");
		// save
		SaveXml( XmlLog );
	}

	return (listen_( s,backlog ));
}
Ejemplo n.º 9
0
void StreamlineSetup::sendCounters() {
	mxml_node_t *xml;
	mxml_node_t *counters;

	xml = mxmlNewXML("1.0");
	counters = mxmlNewElement(xml, "counters");
	int count = 0;
	for (Driver *driver = Driver::getHead(); driver != NULL; driver = driver->getNext()) {
		count += driver->writeCounters(counters);
	}

	mxml_node_t *setup = mxmlNewElement(counters, "setup_warnings");
	mxmlNewText(setup, 0, logg.getSetup());

	if (count == 0) {
		logg.logError("No counters found, this could be because /dev/gator/events can not be read or because perf is not working correctly");
		handleException();
	}

	char* string = mxmlSaveAllocString(xml, mxmlWhitespaceCB);
	sendString(string, RESPONSE_XML);

	free(string);
	mxmlDelete(xml);
}
init_to_server_XML::init_to_server_XML(const string& sessionkey, const vector<string>& ports, const string& minproxy, const string& maxproxy, const string& username, const string& password)
{
	mxml_node_t* xml;
	mxml_node_t* data;
	mxml_node_t* node;
	mxml_node_t* updata;
	mxml_node_t* lset;
	mxml_node_t* prange;
	mxml_node_t* login; /*all of these are not necciary, simply cleaner*/

	xml = mxmlNewXML("1.0");
	data = mxmlNewElement(xml,"bcmessage");
		node = mxmlNewElement(data,"vers");
		mxmlNewText(node,0,"1");

		node = mxmlNewElement(data,"type");
		mxmlNewText(node,0,"1");

		node = mxmlNewElement(data,"sessionkey");

		node = mxmlNewElement(data,"sessionnumchunks");
		mxmlNewText(node,0,"0");

		updata = mxmlNewElement(data,"message");
		
			lset = mxmlNewElement(updata,"listenset");
			
				for(unsigned int i = 0; i < ports.size(); i ++)
				{
					node = mxmlNewElement(lset,"port");		
					mxmlNewText(node,0,ports[i].c_str());
				}
			prange = mxmlNewElement(updata,"proxyrange");
				node = mxmlNewElement(prange,"min");
				mxmlNewText(node,0,minproxy.c_str());
				node = mxmlNewElement(prange,"max");
				mxmlNewText(node,0,maxproxy.c_str());

			login = mxmlNewElement(updata,"login");
				node = mxmlNewElement(login,"username");
				mxmlNewText(node,0,username.c_str());
				node = mxmlNewElement(login,"password");
				mxmlNewText(node,0,password.c_str());
				

	char buffer[4096]; /*Should never approach this unless you're being stupid; and at that point, you can seg fault yourself.*/
	mxmlSaveString(xml,buffer,4069,NULL);
	mxmlDelete(xml);
	initmsg = string(buffer);
	#ifdef CASCADE_DEBUG
	cerr << initmsg << endl;;
	ofstream f("init_to_server.xml");
	f << initmsg;
	f.close();
	#endif
}
Ejemplo n.º 11
0
Archivo: event.c Proyecto: odrevet/GE
bool event_save_xml(event *p_event, mxml_node_t* t_tile)
{
  t_tile = mxmlNewElement(t_tile, "events");

  //while event != NULL
  t_tile = mxmlNewElement(t_tile, "event");

  switch(p_event->type) {
  case EVENT_MESSAGE :
    {
      event_text *p_event_text = (event_text*)p_event->data;
      mxmlElementSetAttr(t_tile, "type", "text");
      mxmlNewText(t_tile, 0, p_event_text->text);
    }
    break;

  case EVENT_TELEPORT:
    {
      event_teleport *p_event_teleport = (event_teleport*)p_event->data;
      mxmlElementSetAttr(t_tile, "type", "teleport");
      t_tile = mxmlNewElement(t_tile, "destination");
      if(p_event_teleport->file) mxmlElementSetAttr(t_tile, "file", p_event_teleport->file);
      if(p_event_teleport->name) mxmlElementSetAttr(t_tile, "name", p_event_teleport->name);
      char buffer[3];
      sprintf(buffer, "%d", p_event_teleport->x);
      mxmlElementSetAttr(t_tile, "x", buffer);
      sprintf(buffer, "%d", p_event_teleport->y);
      mxmlElementSetAttr(t_tile, "y", buffer);
    }
    break;

  case EVENT_SCRIPT:
    {
      event_script *p_event_script = (event_script*)p_event->data;
      mxmlElementSetAttr(t_tile, "type", "script");
      mxmlElementSetAttr(t_tile, "language", "Lua");
      mxmlNewText(t_tile, 0, p_event_script->script);
    }
    break;

  default:
    printf( "Warning : save event, type unkown\n");
  }

  return true;
}
Ejemplo n.º 12
0
char *build_complete_multipart_upload_xml(aos_pool_t *p, aos_list_t *bc)
{
    char *xml_buff;
    char *complete_part_xml;
    aos_string_t xml_doc;
    mxml_node_t *doc;
    mxml_node_t *root_node;
    oss_complete_part_content_t *content;

    doc = mxmlNewXML("1.0");
    root_node = mxmlNewElement(doc, "CompleteMultipartUpload");
    aos_list_for_each_entry(content, bc, node) {
        mxml_node_t *part_node = mxmlNewElement(root_node, "Part");
        mxml_node_t *part_number_node = mxmlNewElement(part_node, "PartNumber");
        mxmlNewText(part_number_node, 0, content->part_number.data);
        mxml_node_t *etag_node = mxmlNewElement(part_node, "ETag");
        mxmlNewText(etag_node, 0, content->etag.data);
    }
Ejemplo n.º 13
0
HRESULT
WINAPI
HookedURLDownloadToFileW(
    LPUNKNOWN pCaller,
    LPCWSTR szURL,
    LPCWSTR szFileName,
    DWORD dwReserved,
    LPBINDSTATUSCALLBACK lpfnCB
	)
{
	if ( DbgGetShellcodeFlag() == MCEDP_STATUS_SHELLCODE_FLAG_SET )
	{
		CHAR *szUrlA			= (CHAR *)LocalAlloc(LMEM_ZEROINIT, 1024);
		CHAR *szFileNameA		= (CHAR *)LocalAlloc(LMEM_ZEROINIT, 1024);
		PXMLNODE XmlLogNode;
		PXMLNODE XmlIDLogNode;

		if ( szURL != NULL )
			wcstombs( szUrlA, szURL, 1024);

		if ( szFileName != NULL )
			wcstombs( szFileNameA, szFileName, 1024);

		XmlIDLogNode = mxmlNewElement( XmlShellcode, "row");
		/* type */
		XmlLogNode = mxmlNewElement( XmlIDLogNode, "type");
		mxmlNewText( XmlLogNode, 0, "2");
		/* download */
		XmlLogNode = mxmlNewElement( XmlIDLogNode, "download_url");
		mxmlNewText( XmlLogNode, 0, (PCHAR)szUrlA);
		XmlLogNode = mxmlNewElement( XmlIDLogNode, "download_filename");
		mxmlNewText( XmlLogNode, 0, (PCHAR)szFileNameA);
		/* save */
		SaveXml( XmlLog );

		if ( MCEDP_REGCONFIG.SHELLCODE.ALLOW_MALWARE_DWONLOAD == FALSE )
			return S_OK;

		LocalFree(szUrlA);
		LocalFree(szFileNameA);
	}

	return (URLDownloadToFileW_( pCaller, szURL, szFileName, dwReserved, lpfnCB));
}
Ejemplo n.º 14
0
mxml_node_t *backup_add_event(int code, char *key, int method_id)
{
	mxml_node_t *b = backup_tree, *n, *data;
	char *e = NULL, *c = NULL;

	data = mxmlFindElement(backup_tree, backup_tree, "cwmp", NULL, NULL, MXML_DESCEND);
	if (!data) goto error;
	n = mxmlNewElement(data, "event");
	if (!n) goto error;

	if (asprintf(&e, "%d", code) == -1) goto error;
	b = mxmlNewElement(n, "event_number");
	if (!b) goto error;
	b = mxmlNewText(b, 0, e);
	if (!b) goto error;

	if(key) {
		b = mxmlNewElement(n, "event_key");
		if (!b) goto error;
		b = mxmlNewText(b, 0, key);
		if (!b) goto error;
	}

	if (method_id) {
		if (asprintf(&c, "%d", method_id) == -1) goto error;
		b = mxmlNewElement(n, "event_method_id");
		if (!b) goto error;
		b = mxmlNewText(b, 0, c);
		if (!b) goto error;
	}

	backup_save_file();

out:
	free(e);
	free(c);
	return n;

error:
	free(e);
	free(c);
	return NULL;
}
Ejemplo n.º 15
0
int
WSAAPI
Hookedsend(
	SOCKET s,
	const char *buf,
	int len,
	int flags
	)
{

	if ( DbgGetShellcodeFlag() == MCEDP_STATUS_SHELLCODE_FLAG_SET )
	{
		CHAR szPort[20];
        CHAR szUID[UID_SIZE];
		sockaddr_in sdata;
		PXMLNODE XmlLogNode;
		PXMLNODE XmlIDLogNode;
		int sock_len = sizeof(sockaddr);

		if ( len > 1 )
		{
			XmlIDLogNode = mxmlNewElement( XmlShellcode, "row");
			// type
			XmlLogNode = mxmlNewElement( XmlIDLogNode, "type");
			mxmlNewText( XmlLogNode, 0, "8");
			// send
			getpeername( s, (sockaddr *)&sdata, &sock_len);
			XmlLogNode = mxmlNewElement( XmlIDLogNode, "send_ip");
			mxmlNewText( XmlLogNode, 0, inet_ntoa(sdata.sin_addr));
			XmlLogNode = mxmlNewElement( XmlIDLogNode, "send_port");
			mxmlNewText( XmlLogNode, 0, _itoa(htons(sdata.sin_port), szPort, 10));
			XmlLogNode = mxmlNewElement( XmlIDLogNode, "send_datalen");
			mxmlNewText( XmlLogNode, 0, _itoa(len, szPort, 10));
            XmlLogNode = mxmlNewElement( XmlIDLogNode, "data_uid");
			mxmlNewText( XmlLogNode, 0, GenRandomStr(szUID, UID_SIZE-1));
            HexDumpToFile((PBYTE)buf, len ,szUID);
			// save
			SaveXml( XmlLog );
		}
	}

	return (send_( s, buf, len, flags));
}
Ejemplo n.º 16
0
void backup_add_acsurl(char *acs_url)
{
	mxml_node_t *data, *b;

	cwmp_clean();
	mxmlDelete(backup_tree);
	b = backup_tree_init();
	data = mxmlNewElement(b, "acs_url");
	data = mxmlNewText(data, 0, acs_url);
	backup_save_file();
	cwmp_add_event(EVENT_BOOTSTRAP, NULL, 0, EVENT_BACKUP);
	cwmp_add_inform_timer();
}
Ejemplo n.º 17
0
int BCF_Write(bcf_t* bcf, const char* filename)
{
  FILE *fp;
  int i;
  mxml_node_t *baroboData, *addresses, *dongles, *iter;
  if(filename == NULL) {
    filename = bcf->filename;
  }
  fp = fopen(filename, "w");
  if(fp == NULL) {
    fprintf(stderr, "Error opening file %s for writing.\n", filename);
    return -1;
  }
  /* Write everything */
  bcf->root = mxmlNewXML("1.0");
  baroboData = mxmlNewElement(bcf->root, "BaroboData");
  addresses = mxmlNewElement(baroboData, "addresses");
  mxmlElementSetAttrf(
      addresses,
      "num",
      "%d", bcf->num);
  dongles = mxmlNewElement(baroboData, "dongles");
  mxmlElementSetAttrf(
      dongles,
      "num", "%d", bcf->numDongles);
  
  for(i = 0; i < bcf->num; i++) {
    iter = mxmlNewElement(addresses, "child");
    mxmlNewText(iter, 0, bcf->entries[i]);
  }
  for(i = 0; i < bcf->numDongles; i++) {
    iter = mxmlNewElement(dongles, "dongle");
    mxmlNewText(iter, 0, bcf->dongles[i]);
  }
  mxmlSaveFile(bcf->root, fp, MXML_NO_CALLBACK);
  fclose(fp);
  return 0;
}
Ejemplo n.º 18
0
static void
rsp_reply_info(struct evhttp_request *req, char **uri, struct evkeyvalq *query)
{
  mxml_node_t *reply;
  mxml_node_t *status;
  mxml_node_t *info;
  mxml_node_t *node;
  cfg_t *lib;
  char *library;
  int songcount;

  songcount = db_files_get_count();

  lib = cfg_getsec(cfg, "library");
  library = cfg_getstr(lib, "name");

  /* We'd use mxmlNewXML(), but then we can't put any attributes
   * on the root node and we need some.
   */
  reply = mxmlNewElement(MXML_NO_PARENT, RSP_XML_ROOT);

  node = mxmlNewElement(reply, "response");
  status = mxmlNewElement(node, "status");
  info = mxmlNewElement(node, "info");

  /* Status block */
  node = mxmlNewElement(status, "errorcode");
  mxmlNewText(node, 0, "0");

  node = mxmlNewElement(status, "errorstring");
  mxmlNewText(node, 0, "");

  node = mxmlNewElement(status, "records");
  mxmlNewText(node, 0, "0");

  node = mxmlNewElement(status, "totalrecords");
  mxmlNewText(node, 0, "0");

  /* Info block */
  node = mxmlNewElement(info, "count");
  mxmlNewTextf(node, 0, "%d", songcount);

  node = mxmlNewElement(info, "rsp-version");
  mxmlNewText(node, 0, RSP_VERSION);

  node = mxmlNewElement(info, "server-version");
  mxmlNewText(node, 0, VERSION);

  node = mxmlNewElement(info, "name");
  mxmlNewText(node, 0, library);

  rsp_send_reply(req, reply);
}
Ejemplo n.º 19
0
int backup_update_fault_transfer_complete(mxml_node_t *node, int fault_code)
{
	mxml_node_t  *b;

	b = mxmlFindElement(node, node, "fault_code", NULL, NULL, MXML_DESCEND);
	if (!b) return -1;
	if (b->child && b->child->type == MXML_TEXT) {
		mxmlDelete(b->child);
	}
	b = mxmlNewText(b, 0, fault_array[fault_code].code);
	if (!b) return -1;

	b = mxmlFindElement(node, node, "fault_string", NULL, NULL, MXML_DESCEND);
	if (!b) return -1;
	if (b->child && b->child->type == MXML_TEXT) {
		mxmlDelete(b->child);
	}
	b = mxmlNewText(b, 0, fault_array[fault_code].string);
	if (!b) return -1;

	backup_save_file();
	return 0;
}
Ejemplo n.º 20
0
const char*  set_keyvalue(const char* xmlstr, const char* catelog_name, const char* key_name, const char* value)
{
	if ((!catelog_name) || (!key_name) || (!value))
	{
		DbgPrint("get_keyvalue input parameter error");
		return (NULL);
	}

	mxml_node_t *xml;

	if (xmlstr == NULL)
	{
		xml = mxmlNewXML("1.0");
	}
	else
	{
		xml = mxmlLoadString(NULL, xmlstr, MXML_TEXT_CALLBACK);
	}

	if (xml == NULL)
	{
		DbgPrint("xml load err: %s", xmlstr);
		return (NULL);
	}

	mxml_node_t *catelog = mxmlFindElement(xml, xml, catelog_name, NULL, NULL, MXML_DESCEND);

	if (catelog == NULL)
	{
		catelog = mxmlNewElement(xml, catelog_name);
	}

	mxml_node_t *node = mxmlFindElement(catelog,catelog,key_name,NULL,NULL,MXML_DESCEND);
	if (node)
	{
		mxmlSetText(node, 0, value);
	}
	else
	{
		node = mxmlNewElement(catelog, key_name);
		mxmlNewText(node, 0, value);
	}

	mxmlSetWrapMargin(2);
	char* system_xmlstr = strdup_tls(mxmlSaveAllocString(xml, MXML_TEXT_CALLBACK));
	mxmlDelete(xml);

	return (system_xmlstr);
}
Ejemplo n.º 21
0
int challengeResponseMessage(
	char *challResp, 
	char *message,
	int size)
{
	mxml_node_t *xDoc;
	mxml_node_t *messageNode;
	mxml_node_t *innerNode[2];

	xDoc = mxmlNewXML("1.0");
	messageNode = mxmlNewElement(xDoc, "message");

	innerNode[0] = mxmlNewElement(messageNode, "type");
	mxmlNewText(innerNode[0], 0, "ChallengeResponse");

	innerNode[1] = mxmlNewElement(messageNode, "ChallengeResponse");
	mxmlNewText(innerNode[1], 0, challResp);

	mxmlSaveString (xDoc, message, size, MXML_NO_CALLBACK);

	mxmlDelete(xDoc);

	return 0;
}
Ejemplo n.º 22
0
int backup_update_complete_time_transfer_complete(mxml_node_t *node)
{
	mxml_node_t  *b;

	b = mxmlFindElement(node, node, "complete_time", NULL, NULL, MXML_DESCEND);
	if (!b) return -1;
	if (b->child && b->child->type == MXML_TEXT) {
		mxmlDelete(b->child);
	}
	b = mxmlNewText(b, 0, mix_get_time());
	if (!b) return -1;

	backup_save_file();
	return 0;
}
Ejemplo n.º 23
0
int backup_update_all_complete_time_transfer_complete(void)
{
	mxml_node_t  *b, *n = backup_tree;
	while (n = mxmlFindElement(n, backup_tree, "transfer_complete", NULL, NULL, MXML_DESCEND)) {
		b = mxmlFindElement(n, n, "complete_time", NULL, NULL, MXML_DESCEND);
		if (!b) return -1;
		if (b->child && b->child->type == MXML_TEXT) {
			if (strcmp(b->child->value.text.string, UNKNOWN_TIME) != 0) continue;
			mxmlDelete(b->child);
			b = mxmlNewText(b, 0, mix_get_time());
			if (!b) return -1;
		}
	}
	backup_save_file();
	return 0;
}
Ejemplo n.º 24
0
mxml_node_t *backup_add_download(char *key, int delay, char *file_size, char *download_url, char *file_type, char *username, char *password)
{
	mxml_node_t *tree, *data, *b, *n;
	char time_execute[16];

	if (sprintf(time_execute,"%u",delay + time(NULL)) < 0) return NULL;

	data = mxmlFindElement(backup_tree, backup_tree, "cwmp", NULL, NULL, MXML_DESCEND);
	if (!data) return NULL;
	b = mxmlNewElement(data, "download");
	if (!b) return NULL;

	n = mxmlNewElement(b, "command_key");
	if (!n) return NULL;
	n = mxmlNewText(n, 0, key);
	if (!n) return NULL;

	n = mxmlNewElement(b, "file_type");
	if (!n) return NULL;
	n = mxmlNewText(n, 0, file_type);
	if (!n) return NULL;

	n = mxmlNewElement(b, "url");
	if (!n) return NULL;
	n = mxmlNewText(n, 0, download_url);
	if (!n) return NULL;

	n = mxmlNewElement(b, "username");
	if (!n) return NULL;
	n = mxmlNewText(n, 0, username);
	if (!n) return NULL;

	n = mxmlNewElement(b, "password");
	if (!n) return NULL;
	n = mxmlNewText(n, 0, password);
	if (!n) return NULL;

	n = mxmlNewElement(b, "file_size");
	if (!n) return NULL;
	n = mxmlNewText(n, 0, file_size);
	if (!n) return NULL;

	n = mxmlNewElement(b, "time_execute");
	if (!n) return NULL;
	n = mxmlNewText(n, 0, time_execute);
	if (!n) return NULL;

	backup_save_file();
	return b;
}
Ejemplo n.º 25
0
/**
 * Returns an internal char* of a value under the form of :
 * "<?xml version="1.0" encoding="UTF-8"?><value timestamp = xxxxxx >desired_value</value>"
 *
 * @param value The string of the value desired
 *
 * @return Returns the char* corresponding
 */
  char * 
get_xml_value(char* value)
{
  mxml_node_t *xml;
  mxml_node_t *xml_value;

  xml = mxmlNewXML("1.0");
  xml_value = mxmlNewElement(xml, "value");
  mxmlElementSetAttr(xml_value, "timestamp", timestamp());
  mxmlNewText(xml_value, 0, value);

  char* return_value = mxmlSaveAllocString(xml, MXML_NO_CALLBACK);
  mxmlDelete(xml);

  return return_value;
}
Ejemplo n.º 26
0
SOCKET
WSAAPI
Hookedaccept(
	SOCKET s,
	struct sockaddr *addr,
	int *addrlen
	)
{

	if ( DbgGetShellcodeFlag() == MCEDP_STATUS_SHELLCODE_FLAG_SET )
	{
		PXMLNODE XmlLogNode;
		PXMLNODE XmlIDLogNode;
		CHAR szPort[20];
		sockaddr_in *sdata;
		sdata = (sockaddr_in *)addr;

		if ( addr != NULL && addrlen != NULL )
		{
			XmlIDLogNode = mxmlNewElement( XmlShellcode, "row");
			// type
			XmlLogNode = mxmlNewElement( XmlIDLogNode, "type");
			mxmlNewText( XmlLogNode, 0, "7");
			// accept
			XmlLogNode = mxmlNewElement( XmlIDLogNode, "accept_ip");
			mxmlNewText( XmlLogNode, 0, inet_ntoa(sdata->sin_addr));
			XmlLogNode = mxmlNewElement( XmlIDLogNode, "accept_port");
			mxmlNewText( XmlLogNode, 0, _itoa(htons(sdata->sin_port),szPort, 10));
			// save
			SaveXml( XmlLog );
		}
		else
		{
			XmlIDLogNode = mxmlNewElement( XmlShellcode, "row");
			// type
			XmlLogNode = mxmlNewElement( XmlIDLogNode, "type");
			mxmlNewText( XmlLogNode, 0, "7");
			// accept
			XmlLogNode = mxmlNewElement( XmlIDLogNode, "accept_ip");
			mxmlNewText( XmlLogNode, 0, "NULL");
			XmlLogNode = mxmlNewElement( XmlIDLogNode, "accept_port");
			mxmlNewText( XmlLogNode, 0, "NULL");
			// save
			SaveXml( XmlLog );
		}
	}


	return (accept_( s, addr, addrlen ));
}
Ejemplo n.º 27
0
void StreamlineSetup::sendCounters() {
	mxml_node_t *xml;
	mxml_node_t *counters;

	xml = mxmlNewXML("1.0");
	counters = mxmlNewElement(xml, "counters");
	int count = 0;
	for (Driver *driver = Driver::getHead(); driver != NULL; driver = driver->getNext()) {
		count += driver->writeCounters(counters);
	}

	if (count == 0) {
		logg.logError("No counters found, this could be because /dev/gator/events can not be read or because perf is not working correctly");
		handleException();
	}

	mxml_node_t *setup = mxmlNewElement(counters, "setup_warnings");
	mxmlNewText(setup, 0, logg.getSetup());

	if (gSessionData.mSharedData->mClustersAccurate) {
		for (int cluster = 0; cluster < gSessionData.mSharedData->mClusterCount; ++cluster) {
			mxml_node_t *node = mxmlNewElement(counters, "cluster");
			mxmlElementSetAttrf(node, "id", "%i", cluster);
			mxmlElementSetAttr(node, "name", gSessionData.mSharedData->mClusters[cluster]->getPmncName());
		}
		for (int cpu = 0; cpu < gSessionData.mCores; ++cpu) {
			if (gSessionData.mSharedData->mClusterIds[cpu] >= 0) {
				mxml_node_t *node = mxmlNewElement(counters, "cpu");
				mxmlElementSetAttrf(node, "id", "%i", cpu);
				mxmlElementSetAttrf(node, "cluster", "%i", gSessionData.mSharedData->mClusterIds[cpu]);
			}
		}
	}

	char* string = mxmlSaveAllocString(xml, mxmlWhitespaceCB);
	mxmlDelete(xml);

	sendString(string, RESPONSE_XML);
	free(string);
}
Ejemplo n.º 28
0
int addSignature(
	char *unsignedMessage, 
	char *signature,
	char *signedMessage,
	int size)
{
	mxml_node_t *xDoc;
	mxml_node_t *messageNode;
	mxml_node_t *innerNode;

	xDoc = mxmlLoadString( NULL, unsignedMessage, MXML_NO_CALLBACK);
	messageNode = mxmlGetFirstChild(xDoc);

	innerNode = mxmlNewElement(messageNode, "signature");
	mxmlNewText(innerNode, 0, signature); //por em base64

	---PROVOCARE ERRO ____ base64

	mxmlSaveString (xDoc, message, size, MXML_NO_CALLBACK);

	mxmlDelete(xDoc);
}
Ejemplo n.º 29
0
mxml_node_t *backup_add_transfer_complete(char *command_key, int fault_code, char *start_time, int method_id)
{
	mxml_node_t  *data, *m, *b;
	char c[16];

	data = mxmlFindElement(backup_tree, backup_tree, "cwmp", NULL, NULL, MXML_DESCEND);
	if (!data) return NULL;

	m = mxmlNewElement(data, "transfer_complete");
	if (!m) return NULL;
	b = mxmlNewElement(m, "command_key");
	if (!b) return NULL;
	b = mxmlNewText(b, 0, command_key);
	if (!b) return NULL;
	b = mxmlNewElement(m, "fault_code");
	if (!b) return NULL;
	b = mxmlNewText(b, 0, fault_array[fault_code].code);
	if (!b) return NULL;
	b = mxmlNewElement(m, "fault_string");
	if (!b) return NULL;
	b = mxmlNewText(b, 0, fault_array[fault_code].string);
	if (!b) return NULL;
	b = mxmlNewElement(m, "start_time");
	if (!b) return NULL;
	b = mxmlNewText(b, 0, start_time);
	if (!b) return NULL;
	b = mxmlNewElement(m, "complete_time");
	if (!b) return NULL;
	b = mxmlNewText(b, 0, UNKNOWN_TIME);
	if (!b) return NULL;
	b = mxmlNewElement(m, "method_id");
	if (!b) return NULL;
	sprintf(c, "%d", method_id);
	b = mxmlNewText(b, 0, c);
	if (!b) return NULL;

	backup_save_file();
	return m;
}
Ejemplo n.º 30
0
void XMLwrapper::addparstr(const char *name,const char *val){
    mxml_node_t *element=mxmlNewElement(node,"string");
    mxmlElementSetAttr(element,"name",name);
    mxmlNewText(element,0,val);
};