Skip to content

Commit ac5528e

Browse files
Leaks fixed, statsfe2 correctly handled
- Some leaks were fixed in this release, as well as the proxy not stopping while shutting down. - Correctly handling every request. - statsfe2 is correctly handled and redirected
1 parent 3edbb35 commit ac5528e

17 files changed

Lines changed: 126 additions & 116 deletions
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
Release: Default-Release
22
WUProxy related files will be missing.
3+
4+
Files/Folders Index:
5+
N/A
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Windows Registry Editor Version 5.00
2+
3+
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\PendingServiceRegistration\7971f918-a847-4430-9279-4a52d1efe18d]
4+
"ClientApplicationID"="My App"
5+
"RegisterWithAU"=dword:00000001
6+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Set ServiceManager = CreateObject("Microsoft.Update.ServiceManager")
2+
ServiceManager.ClientApplicationID = "My App"
3+
4+
'add the Microsoft Update Service, GUID
5+
Set NewUpdateService = ServiceManager.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
Release: WU-Release
22
WUProxy related files will be present.
3+
4+
Files/Folders Index:
5+
certs: Contains all the tools required to produce a certificate in use with WUProxy.
6+
content: Contains content that is replaced by the proxy.
7+
jmagicproxy.cfg: The configuration file which is ready to use with WUProxy.
8+
mu_optin.reg: A registry file to attempt to Opt-In for Microsoft Update ( it didn't work on Windows XP, and still untested on Windows 2000 )
9+
mu_optin.vbs: A VisualBasic script which will Opt-In for Microsoft Update ( tested on Windows XP, it works )

readme.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ proxy.logging.logsfolder | Represents the folder in which you will find log f
2323
proxy.ssl.enabled | Choose whether or not if SSL will be supported.
2424

2525
3) Known issues
26-
- When gracefully shutting down, the proxy may just not stop.
2726
- A lot of exceptions can be thrown in the console.
2827

2928
4) WUProxy Configuration.
@@ -42,5 +41,5 @@ Windows 2000: If you install the proxy certificate as well as the Microsoft Root
4241
also configure Internet Explorer Proxy AND the System Proxy to point to this proxy, everything will work fine with no modifications.
4342

4443
Windows XP: You need to install this proxy certificate, configure Internet Explorer Proxy AND the System Proxy to point to this proxy
45-
and then configure the WSUS Server locations as https://fe2.update.microsoft.com/v6
44+
and then configure the WSUS Server location as https://fe2.update.microsoft.com/v6 and the status server location as http://statsfe2.update.microsoft.com
4645
The website won't work.

src/io/github/explodingbottle/jmagicproxy/DisabledAlgorithmsWarner.java

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@
1919

2020
import java.io.File;
2121
import java.io.FileInputStream;
22+
import java.io.FileNotFoundException;
2223
import java.io.IOException;
2324
import java.util.Properties;
2425

