Java CryptUnprotectData Windows WiFi Passwords
Java CryptUnprotectData Windows WiFi Passwords
我正在尝试使用应该与cryptUnprotectData()
一起使用的Java在同一台计算机上解密Windows WiFi密码,但是我收到以下错误:
Exception in thread "main" com.sun.jna.platform.win32.Win32Exception: The data is invalid.
at com.sun.jna.platform.win32.Crypt32Util.cryptUnprotectData(Crypt32Util.java:128)
at com.sun.jna.platform.win32.Crypt32Util.cryptUnprotectData(Crypt32Util.java:103)
at com.sun.jna.platform.win32.Crypt32Util.cryptUnprotectData(Crypt32Util.java:90)
我正在使用这个Java代码:
String encryptedWirelessKey = "01000000D08C9DDF0115D1118C7A00C0***TRUNCATED***";
byte[] bytes = Crypt32Util.cryptUnprotectData(encryptedWirelessKey.getBytes(Charset.defaultCharset()));
System.out.println(new String(bytes));
在这里,您可以阅读有关Windows存储WiFi密码的位置的更多信息。为什么当我直接从XML
keyMaterial
标签复制数据时数据无效?我是计算机上的管理员,密码由我的用户帐户提供。
更新:
import com.sun.jna.platform.win32.Crypt32Util;
public class Testing
{
public static void main(String[] arguments) throws Exception
{
String encryptedWirelessKey = "01000000D08C9DDF0115D1118C7A00C0***TRUNCATED***";
byte[] bytes = Crypt32Util.cryptUnprotectData(hexStringToByteArray(encryptedWirelessKey));
System.out.println(new String(bytes));
}
private static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
}
这将引发以下异常:
Exception in thread "main" com.sun.jna.platform.win32.Win32Exception: Key not valid for use in specified state.
at com.sun.jna.platform.win32.Crypt32Util.cryptUnprotectData(Crypt32Util.java:128)
at com.sun.jna.platform.win32.Crypt32Util.cryptUnprotectData(Crypt32Util.java:103)
at com.sun.jna.platform.win32.Crypt32Util.cryptUnprotectData(Crypt32Util.java:90)
这到底是什么意思?缺少权限?
当您应该将十六进制字符串解析为字节时,您正在对十六进制字符串使用getBytes()
。
从以下链接中选择您喜欢的方式。
在 Java 中,如何将十六进制字符串转换为字节[]?
使用 Java 将十六进制转储的字符串表示形式转换为字节数组?
相关文章:
- 无法使用 ESP32 连接家庭 WiFi?
- C++ 两台不同机器之间通过wifi进行套接字通信
- 使用WiFi.h从WiFiClient ESP32获取数据
- 在 Windows 问题上连接到企业 WiFi
- 安卓设备上的原生C++ WiFi P2P 网络是否可行?
- 如何在没有网络的情况下控制NodeMCU,但使用像Qt这样的GUI(通过wifi)?
- 只有 SPIFFS 的第一行在 WiFi.begin() - ESP8266-12E 上工作
- wifi.status(),在AP_Mode运行时返回WL_Disconnected(6)
- 如何将 Wifi.localIP() 转换为字符串并将其存储到外部变量
- Java CryptUnprotectData Windows WiFi Passwords
- 使用 QT 创建器通过树莓派上的 Wifi 执行简单的终端命令
- Arduino WiFi101图书馆-将WiFi和WiFiClient传递给儿童课程
- 使用批处理,如何确定您是否已连接到WiFi网络
- 从wifi始终超时从UDP插座读取
- 在c++(WLANAPI)中获取Windows wifi托管网络设备的ip地址
- Arduino WiFi UDP上传问题
- wifi.Rssi-从char*到uint8_t的转换
- WiFi上的原生C++webrtc客户端降低了视频质量,但对来自chrome的呼叫很好
- 访问作为WiFi侦听器回调成员函数一部分的类的成员
- 通过WiFi从Android向Windows发送/保存图像时数据过多