Changeset 1569

Show
Ignore:
Timestamp:
02/25/08 09:23:26 (6 months ago)
Author:
till
Message:

honeytrap
- endian awareness added

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • honeytrap/trunk/src/modules/htm_submitNebula.c

    r1567 r1569  
    182182        unsigned long           cbuf_len; 
    183183        u_char                  *cbuf, response[9]; 
    184         u_int32_t               nonce
    185         u_int16_t               hmac_len
     184        u_int32_t               nonce, len
     185        u_int16_t               hmac_len, hmac_port
    186186        struct sockaddr_in      sock; 
    187187        int                     sock_fd, bytes_read, total_bytes; 
     
    268268                                return(-1); 
    269269                        } 
     270                        nonce = ntohl(nonce); 
    270271                        logmsg(LOG_DEBUG, 1, "SubmitNebula - Nonce received.\n"); 
    271272                } 
     
    286287                return(-1); 
    287288        } 
     289        free(cbuf); 
    288290 
    289291        // send hashed secret 
     
    327329        } 
    328330 
    329         // send port (in host byte order) 
    330         if (write(sock_fd, &(attack->a_conn.l_port), 2) == -1) { 
     331        // send port 
     332        hmac_port = htons(attack->a_conn.l_port); 
     333        if (write(sock_fd, &(hmac_port), 2) == -1) { 
    331334                logmsg(LOG_ERR, 1, "SubmitNebula Error - Writing to socket failed: %m.\n"); 
    332335                close(sock_fd); 
     
    335338 
    336339        // send length of uncompressed attack 
    337         if (write(sock_fd, &(attack->a_conn.payload.size), 4) == -1) { 
     340        len = htonl(attack->a_conn.payload.size); 
     341        if (write(sock_fd, &(len), 4) == -1) { 
    338342                logmsg(LOG_ERR, 1, "SubmitNebula Error - Writing to socket failed: %m.\n"); 
    339343                close(sock_fd); 
     
    364368 
    365369        // send length of compressed attack 
    366         if (write(sock_fd, &cbuf_len, 4) == -1) { 
     370        len = htonl(cbuf_len); 
     371        if (write(sock_fd, &len, 4) == -1) { 
    367372                logmsg(LOG_ERR, 1, "SubmitNebula Error - Writing to socket failed: %m.\n"); 
    368373                close(sock_fd); 
     
    384389        } 
    385390        memcpy(cbuf+cbuf_len, &attack->a_conn.protocol, 1); 
    386         memcpy(cbuf+cbuf_len+1, &attack->a_conn.l_port, 2); 
     391        memcpy(cbuf+cbuf_len+1, &hmac_port, 2); 
    387392 
    388393        if ((sha512sum = hmac(&cbuf, cbuf_len+3)) == NULL) { 
     
    394399 
    395400        // send length of HMAC 
    396         hmac_len = strlen(sha512sum); 
     401        hmac_len = ntohs(strlen(sha512sum)); 
    397402        if (write(sock_fd, &hmac_len, sizeof(hmac_len)) == -1) { 
    398403                logmsg(LOG_ERR, 1, "SubmitNebula Error - Writing to socket failed: %m.\n");