Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added cookie tokenizer

  • Loading branch information...
commit 161b005b3e48e14651e04a443be95a59a1b63488 1 parent db80a5d
naturegirl authored
View
33 src/com/BiscuitSpy/cookies/CookieUtils.java
@@ -0,0 +1,33 @@
+package com.BiscuitSpy.cookies;
+
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+public class CookieUtils {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ String cookies = "clid=2mz5s57011708l6h8vrnywmn004a200809080208108; sglst=41z900bf031liw0o0013z0o000td0o0; ipinfo=2mz5s570zik0bggxe0rxzg0mkt72AW553095HF9CevaprgbajCevaprgbaHavirefvgldcevaprgba.rqh0; acs=019020e0f0h0i0j0k0n0o1mz5s57xzt112gxzt112gxzt112gxzt14a2xzt10xzt10xzt10xzt14a2; vstcnt=41z9010r014sr6g127p1002; rdrlst=40428gamz5t8400000004090428tdmz5wf90000000109012aiimz5t8p0000000209022a0amz5t7n000000050905";
+ tokenize(cookies);
+ }
+ /**
+ * Tokenize the cookies string to return Strings for the individual cookies.
+ * @param cookies the string all the cookies from the http COOKIE field.
+ */
+ public static ArrayList<String> tokenize(String cookies) {
+ if (cookies == null || cookies == "")
+ return new ArrayList<String>();
+ String delim = "; ";
+ StringTokenizer st = new StringTokenizer(cookies, delim);
+ ArrayList<String> result = new ArrayList<String>();
+ while (st.hasMoreTokens())
+ result.add(st.nextToken());
+ for (String s : result)
+ System.out.println(s);
+ return result;
+ }
+
+}
View
12 src/com/BiscuitSpy/testing/Example.java
@@ -8,6 +8,7 @@
import org.jnetpcap.packet.PcapPacketHandler;
import org.jnetpcap.protocol.tcpip.Http;
import org.jnetpcap.protocol.tcpip.Tcp;
+import org.jnetpcap.protocol.tcpip.Http.Request;
/**
* Here is the output generated by this example :
@@ -110,13 +111,10 @@ public void nextPacket(PcapPacket packet, String user) {
* at the beginning of http session.
*/
- System.out.printf("http header::%s%n", http);
-
- /*
- * jNetPcap keeps track of frame numbers for us. The number is simply
- * incremented with every packet scanned.
- */
-
+ if (http.hasField(Request.Cookie)) {
+ System.out.println(http.fieldValue(Request.Cookie));
+ System.out.println(http.fieldValue(Request.Referer));
+ }
}
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.