Giter Site home page Giter Site logo

COM_STMT_SEND_LONG_DATA about tcpcollect HOT 4 CLOSED

hoterran avatar hoterran commented on July 30, 2024
COM_STMT_SEND_LONG_DATA

from tcpcollect.

Comments (4)

hoterran avatar hoterran commented on July 30, 2024
#include <stdio.h>
#include <mysql.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include "c.h"

int main(int argc, char* argv[])
{
    MYSQL *mysql,*sock;
    MYSQL_ROW row;
    MYSQL_RES *result;

mysql = mysql_init(NULL);
if (!(sock = CONN(0))) {
    fprintf(stderr, "Couldn't connect to engine!\n%s\n\n", mysql_error(mysql));
    perror("");
    exit(1);
}

// simple 
char sql[100] = {};

sprintf(sql, "INSERT INTO blob_test(a, b) VALUE (1, 2)");

mysql_query(sock, sql);

mysql_query(sock, "select * from blob_test");

result = mysql_store_result(mysql);
mysql_free_result(result);

#define INSERT_QUERY "INSERT INTO blob_test(a, b) VALUES(?,?)"

MYSQL_STMT    *stmt;
MYSQL_BIND bind[2];
long       length;
int         int_data = 10;
char        str[100];
int         ret;

stmt = mysql_stmt_init(mysql);

mysql_stmt_prepare(stmt, INSERT_QUERY, strlen(INSERT_QUERY));

memset(bind, 0, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer= (char *)&int_data;
bind[0].is_null= 0;
bind[1].buffer_type= MYSQL_TYPE_BLOB;
bind[1].buffer = (char*)&str;
bind[1].is_null= 0;
mysql_stmt_bind_param(stmt, bind);

ret = mysql_stmt_send_long_data(stmt,1,"MySQL",5);

ret = mysql_stmt_send_long_data(stmt,1," - The most popular Open Source database",40);

mysql_stmt_execute(stmt);

return 0;

}

from tcpcollect.

hoterran avatar hoterran commented on July 30, 2024
T 127.0.0.1:57019 -> 127.0.0.1:3306 [AP]
  28 00 00 00 16 49 4e 53    45 52 54 20 49 4e 54 4f    (....INSERT INTO
  20 62 6c 6f 62 5f 74 65    73 74 28 61 2c 20 62 29     blob_test(a, b)
  20 56 41 4c 55 45 53 28    3f 2c 3f 29                 VALUES(?,?)    

T 127.0.0.1:3306 -> 127.0.0.1:57019 [AP]
  0c 00 00 01 00 01 00 00    00 00 00 02 00 00 00 00    ................
  17 00 00 02 03 64 65 66    00 00 00 01 3f 00 0c 3f    .....def....?..?
  00 00 00 00 00 fd 80 00    00 00 00 17 00 00 03 03    ................
  64 65 66 00 00 00 01 3f    00 0c 3f 00 00 00 00 00    def....?..?.....
  fd 80 00 00 00 00 05 00    00 04 fe 00 00 02 00       ............... 

T 127.0.0.1:57019 -> 127.0.0.1:3306 [AP]
  0c 00 00 00 18 01 00 00    00 01 00 4d 79 53 51 4c    ...........MySQL

T 127.0.0.1:57019 -> 127.0.0.1:3306 [AP]
  2f 00 00 00 18 01 00 00    00 01 00 20 2d 20 54 68    /.......... - Th
  65 20 6d 6f 73 74 20 70    6f 70 75 6c 61 72 20 4f    e most popular O
  70 65 6e 20 53 6f 75 72    63 65 20 64 61 74 61 62    pen Source datab
  61 73 65                                              ase             

T 127.0.0.1:57019 -> 127.0.0.1:3306 [AP]
  14 00 00 00 17 01 00 00    00 00 01 00 00 00 00 01    ................
  03 00 fc 00 0a 00 00 00                               ........        

T 127.0.0.1:3306 -> 127.0.0.1:57019 [AP]
  07 00 00 01 00 01 00 02    00 00 00                   ...........     

from tcpcollect.

hoterran avatar hoterran commented on July 30, 2024

18 is COM_STMT_SEND_LONG_DATA

below sniffering process illustrate, after COM_STMT_SEND_LONG_DATA, that second column data will like NULL type

second column has only column type without data part

03 00 fc 00 0a 00 00 00

from tcpcollect.

hoterran avatar hoterran commented on July 30, 2024

Current method, encounter the COM, we will skip parse_param.

from tcpcollect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.