Giter VIP home page Giter VIP logo

straceout-utils's Introduction

straceout-utils

Build Status

A set of tools for working with strace out.

Installation

PHAR

From Source

  • Clone the repository from GitHub
  • Run composer install

TIP: If installing from source, execution entry point is bin/straceout-utils

Features

MySQL Query Results

strace out will include the packets received from MySQL in Client / Server Protocol format. This is not a format that can be read by humans. straceout-utils will process these packets and transform them into a format that is digestable for humans.

Notes

  • You must use the strace -x flag so that the packets are in hex format
  • When capturing the strace use the -s flag to ensure that strings are not truncated. It is not possible to reconstruct the query response if they are.

Example

Obtain the strace

In this example we capture an strace of execution of the script test.php.

$ strace -s 65535 -x -o strace-out.txt php test.php

Review strace-out.txt

You see something like the following in strace-out.txt

sendto(3, "\x2e\x00\x00\x00\x03\x53\x45\x4c\x45\x43\x54\x20\x60\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x60\x2e\x2a\x20\x46\x52\x4f\x4d\x20\x60\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x60", 50, MSG_DONTWAIT, NULL, 0) = 50
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x01\x00\x00\x01\x06\x54\x00\x00\x02\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0a\x77\x65\x62\x73\x69\x74\x65\x5f\x69\x64\x0a\x77\x65\x62\x73\x69\x74\x65\x5f\x69\x64\x0c\x3f\x00\x05\x00\x00\x00\x02\x23\x42\x00\x00\x00\x48\x00\x00\x03\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77", 126, MSG_DONTWAIT, NULL, NULL) = 126
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x04\x63\x6f\x64\x65\x04\x63\x6f\x64\x65\x0c\x21\x00\x60\x00\x00\x00\xfd\x04\x40\x00\x00\x00\x48\x00\x00\x04\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x04\x6e\x61\x6d\x65\x04\x6e\x61\x6d\x65\x0c\x21\x00\xc0\x00\x00\x00\xfd\x00\x00\x00\x00\x00\x54\x00\x00\x05\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0a\x73\x6f\x72\x74\x5f\x6f\x72\x64\x65\x72\x0a\x73\x6f\x72\x74\x5f", 189, MSG_DONTWAIT, NULL, NULL) = 189
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x6f\x72\x64\x65\x72\x0c\x3f\x00\x05\x00\x00\x00\x02\x29\x40\x00\x00\x00\x60\x00\x00\x06\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x10\x64\x65\x66\x61\x75\x6c\x74\x5f\x67\x72\x6f\x75\x70\x5f\x69\x64\x10\x64\x65\x66\x61\x75\x6c\x74\x5f\x67\x72\x6f\x75\x70\x5f\x69\x64\x0c\x3f\x00\x05\x00\x00\x00\x02\x29\x40\x00\x00\x00\x54\x00\x00\x07\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0a\x69\x73\x5f\x64\x65\x66\x61\x75\x6c\x74\x0a\x69\x73\x5f\x64\x65\x66", 189, MSG_DONTWAIT, NULL, NULL) = 189
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x61\x75\x6c\x74\x0c\x3f\x00\x05\x00\x00\x00\x02\x20\x00\x00\x00\x00\x05\x00\x00\x08\xfe\x00\x00\x22\x00\x14\x00\x00\x09\x01\x30\x05\x61\x64\x6d\x69\x6e\x05\x41\x64\x6d\x69\x6e\x01\x30\x01\x30\x01\x30\x1a\x00\x00\x0a\x01\x31\x04\x62\x61\x73\x65\x0c\x4d\x61\x69\x6e\x20\x57\x65\x62\x73\x69\x74\x65\x01\x30\x01\x31\x01\x31\x05\x00\x00\x0b\xfe\x00\x00\x22\x00", 189, MSG_DONTWAIT, NULL, NULL) = 89
sendto(3, "\x25\x00\x00\x00\x03\x53\x48\x4f\x57\x20\x54\x41\x42\x4c\x45\x20\x53\x54\x41\x54\x55\x53\x20\x4c\x49\x4b\x45\x20\x27\x73\x74\x6f\x72\x65\x5f\x67\x72\x6f\x75\x70\x27", 41, MSG_DONTWAIT, NULL, 0) = 41

Process the strace output

straceout-utils writes output to stdout. In this example we sent that to a new text file, named straceout-utils-out

$ straceout-utils process strace-out.txt > straceout-utils-out.txt

Review straceout-utils-out.txt

In straceout-utils-out.txt you see the following:

sendto(3, "\x2e\x00\x00\x00\x03\x53\x45\x4c\x45\x43\x54\x20\x60\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x60\x2e\x2a\x20\x46\x52\x4f\x4d\x20\x60\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x60", 50, MSG_DONTWAIT, NULL, 0) = 50
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x01\x00\x00\x01\x06\x54\x00\x00\x02\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0a\x77\x65\x62\x73\x69\x74\x65\x5f\x69\x64\x0a\x77\x65\x62\x73\x69\x74\x65\x5f\x69\x64\x0c\x3f\x00\x05\x00\x00\x00\x02\x23\x42\x00\x00\x00\x48\x00\x00\x03\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77", 126, MSG_DONTWAIT, NULL, NULL) = 126
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x04\x63\x6f\x64\x65\x04\x63\x6f\x64\x65\x0c\x21\x00\x60\x00\x00\x00\xfd\x04\x40\x00\x00\x00\x48\x00\x00\x04\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x04\x6e\x61\x6d\x65\x04\x6e\x61\x6d\x65\x0c\x21\x00\xc0\x00\x00\x00\xfd\x00\x00\x00\x00\x00\x54\x00\x00\x05\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0a\x73\x6f\x72\x74\x5f\x6f\x72\x64\x65\x72\x0a\x73\x6f\x72\x74\x5f", 189, MSG_DONTWAIT, NULL, NULL) = 189
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x6f\x72\x64\x65\x72\x0c\x3f\x00\x05\x00\x00\x00\x02\x29\x40\x00\x00\x00\x60\x00\x00\x06\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x10\x64\x65\x66\x61\x75\x6c\x74\x5f\x67\x72\x6f\x75\x70\x5f\x69\x64\x10\x64\x65\x66\x61\x75\x6c\x74\x5f\x67\x72\x6f\x75\x70\x5f\x69\x64\x0c\x3f\x00\x05\x00\x00\x00\x02\x29\x40\x00\x00\x00\x54\x00\x00\x07\x03\x64\x65\x66\x10\x6d\x61\x67\x65\x6e\x74\x6f\x5f\x32\x5f\x33\x5f\x34\x5f\x65\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0d\x73\x74\x6f\x72\x65\x5f\x77\x65\x62\x73\x69\x74\x65\x0a\x69\x73\x5f\x64\x65\x66\x61\x75\x6c\x74\x0a\x69\x73\x5f\x64\x65\x66", 189, MSG_DONTWAIT, NULL, NULL) = 189
poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=3, revents=POLLIN}])
recvfrom(3, "\x61\x75\x6c\x74\x0c\x3f\x00\x05\x00\x00\x00\x02\x20\x00\x00\x00\x00\x05\x00\x00\x08\xfe\x00\x00\x22\x00\x14\x00\x00\x09\x01\x30\x05\x61\x64\x6d\x69\x6e\x05\x41\x64\x6d\x69\x6e\x01\x30\x01\x30\x01\x30\x1a\x00\x00\x0a\x01\x31\x04\x62\x61\x73\x65\x0c\x4d\x61\x69\x6e\x20\x57\x65\x62\x73\x69\x74\x65\x01\x30\x01\x31\x01\x31\x05\x00\x00\x0b\xfe\x00\x00\x22\x00", 189, MSG_DONTWAIT, NULL, NULL) = 89
-- Begin -- StraceOutUtils\Processor\MysqlQueryResult
.SELECT `store_website`.* FROM `store_website`
************* 1 *************
website_id: 0
code: admin
name: Admin
sort_order: 0
default_group_id: 0
is_default: 0
************* 2 *************
website_id: 1
code: base
name: Main Website
sort_order: 0
default_group_id: 1
is_default: 1

-- End -- StraceOutUtils\Processor\MysqlQueryResult
sendto(3, "\x25\x00\x00\x00\x03\x53\x48\x4f\x57\x20\x54\x41\x42\x4c\x45\x20\x53\x54\x41\x54\x55\x53\x20\x4c\x49\x4b\x45\x20\x27\x73\x74\x6f\x72\x65\x5f\x67\x72\x6f\x75\x70\x27", 41, MSG_DONTWAIT, NULL, 0) = 41

straceout-utils's People

Contributors

mpchadwick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

straceout-utils's Issues

MysqlQueryResult: Handle recvfrom buffers truncated by strace

Handle cases where recvfrom buffer display is truncated by strace

In this case the buffer will be closed like this:

"...,

If the recvfrom buffer is truncated it will be impossible to reconstruct the query results.

Need to do something about that...

hex2bin(): Hexadecimal input string must have an even length

PHP Warning:  hex2bin(): Hexadecimal input string must have an even length in /home/amk/local-workspace/straceout-utils/src/StraceOutUtils/Processor/MysqlQueryResult.php on line 61
sendto(11, "\x09\x02\x00\x00\x03\x53\x45\x4c\x45\x43\x54\x20\x60\x63\x61\x74\x61\x6c\x6f\x67\x5f\x70\x72\x6f\x64\x75\x63\x74\x5f\x65\x6e\x74"..., 525, MSG_DONTWAIT, NULL, 0) = 525
poll([{fd=11, events=POLLIN|POLLERR|POLLHUP}], 1, 86400000) = 1 ([{fd=11, revents=POLLIN}])
recvfrom(11, "\x01\x00\x00\x01\x07\x74\x00\x00\x02\x03\x64\x65\x66\x0c\x6b\x75\x65\x62\x6c\x65\x72\x5f\x70\x72\x6f\x64\x21\x63\x61\x74\x61\x6c"..., 3129, MSG_DONTWAIT, NULL, NULL) = 888
PHP Warning:  hex2bin(): Hexadecimal input string must have an even length in /home/amk/local-workspace/straceout-utils/src/StraceOutUtils/Processor/MysqlQueryResult/PacketParser.php on line 192
-- Begin -- StraceOutUtils\Processor\MysqlQueryResult

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.