Windows注册表项HKCU \ Software \ Microsoft \ Windows \ CurrentVersion \ Internet Settings \ Connections包含一个名为DefaultConnectionSettings的二进制值,用于存储有关用户代理配置的所有类型的数据。这些数据的确切格式是什么?
到目前为止,我所能找到的只是this forum post中的内容,这在某些方面并不完整,似乎是错误的。
答案 0 :(得分:5)
我发现这可能对你有帮助!
0. keep this value
1. "00" placeholder
2. "00" placeholder
3. "00" placeholder
4. "xx" increments if changed
5. "xx" increments if 4. is "FF"
6. "00" placeholder
7. "00" placeholder
8. "01"=proxy deaktivated; other value=proxy enabled
9. "00" placeholder
10. "00" placeholder
11. "00" placeholder
12. "xx" length of "proxyserver:port"
13. "00" placeholder
14. "00" placeholder
15. "00" placeholder
"proxyserver:port"
if 'Bypass proxy for local addresses':::
other stuff with unknown length
"<local>"
36 times "00"
if no 'Bypass proxy for local addresses':::
40 times "00"
答案 1 :(得分:4)
您应该使用WinInet的InternetQueryOption()
和InternetSetOption()
函数,而不是直接读取/写入注册表值。
说完,看看这些:
How to set 'automatic configuration script' for a dial-up connection programmatically?
答案 2 :(得分:2)
史蒂文·霍尔(Steven Hall)和扎因·阿里(Zain Ali)的回答确实不错,但并不准确。
我尽力使它尽可能准确,但是如您所知,对没有文档的API进行逆向工程可能会出错:
1. 46
2. 00
3. 00
4. 00
5. Increments when you click the OK button on Lan Settings window
6. Inc overflow of 5
7. Inc overflow of 6
8. Inc overflow of 7
9. Toggle proxy* (This can have different values, read below)
10. 00
11. 00
12. 00
13. Length of server addresses and ports
14. Inc overflow of the length of server addresses and ports
15. Inc overflow of the length of server addresses and ports of above
16. Inc overflow of the length of server addresses and ports of above
17. Server addresses and ports (Omitted if length was 0)
??. Length of Exception addresses / Bypass local
??. Inc overflow of the length of Exception addresses / Bypass local
??. Inc overflow of the length of Exception addresses / Bypass local of above
??. Inc overflow of the length of Exception addresses / Bypass local of above
??. Exception addresses / Bypass local (Omitted if length was 0)
??. Length of Automatic Configuration Script Address and port
??. Inc overflow of the Length of Automatic Configuration Script Address and port
??. Inc overflow of the Length of Automatic Configuration Script Address and port of above
??. Inc overflow of the Length of Automatic Configuration Script Address and port of above
??. Automatic Configuration Script Address and port (Omitted if length was 0)
??. Mysterious 01: It only appears when: Automatically detect settings should be off and settings applied, now tick both Auto detect settings and auto config address (doesn't matter if it's empty). There's no way to get rid of this 01.
??. 31 00's at the end
代理切换二进制文件: 根据值的不同,它可以切换代理服务器,“自动检测设置”和“使用自动配置脚本”复选框。
Disabled
1
5 autoconf
9 autodetect
4 autoconf
8 autodetect
0c (12) autoconf, autodetect
0d (13) autoconf, autodetect
Enabled
2
3
6 autoconf
7 autoconf
0a (10) autodetect
0b (11) autodetect
0e (14) autoconf, autodetect
0f (15) autoconf, autodetect
我想弄清楚所有这一切,因为我正在Github上编写代理管理器AHK脚本,一旦完成,我将在这里共享链接以便您使用。而且,如果我确定剩下的00还是什么,或有其他发现,我将更新此答案。
答案 3 :(得分:1)
4 bytes int: 0x46 or 0x3C (whatever that means)
4 bytes int: counter, increment upon every change
4 bytes int: proxy settings, i.e. a merge of these bits:
0x1 always present
0x2 enable manual proxy
0x4 enable autoconfig
0x8 enable autodetect
4 bytes int: length of proxyServer string (can be 0)
proxyServer string in ASCII (i.e. server:port)
4 bytes int: length of proxyOverrides string (can be 0)
proxyOverrides string in ASCII (domains separated by ;
use <local> for local override)
4 bytes int: length of autoconfigUrl string (can be 0)
autoconfigUrl string in ASCII
4 bytes int: 0x00 or 0x01 (whatever that means)
31 bytes: 0x00 (whatever that means)
答案 4 :(得分:0)
只想扩展Zain Ali的答案(作为答案,因为我没有足够的声誉点来评论),当然,感谢Zain发布了他们所做的信息。当我试图解决剩下的问题时,我帮了大忙。
数字8比仅显示代理被禁用要复杂得多。它还在设置中设置了另外两个复选框。
将数字8设置为&#34; 01&#34;取消选中该框以启用代理,并取消选中该框以自动检测设置&#34;以及使用脚本的框。
将数字8设置为&#34; 0f&#34;但是能够实现一切。
要清楚,第8个字节基本上是设置标志。该字节的最低有效位始终为&#34; 1&#34;据我所知。第二个最低有效位是&#34; 1&#34;如果选中手动代理设置复选框。第三个最低有效位是&#34; 1&#34;如果选中了使用脚本的框,并且您提供了脚本的地址。第四个最低有效位是设置复选框&#34;自动检测设置&#34; (基本上,将这些位设置为1将选中该框,并取消选中它们)
我已经把它设置为&#34; 03&#34;它只启用手动代理
此外,&#34;其他未知长度的东西&#34;长度是已知的,似乎不正确。之后引用的东西是由分号分隔的代理的例外列表。此列表的长度是&#34; proxyserver:port&#34;之后的字节。这与3&#34; 00&#34;的填充相结合,说明了4个字节的差异,根据你的其他内容,这个差异被提到不同。
0. keep this value
1. "00" placeholder
2. "00" placeholder
3. "00" placeholder
4. "xx" increments if changed
5. "xx" increments if 4. is "FF"
6. "00" placeholder
7. "00" placeholder
8. "03"=enable proxy, enable auto detect settings, auto script etc
9. "00" placeholder
10. "00" placeholder
11. "00" placeholder
12. "xx" length of "proxyserver:port"
13. "00" placeholder
14. "00" placeholder
15. "00" placeholder
"proxyserver:port"
"xx" length of proxy exception list
"00" placeholder
"00" placeholder
"00" placeholder
Proxy Exception list delimited by semi-colons (use "<local>" to exclude local addresses)
36 times "00"
我花了很多时间试图弄清楚这一切,所以希望我没有错过任何东西。
我已经创建了一个批处理脚本,您可以在其中提供代理服务器和端口,以及您的异常列表,它将自动创建二进制代码并将其粘贴到需要的注册表中(假设为第8个byte是&#34; 03&#34;)。
将代码更改为仅打印出二进制文件而不是替换整个&#34; reg add&#34;这将是微不足道的。使用&#34; echo%data%&#34;。
另请注意,我在下面提供的脚本正在更改HKLM密钥,因为我使用脚本将机器范围的代理与GPO一起设置。改为HKCU应该解决这个问题。
这可以在这里找到(如果您对批处理很好,请随意使脚本更好,因为我对它并不十分熟悉,我认为它可能会在代码中显示):https://gist.github.com/hallzy/b7dfba5f71c0251f1139f8c531cd7817