Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. Buffer dump
  2. buffer.length=167
  3. 00 A7 00 00 06 00 00 00 |........|
  4. 00 00 03 76 00 01 01 05 |...v....|
  5. 01 01 01 01 05 01 01 53 |.......S|
  6. 43 4F 54 54 01 0D 0D 41 |COTT...A|
  7. 55 54 48 5F 54 45 52 4D |UTH_TERM|
  8. 49 4E 41 4C 01 07 07 75 |INAL...u|
  9. 6E 6B 6E 6F 77 6E 00 01 |nknown..|
  10. 0F 0F 41 55 54 48 5F 50 |..AUTH_P|
  11. 52 4F 47 52 41 4D 5F 4E |ROGRAM_N|
  12. 4D 01 10 10 4A 44 42 43 |M...JDBC|
  13. 20 54 68 69 6E 20 43 6C |.Thin.Cl|
  14. 69 65 6E 74 00 01 0C 0C |ient....|
  15. 41 55 54 48 5F 4D 41 43 |AUTH_MAC|
  16. 48 49 4E 45 01 0D 0D 6A |HINE...j|
  17. 64 65 6C 61 76 61 72 2D |delavar-|
  18. 6C 61 70 32 00 01 08 08 |lap2....|
  19. 41 55 54 48 5F 50 49 44 |AUTH_PID|
  20. 01 04 04 31 32 33 34 00 |...1234.|
  21. 01 08 08 41 55 54 48 5F |...AUTH_|
  22. 53 49 44 01 08 08 6A 64 |SID...jd|
  23. 65 6C 61 76 61 72 00 |elavar. |
  24.  
  25. static String dump(byte[] buffer, int offset, int len) {
  26. java.nio.charset.Charset asciiCs = java.nio.charset.Charset.forName("ASCII");
  27. int bytes = 0;
  28. StringBuffer sb = new StringBuffer();
  29. sb.append("Buffer dumpn");
  30. sb.append("buffer.length="+buffer.length+"n");
  31. sb.append("offset ="+offset+"n");
  32. sb.append("len ="+len+"n");
  33.  
  34. java.nio.ByteBuffer buff = java.nio.ByteBuffer.allocate(8);
  35. buff.position(0);
  36. buff.limit(buff.capacity());
  37. int j;
  38. String strTemp;
  39. for ( int i=offset; i<len; i+=8) {
  40. for (j=0; j<8 && bytes<len-1; j++){
  41. bytes = i+j;
  42. strTemp = Integer.toHexString(((int)buffer[bytes])&0xFF);
  43. while(strTemp.length() < 2){ strTemp = "0" + strTemp; }
  44. sb.append(strTemp);
  45. sb.append(" ");
  46. if(buffer[bytes] > 33 && buffer[bytes] < 127)
  47. buff.put(buffer[bytes]);
  48. else
  49. buff.put((byte)'.');
  50. }
  51. while(j <= 7 ) {
  52. sb.append(" ");
  53. j++;
  54. }
  55. sb.append("|");
  56. buff.rewind();
  57. java.nio.CharBuffer cb = asciiCs.decode(buff);
  58. buff.rewind();
  59. sb.append(" "+cb.toString()+ " |n");
  60. }
  61. sb.append("finish dumpn");
  62. return sb.toString();
  63. }
  64. static void dumpStdOut(byte[] buff){
  65. System.out.println(dump(buff,0,buff.length));
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement