Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/core/packetproxy/ListenPortManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void stopIfRunning() throws Exception {
}
if (found == false) {

// System.out.println("## close:"+p);
// Logging.log("## close:"+p);
listen_map.get(p).close();
port.remove();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/core/packetproxy/ProxyHttp.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public byte[] onChunkReceived(byte[] data) throws Exception {
byte[] result = new byte[]{};
synchronized (client_loopback) {
Http http = Http.create(data);
// System.out.println(String.format("%s: %s:%s", http.getMethod(),
// Logging.log(String.format("%s: %s:%s", http.getMethod(),
// http.getServerName(), http.getServerPort()));

if (http.getMethod().equals("CONNECT")) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/core/packetproxy/ProxyXmppSSLForward.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private void skipDataUntilSSLConnectionStarted(Socket client, Socket server) thr
return;
}
String body = new String(ArrayUtils.subarray(buff, 0, len));
// System.out.println("-->" + body);
// Logging.log("-->" + body);
sO.write(buff, 0, len);
}
sleep(1000); // wait 1s
Expand Down Expand Up @@ -121,7 +121,7 @@ private void skipDataUntilSSLConnectionStarted(Socket client, Socket server) thr
return;
}
String body = new String(ArrayUtils.subarray(buff, 0, len2));
// System.out.println("<--" + body);
// Logging.log("<--" + body);
if (body.contains("proceed")) {

finishFlag = true;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/core/packetproxy/Simplex.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ public Integer call() throws Exception {
ret = in.read(input_data);
} catch (SSLException e) {

// System.err.println(String.format("SSLException: %s", e.getMessage()));
// Logging.err(String.format("SSLException: %s", e.getMessage()));
ret = -1; // should be finished
} catch (SocketException e) {

// System.err.println(String.format("SocketException: %s", e.getMessage()));
// Logging.err(String.format("SocketException: %s", e.getMessage()));
ret = -1; // should be finished
}
return ret;
Expand Down Expand Up @@ -279,10 +279,10 @@ public Integer call() throws Exception {
}
} catch (SSLException e) {

// System.err.println(String.format("SSLException: %s", e.getMessage()));
// Logging.err(String.format("SSLException: %s", e.getMessage()));
} catch (SocketException e) {

// System.err.println(String.format("SocketException: %s", e.getMessage()));
// Logging.err(String.format("SocketException: %s", e.getMessage()));
} catch (Exception e) {

errWithStackTrace(e);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/core/packetproxy/common/BinaryBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public class BinaryBuffer {
* try {
* BinaryBuffer a = new BinaryBuffer("hello, world".getBytes());
* a.remove(1, 1);
* System.out.println(a.toString());
* Logging.log(a.toString());
* BinaryBuffer b = new BinaryBuffer("hello, world".getBytes());
* b.insert(1, "aa".getBytes());
* System.out.println(b.toString());
* Logging.log(b.toString());
* BinaryBuffer c = new BinaryBuffer("hello, world".getBytes());
* c.insert(1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".getBytes());
* System.out.println(c.toString());
* Logging.log(c.toString());
* } catch (Exception e) {
* errWithStackTrace(e);
* }
Expand Down Expand Up @@ -90,7 +90,7 @@ public void removeAll() {
}

public void remove(int index, int length) {
// System.out.println(String.format("remove! length: %d", length));
// Logging.log(String.format("remove! length: %d", length));
/*
* データをUTF-8テキストとして扱いたいときは、下記を有効にすること
*/
Expand Down Expand Up @@ -120,8 +120,8 @@ public void remove(int index, int length) {
}

public void insert(int index, byte[] in) throws Exception {
// System.out.println("insert!");
// System.out.println(new Binary(in).toHexString(64).toString());
// Logging.log("insert!");
// Logging.log(new Binary(in).toHexString(64).toString());
if (in == null)
return;
if (data_size + in.length > buffer_capacity) {
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/core/packetproxy/common/CryptUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,19 @@ public static String encryptECB(String padding, byte[] key, byte[] cipherText) t
public static String encryptCBCISO10126(byte [] key, byte [] iv, byte [] input) throws Exception {
Cipher cipher = Cipher.getInstance("AES/CBC/ISO10126Padding");
if( iv != null) {
System.out.println("not null");
Logging.log("not null");
}else{
iv = cipher.getIV();
}
IvParameterSpec ivSpec = new IvParameterSpec(iv);
System.out.println("ivSpec="+ivSpec);
Logging.log("ivSpec="+ivSpec);
SecretKeySpec keySpec = new SecretKeySpec(key, "AES");
System.out.println("keySpec="+keySpec);
Logging.log("keySpec="+keySpec);
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec);
byte[] encrypted = cipher.doFinal(input);
byte[] result = new byte[iv.length+encrypted.length];
System.arraycopy(iv, 0, result, 0, iv.length);
System.out.println("iv="+toHex(iv));
Logging.log("iv="+toHex(iv));
System.arraycopy(encrypted, 0, result, iv.length, encrypted.length);

return toHex(result);
Expand All @@ -151,20 +151,20 @@ public static String encryptCBC(String padding, byte[] key, byte[] iv, byte[] in
Cipher cipher = Cipher.getInstance(style);
if (iv != null) {

// System.out.println("not null");
// Logging.log("not null");
} else {

iv = cipher.getIV();
}
IvParameterSpec ivSpec = new IvParameterSpec(iv);
// System.out.println("ivSpec="+ivSpec);
// Logging.log("ivSpec="+ivSpec);
SecretKeySpec keySpec = new SecretKeySpec(key, "AES");
// System.out.println("keySpec="+keySpec);
// Logging.log("keySpec="+keySpec);
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec);
byte[] encrypted = cipher.doFinal(input);
byte[] result = new byte[iv.length + encrypted.length];
System.arraycopy(iv, 0, result, 0, iv.length);
// System.out.println("iv="+toHex(iv));
// Logging.log("iv="+toHex(iv));
System.arraycopy(encrypted, 0, result, iv.length, encrypted.length);

return toHex(result);
Expand Down Expand Up @@ -198,7 +198,7 @@ public static String decryptCBCISO10126(byte [] key, byte [] input) throws Excep
System.arraycopy(input, 16, cipherByte, 0, input.length-16);
IvParameterSpec ivSpec = new IvParameterSpec(iv);
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
System.out.println(new String(input));
Logging.log(new String(input));
return new String(cipher.doFinal(cipherByte),"UTF-8");

}
Expand All @@ -216,7 +216,7 @@ public static String decryptCBC(String padding, byte[] key, byte[] input) throws
System.arraycopy(input, 16, cipherByte, 0, input.length - 16);
IvParameterSpec ivSpec = new IvParameterSpec(iv);
cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
// System.out.println(new String(input));
// Logging.log(new String(input));
return new String(cipher.doFinal(cipherByte), "UTF-8");
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/core/packetproxy/common/MessagePack.java
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ private int getUnsignedIntegerSize(long n) {
public static String decode(byte[] input_data) throws Exception {
ByteArrayInputStream input = new ByteArrayInputStream(input_data);
Map<String, Object> messages = new TreeMap<>();
// System.out.println("Decode");
// System.out.println(StringUtils.byteToHex(input_data));
// Logging.log("Decode");
// Logging.log(StringUtils.byteToHex(input_data));
decodeData(0, input, messages);
// int useLength = input_data.length - input.available();
ObjectMapper mapper = new ObjectMapper();
Expand All @@ -448,7 +448,7 @@ public static boolean decodeData(int ordinary, ByteArrayInputStream input, Map<S
byte firstByte = (byte) (input.read() & 0xff);
Key key = new Key(firstByte);
Object value = null;
// System.out.println(key + " rest: " + input.available());
// Logging.log(key + " rest: " + input.available());
switch (key.type) {
case Integer : {
if (key.fix) {
Expand Down Expand Up @@ -584,8 +584,8 @@ public static byte[] encode(String input) throws Exception {
});
ByteArrayOutputStream output = new ByteArrayOutputStream();
encodeData(messages, output);
// System.out.println("Encode");
// System.out.println(StringUtils.byteToHex(output.toByteArray()));
// Logging.log("Encode");
// Logging.log(StringUtils.byteToHex(output.toByteArray()));
return output.toByteArray();
}

Expand All @@ -608,7 +608,7 @@ public static void encodeData(Map<String, Object> messages, ByteArrayOutputStrea
boolean fix = Integer.parseInt(keyval[3]) == 1;
key = new Key(type, size, fix);
}
// System.out.println(key);
// Logging.log(key);

switch (key.type) {
case Integer : {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/core/packetproxy/common/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static byte[] hexToByte(byte[] hexa) throws Exception {
throw new Exception(I18nString.get("Length of string is not multiples of 2"));
}

// System.out.println(hex);
// Logging.log(hex);
byte[] bytes = new byte[hex.length() / 2];
for (int index = 0; index < bytes.length; index++) {

Expand Down Expand Up @@ -169,19 +169,19 @@ public static byte[] pseudoBinaryPatternReplace(byte[] input, String regex, Stri

String matched = matcher.group(0);
int from = pseudoString.indexOf(matched);
// System.err.println("Match! : " + pseudoString.length() + " : " + from + " : "
// Logging.err("Match! : " + pseudoString.length() + " : " + from + " : "
// + regex + " : " + pseudoString);
byte[] tmp_result = new byte[matched.length()];
for (int i = 0; i < matched.length(); ++i) {

tmp_result[i] = input[from + i];
}
result.write(input, 0, from);
// System.err.println(result);
// Logging.err(result);
result.write(replace.getBytes(), 0, replace.getBytes().length);
// System.err.println(result);
// Logging.err(result);
result.write(input, from + matched.length(), input.length - (from + matched.length()));
// System.err.println(result);
// Logging.err(result);
}
return result.toByteArray();
}
Expand Down Expand Up @@ -226,7 +226,7 @@ public static byte[] binaryReplace(byte[] input, byte[] pattern, byte[] replace)
int start = 0;
while ((start = binaryFind(input, pattern, start)) > 0) {

// System.out.println("Replace : " + input.length + " : " + start + " : " + new
// Logging.log("Replace : " + input.length + " : " + start + " : " + new
// String(byteToHex(pattern)) + " -> " + new String(byteToHex(replace)));
for (int j = 0; j < replace.length; j++) {

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/core/packetproxy/common/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ private static String[] addRubyPath(String... args) {
for (String s : args) {

cmd_array.add(s);
// System.out.print(s+ " ");
// Logging.log(s+ " ");
}
// System.out.println("");
// Logging.log("");
return cmd_array.toArray(new String[0]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/core/packetproxy/gui/ExtendedTextPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void removeUpdate(DocumentEvent e) {
String removed_string = prev_text_panel.substring(e.getOffset(), e.getOffset() + e.getLength());
prev_text_panel = e.getDocument().getText(0, e.getDocument().getLength());
raw_data.remove(before_removed_string.getBytes().length, removed_string.getBytes().length);
// System.out.println(String.format("remove: <%s> %d %d", removed_string,
// Logging.log(String.format("remove: <%s> %d %d", removed_string,
// removed_string.getBytes().length, e.getLength()));
} catch (Exception e1) {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/core/packetproxy/gui/GUIHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public void tableChanged(TableModelEvent e) {
if (e.getType() == TableModelEvent.INSERT) {

// List<Integer> ids = searchFromRequest("google");
// System.out.println(ids.toString());
// Logging.log(ids.toString());
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/core/packetproxy/gui/GUIHistoryBinary.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public int coloringSearchBinary() {
String str = hex_text.getText();
if (str.length() > 1000000) {

// System.err.println("[Warning] coloringSearchBinary: too long string. Skipping
// Logging.err("[Warning] coloringSearchBinary: too long string. Skipping
// Highlight");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/core/packetproxy/gui/GUIPacket.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class GUIPacket {
// String s = "ABgNBHJfb2sAAAJhbANtc2cAB4NoAmEMYQANCg0KeyJlbXB0eSI6N30=";
// byte[] data = Base64.getDecoder().decode(s.getBytes());
// byte[] result = gui.prettyFormatJSONInRawData(data, "hoge");
// System.out.println(new String(result));
// Logging.log(new String(result));
// } catch (Exception e) {
// errWithStackTrace(e);
// }
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/core/packetproxy/gui/RawTextPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ public void setData(byte[] data) throws Exception {
}

public byte[] getData() {
// System.out.println(raw_data.toString());
// Logging.log(raw_data.toString());
return raw_data.toByteArray();
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/core/packetproxy/http/Http.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ public static Http createWithoutTouchingContentLength(byte[] data) throws Except
* //String test =
* "GET /a/b/c.html?abc=h%20oge HTTP/1.1\r\nHost: www.example.com\r\n\r\nbody";
* String test = "HTTP/1.1 100 Continue\r\n\r\n";
* //System.out.println(test1.length());
* //Logging.log(test1.length());
* //test1 += "POST /aaa/bbb HTTP/1.1";
* //System.out.println(test1.length());
* //Logging.log(test1.length());
* Http http = new Http(test1.getBytes());
* byte[] body = http.getBody();
* util.packetProxyLog(new String(body));
Expand All @@ -106,10 +106,10 @@ public static Http createWithoutTouchingContentLength(byte[] data) throws Except
*
* http.getBodyParamsOrder().stream().forEach(s ->
* util.packetProxyLog((map.get(s).toString())));
* // System.out.println("-----");
* // System.out.println(new String(http.toByteArray()));
* // System.out.println(parseHttpDelimiter(test1.getBytes()));
* // System.out.println(new String(http.toByteArray()));
* // Logging.log("-----");
* // Logging.log(new String(http.toByteArray()));
* // Logging.log(parseHttpDelimiter(test1.getBytes()));
* // Logging.log(new String(http.toByteArray()));
*
* } catch (Exception e) {
* errWithStackTrace(e);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/core/packetproxy/http/Https.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public static SSLSocket[] createBothSideSSLSockets(Socket clientSocket, InputStr
/* case: ALPN is not supported */
if (serverSSLSocket[0] == null) {

// System.out.println("ALPN is not supported: " + serverName);
// Logging.log("ALPN is not supported: " + serverName);
Socket serverSocket;
if (proxyAddr != null) {

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/core/packetproxy/http2/FlowControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public synchronized Stream dequeue(int connectionWindowSize) throws Exception {
// 最初にheadersFrameを送信する
if (!this.headersFrameSent && this.headersFrame != null) {

// System.out.printf("[%d] HeadersFrame sent!\n", streamId);
// Logging.log("[%d] HeadersFrame sent!\n", streamId);
stream.write(this.headersFrame);
this.headersFrameSent = true;
return stream;
Expand All @@ -94,7 +94,7 @@ public synchronized Stream dequeue(int connectionWindowSize) throws Exception {
if (this.headersFrameSent && (this.dataFrameSent || queue.size() == 0) && !this.grpcHeadersFrameSent
&& this.grpcHeaderFrame != null) {

// System.out.printf("[%d] gRPC HeadersFrame sent!\n", streamId);
// Logging.log("[%d] gRPC HeadersFrame sent!\n", streamId);
stream.write(this.grpcHeaderFrame);
this.grpcHeadersFrameSent = true;
return stream;
Expand Down Expand Up @@ -165,7 +165,7 @@ public synchronized Stream dequeue(int connectionWindowSize) throws Exception {
// データの送信が終わっていたら、grpcヘッダを送信する
if (this.headersFrameSent && this.dataFrameSent && !this.grpcHeadersFrameSent && this.grpcHeaderFrame != null) {

// System.out.printf("[%d] gRPC HeadersFrame sent!\n", streamId);
// Logging.log("[%d] gRPC HeadersFrame sent!\n", streamId);
stream.write(this.grpcHeaderFrame);
this.grpcHeadersFrameSent = true;
}
Expand Down
Loading