Skip to content

Commit 3edbb35

Browse files
Initial commit
1 parent 20b6d7c commit 3edbb35

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+4509
-0
lines changed

.classpath

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
4+
<classpathentry kind="src" path="src"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>JMagicProxy</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

.settings/org.eclipse.jdt.core.prefs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.release=disabled
12+
org.eclipse.jdt.core.compiler.source=1.8

custom_files/default_release/note.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Release: Default-Release
2+
WUProxy related files will be missing.

custom_files/readme.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
You will find files that will be distributed in the two distinct releases of this proxy.
2+
This folder MUST NOT be in a release.

custom_files/starttool.bat

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@echo off
2+
rem Simple start tool for the proxy.
3+
4+
java -jar jmagicproxy.jar
5+
pause
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@echo off
2+
cd "%~dp0"
3+
copy wupd_certificate.sed_ wupd_certificate.sed
4+
cscript "replacetool.vbs
5+
%WINDIR%\System32\iexpress /N /Q wupd_certificate.sed
6+
%WINDIR%\SysWOW64\iexpress /N /Q wupd_certificate.sed
7+
del wupd_certificate.sed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Set WshShell = WScript.CreateObject("WScript.Shell")
2+
3+
RetCode = WshShell.Run("certutil -addstore -v Root updcert.cer", 0, TRUE)
4+
If RetCode = 0 Then
5+
MsgBox "The certificate has been successfully installed !", vbInformation, "Installation success"
6+
ElseIf RetCode = -2147024156 Then
7+
MsgBox "The certificate installation failed with error " & RetCode & ". Try running the program as administrator to continue." , vbExclamation, "Installation failure"
8+
Else
9+
MsgBox "The certificate installation failed with error " & RetCode & "." , vbExclamation, "Installation failure"
10+
End If
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
2+
Set WshShell = CreateObject("WScript.Shell")
3+
Set oInput = oFSO.OpenTextFile("wupd_certificate.sed", 1)
4+
sData = Replace(oInput.ReadAll, "${SourceFolder}", WshShell.CurrentDirectory)
5+
sData = Replace(sData, "${TargetName}", WshShell.CurrentDirectory & "\wupdcerts_installer.exe")
6+
Set oOutput = oFSO.CreateTextFile("wupd_certificate.sed", True)
7+
oOutput.Write sData
8+
oInput.Close
9+
oOutput.Close
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@echo off
2+
3+
cscript installer.vbs
4+
exit
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[Version]
2+
Class=IEXPRESS
3+
SEDVersion=3
4+
[Options]
5+
PackagePurpose=InstallApp
6+
ShowInstallProgramWindow=1
7+
HideExtractAnimation=0
8+
UseLongFileName=1
9+
InsideCompressed=0
10+
CAB_FixedSize=0
11+
CAB_ResvCodeSigning=0
12+
RebootMode=I
13+
InstallPrompt=%InstallPrompt%
14+
DisplayLicense=%DisplayLicense%
15+
FinishMessage=%FinishMessage%
16+
TargetName=%TargetName%
17+
FriendlyName=%FriendlyName%
18+
AppLaunched=%AppLaunched%
19+
PostInstallCmd=%PostInstallCmd%
20+
AdminQuietInstCmd=%AdminQuietInstCmd%
21+
UserQuietInstCmd=%UserQuietInstCmd%
22+
SourceFiles=SourceFiles
23+
[Strings]
24+
TargetName=${TargetName}
25+
InstallPrompt=Are you sure that you want to install the certificate ? This may constitute a securiy risk as this certificate will be used to intercept secured connections.
26+
DisplayLicense=
27+
FinishMessage=
28+
FriendlyName=Windows Update Certificate Installer
29+
AppLaunched=start.cmd
30+
PostInstallCmd=<None>
31+
AdminQuietInstCmd=
32+
UserQuietInstCmd=
33+
FILE0="installer.vbs"
34+
FILE1="start.cmd"
35+
FILE2="updcert.cer"
36+
[SourceFiles]
37+
SourceFiles0=${SourceFolder}
38+
[SourceFiles0]
39+
%FILE0%=
40+
%FILE1%=
41+
%FILE2%=
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@echo off
2+
3+
set JRE_HOME="C:\Program Files\Java\jre1.8.0_351"
4+
5+
%JRE_HOME%\bin\keytool -genkeypair -alias WUHTTP -keysize 2048 -keyalg RSA -startdate "2010/12/03 16:33:48" -validity 9999 -keystore updks.jks -keypass WindowsUpdate -storepass WindowsUpdate -ext "san=DNS:*.microsoft.com,DNS:*.windowsupdate.com,DNS:*.update.microsoft.com" -ext "ExtendedkeyUsage=serverAuth" -ext "BC:critical=ca:false" -ext "KeyUsage:critical=digitalSignature,nonRepudiation,keyEncipherment,dataEncipherment" -sigalg SHA1WithRSA -dname "CN=update.microsoft.com, OU=Fake, O=Fake Certificator, C=France"
6+
%JRE_HOME%\bin\keytool -importkeystore -srckeystore updks.jks -destkeystore updks.p12 -deststoretype pkcs12 -srcstorepass WindowsUpdate -deststorepass WindowsUpdate
7+
%JRE_HOME%\bin\keytool -exportcert -keystore updks.p12 -rfc -alias WUHTTP -file iexpress_installer\updcert.cer -storepass WindowsUpdate
8+
9+
pause
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1. Build certificates using makecerts.bat tool. If needed, change the JRE_HOME variable to match the real JRE home.
2+
2. Go in iexpress_installer and run build.bat.
3+
4+
The file wupdcerts_installer.exe is ready to be launched on a client machine.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("redirect.js disabled by JMagicProxy.");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#JMagicProxy Configuration File
2+
#Sun Feb 12 16:36:19 CET 2023
3+
proxy.ssl.keystoretype=pkcs12
4+
proxy.plugins=io.github.explodingbottle.jmagicproxy.implementation.WUProxy;io.github.explodingbottle.jmagicproxy.implementation.BasicProxy
5+
proxy.ssl.keystorepass=WindowsUpdate
6+
proxy.ssl.warn.algorithms=true
7+
proxy.ssl.keystorepath=certs/updks.p12
8+
proxy.server.port=8087
9+
proxy.logging.logfile=log&$LNUM$.txt
10+
proxy.plugin.wuproxy.redirectjs=content/redirect.js
11+
proxy.ssl.scan.startingport=9784
12+
proxy.logging.logsfolder=logs
13+
proxy.ssl.enabled=true