26+
import io.github.explodingbottle.jmagicproxy.logging.LoggingLevel;
27+
import io.github.explodingbottle.jmagicproxy.logging.ProxyLogger;
28+
2529
/**
2630
* This class is very useful to find issues that may be related to the
2731
* java.security file with disabled algorithms.
@@ -32,20 +36,44 @@
3236
public class DisabledAlgorithmsWarner {
3337

3438
private Properties javaSecurity;
39+
private ProxyLogger logger;
3540

3641
/**
3742
* Gets ready the warner.
3843
*
39-
* @throws IOException if an issue happens to load the file.
4044
*/
41-
public DisabledAlgorithmsWarner() throws IOException {
45+
public DisabledAlgorithmsWarner() {
46+
logger = ProxyMain.getLoggerProvider().createLogger();
4247
javaSecurity = new Properties();
43-
FileInputStream is = new FileInputStream(
44-
new File(new File(new File(System.getProperty("java.home"), "lib"), "security"), "java.security"));
45-
javaSecurity.load(is);
46-
is.close();
48+
FileInputStream is = null;
49+
try {
50+
is = new FileInputStream(
51+
new File(new File(new File(System.getProperty("java.home"), "lib"), "security"), "java.security"));
52+
} catch (FileNotFoundException e) {
53+
logger.log(LoggingLevel.WARN,
54+
"Failed to open the input stream to check java.security. No warnings will be emitted.", e);
55+
}
56+
if (is != null) {
57+
try {
58+
javaSecurity.load(is);
59+
} catch (IOException e) {
60+
logger.log(LoggingLevel.WARN, "Failed to load the properties contained in java.security.", e);
61+
}
62+
try {
63+
is.close();
64+
} catch (IOException e) {
65+
logger.log(LoggingLevel.WARN, "Failed to close the java.security file.", e);
66+
}
67+
}
68+
4769
}
4870

71+
/**
72+
* This function will say if the user must be warned about the
73+
* jdk.tls.disabledAlgorithms property.
74+
*
75+
* @return if the user must be warned about jdk.tls.disabledAlgorithms.
76+
*/
4977
public boolean mustWarn() {
5078
String found = javaSecurity.getProperty("jdk.tls.disabledAlgorithms");
5179
if (found != null && !found.trim().isEmpty())

src/io/github/explodingbottle/jmagicproxy/HardcodedConfig.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
*/
2525
public class HardcodedConfig {
2626

27+
/**
28+
* Preventing this class to be instantiated.
29+
*/
30+
private HardcodedConfig() {
31+
32+
}
33+
2734
/**
2835
* Returns the path to the config file.
2936
*

src/io/github/explodingbottle/jmagicproxy/ProxyMain.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,11 @@ public static void main(String[] args) {
143143
pluginsManager = new PluginsManager(propsProvider.getAsString(PropertyKey.PROXY_PLUGINS));
144144
pluginsManager.loadPlugins();
145145
if (propsProvider.getAsBoolean(PropertyKey.PROXY_SSL_WARN_ALGORITHMS)) {
146-
try {
147-
DisabledAlgorithmsWarner warner = new DisabledAlgorithmsWarner();
148-
if (warner.mustWarn()) {
149-
mainLogger.log(LoggingLevel.WARN,
150-
"The system has detected that algorithms were present in the jdk.tls.disabledAlgorithms property of java.security. "
151-
+ "This will cause issues with SSL and old algorithms.");
152-
}
153-
} catch (IOException e1) {
154-
mainLogger.log(LoggingLevel.WARN, "Failed to check for disabled algorithms.", e1);
146+
DisabledAlgorithmsWarner warner = new DisabledAlgorithmsWarner();
147+
if (warner.mustWarn()) {
148+
mainLogger.log(LoggingLevel.WARN,
149+
"The system has detected that algorithms were present in the jdk.tls.disabledAlgorithms property of java.security. "
150+
+ "This will cause issues with SSL and old algorithms.");
155151
}
156152
}
157153
if (propsProvider.getAsBoolean(PropertyKey.PROXY_SSL_ENABLED)) {

src/io/github/explodingbottle/jmagicproxy/implementation/WUProxy.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public ConnectionDirective onReceiveProxyRequest(HttpRequestHeader request) {
5454
}
5555
logger.log(LoggingLevel.INFO, "Replaced to a fe2 request.");
5656
}
57-
58-
if (request.getHost().toLowerCase().contains("/windowsupdate/v6/shared/js/redirect.js")) {
57+
if (request.getHost().toLowerCase().contains("/windowsupdate/v6/shared/js/redirect.js")
58+
|| request.getHost().toLowerCase().contains("/microsoftupdate/v6/shared/js/redirect.js")) {
5959
logger.log(LoggingLevel.INFO, "Found a redirect.js request.");
6060
File file = new File(ProxyMain.getPropertiesProvider().getAsString(PropertyKey.WUPROXY_REDIRECTJS));
6161
if (file.exists()) {
@@ -73,8 +73,7 @@ public SSLControlDirective onReceiveProxyRequestSSL(SSLControlInformations reque
7373
if (computed.getOutcomingRequest().getHost().toLowerCase().startsWith("/v6/selfupdate/")
7474
&& computed.getHost().equals("fe2.update.microsoft.com")) {
7575
logger.log(LoggingLevel.INFO, "Detected a selfupdate to replace line.");
76-
if (computed.getOutcomingRequest().getHost().toLowerCase()
77-
.contains("/WSUS3/x86/Other/".toLowerCase())) {
76+
if (computed.getOutcomingRequest().getHost().toLowerCase().contains("/WSUS3/x86/Other/".toLowerCase())) {
7877
logger.log(LoggingLevel.INFO, "Using wsus3 special.");
7978
computed.getOutcomingRequest().setHost(computed.getOutcomingRequest().getHost()
8079
.replace("/v6/selfupdate/", "/v11/3/windowsupdate/selfupdate/"));
@@ -88,6 +87,15 @@ public SSLControlDirective onReceiveProxyRequestSSL(SSLControlInformations reque
8887
.replace("/v6/selfupdate/", "/v11/3/legacy/windowsupdate/selfupdate/"));
8988
}
9089
}
90+
if (computed.getOutcomingRequest().getHost().toLowerCase().startsWith("/v6/reportingwebservice/")
91+
&& computed.getHost().equals("fe2.update.microsoft.com")) {
92+
logger.log(LoggingLevel.INFO, "Using statsfe2 special.");
93+
computed.getOutcomingRequest().setHost(computed.getOutcomingRequest().getHost()
94+
.replace("/v6/ReportingWebService/", "/ReportingWebService/"));
95+
computed.setSSL(false);
96+
computed.setHost("statsfe2.update.microsoft.com");
97+
computed.setPort(80);
98+
}
9199
return computed;
92100
}
93101

src/io/github/explodingbottle/jmagicproxy/proxy/ConnectionDirectiveHandler.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ public void openSocket() {
166166
if (directive.isSSL()) {
167167
logger.log(LoggingLevel.INFO, "Opening outgoing socket for " + directive.getHost() + ":"
168168
+ directive.getPort() + " with SSL.");
169-
sslCommunicator = new SSLComunicator(handlerThread.getOutputStream(), this, directive.getHost(), directive.getPort());
169+
sslCommunicator = new SSLComunicator(handlerThread.getOutputStream(), this, directive.getHost(),
170+
directive.getPort());
170171
sslCommunicator.startConnection();
171172

172173
} else {
@@ -234,22 +235,6 @@ public void closeSocket() {
234235
if (sslCommunicator != null) {
235236
sslCommunicator.stopCommunicator();
236237
}
237-
try {
238-
if (inputStream != null) {
239-
inputStream.close();
240-
inputStream = null;
241-
}
242-
} catch (IOException e) {
243-
logger.log(LoggingLevel.WARN, "Failed to close the input stream coming from outside.", e);
244-
}
245-
try {
246-
if (outputStream != null) {
247-
outputStream.close();
248-
outputStream = null;
249-
}
250-
} catch (IOException e) {
251-
logger.log(LoggingLevel.WARN, "Failed to close the output stream coming from outside.", e);
252-
}
253238
try {
254239
if (referenceSocket != null) {
255240
referenceSocket.close();

0 commit comments

Comments
 (0)