Skip to content

Commit 42512c0

Browse files
author
t.isayama
committed
SendToのバグ修正
1 parent 4374676 commit 42512c0

File tree

7 files changed

+122
-119
lines changed

7 files changed

+122
-119
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
netbeans.org-netbeans-modules-javascript2-requirejs.enabled=true
22
release_version_major=2.2
3-
release_version_minor=13.3
3+
release_version_minor=13.4

help/help-ja.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,7 @@ <h3 id="_version">2.9. Version</h3>
20712071
</div>
20722072
<div id="footer">
20732073
<div id="footer-text">
2074-
Last updated 2022-02-23 11:52:09 +0900
2074+
Last updated 2022-05-16 08:12:08 +0900
20752075
</div>
20762076
</div>
20772077
</body>

help/help.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,7 @@ <h3 id="_version">2.9. Version</h3>
20972097
</div>
20982098
<div id="footer">
20992099
<div id="footer-text">
2100-
Last updated 2022-02-23 11:59:31 +0900
2100+
Last updated 2022-05-16 08:12:08 +0900
21012101
</div>
21022102
</div>
21032103
</body>
Binary file not shown.

release/YaguraExtender-v2.2.jar

-1.95 KB
Binary file not shown.

src/main/java/yagura/model/SendToServer.java

