Пример #1
0
static void saveconfig(void)
{
    const char *uid = gtk_entry_get_text(GTK_ENTRY(entry1));
    const char *url = gtk_entry_get_text(GTK_ENTRY(entry3));

    unsigned char md5pword[16];
    gsize md5len = 16;

    if (pwd != NULL && pwd[0] != '\0') {
        GChecksum * state = g_checksum_new (G_CHECKSUM_MD5);
        g_checksum_update (state, (unsigned char *) pwd, strlen (pwd));
        g_checksum_get_digest (state, md5pword, & md5len);
        g_checksum_free (state);

        aud_set_string ("audioscrobbler", "password",
         hexify ((gchar *) md5pword, sizeof md5pword));
    }
    if (uid != NULL && uid[0] != '\0') {
        aud_set_string ("audioscrobbler", "username", uid);
    } else {
        aud_set_string ("audioscrobbler", "username", "");
        aud_set_string ("audioscrobbler", "password", "");
    }

    if (url != NULL && url[0] != '\0')
        aud_set_string ("audioscrobbler", "sc_url", url);
    else
        aud_set_string ("audioscrobbler", "sc_url", LASTFM_HS_URL);
}
bool LayoutCreator::write_file()
{
    // Copy the file to the new location
    QFile file(m_parent->filename());
    if(!file.copy(m_file_name)) {
        //TODO: Error handling
        LOGD << "\tError copying file to new location!";
        return false;
    }

    if( !file.setPermissions((QFile::Permission)0x666) ) {
        LOGD << "WARNING: Unable to set permissions for new layout.";
    }

    // Read the file

    // Update values
    MemoryLayout newLayout(m_file_name, m_parent->data());
    QString checksum = hexify(m_df->calculate_checksum());
    newLayout.set_game_version(m_version_name);
    newLayout.set_checksum(checksum);
    newLayout.set_address("addresses/translation_vector", m_translation_vector);
    newLayout.set_address("addresses/language_vector", m_language_vector);
    newLayout.set_address("addresses/creature_vector", m_creature_vector);
    newLayout.set_address("addresses/dwarf_race_index", m_dwarf_race_index);
    newLayout.set_address("addresses/squad_vector", m_squad_vector);
    newLayout.set_address("addresses/current_year", m_current_year);
    newLayout.set_complete();
    LOGD << "\tWriting file.";
    newLayout.save_data();
    return true;
}
Пример #3
0
void check(mock_writer_t* writer, const std::string& hex) {
	writer->flush_all();

	ASSERT_EQ(remove_spaces(hex), hexify(writer->data));

	writer->data.clear();
}
Пример #4
0
int hash_s(char * const salt, char * const pass, char * const hash)
{
    register unsigned i;
    unsigned char * buffer;
    size_t bufferLen = 0;

    /*
     * Sanity checks
     */
    assert(salt != NULL);
    assert(pass != NULL);
    assert(hash != NULL);

    /*
     * Alloc mem and compose the buffer
     */
    bufferLen = strlen(salt) + strlen(pass) + 16 /* Len of MD5 */;

    buffer = (unsigned char *) malloc( sizeof(unsigned char) * bufferLen);
    if (buffer == NULL) {
        return -1;
    }
    memset_s(buffer, 0, bufferLen);

    /*
     * https://en.wikipedia.org/wiki/Key_stretching
     *
     * key = ""
     * for 1 to HASH_ITERATIONS do
     *     key = hash(key + password + salt)
     */
    char * actual = (char *) buffer;
    assert(len(buffer) == 0);
    for (i = 0; i < HASH_ITERATIONS; ++i) {
        MD5_CTX ctx;

        strcpy(actual, pass);
        actual += strlen(pass);
        strcpy(actual, salt);
        actual += strlen(salt);
        *actual = '\0';

        MD5_Init(&ctx);
        MD5_Update(&ctx, buffer, actual - (char *) buffer);
        MD5_Final(buffer, &ctx);

        actual = (char *) buffer + 16;
    }

    hexify(buffer, 16, hash);

    /*
     * Free and burn mem
     */
    memset_s(buffer, 0, bufferLen);
    free(buffer);
    buffer = NULL;

    return 0;
}
Пример #5
0
void service_init(struct service *sv, uint16_t port, const char *key, const char *capture, const char *playback, uint32_t bitrate,
        void (*handler)(enum service_event event, const uint8_t uid[20], void *args), void *args)
{
    sv->state = STATE_IDLE;
    sv->state_handler = handler;
    sv->state_args = args;
    sv->epfd = epoll_create1(0); assert(sv->epfd > 0);
    sv->timerfd = timerfd_create(CLOCK_MONOTONIC, 0); assert(sv->timerfd > 0);
    service_pollfd(sv, sv->timerfd, (void(*)(void*))timer_handler, sv);

    const int optval = 1;
    const struct sockaddr_in addr = { AF_INET, htons(port) };
    sv->sockfd = socket(AF_INET, SOCK_DGRAM, 0); assert(sv->sockfd > 0);
    int res = setsockopt(sv->sockfd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); assert(res == 0);
    if(bind(sv->sockfd, (struct sockaddr*)&addr, sizeof(addr)) != 0) { ERROR("Cannot bind socket"); abort(); }
    service_pollfd(sv, sv->sockfd, (void(*)(void*))socket_handler, sv);

    route_init(sv->table);
    sv->crypto = (struct crypto*)((void*)sv + sizeof(struct service));
    crypto_init(sv->crypto, key, sv->srcid);
    sv->media = (struct media*)((void*)sv + sizeof(struct service) + crypto_sizeof());
    media_init(sv->media, capture, playback);
    sv->packet_size = bitrate / 8 / 50;
    INFO("Media: bitrate = %u, capture = %s, playback = %s", bitrate, capture, playback);

    char tmp[128]; INFO("User ID is %.40s", hexify(sv->srcid, tmp, 20));
}
Пример #6
0
void GdbServer::gdb_out(const char *buf) {
  int i = strlen (buf) * 2 + 1;

  char hexdata [i + 1];
  hexdata[0] = 'O';
  hexify (hexdata + 1, (unsigned char*) buf, strlen(buf));
  gdb_putpacket (hexdata, i);
}
Пример #7
0
void Format::put(const void* vp, const FormatFlags& flags)
{
	String s;
	if( !vp )
	{
		s = "<NULL>";
	}
	else
	{
#if __SIZEOF_POINTER__ == 4
		s = "0x" + hexify(Int32(vp));
#else
		s = "0x" + hexify(Int64(vp));
#endif
	}
	oss.append(align(s, flags));
}
void GameStateManager::deserializePlayer(int32_t eid)
{
  PlayerState & player = *m_states[eid];

  const std::string name = m_connection_manager.getNickname(eid);
  const std::string nickhash = sha1::calcToString(name.data(), name.length());
  std::copy(nickhash.begin(), nickhash.end(), player.nickhash.begin());

  if (PROGRAM_OPTIONS.count("verbose")) 
  {
    std::cout << "Player nickname is \"" << name << "\", hash: 0x" << hexify(nickhash)
              << ". Attempting to load player data from disk...";
  }

  std::ifstream playerfile("/tmp/mymap.player." + nickhash, std::ios::binary);

  if (!playerfile)
  {
    if (PROGRAM_OPTIONS.count("verbose"))
    {
      std::cout << " failed. Setting default start data." << std::endl;
    }

    const WorldCoords start_pos(8, 80, 8);

    player.position = RealCoords(wX(start_pos) + 0.5, wY(start_pos) + 0.5, wZ(start_pos) + 0.5);
    player.stance   = wY(start_pos) + 0.5;

    player.setInv(37, ITEM_DiamondPickaxe, 1, 0);
    player.setInv(36, BLOCK_Torch, 50, 0);
    player.setInv(29, ITEM_Coal, 50, 0);
    player.setInv(21, BLOCK_Cobblestone, 60, 0);
    player.setInv(22, BLOCK_IronOre, 60, 0);
    player.setInv(30, BLOCK_Wood, 50, 0);
    player.setInv(38, ITEM_DiamondShovel, 1, 0);
    player.setInv(39, BLOCK_BrickBlock, 64, 0);
    player.setInv(40, BLOCK_Stone, 64, 0);
    player.setInv(41, BLOCK_Glass, 64, 0);
    player.setInv(42, BLOCK_WoodenPlank, 64, 0);
    player.setInv(44, BLOCK_Obsidian, 64, 0);
    player.setInv(43, ITEM_Bucket, 1, 0);

    player.holding = 4;
  }
  else
  {
    if (PROGRAM_OPTIONS.count("verbose"))
    {
      std::cout << " done!" << std::endl;
    }

    const WorldCoords start_pos(8, 80, 8);

    player.position = RealCoords(wX(start_pos) + 0.5, wY(start_pos) + 0.5, wZ(start_pos) + 0.5);
    player.stance   = wY(start_pos) + 0.5;
  }
    
}
Пример #9
0
static int icdi_send_remote_cmd(void *handle, const char *data)
{
	struct icdi_usb_handle_s *h = handle;

	size_t cmd_len = sprintf(h->write_buffer, PACKET_START "qRcmd,");
	cmd_len += hexify(h->write_buffer + cmd_len, data, 0, h->max_packet - cmd_len);

	return icdi_send_packet(handle, cmd_len);
}
Пример #10
0
/* Stores the arbitrary buffer of bytes, 'buf' (of length 'len') to
	the master server.  It is written into the user record for the
	user with username 'user', and password 'pass'.
	Returns 0 on success, 1 on failure. */