custom_files/wuproxy_release/note.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Release: WU-Release
2+
WUProxy related files will be present.

readme.txt

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
JMagicProxy
2+
===============
3+
This proxy consists in a system which allows HTTP and HTTPS requests to be modified.
4+
5+
1) Command line arguments
6+
-help | Displays the help.
7+
-override-config:<cfg> | Overrides the path to the configuration file which is jmagicproxy.cfg by default.
8+
9+
2) Configuration file
10+
proxy.ssl.keystoretype | Represents the type of the keystore ( pkcs12 by default )
11+
proxy.plugins | Represents the list of plugins to modify requests. Multiple plugins can be used with a semicolon
12+
Example: io.github.explodingbottle.jmagicproxy.implementation.WUProxy;io.github.explodingbottle.jmagicproxy.implementation.BasicProxy
13+
The plugin which is at the left will be the most priority, and the one at the right will be the less priority one.
14+
proxy.ssl.keystorepass | Represents the password to access the keystore.
15+
proxy.ssl.warn.algorithms | Choose whether or not you must be warned if the java.security file disables some algorithms.
16+
proxy.ssl.keystorepath | Where to find the keystore file.
17+
proxy.server.port | Represents the proxy port for both HTTP and HTTPS.
18+
proxy.logging.logfile | Represents the naming of log files.
19+
&$LNUM$ is a placeholder that can be used and denotes the current milliseconds.
20+
proxy.plugin.wuproxy.redirectjs | A setting specific for WUProxy: Where can we find a replaced version of redirect.js
21+
proxy.ssl.scan.startingport | Represents what is the first port to scan to find where a SSL Server Socket can be created on the local machine.
22+
proxy.logging.logsfolder | Represents the folder in which you will find log files.
23+
proxy.ssl.enabled | Choose whether or not if SSL will be supported.
24+
25+
3) Known issues
26+
- When gracefully shutting down, the proxy may just not stop.
27+
- A lot of exceptions can be thrown in the console.
28+
29+
4) WUProxy Configuration.
30+
IMPORTANT: Some files may be missing if you download the standard release.
31+
32+
To allow Windows Update to be used, you must change the property proxy.plugins to
33+
io.github.explodingbottle.jmagicproxy.implementation.WUProxy;io.github.explodingbottle.jmagicproxy.implementation.BasicProxy
34+
in order to allow the WUProxy plugin impact requests.
35+
Next, you must set proxy.plugin.wuproxy.redirectjs to where you can find a replaced redirect.js ( very important as it allows you to access the Windows Update website )
36+
Be sure to generate a certificate using the tools available in the certs folder and to install it as computer account.
37+
38+
Operating System Status:
39+
40+
Windows 2000: If you install the proxy certificate as well as the Microsoft Root Certificate Authority
41+
(it can be extracted from https://fe2.update.microsoft.com/v8/windowsupdate/redir/muv3wuredir.cab), if you
42+
also configure Internet Explorer Proxy AND the System Proxy to point to this proxy, everything will work fine with no modifications.
43+
44+
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
46+
The website won't work.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* JMagic Proxy - A HTTP and HTTPS Proxy
3+
* Copyright (C) 2023 ExplodingBottle
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
package io.github.explodingbottle.jmagicproxy;
19+
20+
import java.util.TreeMap;
21+
22+
/**
23+
* This class is useful to parse arguments from the {@code main} method.
24+
*
25+
* @author ExplodingBottle
26+
*/
27+
public class ArgumentsParser {
28+
29+
private TreeMap<String, String> argsParsed;
30+
31+
/**
32+
* Initiates the parser with the arguments. Arguments will also be parsed while
33+
* constructing.
34+
*
35+
* @param args Arguments provided by the {@code main} method.
36+
*/
37+
public ArgumentsParser(String[] args) {
38+
argsParsed = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
39+
for (String s : args) {
40+
if (s.startsWith("-")) {
41+
String[] split = s.split(":");
42+
String argument = split[0].replaceFirst("-", "");
43+
if (split.length > 1) {
44+
String p2 = "";
45+
for (int i = 1; i < split.length; i++) {
46+
if (i == split.length - 1)
47+
p2 += split[i];
48+
else
49+
p2 += split[i] + ":";
50+
}
51+
argsParsed.put(argument, p2);
52+
} else {
53+
argsParsed.put(argument, "");
54+
}
55+
}
56+
}
57+
}
58+
59+
/**
60+
* Get a parsed arguments by giving its name.
61+
*
62+
* @param argName The name of the argument.
63+
* @return The value of the argument or {@code null}.
64+
*/
65+
public String getArgumentByName(String argName) {
66+
return argsParsed.get(argName);
67+
}
68+
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* JMagic Proxy - A HTTP and HTTPS Proxy
3+
* Copyright (C) 2023 ExplodingBottle
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
package io.github.explodingbottle.jmagicproxy;
19+
20+
import java.io.File;
21+
import java.io.FileInputStream;
22+
import java.io.IOException;
23+
import java.util.Properties;
24+
25+
/**
26+
* This class is very useful to find issues that may be related to the
27+
* java.security file with disabled algorithms.
28+
*
29+
* @author ExplodingBottle
30+
*
31+
*/
32+
public class DisabledAlgorithmsWarner {
33+
34+
private Properties javaSecurity;
35+
36+
/**
37+
* Gets ready the warner.
38+
*
39+
* @throws IOException if an issue happens to load the file.
40+
*/
41+
public DisabledAlgorithmsWarner() throws IOException {
42+
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();
47+
}
48+
49+
public boolean mustWarn() {
50+
String found = javaSecurity.getProperty("jdk.tls.disabledAlgorithms");
51+
if (found != null && !found.trim().isEmpty())
52+
return true;
53+
return false;
54+
}
55+
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* JMagic Proxy - A HTTP and HTTPS Proxy
3+
* Copyright (C) 2023 ExplodingBottle
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
package io.github.explodingbottle.jmagicproxy;
19+
20+
/**
21+
* This class is here to store some hard-coded values, such as config file name.
22+
*
23+
* @author ExplodingBottle
24+
*/
25+
public class HardcodedConfig {
26+
27+
/**
28+
* Returns the path to the config file.
29+
*
30+
* @return The config file name or path.
31+
*/
32+
public static String getConfigFileName() {
33+
return "jmagicproxy.cfg";
34+
}
35+
36+
/**
37+
* Returns the buffer size that will be used everywhere.
38+
*
39+
* @return The buffer size.
40+
*/
41+
public static int returnBufferSize() {
42+
return 16384; // Note: I tried before allowing to change the buffer size but, for example, a
43+
// buffer size of 16 makes cURL not getting the whole content.
44+
}
45+
}

0 commit comments

Comments
 (0)