这个脚本是我之前在网上无意间找个一个利用tcpdump 抓包工具获取mysql流量,并通过过滤把sql 语句输入。

脚本不是很长,但是效果很好。

#!/bin/bash
#this script used montor mysql network traffic.echo sql
tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | perl -e '
while(<>) { chomp; next if /^[^ ]+[ ]*$/;if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL)/i){if (defined $q) { print "$q\n"; }$q=$_;} else {$_ =~ s/^[ \t]+//; $q.=" $_";}
}'

下面是执行脚本的输出:

SELECT b.id FROM module as a,rights as b where a.id=b.module_id and b.sid='179' and a.pname like 'vip/member_order_manage.php%'
SELECT count(id) as cc,sum(cash) as total from morder_stat_all  where (ymd BETWEEN '1312214400' and '1312336486') and depart_id=5 an
d order_class=2
select id,name from media where symd='0000-00-00'
select id,name from depart where s_flag=' '  and onoff=1 order by sno
select id,name from plank where depart_id=5  and onoff=1 order by no
select id,name from grp where plank_id=0  and onoff=1 order by no
select id,CONCAT(pname,'-',name) as name from pvc order by pname
select id,CONCAT(no,'-',name) as name from local where pvc_id=0 order by no
select id,name from product_breed
select color_name from product_color where id=5
select id,name from product where id = '0'
select * from morder_stat_all  where (ymd BETWEEN '1312214400' and '1312336486') and depart_id=5 and order_class=2 order by ymd DESCLIMIT 0,50
select urlkey from sys_config where id=1
select name from morder where id=7195793
select no,name from staff where id=5061
select product_id,amt,price0 from order_product where order_id = 7195793
select concat_ws('/',name,NULLIF((select color_name as cn from product_color where id=color_id),''),NULLIF((select style_name from p
roduct_style where id=style_id),'')) as name,spec,weight,price from product where id = 16938
select concat_ws('/',name,NULLIF((select color_name as cn from product_color where id=color_id),''),NULLIF((select style_name from p
roduct_style where id=style_id),'')) as name,spec,weight,price from product where id = 19005
select name from morder where id=7195768
select no,name from staff where id=221
select product_id,amt,price0 from order_product where order_id = 7195768
select concat_ws('/',name,NULLIF((select color_name as cn from product_color where id=color_id),''),NULLIF((select style_name from p
roduct_style where id=style_id),'')) as name,spec,weight,price from product where id = 18978
select concat_ws('/',name,NULLIF((select color_name as cn from product_color where id=color_id),''),NULLIF((select style_name from p
roduct_style where id=style_id),'')) as name,spec,weight,price from product where id = 18282
select concat_ws('/',name,NULLIF((select color_name as cn from product_color where id=color_id),''),NULLIF((select style_name from p
roduct_style where id=style_id),'')) as name,spec,weight,price from product where id = 19740

从上面的日志可以看出,脚本的功能还是很强大吧 。

转载于:https://www.cnblogs.com/ylqmf/archive/2012/07/11/2586741.html

利用tcpdump抓取mysql sql语句相关推荐

  1. tcpdump抓取mysql语句

    抓包工具tcpdump的使用,抓取具体的sql语句 [root@test7_chat_api_im ~]# tcpdump -s 0 -l -w - dst 106.75.74.38 and port ...

  2. oracle tcpdump生成bpf,[20140212]linux下使用tcpdump抓取sql语句

    [20140212]linu下使用tcpdump抓取sql语句.txt 我们生产系统问题多多,经常要跟踪用户执行的sql语句,当出现问题时要跟踪比较麻烦,我需要一个快捷的方式"看到" ...

  3. MySQL与PostgreSQL抓取慢sql的方法

    文章目录 1. MySQL中抓取慢SQL 2. PostgreSQL抓取慢SQL 1. MySQL中抓取慢SQL 查看慢查询相关配置 show variables like '%quer%'; slo ...

  4. sqlserver 抓取所有执行语句 SQL语句分析 死锁 抓取

    sqlserver 抓取所有执行语句 SQL语句分析 死锁 抓取 原文:sqlserver 抓取所有执行语句 SQL语句分析 死锁 抓取 在多人开发中最头疼的是人少事多没有时间进行codereview ...

  5. 数据库Mysql——sql语句大全

    注意:练习sql语句之前推荐先安装可视化软件如:SQLyog.Navicat 15 for MySQL 不然就在cmd小黑窗口敲命令练习. 一篇掌握Mysql--sql语句 #注意:sql语句不区分大 ...

  6. python抓取数据包_利用python-pypcap抓取带VLAN标签的数据包方法

    1.背景介绍 在采用通常的socket抓包方式下,操作系统会自动将收到包的VLAN信息剥离,导致上层应用收到的包不会含有VLAN标签信息.而libpcap虽然是基于socket实现抓包,但在收到数据包 ...

  7. 利用wget 抓取 网站网页 包括css背景图片

    利用wget 抓取 网站网页 包括css背景图片 wget是一款非常优秀的http/ftp下载工具,它功能强大,而且几乎所有的unix系统上都有.不过用它来dump比较现代的网站会有一个问题:不支持c ...

  8. 导出mysql sql语句吗_mysql sql语句导入与导出

    mysql sql语句导入与导出 导入: mysql -u root -p 数据库名 如: C:/mysql/bin>mysql -u root -p house < c:/1-1.txt ...

  9. 利用urllib3 抓取博客列表

    利用urllib3 抓取博客列表 分析页面代码 分析正则表达式 完整代码 分析页面代码 从这段代码中可以找到很多规律,例如,每条博客的所有信息都包含在一个 <div> 节点中,这个< ...

最新文章

  1. 【十大经典排序算法】java实现--插入排序(3)
  2. GO 语言websocket编程
  3. 将Java EE与jOOQ结合使用的初学者指南
  4. 逃跑吧少年服务器临时维护中,逃跑吧少年—逃跑吧少年5月30日更新 主动技能解锁...
  5. [读书笔记] 设计模式与游戏完美开发
  6. Python自学——python的常用模块
  7. HTML内置css改变文字效果,CSS+HTML文字效果
  8. ELK下一个配置文件收集多个日志-if根据type类型判断
  9. 表必须要有主键吗_玄关隔断什么材质好?玄关隔断必须要做吗
  10. linux pwm测试程序,DM8168 PWM驱动与测试程序
  11. [禅悟人生]将所学转化成修行
  12. 基于Web的仓库管理系统的设计与实现
  13. git里面的文件怎么删不掉_git如何删除已经提交的文件夹
  14. python you-get库
  15. 刷爆朋友圈,码农月薪七万可以落户北京啦
  16. FOJ 1921 栀子花开 线段树裸题
  17. 香橙派PC Plus电脑开发板制作网络打印服务器
  18. c语言中100m怎么表示,科目三道路驾驶技能和安全文明驾驶常识考试满分分别为100分,成绩分别达到80和90分的为合格。...
  19. C语言之strtok函数
  20. 尚硅谷2020微服务分布式电商项目《谷粒商城》-商品搜索

热门文章

  1. C语言关于static的解析
  2. sublime text使用小技巧
  3. Java填坑系列之SparseArray
  4. 让ie8、ie9支持媒体查询
  5. Spring Cloud Stream 使用延迟消息实现定时任务(RabbitMQ)
  6. 去除桌面图标蓝底的方法步骤
  7. 19、Cocos2dx 3.0游戏开发找小三之Action:流动的水没有形状,漂流的风找不到踪迹、、、...
  8. 浏览器显示XML文档
  9. orcal创建表空间、用户、授权
  10. BGP的各种属性配置