Beispiel #1
0
void read_port_list_resp(struct bufferevent* bev, void* args) {
	hoststate_t* state = (hoststate_t*) args;
	log_trace("read-port-list-resp", "%s", state->ip_address_str);

	char replyCode[REPLY_CODE_SIZE];

	RespResult_e res = parse_response(bev, state, replyCode);
	switch (res) {
	case (RESP_INCOMPLETE) :
			log_debug(
								"read-port-list-resp",
								"%s: Partial response",
								state->ip_address_str
			);
			break;
	case (RESP_EXTRA) :
			log_debug(
								"read-port-list-resp",
								"%s: Extra data in buffer",
								state->ip_address_str
			);
			// no break
	case (RESP_FOUND) :
			record_raw_dbuffer(
										state,
										RECKEY_BAD_PORT_LIST_RESP,
										state->itemDBuffer.startPtr,
										state->itemDBuffer.len,
										&state->ctrlDBuffer
			);

			if (
					(is_reply_code(replyCode, FTP_LIST_IN))
					|| (is_reply_code(replyCode, FTP_LIST_IN_ALT))
			) {
				help_port_list_xfer(bev, state);
			}
			else {
				unexpected_reply(
												bev,
												state,
												FAIL_BAD_PORT_LIST_RESP,
												"read-port-list-resp"
				);
			}
			break;
	case (RESP_ERROR) :
			return;
	}
}
Beispiel #2
0
error_t
ftp_conn_get_pasv_addr (struct ftp_conn *conn, struct sockaddr **addr)
{
    int reply;
    const char *txt;
    error_t err = ftp_conn_cmd_reopen (conn, "pasv", 0, &reply, &txt);

    if (! err)
    {
        if (reply == REPLY_PASV_OK)
            err = (*(conn->syshooks.pasv_addr ?: ftp_conn_unix_pasv_addr))
                  (conn, txt, addr);
        else
            err = unexpected_reply (conn, reply, txt, 0);
    }
Beispiel #3
0
void read_port_resp(struct bufferevent* bev, void* args) {
	char replyCode[REPLY_CODE_SIZE];
	hoststate_t* state = (hoststate_t*) args;
	log_trace("read-port-resp", "%s", state->ip_address_str);

	RespResult_e res = parse_response(bev, state, replyCode);
	switch (res) {
	case (RESP_INCOMPLETE) :
			log_debug(
								"read-port-resp",
								"%s: Partial response found",
								state->ip_address_str
			);
			break;

	case (RESP_FOUND) :
			record_raw_dbuffer(state, RECKEY_PORT_RESP, NULL, 0, &state->ctrlDBuffer);

			if (
					(is_reply_code(replyCode, FTP_BAD_PORT_DENY_1))
					|| (is_reply_code(replyCode, FTP_BAD_PORT_DENY_2))
			) {
				log_info(
								"read-port-resp",
								"%s: Destination refused to PORT bounce",
								state->ip_address_str
				);
				if (state->ctrlUsingSec) {
					state->terminationCode = SUCCESS_EXIT;
					snprintf(
									state->terminationDesc,
									MAX_STATIC_BUFFER_SIZE,
									"%s",
									"SUCCESS OK"
					);
					disconnect_pleasant(bev, state);
				}
				else {
					return setup_ending_optional_sec_check(bev, state);
				}
			}
			else if (is_reply_code(replyCode, FTP_BAD_PORT_ALLOW)) {
				log_info(
								"read-port-resp",
								"%s: Destination allowed PORT bounce setup",
								state->ip_address_str
				);
				state->interestMask |= INTEREST_PORT_SETUP_ALLOWED;
				send_port_list(bev, state);
			}
			else {
				unexpected_reply(bev, state, FAIL_UNK_BOUNCE_RESP, "read-port-resp");
			}
			break;

	case (RESP_EXTRA) :
			handle_extra_resp_error(bev, state, "read-port-resp");
			break;

	case (RESP_ERROR) :
			return;
	}
}