int master_gamesave(const char *user, const char *pass, const unsigned char *buf, int len)
{
	if(strlen(user) >= 25)
		return 1;
	if(strlen(pass) >= 25)
		return 1;

	if(len > ((sizeof(hex) - 1) / 2))
		return 0;

	hexify(buf, len);

	strcpy(path, master_path);
	strcat(path, "?action=gamesave2&");
	if(URLEncode::addParam(path, sizeof(path), user, "username") == false)
		return 1;
	if(URLEncode::addParam(path, sizeof(path), pass, "password") == false)
		return 1;

	/* XXX If the windows HTTPGetRequest() thing can be made to work with
	long, 4K char paths (which it's supposed to, but for some reason
	refused to work for me) then the following, commented out code can
	be used instead of the httpGet() call below it (which requires you to
	roll your own Socket() class. */
#if 0
	HTTPGetRequest *hgr = new HTTPGetRequest(master_host, 80, path, false, true, false);
	if(!hgr)
		return 1;
	int r = 0;
	char *b = master_http_buf;
	int bs = sizeof(master_http_buf);
	while(true)
	{
		int n = hgr->read(b, bs);
		if(n == 0)
			break;		// normal EOF
		if(hgr->failed)
			break;
		bs -= n;
		b += n;
		r += n;
	}
	bool f = hgr->failed;
	delete hgr;
	if(f)
		return 1;	// error
#else
	char *b = master_http_buf;
	int bs = sizeof(master_http_buf);
	if(httpPost(master_host, 80, path, b, bs, hex, len*2, "userfile", "gamedata", "text/hexed") == -1)
		return 1;
#endif


	return bustup_response();
}
Пример #11
0
int main(void) {
  {
    char path[] = "./test/casper/formelement.input.test.coffee.tested.do";
    char dir[sizeof path];
    char base[sizeof path];

    dirname(dir, base, path);

    eqStr(dir, "./test/casper");
    eqStr(base, "formelement.input.test.coffee.tested.do");
  }

  {
    const char *filename = "dir/file.tar.gz";
    char       *iter     = (char*)filename;

    eqStr(iter, "dir/file.tar.gz");
    iter = nextExtension(iter);
    eqStr(iter, ".tar.gz");
    iter = nextExtension(iter);
    eqStr(iter, ".gz");
    iter = nextExtension(iter);
    eqStr(iter, "");
  }

  {
    const char *s = "/this/is/a/file.gz";
    char        hex[strlen(s)*2+1];
    char        unhex[sizeof hex + 1];

    hexify(hex, s);
    eqStr(hex, "-_this-_is-_a-_file.gz");
    unhexify(unhex, hex);
    eqStr(unhex, "/this/is/a/file.gz");
  }

  {
    char cwd[] = "/root",
         target[] = "./a/b",
         dest[4096];

    normalizePath(dest, cwd, target);
    eqStr(dest, "/root/a/b");
  }

  {
    char cwd[] = "/root/other",
         target[] = "./a/../b/dir/e",
         dest[4096];

    normalizePath(dest, cwd, target);
    eqStr(dest, "/root/other/b/dir/e");
  }

  return 0;
}
Пример #12
0
static int 
write_env(stream_t *s, EXTENSION_CONTROL_BLOCK *r)
{
	int isHttp11 = 0;

	char protocol[BUF_LENGTH];
	char path_info_buffer[BUF_LENGTH];
	char *path_info = path_info_buffer;
	char uri_buffer[BUF_LENGTH];
	char *uri = uri_buffer;
	unsigned long size = sizeof(protocol);

	if (r->GetServerVariable(r->ConnID, "SERVER_PROTOCOL", protocol, &size) && size > 0) {
		protocol[size] = 0;
		isHttp11 = ! strcmp(protocol, "HTTP/1.1");
	}
	size = sizeof(path_info_buffer);
	if (r->GetServerVariable(r->ConnID, "PATH_INFO", path_info, &size) && size > 0) {
	        int i;
	  
		path_info[size] = 0;
		if (! strncmp(path_info, ISAPI_SCRIPT, sizeof(ISAPI_SCRIPT) - 1))
			path_info += sizeof(ISAPI_SCRIPT) - 1;

		i = 0;
		while (i < BUF_LENGTH - 6) {
		  int ch = *path_info++ & 0xff;

		  if (ch == 0)
		    break;
		  else if (' ' <= ch && ch < 0x80 && ch != '%') {
		    uri[i++] = ch;
		  }
		  else if (ch < 0x80) {
		    i = hexify(uri, i, ch);
		  }
		  else {
		    i = hexify(uri, i, 0xc0 | ((ch >> 6) & 0x1f));
		    i = hexify(uri, i, 0x80 | (ch & 0x3f));
		  }
		}
		uri[i] = 0;
	}
Пример #13
0
void
log_dump(const char* fmt, int len)
{
//#ifndef _DEBUG
//	return;
//#else
	unsigned char tmp[BUFFER_SIZE];
	hexify(tmp, (const unsigned char *)fmt, len, true);
	printf((char*)tmp);
//#endif
}
Пример #14
0
void Plant::load_data() {
    if (!m_df || !m_df->memory_layout() || !m_df->memory_layout()->is_valid()) {
        LOGW << "load of plants called but we're not connected";
        return;
    }
    // make sure our reference is up to date to the active memory layout
    m_mem = m_df->memory_layout();
    TRACE << "Starting refresh of plant data at" << hexify(m_address);

    read_plant();
}
Пример #15
0
static char * read_stdio(FILE * f) {

  static unsigned char buf[2 * TEMPBUFSIZE + 1];
  size_t      nact = 0;

  if ( ! feof(f) )
    nact = fread(buf, 1, TEMPBUFSIZE, f);
  if ( ferror(f) )
    nact = 0;
  hexify(buf, nact);
  return buf;
}
Пример #16
0
char *EMSCRIPTEN_KEEPALIVE GroestlCoinHash(char *hexstring)
{
	size_t i, sl;
	unsigned char *unhexed;
	uint32_t hashA[16], hashB[16];
	sph_groestl512_context ctx_groestl[2];

	//output buffer [we're not releasing it, so it'll be a memory leak. don't care in this case]
	if(!g_pHexedOutput)
	{
		g_pHexedOutput = malloc(65);
		for(i=0; i<65; i++)
			g_pHexedOutput[i] = 0;
	}

	//input length
	sl = 0;
	while(hexstring[sl])
		sl++;

	sl /= 2;
	unhexed = malloc(sl);
	if(unhexed)
	{
		//unhex the buffer
		for(i = 0; i < sl; i++)
			unhexed[i] = unhexify(hexstring[i*2]) * 16 + unhexify(hexstring[i*2+1]);

		//grs 1 pass
		sph_groestl512_init(&ctx_groestl[0]);
		sph_groestl512(&ctx_groestl[0], unhexed, sl);
		sph_groestl512_close(&ctx_groestl[0], hashA);

		free(unhexed);

		//grs 2 pass
		sph_groestl512_init(&ctx_groestl[1]);
		sph_groestl512(&ctx_groestl[1], hashA, 64);
		sph_groestl512_close(&ctx_groestl[1], hashB);

		//copy result
		for(i = 0; i < 32; i++)
		{
			unsigned ch = ((unsigned char*)hashB)[i];
			g_pHexedOutput[i*2] = hexify(ch >> 4);
			g_pHexedOutput[i*2+1] = hexify(ch & 0x0F);
		}
	}

	return g_pHexedOutput;
}
QVector<uint> DFInstanceLinux::enumerate_vector(const uint &addr) {
    QVector<uint> addrs;
    if (!addr)
        return addrs;

    attach();
    VIRTADDR start = read_addr(addr);
    VIRTADDR end = read_addr(addr + 4);
    int bytes = end - start;
    int entries = bytes / 4;
    TRACE << "enumerating vector at" << hex << addr << "START" << start
        << "END" << end << "UNVERIFIED ENTRIES" << dec << entries;
    VIRTADDR tmp_addr = 0;

    if (entries > 5000) {
        LOGW << "vector at" << hexify(addr) << "has over 5000 entries! (" <<
                entries << ")";
    }

#ifdef _DEBUG
    if (m_layout->is_complete()) {
        Q_ASSERT_X(start > 0, "enumerate_vector", "start pointer must be larger than 0");
        Q_ASSERT_X(end > 0, "enumerate_vector", "End must be larger than start!");
        Q_ASSERT_X(start % 4 == 0, "enumerate_vector", "Start must be divisible by 4");
        Q_ASSERT_X(end % 4 == 0, "enumerate_vector", "End must be divisible by 4");
        Q_ASSERT_X(end >= start, "enumerate_vector", "End must be >= start!");
        Q_ASSERT_X((end - start) % 4 == 0, "enumerate_vector", "end - start must be divisible by 4");
    } else {
        // when testing it's usually pretty bad to find a vector with more
        // than 5000 entries... so throw
        //Q_ASSERT_X(entries < 5000, "enumerate_vector", "more than 5000 entires");
    }
#endif
    QByteArray data(bytes, 0);
    int bytes_read = read_raw(start, bytes, data);
    if (bytes_read != bytes && m_layout->is_complete()) {
        LOGW << "Tried to read" << bytes << "bytes but only got"
                << bytes_read;
        detach();
        return addrs;
    }
    for(int i = 0; i < bytes; i += 4) {
        tmp_addr = decode_dword(data.mid(i, 4));
        addrs << tmp_addr;
    }
    detach();
    return addrs;
}
Пример #18
0
void Squad::read_data() {
    if (!m_df || !m_df->memory_layout() || !m_df->memory_layout()->is_valid()) {
        LOGW << "refresh of squad called but we're not connected";
        return;
    }
    // make sure our reference is up to date to the active memory layout
    m_mem = m_df->memory_layout();
    TRACE << "Starting refresh of squad data at" << hexify(m_address);

    //qDeleteAll(m_members);
    m_members.clear();

    read_id();
    read_name();
    read_members();
}
Пример #19
0
int linux_thread_extra_info(struct target *target,
	struct connection *connection, char const *packet,
	int packet_size)
{
	int64_t threadid = 0;
	struct linux_os *linux_os = (struct linux_os *)
		target->rtos->rtos_specific_params;
	sscanf(packet, "qThreadExtraInfo,%" SCNx64, &threadid);
	/*LOG_INFO("lookup extra info for thread %" SCNx64, threadid);*/
	struct threads *temp = linux_os->thread_list;

	while (temp != NULL) {
		if (temp->threadid == threadid) {
			char *pid = " PID: ";
			char *pid_current = "*PID: ";
			char *name = "NAME: ";
			int str_size = strlen(pid) + strlen(name);
			char *tmp_str = calloc(1, str_size + 50);
			char *tmp_str_ptr = tmp_str;

			/*  discriminate current task */
			if (temp->status == 3)
				tmp_str_ptr += sprintf(tmp_str_ptr, "%s",
						pid_current);
			else
				tmp_str_ptr += sprintf(tmp_str_ptr, "%s", pid);

			tmp_str_ptr +=
				sprintf(tmp_str_ptr, "%d", (int)temp->pid);
			tmp_str_ptr += sprintf(tmp_str_ptr, "%s", " | ");
			sprintf(tmp_str_ptr, "%s", name);
			sprintf(tmp_str_ptr, "%s", temp->name);
			char *hex_str = calloc(1, strlen(tmp_str) * 2 + 1);
			int pkt_len = hexify(hex_str, tmp_str, 0, strlen(tmp_str) * 2 + 1);
			gdb_put_packet(connection, hex_str, pkt_len);
			free(hex_str);
			free(tmp_str);
			return ERROR_OK;
		}

		temp = temp->next;
	}

	LOG_INFO("thread not found");
	return ERROR_OK;
}
Пример #20
0
void Material::load_data() {
    if (!m_df || !m_df->memory_layout() || !m_df->memory_layout()->is_valid()) {
        LOGW << "load of materials called but we're not connected";
        return;
    }
    // make sure our reference is up to date to the active memory layout
    m_mem = m_df->memory_layout();

    //if passed in an inorganic material, we have to offset to the material.common first
    if(m_inorganic)
        m_address += m_mem->material_offset("inorganic_materials_vector");

    m_flag_address = m_address + m_mem->material_offset("flags");

    TRACE << "Starting refresh of material data at" << hexify(m_address);

    read_material();
}
Пример #21
0
/* packet j :smp status request */
int gdb_read_smp_packet(struct connection *connection,
		char const *packet, int packet_size)
{
	struct target *target = get_target_from_connection(connection);
	int retval = ERROR_OK;
	if (target->smp) {
		if (strncmp(packet, "jc", 2) == 0) {
			const uint32_t len = sizeof(target->gdb_service->core[0]);
			char hex_buffer[len * 2 + 1];
			char buffer[len];
			buf_set_u32(buffer, 0, len * 8, target->gdb_service->core[0]);
			int pkt_len = hexify(hex_buffer, buffer, sizeof(buffer), sizeof(hex_buffer));

			retval = gdb_put_packet(connection, hex_buffer, pkt_len);
		}
	} else
		retval = gdb_put_packet(connection, "E01", 3);
	return retval;
}
Пример #22
0
static int icdi_usb_write_reg(void *handle, int num, uint32_t val)
{
	int result;
	char cmd[20];

	int cmd_len = snprintf(cmd, sizeof(cmd), "P%x=", num);
	hexify(cmd + cmd_len, (char *)&val, 4, sizeof(cmd));

	result = icdi_send_cmd(handle, cmd);
	if (result != ERROR_OK)
		return result;

	/* check result */
	result = icdi_get_cmd_result(handle);
	if (result != ERROR_OK) {
		LOG_ERROR("register write failed: 0x%x", result);
		return ERROR_FAIL;
	}

	return result;
}
Пример #23
0
/* packet j :smp status request */
int gdb_read_smp_packet(struct connection *connection,
		char *packet, int packet_size)
{
	struct target *target = get_target_from_connection(connection);
	uint32_t len = sizeof(int32_t);
	uint8_t *buffer;
	char *hex_buffer;
	int retval = ERROR_OK;
	if (target->smp) {
		if (strncmp(packet, "jc", 2) == 0) {
			hex_buffer = malloc(len * 2 + 1);
			buffer = (uint8_t *)&target->gdb_service->core[0];
			int pkt_len = hexify(hex_buffer, (char *)buffer, len, len * 2 + 1);

			retval = gdb_put_packet(connection, hex_buffer, pkt_len);
			free(hex_buffer);
		}
	} else
		retval = gdb_put_packet(connection, "E01", 3);
	return retval;
}
Пример #24
0
// Read data into the Device input buffer.
boost::shared_array<boost::uint8_t>
InputDevice::readData(size_t size)
{
    GNASH_REPORT_FUNCTION;

    boost::shared_array<boost::uint8_t> inbuf;

    if (_fd < 0) {
        return inbuf;   // no mouse available
    }

    fd_set fdset;
    FD_ZERO(&fdset);
    FD_SET(_fd, &fdset);
    struct timeval tval;
    tval.tv_sec  = 0;
    tval.tv_usec = 1;
    errno = 0;
    int ret = ::select(_fd+1, &fdset, NULL, NULL, &tval);
    if (ret == 0) {
//            log_debug ("The pipe for fd #%d timed out waiting to read", fd);
        return inbuf;
    } else if (ret == 1) {
        log_debug ("The device for fd #%d is ready", _fd);
    } else {
        log_error("The device has this error: %s", strerror(errno));
        return inbuf;
    }
    
    inbuf.reset(new boost::uint8_t[size]);
    ret = ::read(_fd, inbuf.get(), size);
    if (ret > 0) {
        log_debug("Read %d bytes, %s", ret, hexify(inbuf.get(), ret, false));
    } else {
        inbuf.reset();
    }

    return inbuf;
}   
Пример #25
0
int main(int argc, char** argv)
{
    if (argc != 5)
    {
        std::cerr << "Usage: dl_prove DOCUMENT CHUNKS BLOCK_HASH REVEAL"
            << std::endl;
        return -1;
    }
    const std::string document_filename = argv[1];
    const std::string chunks_str = argv[2];
    const std::string reveal_str = argv[4];
    size_t chunks = 0, reveal = 0;
    try
    {
        chunks = boost::lexical_cast<size_t>(chunks_str);
        reveal = boost::lexical_cast<size_t>(reveal_str);
    }
    catch (const boost::bad_lexical_cast&)
    {
        std::cerr << "dl_start: bad CHUNKS or REVEAL provided." << std::endl;
        return -1;
    }
    const std::string hex = argv[3];
    std::string hash;
    if (!hex_to_hash(hex, hash))
    {
        std::cerr << "dl_prove: not a valid BLOCK_HASH." << std::endl;
        return -1;
    }
    auto result = darkleaks::prove(
        document_filename, chunks, hash, reveal);
    for (const auto row: result)
    {
        std::cout << row.index << " "
            << hexify(row.pubkey) << std::endl;
    }
    return 0;
}
Пример #26
0
int rtos_thread_packet(struct connection *connection, char const *packet, int packet_size)
{
	struct target *target = get_target_from_connection(connection);

	if (strncmp(packet, "qThreadExtraInfo,", 17) == 0) {
		if ((target->rtos != NULL) && (target->rtos->thread_details != NULL) &&
				(target->rtos->thread_count != 0)) {
			threadid_t threadid = 0;
			int found = -1;
			sscanf(packet, "qThreadExtraInfo,%" SCNx64, &threadid);

			if ((target->rtos != NULL) && (target->rtos->thread_details != NULL)) {
				int thread_num;
				for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
					if (target->rtos->thread_details[thread_num].threadid == threadid) {
						if (target->rtos->thread_details[thread_num].exists)
							found = thread_num;
					}
				}
			}
			if (found == -1) {
				gdb_put_packet(connection, "E01", 3);	/* thread not found */
				return ERROR_OK;
			}

			struct thread_detail *detail = &target->rtos->thread_details[found];

			int str_size = 0;
			if (detail->display_str != NULL)
				str_size += strlen(detail->display_str);
			if (detail->thread_name_str != NULL)
				str_size += strlen(detail->thread_name_str);
			if (detail->extra_info_str != NULL)
				str_size += strlen(detail->extra_info_str);

			char *tmp_str = calloc(str_size + 7, sizeof(char));
			char *tmp_str_ptr = tmp_str;

			if (detail->display_str != NULL)
				tmp_str_ptr += sprintf(tmp_str_ptr, "%s", detail->display_str);
			if (detail->thread_name_str != NULL) {
				if (tmp_str_ptr != tmp_str)
					tmp_str_ptr += sprintf(tmp_str_ptr, " : ");
				tmp_str_ptr += sprintf(tmp_str_ptr, "%s", detail->thread_name_str);
			}
			if (detail->extra_info_str != NULL) {
				if (tmp_str_ptr != tmp_str)
					tmp_str_ptr += sprintf(tmp_str_ptr, " : ");
				tmp_str_ptr +=
					sprintf(tmp_str_ptr, " : %s", detail->extra_info_str);
			}

			assert(strlen(tmp_str) ==
				(size_t) (tmp_str_ptr - tmp_str));

			char *hex_str = malloc(strlen(tmp_str) * 2 + 1);
			int pkt_len = hexify(hex_str, tmp_str, 0, strlen(tmp_str) * 2 + 1);

			gdb_put_packet(connection, hex_str, pkt_len);
			free(hex_str);
			free(tmp_str);
			return ERROR_OK;

		}
		gdb_put_packet(connection, "", 0);
		return ERROR_OK;
	} else if (strncmp(packet, "qSymbol", 7) == 0) {
		if (rtos_qsymbol(connection, packet, packet_size) == 1) {
			target->rtos_auto_detect = false;
			target->rtos->type->create(target);
			target->rtos->type->update_threads(target->rtos);
		}
		return ERROR_OK;
	} else if (strncmp(packet, "qfThreadInfo", 12) == 0) {
		int i;
		if (target->rtos != NULL) {
			if (target->rtos->thread_count == 0) {
				gdb_put_packet(connection, "l", 1);
			} else {
				/*thread id are 16 char +1 for ',' */
				char *out_str = malloc(17 * target->rtos->thread_count + 1);
				char *tmp_str = out_str;
				for (i = 0; i < target->rtos->thread_count; i++) {
					tmp_str += sprintf(tmp_str, "%c%016" PRIx64, i == 0 ? 'm' : ',',
										target->rtos->thread_details[i].threadid);
				}
				gdb_put_packet(connection, out_str, strlen(out_str));
				free(out_str);
			}
		} else
			gdb_put_packet(connection, "l", 1);

		return ERROR_OK;
	} else if (strncmp(packet, "qsThreadInfo", 12) == 0) {
		gdb_put_packet(connection, "l", 1);
		return ERROR_OK;
	} else if (strncmp(packet, "qAttached", 9) == 0) {
		gdb_put_packet(connection, "1", 1);
		return ERROR_OK;
	} else if (strncmp(packet, "qOffsets", 8) == 0) {
		char offsets[] = "Text=0;Data=0;Bss=0";
		gdb_put_packet(connection, offsets, sizeof(offsets)-1);
		return ERROR_OK;
	} else if (strncmp(packet, "qCRC:", 5) == 0) {
		/* make sure we check this before "qC" packet below
		 * otherwise it gets incorrectly handled */
		return GDB_THREAD_PACKET_NOT_CONSUMED;
	} else if (strncmp(packet, "qC", 2) == 0) {
		if (target->rtos != NULL) {
			char buffer[19];
			int size;
			size = snprintf(buffer, 19, "QC%016" PRIx64, target->rtos->current_thread);
			gdb_put_packet(connection, buffer, size);
		} else
			gdb_put_packet(connection, "QC0", 3);
		return ERROR_OK;
	} else if (packet[0] == 'T') {	/* Is thread alive? */
		threadid_t threadid;
		int found = -1;
		sscanf(packet, "T%" SCNx64, &threadid);
		if ((target->rtos != NULL) && (target->rtos->thread_details != NULL)) {
			int thread_num;
			for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
				if (target->rtos->thread_details[thread_num].threadid == threadid) {
					if (target->rtos->thread_details[thread_num].exists)
						found = thread_num;
				}
			}
		}
		if (found != -1)
			gdb_put_packet(connection, "OK", 2);	/* thread alive */
		else
			gdb_put_packet(connection, "E01", 3);	/* thread not found */
		return ERROR_OK;
	} else if (packet[0] == 'H') {	/* Set current thread ( 'c' for step and continue, 'g' for
					 * all other operations ) */
		if ((packet[1] == 'g') && (target->rtos != NULL)) {
			sscanf(packet, "Hg%16" SCNx64, &target->rtos->current_threadid);
			LOG_DEBUG("RTOS: GDB requested to set current thread to 0x%" PRIx64 "\r\n",
										target->rtos->current_threadid);
		}
		gdb_put_packet(connection, "OK", 2);
		return ERROR_OK;
	}

	return GDB_THREAD_PACKET_NOT_CONSUMED;
}
Пример #27
0
/* rtos_qsymbol() processes and replies to all qSymbol packets from GDB.
 *
 * GDB sends a qSymbol:: packet (empty address, empty name) to notify
 * that it can now answer qSymbol::hexcodedname queries, to look up symbols.
 *
 * If the qSymbol packet has no address that means GDB did not find the
 * symbol, in which case auto-detect will move on to try the next RTOS.
 *
 * rtos_qsymbol() then calls the next_symbol() helper function, which
 * iterates over symbol names for the current RTOS until it finds the
 * symbol in the received GDB packet, and then returns the next entry
 * in the list of symbols.
 *
 * If GDB replied about the last symbol for the RTOS and the RTOS was
 * specified explicitly, then no further symbol lookup is done. When
 * auto-detecting, the RTOS driver _detect() function must return success.
 *
 * rtos_qsymbol() returns 1 if an RTOS has been detected, or 0 otherwise.
 */
