mysql 协议抓包

为了时区

 

服务器抓包:tcpdump -i eth0 tcp and port 3306  -s 0 -w mysql.pcap

数据源:1 ee

 

public class JdbcUtilTcp {

private static final String URL_NO_TIMEZONE="jdbc:mysql://49.235.75.155:3306/mytest?useUnicode=true&characterEncoding=utf-8&useSSL=false";
private static final String USER="root";
private static final String PASSWORD="Sunyumin";

public static void main(String []f) {
select();
}

public static List<Map<String,Object>> select() {
Connection conn = null;
ResultSet rs = null;
List<Map<String,Object>> list = new ArrayList<>();
try{
conn = DriverManager.getConnection(URL_NO_TIMEZONE, USER, PASSWORD);

conn.setAutoCommit(false);

PreparedStatement pstmt = conn.prepareStatement("select * from mytest where id = 1");
rs = pstmt.executeQuery();
ResultSetMetaData md = rs.getMetaData();
int columnCount = md.getColumnCount();
while (rs.next()) {
Map<String,Object> rowData = new HashMap<String,Object>();
for (int i = 1; i <= columnCount; i++) {
rowData.put(md.getColumnLabel(i), rs.getObject(i));
}
list.add(rowData);
}

if(!conn.getAutoCommit())
conn.commit();

System.out.println(list);

} catch (Exception e){
e.printStackTrace();
try {
if(!conn.getAutoCommit())
conn.rollback();
} catch (SQLException e1) {
e1.printStackTrace();
}

}
return list;
}
}

 

 

 

 

 

证明了mysql很可能是文本协议,通篇没有找到明显时区信息

mysql.pcap.zip

注意,tcp包里面sql是明文的,容易被中间人篡改

posted on 2020-04-18 00:32  silyvin  阅读(723)  评论(0编辑  收藏  举报