Lines changed: 118 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import extension.helpers.HttpUtil;
1010
import extension.helpers.HttpUtil.DummyOutputStream;
1111
import extension.helpers.StringUtil;
12+
import java.lang.UnsupportedOperationException;
1213
import java.awt.event.ActionEvent;
1314
import java.io.BufferedInputStream;
1415
import java.io.ByteArrayOutputStream;
@@ -78,7 +79,7 @@ protected void sendToServer(IHttpRequestResponse messageInfo) {
7879
Properties prop = getExtendProperty();
7980
String useProxy = prop.getProperty("useProxy", SendToExtend.USE_CUSTOM_PROXY);
8081
if (SendToExtend.USE_CUSTOM_PROXY.equals(useProxy)) {
81-
sendToServerUseJDKClient(messageInfo);
82+
sendToServerUseHttpClient(messageInfo);
8283
} else {
8384
sendToServerUseBurpClient(messageInfo);
8485
}
@@ -131,124 +132,125 @@ public void run() {
131132
}
132133

133134
protected void sendToServerUseJDKClient(IHttpRequestResponse messageInfo) {
134-
Runnable sendTo = new Runnable() {
135-
@Override
136-
public void run() {
137-
String boundary = HttpUtil.generateBoundary();
138-
HttpURLConnection conn = null;
139-
try {
140-
DummyOutputStream dummy = new DummyOutputStream();
141-
outMultipart(boundary, dummy, messageInfo);
142-
int contentLength = dummy.getSize();
143-
144-
URL url = new URL(getTarget()); // 送信先
145-
// 拡張オプションを取得
146-
Properties prop = getExtendProperty();
147-
String proxyProtocol = prop.getProperty("proxyProtocol", Proxy.Type.DIRECT.name());
148-
Proxy proxy = Proxy.NO_PROXY;
149-
if (!Proxy.Type.DIRECT.name().equals(proxyProtocol)) {
150-
String proxyHost = prop.getProperty("proxyHost", "");
151-
if (Proxy.Type.HTTP.name().equals(proxyProtocol)) {
152-
int proxyPort = ConvertUtil.parseIntDefault(prop.getProperty("proxyPort", "8080"), 8080);
153-
SocketAddress addr = new InetSocketAddress(proxyHost, proxyPort);
154-
proxy = new Proxy(Proxy.Type.HTTP, addr);
155-
}
156-
else if (Proxy.Type.SOCKS.name().equals(proxyProtocol)) {
157-
int proxyPort = ConvertUtil.parseIntDefault(prop.getProperty("proxyPort", "1080"), 1080);
158-
SocketAddress addr = new InetSocketAddress(proxyHost, proxyPort);
159-
proxy = new Proxy(Proxy.Type.SOCKS, addr);
160-
}
161-
}
162-
String proxyUser = prop.getProperty("proxyUser", "");
163-
String proxyPasswd = prop.getProperty("proxyPasswd", "");
164-
Authenticator authenticator = new Authenticator() {
165-
@Override
166-
protected PasswordAuthentication getPasswordAuthentication() {
167-
return new PasswordAuthentication(proxyUser, proxyPasswd.toCharArray());
168-
}
169-
};
170-
// if (!proxyUser.isEmpty()) {
171-
Authenticator.setDefault(authenticator);
135+
throw new UnsupportedOperationException();
136+
// Runnable sendTo = new Runnable() {
137+
// @Override
138+
// public void run() {
139+
// String boundary = HttpUtil.generateBoundary();
140+
// HttpURLConnection conn = null;
141+
// try {
142+
// DummyOutputStream dummy = new DummyOutputStream();
143+
// outMultipart(boundary, dummy, messageInfo);
144+
// int contentLength = dummy.getSize();
145+
//
146+
// URL url = new URL(getTarget()); // 送信先
147+
// // 拡張オプションを取得
148+
// Properties prop = getExtendProperty();
149+
// String proxyProtocol = prop.getProperty("proxyProtocol", Proxy.Type.DIRECT.name());
150+
// Proxy proxy = Proxy.NO_PROXY;
151+
// if (!Proxy.Type.DIRECT.name().equals(proxyProtocol)) {
152+
// String proxyHost = prop.getProperty("proxyHost", "");
153+
// if (Proxy.Type.HTTP.name().equals(proxyProtocol)) {
154+
// int proxyPort = ConvertUtil.parseIntDefault(prop.getProperty("proxyPort", "8080"), 8080);
155+
// SocketAddress addr = new InetSocketAddress(proxyHost, proxyPort);
156+
// proxy = new Proxy(Proxy.Type.HTTP, addr);
157+
// }
158+
// else if (Proxy.Type.SOCKS.name().equals(proxyProtocol)) {
159+
// int proxyPort = ConvertUtil.parseIntDefault(prop.getProperty("proxyPort", "1080"), 1080);
160+
// SocketAddress addr = new InetSocketAddress(proxyHost, proxyPort);
161+
// proxy = new Proxy(Proxy.Type.SOCKS, addr);
162+
// }
163+
// }
164+
// String proxyUser = prop.getProperty("proxyUser", "");
165+
// String proxyPasswd = prop.getProperty("proxyPasswd", "");
166+
// Authenticator authenticator = new Authenticator() {
167+
// @Override
168+
// protected PasswordAuthentication getPasswordAuthentication() {
169+
// return new PasswordAuthentication(proxyUser, proxyPasswd.toCharArray());
170+
// }
171+
// };
172+
//// if (!proxyUser.isEmpty()) {
173+
// Authenticator.setDefault(authenticator);
174+
//// }
175+
//// else {
176+
//// Authenticator.setDefault(null);
177+
//// }
178+
//
179+
//// boolean ignoreValidateCertification = ConvertUtil.parseBooleanDefault(prop.getProperty("ignoreValidateCertification", Boolean.TRUE.toString()), false);
180+
//// if (ignoreValidateCertification) {
181+
// HttpUtil.ignoreSocketFactory();
182+
//// }
183+
//
184+
// conn = (HttpURLConnection) url.openConnection(proxy);
185+
// conn.setFixedLengthStreamingMode(contentLength);
186+
// conn.setRequestMethod("POST");
187+
// conn.setDoOutput(true);
188+
// if (!proxyUser.isEmpty() && Proxy.Type.HTTP.name().equals(proxyProtocol)) {
189+
// byte [] basicAuth = Base64.getEncoder().encode(StringUtil.getBytesRaw(String.format("%s:%s", new Object [] {proxyUser, proxyPasswd})));
190+
// conn.setRequestProperty("Authorization", "Basic " + StringUtil.getStringRaw(basicAuth));
172191
// }
173-
// else {
174-
// Authenticator.setDefault(null);
192+
// conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
193+
// conn.connect();
194+
// OutputStream ostm = null;
195+
// try {
196+
// ostm = conn.getOutputStream();
197+
// outMultipart(boundary, ostm, messageInfo);
198+
// } catch (IOException e) {
199+
// fireSendToErrorEvent(new SendToEvent(this, e.getMessage()));
200+
// } catch (Exception e) {
201+
// fireSendToErrorEvent(new SendToEvent(this, e.getMessage()));
202+
// } finally {
203+
// if (ostm != null) {
204+
// ostm.close();
205+
// }
175206
// }
176-
177-
// boolean ignoreValidateCertification = ConvertUtil.parseBooleanDefault(prop.getProperty("ignoreValidateCertification", Boolean.TRUE.toString()), false);
178-
// if (ignoreValidateCertification) {
179-
HttpUtil.ignoreSocketFactory();
207+
//
208+
// InputStream istm = conn.getInputStream();
209+
// ByteArrayOutputStream bostm = new ByteArrayOutputStream();
210+
// try {
211+
// BufferedInputStream bistm = new BufferedInputStream(istm);
212+
// String decodeMessage;
213+
// byte buf[] = new byte[4096];
214+
// int len;
215+
// while ((len = bistm.read(buf)) != -1) {
216+
// bostm.write(buf, 0, len);
217+
// }
218+
// int statusCode = conn.getResponseCode();
219+
// decodeMessage = StringUtil.getBytesRawString(bostm.toByteArray());
220+
// if (statusCode == HttpURLConnection.HTTP_OK) {
221+
// if (decodeMessage.length() == 0) {
222+
// fireSendToCompleteEvent(new SendToEvent(this, "Success[" + statusCode + "]"));
223+
// } else {
224+
// fireSendToWarningEvent(new SendToEvent(this, "Warning[" + statusCode + "]:" + decodeMessage));
225+
// }
226+
// } else {
227+
// // 200以外
228+
// fireSendToErrorEvent(new SendToEvent(this, "Error[" + statusCode + "]:" + decodeMessage));
229+
// }
230+
//
231+
// } catch (IOException e) {
232+
// fireSendToErrorEvent(new SendToEvent(this, "Error[" + e.getClass().getName() + "]:" + e.getMessage()));
233+
// } finally {
234+
// if (istm != null) {
235+
// istm.close();
236+
// }
237+
// if (bostm != null) {
238+
// bostm.close();
239+
// }
180240
// }
181-
182-
conn = (HttpURLConnection) url.openConnection(proxy);
183-
conn.setFixedLengthStreamingMode(contentLength);
184-
conn.setRequestMethod("POST");
185-
conn.setDoOutput(true);
186-
if (!proxyUser.isEmpty() && Proxy.Type.HTTP.name().equals(proxyProtocol)) {
187-
byte [] basicAuth = Base64.getEncoder().encode(StringUtil.getBytesRaw(String.format("%s:%s", new Object [] {proxyUser, proxyPasswd})));
188-
conn.setRequestProperty("Authorization", "Basic " + StringUtil.getStringRaw(basicAuth));
189-
}
190-
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
191-
conn.connect();
192-
OutputStream ostm = null;
193-
try {
194-
ostm = conn.getOutputStream();
195-
outMultipart(boundary, ostm, messageInfo);
196-
} catch (IOException e) {
197-
fireSendToErrorEvent(new SendToEvent(this, e.getMessage()));
198-
} catch (Exception e) {
199-
fireSendToErrorEvent(new SendToEvent(this, e.getMessage()));
200-
} finally {
201-
if (ostm != null) {
202-
ostm.close();
203-
}
204-
}
205-
206-
InputStream istm = conn.getInputStream();
207-
ByteArrayOutputStream bostm = new ByteArrayOutputStream();
208-
try {
209-
BufferedInputStream bistm = new BufferedInputStream(istm);
210-
String decodeMessage;
211-
byte buf[] = new byte[4096];
212-
int len;
213-
while ((len = bistm.read(buf)) != -1) {
214-
bostm.write(buf, 0, len);
215-
}
216-
int statusCode = conn.getResponseCode();
217-
decodeMessage = StringUtil.getBytesRawString(bostm.toByteArray());
218-
if (statusCode == HttpURLConnection.HTTP_OK) {
219-
if (decodeMessage.length() == 0) {
220-
fireSendToCompleteEvent(new SendToEvent(this, "Success[" + statusCode + "]"));
221-
} else {
222-
fireSendToWarningEvent(new SendToEvent(this, "Warning[" + statusCode + "]:" + decodeMessage));
223-
}
224-
} else {
225-
// 200以外
226-
fireSendToErrorEvent(new SendToEvent(this, "Error[" + statusCode + "]:" + decodeMessage));
227-
}
228-
229-
} catch (IOException e) {
230-
fireSendToErrorEvent(new SendToEvent(this, "Error[" + e.getClass().getName() + "]:" + e.getMessage()));
231-
} finally {
232-
if (istm != null) {
233-
istm.close();
234-
}
235-
if (bostm != null) {
236-
bostm.close();
237-
}
238-
}
239-
} catch (IOException ex) {
240-
fireSendToErrorEvent(new SendToEvent(this, "Error[" + ex.getClass().getName() + "]:" + ex.getMessage()));
241-
} catch (Exception ex) {
242-
fireSendToErrorEvent(new SendToEvent(this, "Error[" + ex.getClass().getName() + "]:" + ex.getMessage()));
243-
} finally {
244-
if (conn != null) {
245-
conn.disconnect();
246-
}
247-
}
248-
}
249-
250-
};
251-
this.threadExecutor.submit(sendTo);
241+
// } catch (IOException ex) {
242+
// fireSendToErrorEvent(new SendToEvent(this, "Error[" + ex.getClass().getName() + "]:" + ex.getMessage()));
243+
// } catch (Exception ex) {
244+
// fireSendToErrorEvent(new SendToEvent(this, "Error[" + ex.getClass().getName() + "]:" + ex.getMessage()));
245+
// } finally {
246+
// if (conn != null) {
247+
// conn.disconnect();
248+
// }
249+
// }
250+
// }
251+
//
252+
// };
253+
// this.threadExecutor.submit(sendTo);
252254
}
253255

254256
protected void sendToServerUseHttpClient(IHttpRequestResponse messageInfo) {

src/main/java/yagura/view/SendToServerExtendDlg.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package yagura.view;
22

3+
import burp.BurpExtender;
34
import extension.helpers.ConvertUtil;
45
import extension.helpers.StringUtil;
56
import extension.helpers.SwingUtil;

0 commit comments

Comments
 (0)