int rtos_qsymbol(struct connection *connection, char const *packet, int packet_size)
{
	int rtos_detected = 0;
	uint64_t addr = 0;
	size_t reply_len;
	char reply[GDB_BUFFER_SIZE], cur_sym[GDB_BUFFER_SIZE / 2] = "";
	symbol_table_elem_t *next_sym = NULL;
	struct target *target = get_target_from_connection(connection);
	struct rtos *os = target->rtos;

	reply_len = sprintf(reply, "OK");

	if (!os)
		goto done;

	/* Decode any symbol name in the packet*/
	int len = unhexify(cur_sym, strchr(packet + 8, ':') + 1, strlen(strchr(packet + 8, ':') + 1));
	cur_sym[len] = 0;

	if ((strcmp(packet, "qSymbol::") != 0) &&               /* GDB is not offering symbol lookup for the first time */
	    (!sscanf(packet, "qSymbol:%" SCNx64 ":", &addr)) && /* GDB did not find an address for a symbol */
	    is_symbol_mandatory(os, cur_sym)) {					/* the symbol is mandatory for this RTOS */

		/* GDB could not find an address for the previous symbol */
		if (!target->rtos_auto_detect) {
			LOG_WARNING("RTOS %s not detected. (GDB could not find symbol \'%s\')", os->type->name, cur_sym);
			goto done;
		} else {
			/* Autodetecting RTOS - try next RTOS */
			if (!rtos_try_next(target)) {
				LOG_WARNING("No RTOS could be auto-detected!");
				goto done;
			}

			/* Next RTOS selected - invalidate current symbol */
			cur_sym[0] = '\x00';
		}
	}
	next_sym = next_symbol(os, cur_sym, addr);

	if (!next_sym->symbol_name) {
		/* No more symbols need looking up */

		if (!target->rtos_auto_detect) {
			rtos_detected = 1;
			goto done;
		}

		if (os->type->detect_rtos(target)) {
			LOG_INFO("Auto-detected RTOS: %s", os->type->name);
			rtos_detected = 1;
			goto done;
		} else {
			LOG_WARNING("No RTOS could be auto-detected!");
			goto done;
		}
	}

	if (8 + (strlen(next_sym->symbol_name) * 2) + 1 > sizeof(reply)) {
		LOG_ERROR("ERROR: RTOS symbol '%s' name is too long for GDB!", next_sym->symbol_name);
		goto done;
	}

	reply_len = snprintf(reply, sizeof(reply), "qSymbol:");
	reply_len += hexify(reply + reply_len, next_sym->symbol_name, 0, sizeof(reply) - reply_len);

done:
	gdb_put_packet(connection, reply, reply_len);
	return rtos_detected;
}
Пример #28
0
void
HTTPRemotingHandler::call(as_object* asCallback, const std::string& methodName,
            const std::vector<as_value>& args, size_t firstArg)
{
    SimpleBuffer buf(32);

    // method name
    buf.appendNetworkShort(methodName.size());
    buf.append(methodName.c_str(), methodName.size());

    // client id (result number) as counted string
    // the convention seems to be / followed by a unique (ascending) number
    std::ostringstream os;
    os << "/";
    // Call number is not used if the callback is undefined
    if (asCallback) {
        os << ++_numCalls; 
    }
    const std::string callNumberString = os.str();

    buf.appendNetworkShort(callNumberString.size());
    buf.append(callNumberString.c_str(), callNumberString.size());

    size_t total_size_offset = buf.size();
    buf.append("\000\000\000\000", 4); // total size to be filled in later

    // encode array of arguments to remote method
    buf.appendByte(amf::STRICT_ARRAY_AMF0);
    buf.appendNetworkLong(args.size() - firstArg);

    // STRICT_ARRAY encoding is allowed for remoting
    amf::Writer w(buf, true);

    for (unsigned int i = firstArg; i < args.size(); ++i)
    {
        const as_value& arg = args[i];
        if (!arg.writeAMF0(w)) {
            log_error("Could not serialize NetConnection.call argument %d",
                    i);
        }
    }

    // Set the "total size" parameter.
    *(reinterpret_cast<uint32_t*>(buf.data() + total_size_offset)) = 
        htonl(buf.size() - 4 - total_size_offset);

#ifdef GNASH_DEBUG_REMOTING
    log_debug(_("NetConnection.call(): encoded args: %s"),
            hexify(buf.data(), buf.size(), false));
#endif

    if (asCallback) {
#ifdef GNASH_DEBUG_REMOTING
        log_debug("calling enqueue with callback");
#endif
        enqueue(buf, callNumberString, asCallback);
    }
    
    else {
#ifdef GNASH_DEBUG_REMOTING
        log_debug("calling enqueue without callback");
#endif
        enqueue(buf);
    }
}
Пример #29
0
bool
HTTPRemotingHandler::advance()
{

#ifdef GNASH_DEBUG_REMOTING
    log_debug("advancing HTTPRemotingHandler");
#endif
    if (_connection) {

#ifdef GNASH_DEBUG_REMOTING
        log_debug("have connection");
#endif

        // Fill last chunk before reading in the next
        size_t toRead = reply.capacity() - reply.size();
        if (! toRead) toRead = NCCALLREPLYCHUNK;

#ifdef GNASH_DEBUG_REMOTING
        log_debug("Attempt to read %d bytes", toRead);
#endif

        // See if we need to allocate more bytes for the next
        // read chunk
        if (reply.capacity() < reply.size() + toRead) {
            // if _connection->size() >= 0, reserve for it, so
            // if HTTP Content-Length response header is correct
            // we'll be allocating only once for all.
            const size_t newCapacity = reply.size() + toRead;

#ifdef GNASH_DEBUG_REMOTING
            log_debug("NetConnection.call: reply buffer capacity (%d) "
                      "is too small to accept next %d bytes of chunk "
                      "(current size is %d). Reserving %d bytes.",
                reply.capacity(), toRead, reply.size(), newCapacity);
#endif

            reply.reserve(newCapacity);

#ifdef GNASH_DEBUG_REMOTING
            log_debug(" after reserve, new capacity is %d", reply.capacity());
#endif
        }

        const int read =
            _connection->readNonBlocking(reply.data() + reply.size(), toRead);

        if (read > 0) {
#ifdef GNASH_DEBUG_REMOTING
            log_debug("read '%1%' bytes: %2%", read, 
                    hexify(reply.data() + reply.size(), read, false));
#endif
            reply.resize(reply.size() + read);
        }

        // There is no way to tell if we have a whole amf reply without
        // parsing everything
        //
        // The reply format has a header field which specifies the
        // number of bytes in the reply, but potlatch sends 0xffffffff
        // and works fine in the proprietary player
        //
        // For now we just wait until we have the full reply.
        //
        // FIXME make this parse on other conditions, including: 1) when
        // the buffer is full, 2) when we have a "length in bytes" value
        // thas is satisfied

        if (_connection->bad()) {
            log_debug("connection is in error condition, calling "
                    "NetConnection.onStatus");
            reply.resize(0);
            reply_start = 0;
            // reset connection before calling the callback
            _connection.reset();

            // This is just a guess, but is better than sending
            // 'undefined'
            _nc.notifyStatus(NetConnection_as::CALL_FAILED);
        }
        else if (_connection->eof()) {

            if (reply.size() > 8) {


#ifdef GNASH_DEBUG_REMOTING
                log_debug("hit eof");
#endif
                boost::uint16_t li;
                const boost::uint8_t *b = reply.data() + reply_start;
                const boost::uint8_t *end = reply.data() + reply.size();
                
                amf::Reader rd(b, end, getGlobal(_nc.owner()));

                // parse header
                b += 2; // skip version indicator and client id

                // NOTE: this looks much like parsing of an OBJECT_AMF0
                boost::int16_t si = readNetworkShort(b);
                b += 2; // number of headers
                uint8_t headers_ok = 1;
                if (si != 0) {

#ifdef GNASH_DEBUG_REMOTING
                    log_debug("NetConnection::call(): amf headers "
                            "section parsing");
#endif
                    as_value tmp;
                    for (size_t i = si; i > 0; --i) {
                        if(b + 2 > end) {
                            headers_ok = 0;
                            break;
                        }
                        si = readNetworkShort(b); b += 2; // name length
                        if(b + si > end) {
                            headers_ok = 0;
                            break;
                        }
                        std::string headerName((char*)b, si); // end-b);
#ifdef GNASH_DEBUG_REMOTING
                        log_debug("Header name %s", headerName);
#endif
                        b += si;
                        if ( b + 5 > end ) {
                            headers_ok = 0;
                            break;
                        }
                        b += 5; // skip past bool and length long
                        if(!rd(tmp)) {
                            headers_ok = 0;
                            break;
                        }
#ifdef GNASH_DEBUG_REMOTING
                        log_debug("Header value %s", tmp);
#endif

                        { // method call for each header
                          // FIXME: it seems to me that the call should happen
                            VM& vm = getVM(_nc.owner());
                            string_table& st = vm.getStringTable();
                            string_table::key key = st.find(headerName);
#ifdef GNASH_DEBUG_REMOTING
                            log_debug("Calling NetConnection.%s(%s)",
                                    headerName, tmp);
#endif
                            callMethod(&_nc.owner(), key, tmp);
                        }
                    }
                }

                if(headers_ok == 1) {

                    si = readNetworkShort(b); b += 2; // number of replies

                    // TODO consider counting number of replies we
                    // actually parse and doing something if it
                    // doesn't match this value (does it matter?
                    if(si > 0) {
                        // parse replies until we get a parse error or we reach the end of the buffer
                        while(b < end) {
                            if(b + 2 > end) break;
                            si = readNetworkShort(b); b += 2; // reply length
                            if(si < 4) { // shorted valid response is '/1/a'
                                log_error("NetConnection::call(): reply message name too short");
                                break;
                            }
                            if(b + si > end) break;

                            // Reply message is: '/id/methodName'

                            int ns = 1; // next slash position
                            while (ns<si-1 && *(b+ns) != '/') ++ns;
                            if ( ns >= si-1 ) {
                                std::string msg(
                                        reinterpret_cast<const char*>(b), si);
                                log_error("NetConnection::call(): invalid "
                                        "reply message name (%s)", msg);
                                break;
                            }

                            std::string id(reinterpret_cast<const char*>(b),
                                    ns);

                            std::string methodName(
                                    reinterpret_cast<const char*>(b+ns+1),
                                    si-ns-1);

                            b += si;

                            // parse past unused string in header
                            if(b + 2 > end) break;
                            si = readNetworkShort(b); b += 2; // reply length
                            if(b + si > end) break;
                            b += si;

                            // this field is supposed to hold the
                            // total number of bytes in the rest of
                            // this particular reply value, but
                            // openstreetmap.org (which works great
                            // in the adobe player) sends
                            // 0xffffffff. So we just ignore it
                            if(b + 4 > end) break;
                            li = readNetworkLong(b); b += 4; // reply length

#ifdef GNASH_DEBUG_REMOTING
                            log_debug("about to parse amf value");
#endif
                            // this updates b to point to the next unparsed byte
                            as_value replyval;
                            if (!rd(replyval)) {
                                log_error("parse amf failed");
                                // this will happen if we get
                                // bogus data, or if the data runs
                                // off the end of the buffer
                                // provided, or if we get data we
                                // don't know how to parse
                                break;
                            }
#ifdef GNASH_DEBUG_REMOTING
                            log_debug("parsed amf");
#endif

                            // update variable to show how much we've parsed
                            reply_start = b - reply.data();

                            // if actionscript specified a callback object,
                            // call it
                            as_object* callback = pop_callback(id);
                            if (callback) {

                                string_table::key methodKey;
                                if ( methodName == "onResult" ) {
                                    methodKey = NSV::PROP_ON_RESULT;
                                }
                                else if (methodName == "onStatus") {
                                    methodKey = NSV::PROP_ON_STATUS;
                                }
                                else {
                                    // NOTE: the pp is known to actually
                                    // invoke the custom method, but with 7
                                    // undefined arguments (?)
                                    log_error("Unsupported HTTP Remoting "
                                            "response callback: '%s' "
                                            "(size %d)", methodName,
                                            methodName.size());
                                    continue;
                                }

#ifdef GNASH_DEBUG_REMOTING
                                log_debug("calling onResult callback");
#endif
                                // FIXME check if above line can fail and we
                                // have to react
                                callMethod(callback, methodKey, replyval);
#ifdef GNASH_DEBUG_REMOTING
                                log_debug("callback called");
#endif
                            } else {
                                log_error("Unknown HTTP Remoting response identifier '%s'", id);
                            }
                        }
                    }
                }
            }
            else
            {
                log_error("Response from remoting service < 8 bytes");
            }

#ifdef GNASH_DEBUG_REMOTING
            log_debug("deleting connection");
#endif
            _connection.reset();
            reply.resize(0);
            reply_start = 0;
        }
    }

    if(!_connection && queued_count > 0) {
//#ifdef GNASH_DEBUG_REMOTING
        log_debug("creating connection");
//#endif
        // set the "number of bodies" header

        (reinterpret_cast<boost::uint16_t*>(_postdata.data() + 4))[0] = htons(queued_count);
        std::string postdata_str(reinterpret_cast<char*>(_postdata.data()), _postdata.size());
#ifdef GNASH_DEBUG_REMOTING
        log_debug("NetConnection.call(): encoded args from %1% calls: %2%", queued_count, hexify(postdata.data(), postdata.size(), false));
#endif
        queued_count = 0;

        // TODO: it might be useful for a Remoting Handler to have a 
        // StreamProvider member
        const StreamProvider& sp =
            getRunResources(_nc.owner()).streamProvider();

        _connection.reset(sp.getStream(_url, postdata_str, _headers).release());

        _postdata.resize(6);
#ifdef GNASH_DEBUG_REMOTING
        log_debug("connection created");
#endif
    }

    if (_connection == 0) {
        // nothing more to do
        return false;
    }

    return true;
}
Пример #30
0
int main(int argc, char *argv[]){
	struct mach_header currentHeader;

	FILE *fp; //edited file pointer
	FILE *fw; //backup file pointer
	char fwName[80];
	char fwPrefix[4] = ".bak"; //app.bak
	
	if(argc < 1){
		printf("Please enter the filename binary: in the format removePIE filename");
		return EXIT_FAILURE;}
	if((fp = fopen(argv[1], "rb+")) == NULL) {
		printf("Error, unable to open file\n");
		return EXIT_FAILURE; }
	//create app.bak filename
	strlcpy(fwName, argv[1], strlen(argv[1])+1);
	strlcat(fwName, fwPrefix, strlen(fwPrefix)+1);
	if((fw = fopen(fwName, "wb")) == NULL){
        return EXIT_FAILURE;}
	
	if((fread(&currentHeader.magic, sizeof(int32_t), 1, fp)) == (int)NULL)
	{printf("Error reading magic constant in file\n");
		return EXIT_FAILURE;}

	if(currentHeader.magic == MH_MAGIC || currentHeader.magic == 0xbebafeca){ //little endian
		printf("loading header\n");
		fseek(fp, 0, SEEK_SET);
		if((fread(&currentHeader, sizeof(currentHeader), 1, fp)) == (int)NULL)
		{
			printf("Error reading MACH-O header");
			return EXIT_FAILURE;
		}
		fseek(fp, 0, SEEK_SET); //set fp back to 0 to get full copy
		printf("\nbacking up application binary...\n");
		fcopy(fp, fw);
		fclose(fw);
		printf("\nbinary backed up to:\t%s\n", fwName);
		printf("\nmach_header:\t");
		hexify((unsigned char *)&currentHeader,sizeof(currentHeader));
		printf("\noriginal flags:\t");
		hexify((unsigned char *)&currentHeader.flags, sizeof(currentHeader.flags));
		printf("\nDisabling ASLR/PIE ...\n");
		currentHeader.flags &= ~MH_PIE;
		printf("new flags:\t");
		hexify((unsigned char *)&currentHeader.flags, sizeof(currentHeader.flags));
		
		fseek(fp, 0, SEEK_SET);
		if((fwrite(&currentHeader, sizeof(char), 28, fp)) == (int)NULL)
		{
			printf("Error writing to application file %s\n",fwName);
		}
		printf("\nASLR has been disabled for %s\n", argv[1]);
		//exit and close memory
		//free(mach_header);
		fclose(fp);
		return EXIT_SUCCESS;
	}
	else if(currentHeader.magic == MH_CIGAM) // big endian
	{
		printf("file is big-endian, not an iOS binary");
		return EXIT_FAILURE;
	}
	else
	{
		printf("File is not a MACH_O binary");
		return EXIT_FAILURE;
	}
	//exit
	return EXIT_FAILURE;
}