├── DecryptionUtil.cs
├── FiddlerDecryption.csproj
├── FiddlerDecryption.csproj.user
├── Properties
└── AssemblyInfo.cs
├── README.md
├── RequestDecryption.cs
├── RequestDecryptionFormat.cs
├── ResponseDecryption.cs
├── ResponseDecryptionFormat.cs
└── packages.config
/DecryptionUtil.cs:
--------------------------------------------------------------------------------
1 | using Fiddler;
2 | using System;
3 | using System.Security.Cryptography;
4 | using System.Text;
5 |
6 | namespace Util
7 | {
8 | class DecryptionUtil
9 | {
10 | private static readonly string iv = "替换为自己的iv";
11 | private static readonly string key = "替换为自己的key";
12 | public static string DecryptSDKBody(String bodyContent)
13 | {
14 | return AESDecryption(bodyContent, key, iv);
15 | }
16 |
17 | // AES解密
18 | public static string AESDecryption(string text, string AesKey, string AesIV)
19 | {
20 | try
21 | {
22 | // 16进制数据转换成byte
23 | byte[] encryptedData = HexStrToBytes(text);
24 | Console.WriteLine(encryptedData.Length + "");
25 | RijndaelManaged rijndaelCipher = new RijndaelManaged
26 | {
27 | Key = Encoding.UTF8.GetBytes(AesKey),
28 | IV = Encoding.UTF8.GetBytes(AesIV),
29 | Mode = CipherMode.CBC,
30 | Padding = PaddingMode.None
31 | };
32 | ICryptoTransform transform = rijndaelCipher.CreateDecryptor();
33 | byte[] plainText = transform.TransformFinalBlock(encryptedData, 0, encryptedData.Length);
34 | string result = Encoding.UTF8.GetString(plainText);
35 | FiddlerApplication.Log.LogString(result);
36 | return result;
37 | }
38 | catch (Exception ex)
39 | {
40 | // Console.WriteLine(ex.ToString());
41 | FiddlerApplication.Log.LogString(ex.ToString());
42 | return null;
43 | }
44 | }
45 |
46 | private static byte[] HexStrToBytes(string hexString)
47 | {
48 | hexString = hexString.Replace(" ", "");
49 | if ((hexString.Length % 2) != 0)
50 | hexString += " ";
51 | byte[] returnBytes = new byte[hexString.Length / 2];
52 | for (int i = 0; i < returnBytes.Length; i++)
53 | returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2).Trim(), 16);
54 | return returnBytes;
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/FiddlerDecryption.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {1210036A-18F1-4786-BC4F-C3B2AECDE45B}
8 | Library
9 | Properties
10 | FiddlerDecryption
11 | FiddlerDecryption
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 | C:\Users\zhangjl\AppData\Local\Programs\Fiddler\Fiddler.exe
39 |
40 |
41 | C:\Users\zhangjl\AppData\Local\Programs\Fiddler\Inspectors\Standard.dll
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | copy "$(TargetPath)" "C:\Users\zhangjl\AppData\Local\Programs\Fiddler\Inspectors\$(TargetFilename)"
68 |
69 |
--------------------------------------------------------------------------------
/FiddlerDecryption.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Program
5 |
6 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("FiddlerDecryption")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("FiddlerDecryption")]
13 | [assembly: AssemblyCopyright("Copyright © 2019")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("1210036a-18f1-4786-bc4f-c3b2aecde45b")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 | [assembly: Fiddler.RequiredVersion("4.6.20171.9220")]
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # FiddlerDecryption
2 |
3 | 功能:实时解密接口数据并格式化展示。
4 |
5 | 
6 |
7 | 代码内容:
8 |
9 | * DecryptionUtil.cs:解密方法
10 | * RequestDecryption.cs:请求数据的解密插件
11 | * RequestDecryptionFormat.cs:请求数据的解密&格式化插件
12 | * ResponseDecryption.cs:返回数据的解密插件
13 | * ResponseDecryptionFormat.cs:返回数据的解密&格式化插件
14 |
15 | 如需应用到自己的项目,修改 DecryptionUtil 中的解密算法即可。
16 |
17 | 更多介绍请见[Fiddler 插件开发:数据解密](https://blog.csdn.net/Gdeer/article/details/102756017)。
18 |
--------------------------------------------------------------------------------
/RequestDecryption.cs:
--------------------------------------------------------------------------------
1 | using Fiddler;
2 | using System;
3 | using Standard;
4 | using System.Windows.Forms;
5 | using Util;
6 |
7 | namespace Request
8 | {
9 | public sealed class RequestDecryption : Inspector2, IRequestInspector2, IBaseInspector2
10 | {
11 | private bool mBDirty;
12 | private bool mBReadOnly;
13 | private byte[] mBody;
14 | private HTTPRequestHeaders mRequestHeaders;
15 | private RequestTextViewer mRequestTextViewer;
16 |
17 | public RequestDecryption()
18 | {
19 | mRequestTextViewer = new RequestTextViewer();
20 | }
21 |
22 | public bool bDirty
23 | {
24 | get
25 | {
26 | return mBDirty;
27 | }
28 | }
29 |
30 | public byte[] body
31 | {
32 | get
33 | {
34 | return mBody;
35 | }
36 |
37 | set
38 | {
39 | mBody = value;
40 | byte[] decodedBody = DoDecryption();
41 | if (decodedBody != null)
42 | {
43 | mRequestTextViewer.body = decodedBody;
44 | }
45 | else
46 | {
47 | mRequestTextViewer.body = value;
48 | }
49 | }
50 | }
51 |
52 |
53 | public byte[] DoDecryption()
54 | {
55 | // 将 byte[] 转成字符串
56 | String rawBody = System.Text.Encoding.Default.GetString(mBody);
57 | String showBody = rawBody;
58 | if (!rawBody.Contains("{"))
59 | {
60 | // 需要解密
61 | FiddlerApplication.Log.LogString("rawBody: " + rawBody);
62 | showBody = DecryptionUtil.DecryptSDKBody(rawBody);
63 | }
64 | if (showBody != null)
65 | {
66 | byte[] decodeBody = System.Text.Encoding.UTF8.GetBytes(showBody);
67 | return decodeBody;
68 | }
69 | else
70 | {
71 | Clear();
72 | return null;
73 | }
74 | }
75 |
76 | public bool bReadOnly
77 | {
78 | get
79 | {
80 | return mBReadOnly;
81 | }
82 |
83 | set
84 | {
85 | mBReadOnly = value;
86 | }
87 | }
88 |
89 | public HTTPRequestHeaders headers
90 | {
91 | get
92 | {
93 | FiddlerApplication.Log.LogString("headers get function.");
94 | return mRequestHeaders;
95 | }
96 | set
97 | {
98 | mRequestHeaders = value;
99 |
100 | }
101 |
102 | }
103 |
104 | public override void AddToTab(TabPage o)
105 | {
106 | mRequestTextViewer.AddToTab(o);
107 | o.Text = "Decryption";
108 | }
109 |
110 | public void Clear()
111 | {
112 | mBody = null;
113 | mRequestTextViewer.Clear();
114 | }
115 |
116 | // 在 Tab 上的摆放位置
117 | public override int GetOrder() => 100;
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/RequestDecryptionFormat.cs:
--------------------------------------------------------------------------------
1 | using Fiddler;
2 | using System;
3 | using System.Windows.Forms;
4 | using Standard;
5 | using Util;
6 |
7 | namespace Request
8 | {
9 | public class RequestDecryptionFormat : Inspector2, IRequestInspector2, IBaseInspector2
10 | {
11 | private bool mBDirty;
12 | private bool mBReadOnly;
13 | private byte[] mBody;
14 | private HTTPRequestHeaders mRequestHeaders;
15 | private JSONRequestViewer mJsonRequestViewer;
16 |
17 | public RequestDecryptionFormat()
18 | {
19 | mJsonRequestViewer = new JSONRequestViewer();
20 | }
21 |
22 | public bool bDirty
23 | {
24 | get
25 | {
26 | return mBDirty;
27 | }
28 | }
29 |
30 | public byte[] body
31 | {
32 | get
33 | {
34 | return mJsonRequestViewer.body;
35 | }
36 |
37 | set
38 | {
39 | mBody = value;
40 | byte[] decodedBody = DoDecryption();
41 | if (decodedBody != null)
42 | {
43 | mJsonRequestViewer.body = decodedBody;
44 | }
45 | else
46 | {
47 | mJsonRequestViewer.body = value;
48 | }
49 | }
50 | }
51 |
52 | public byte[] DoDecryption()
53 | {
54 | // 将 byte[] 转成字符串
55 | String rawBoday = System.Text.Encoding.Default.GetString(mBody);
56 | String showBody = rawBoday;
57 | if (!rawBoday.Contains("{"))
58 | {
59 | // 需要解密
60 | FiddlerApplication.Log.LogString("rawBoday: " + rawBoday);
61 | showBody = DecryptionUtil.DecryptSDKBody(rawBoday);
62 | }
63 | if (showBody != null)
64 | {
65 | byte[] decodeBody = System.Text.Encoding.UTF8.GetBytes(showBody);
66 | return decodeBody;
67 | }
68 | else
69 | {
70 | Clear();
71 | return null;
72 | }
73 | }
74 |
75 | public bool bReadOnly
76 | {
77 | get
78 | {
79 | return mBReadOnly;
80 | }
81 |
82 | set
83 | {
84 | mBReadOnly = value;
85 | mJsonRequestViewer.bReadOnly = value;
86 | }
87 | }
88 |
89 | public HTTPRequestHeaders headers
90 | {
91 | get
92 | {
93 | return mRequestHeaders;
94 | }
95 |
96 | set
97 | {
98 |
99 | mRequestHeaders = value;
100 | mJsonRequestViewer.headers = value;
101 | }
102 | }
103 |
104 | public override void AddToTab(TabPage o)
105 | {
106 | mJsonRequestViewer.AddToTab(o);
107 | o.Text = "DecryptionJSON";
108 | }
109 |
110 | public void Clear()
111 | {
112 | mBody = null;
113 | mJsonRequestViewer.Clear();
114 | }
115 |
116 | // 在 Tab 上的摆放位置
117 | public override int GetOrder() => 100;
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/ResponseDecryption.cs:
--------------------------------------------------------------------------------
1 | using Fiddler;
2 | using System;
3 | using Standard;
4 | using System.Windows.Forms;
5 | using Util;
6 |
7 | namespace Response
8 | {
9 | public sealed class ResponseDecryption : Inspector2, IResponseInspector2, IBaseInspector2
10 | {
11 | private bool mBDirty;
12 | private bool mBReadOnly;
13 | private byte[] mBody;
14 | private HTTPResponseHeaders mResponseHeaders;
15 | private ResponseTextViewer mResponseTextViewer;
16 |
17 | public ResponseDecryption()
18 | {
19 | mResponseTextViewer = new ResponseTextViewer();
20 | }
21 |
22 | public bool bDirty
23 | {
24 | get
25 | {
26 | return mBDirty;
27 | }
28 | }
29 |
30 | public byte[] body
31 | {
32 | get
33 | {
34 | return mBody;
35 | }
36 |
37 | set
38 | {
39 | mBody = value;
40 | byte[] decodedBody = DoDecryption();
41 | if (decodedBody != null)
42 | {
43 | mResponseTextViewer.body = decodedBody;
44 | }
45 | else
46 | {
47 | mResponseTextViewer.body = value;
48 | }
49 | }
50 | }
51 |
52 | public byte[] DoDecryption()
53 | {
54 | // 将 byte[] 转成字符串
55 | String rawBody = System.Text.Encoding.Default.GetString(mBody);
56 | String showBody = rawBody;
57 | if (!rawBody.Contains("{"))
58 | {
59 | // 需要解密
60 | FiddlerApplication.Log.LogString("rawBody: " + rawBody);
61 | showBody = DecryptionUtil.DecryptSDKBody(rawBody);
62 | }
63 | if (showBody != null)
64 | {
65 | byte[] decodeBody = System.Text.Encoding.UTF8.GetBytes(showBody);
66 | return decodeBody;
67 | }
68 | else
69 | {
70 | Clear();
71 | return null;
72 | }
73 | }
74 |
75 | public bool bReadOnly
76 | {
77 | get
78 | {
79 | return mBReadOnly;
80 | }
81 |
82 | set
83 | {
84 | mBReadOnly = value;
85 | }
86 | }
87 |
88 | HTTPResponseHeaders IResponseInspector2.headers
89 | {
90 | get
91 | {
92 | FiddlerApplication.Log.LogString("headers get function.");
93 | return mResponseHeaders;
94 | }
95 | set
96 | {
97 | FiddlerApplication.Log.LogString("headers set function.");
98 | mResponseHeaders = value;
99 | }
100 | }
101 |
102 | public override void AddToTab(TabPage o)
103 | {
104 | mResponseTextViewer.AddToTab(o);
105 | o.Text = "Decryption";
106 | }
107 |
108 | public void Clear()
109 | {
110 | mBody = null;
111 | mResponseTextViewer.Clear();
112 | }
113 |
114 | // 在 Tab 上的摆放位置
115 | public override int GetOrder() => 100;
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/ResponseDecryptionFormat.cs:
--------------------------------------------------------------------------------
1 | using Fiddler;
2 | using System;
3 | using System.Windows.Forms;
4 | using Standard;
5 | using Util;
6 |
7 | namespace Response
8 | {
9 | public class ResponseDecryptionFormat : Inspector2, IResponseInspector2, IBaseInspector2
10 | {
11 | private bool mBDirty;
12 | private bool mBReadOnly;
13 | private byte[] mBody;
14 | private HTTPResponseHeaders mResponseHeaders;
15 | private JSONResponseViewer mJsonResponseViewer;
16 |
17 | public ResponseDecryptionFormat()
18 | {
19 | mJsonResponseViewer = new JSONResponseViewer();
20 | }
21 |
22 | public bool bDirty
23 | {
24 | get
25 | {
26 | return mBDirty;
27 | }
28 | }
29 |
30 | public byte[] body
31 | {
32 | get
33 | {
34 | return mJsonResponseViewer.body;
35 | }
36 |
37 | set
38 | {
39 | mBody = value;
40 | byte[] decodedBody = DoDecryption();
41 | if (decodedBody != null)
42 | {
43 | mJsonResponseViewer.body = decodedBody;
44 | }
45 | else
46 | {
47 | mJsonResponseViewer.body = value;
48 | }
49 | }
50 | }
51 |
52 | public byte[] DoDecryption()
53 | {
54 | // 将 byte[] 转成字符串
55 | String rawBody = System.Text.Encoding.Default.GetString(mBody);
56 | String showBody = rawBody;
57 | if (!rawBody.Contains("{"))
58 | {
59 | // 需要解密
60 | FiddlerApplication.Log.LogString("rawBody: " + rawBody);
61 | showBody = DecryptionUtil.DecryptSDKBody(rawBody);
62 | }
63 | if (showBody != null)
64 | {
65 | byte[] decodeBody = System.Text.Encoding.UTF8.GetBytes(showBody);
66 | return decodeBody;
67 | }
68 | else
69 | {
70 | Clear();
71 | return null;
72 | }
73 | }
74 |
75 |
76 | public bool bReadOnly
77 | {
78 | get
79 | {
80 | return mBReadOnly;
81 | }
82 |
83 | set
84 | {
85 | mBReadOnly = value;
86 | mJsonResponseViewer.bReadOnly = value;
87 | }
88 | }
89 |
90 | HTTPResponseHeaders IResponseInspector2.headers
91 | {
92 | get => mResponseHeaders;
93 | set
94 | {
95 | mResponseHeaders = value;
96 | mJsonResponseViewer.headers = value;
97 | }
98 | }
99 |
100 | public override void AddToTab(TabPage o)
101 | {
102 | mJsonResponseViewer.AddToTab(o);
103 | o.Text = "DecryptionJSON";
104 | }
105 |
106 | public void Clear()
107 | {
108 | mBody = null;
109 | mJsonResponseViewer.Clear();
110 | }
111 |
112 | // 在 Tab 上的摆放位置
113 | public override int GetOrder() => 100;
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------