First off, I've seen this.
Decrypt WEP wlan profile key using CryptUnprotectData
My question now is. How do I do this in Java? I have this.
The problem is. The error given is "data is invalid", that is a problem on the dll side.
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.bind.DatatypeConverter;
import net.sourceforge.jdpapi.DataProtector;
public class Decrypt {
public static void main(String[] args) throws IOException {
String pass = "01000000D08C9DDF0115D1118C7A00C04FC297EB0100000035E8D4938EE54841A43D43E96688421A00000000020000000000106600000001000020000000AAD01A6044EC0E4D567D1B31FC0E7A98123514104B311E5CD5A649056EACDA63000000000E8000000002000020000000E38C9631DCD7222D9E20A80341BFC5965CF7C10E61226489317C880D14436DCE10000000437532E63549CB529B8CCAA408CA001840000000ED1F45A9934CCD4F3B06145A6BFFAE41872F03597D4DE4E1B5090B11BF49E7A68A2B61B5B39B8DC3018183066005A6226A144675002ED14143A720DB39B3C437";
loadJarDll("resources/dlls/jdpapi-native-1.0.dll");
DataProtector dp = new DataProtector();
String todecrypt = toBinary(pass);
System.out.println(dp.unprotect(todecrypt.getBytes()));
}
public static void loadJarDll(String name) throws IOException {
InputStream in = Decrypt.class.getResourceAsStream(name);
byte[] buffer = new byte[1024];
int read = -1;
File temp = File.createTempFile(name, "");
temp.deleteOnExit();
FileOutputStream fos = new FileOutputStream(temp);
while((read = in.read(buffer)) != -1) {
fos.write(buffer, 0, read);
}
fos.close();
in.close();
System.load(temp.getAbsolutePath());
}
public static String toBinary(String input){
byte[] bytes = input.getBytes();
StringBuilder binary = new StringBuilder();
for (byte b : bytes)
{
int val = b;
for (int i = 0; i < 8; i++)
{
binary.append((val & 128) == 0 ? 0 : 1);
val <<= 1;
}
binary.append(' ');
}
return binary.toString();
}
}
Any solutions?
Thanks.
Aucun commentaire:
Enregistrer un commentaire