-SnooPY- Posted February 19, 2019 Posted February 19, 2019 (edited) I accidentally found out that our colleague @jumper created the ImportPatcher tool. Do you think it can be useful in this case, given that _openssl.cp37-win32.pyd is in essence a DLL? Edited February 24, 2019 by -SnooPY-
jumper Posted February 21, 2019 Posted February 21, 2019 [DLL replacements] BCrypt.dll=IPstub.dll [IPstub.dll] BCryptGenRandom=c4
Thomas S. Posted February 21, 2019 Posted February 21, 2019 On 1/28/2019 at 9:35 PM, -SnooPY- said: File "C:\Temp\python-3.7.1\Lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 14, in <module> from cryptography.hazmat.bindings._openssl import ffi, lib ImportError: DLL load failed: The specified module could not be found. At this time I don't know exact what the problem is. I compile a updated version of HTTPSProxy under Python 3.4.4 to a little suite for XP (see my signature) and found that the package "cryptography v2.5" results in this error. So I step back to "cryptography v2.4.2" an it works OK.
heinoganda Posted February 21, 2019 Posted February 21, 2019 19 minutes ago, Thomas S. said: I compile a updated version of HTTPSProxy under Python 3.4.4 to a little suite for XP (see my signature) and found that the package "cryptography v2.5" results in this error. So I step back to "cryptography v2.4.2" an it works OK. In my latest version of HTTPSProxy, I also found the misconduct of the cryptography module version 2.5 (Jan 22, 2019). Yesterday again updated the modules for Python 3.4.4, because the support should end in March 2019. From GitHub I downloaded the cryptography module version 2.5 from the developer side and created it again with the help of "GRMSDK Version 7.1", without success. A test for creating cryptography version 2.4.2 was positive. 1
Thomas S. Posted February 21, 2019 Posted February 21, 2019 Just in this moment I was looking at this post https://github.com/pyca/cryptography/issues/4011#issuecomment-389711206. I think it is a problem with missing OpenSSL libraries which are not in the cryptography package.
heinoganda Posted February 21, 2019 Posted February 21, 2019 (edited) 10 hours ago, Thomas S. said: I think it is a problem with missing OpenSSL libraries which are not in the cryptography package Under "cryptography\hazmat\bindings" in the file "_openssl.pyd" I have no more errors after the exchange from the file from the version 2.4.2 under HTTPSProxy, maybe it helps narrow down the error. Edited February 21, 2019 by heinoganda
-SnooPY- Posted February 21, 2019 Posted February 21, 2019 I dare to offer you the results of my experiments. I just built an empty bcrypt.dll and the error disappeared. However, I have no ideas about replacing missing functions with XP-compatible ones. Can you advise something? This is my first such experience. Sorry if something is wrong. bcrypt.zip
-SnooPY- Posted February 21, 2019 Posted February 21, 2019 (edited) On 2/21/2019 at 1:11 PM, heinoganda said: From GitHub I downloaded the cryptography module version 2.5 from the developer side and created it again with the help of "GRMSDK Version 7.1", without success. Unfortunately, I did not find any instructions at all on how to build "cryptography-2.5" from sources. The only thing I could find was OpenSSL code like this: /* On Windows 7 or higher use BCrypt instead of the legacy CryptoAPI */ # if defined(_MSC_VER) && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0601 # define USE_BCRYPTGENRANDOM # endif # ifdef USE_BCRYPTGENRANDOM # include <bcrypt.h> # pragma comment(lib, "bcrypt.lib") # ifndef STATUS_SUCCESS # define STATUS_SUCCESS ((NTSTATUS)0x00000000L) # endif # else # include <wincrypt.h> But "cryptography-2.5" modules seem to come only in binaries. Edited February 24, 2019 by -SnooPY-
DosFreak Posted February 22, 2019 Posted February 22, 2019 Don't know if this is helpful or not but according to this http://wp.xin.at/archives/4479 you can compile OpenSSL to not rely on Windows bcrypt or CryptAPI using the no-engine switch
hotnuma Posted February 22, 2019 Posted February 22, 2019 From the sources :https://github.com/openssl/openssl/blob/master/crypto/rand/rand_win.c Line 64, if the macro USE_BCRYPTGENRANDOM is defined, the block from line 65 to 77 is built, using BCryptGenRandom. Otherwise, the block from 79 to 115 is built, using CryptAcquireContextW and other functions. Rebuilding OpenSSL should fix that problem but unfortunately, OpenSSL seems to use a horrid build system written in Perl and that makes it not so easy. In a perfect world, it would simply use CMake but we're not in a perfect world.
-SnooPY- Posted February 22, 2019 Posted February 22, 2019 4 hours ago, hotnuma said: From the sources :https://github.com/openssl/openssl/blob/master/crypto/rand/rand_win.c Line 64, if the macro USE_BCRYPTGENRANDOM is defined, the block from line 65 to 77 is built, using BCryptGenRandom. Otherwise, the block from 79 to 115 is built, using CryptAcquireContextW and other functions. By the way, what happens if add the XP-compatible code to the BCryptGenRandom function in the empty bcrypt.dll that I built? /* poll the CryptoAPI PRNG */ if (CryptAcquireContextW(&hProvider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT) != 0) { if (CryptGenRandom(hProvider, bytes_needed, buffer) != 0) bytes = bytes_needed; CryptReleaseContext(hProvider, 0); }
hotnuma Posted February 22, 2019 Posted February 22, 2019 (edited) 27 minutes ago, -SnooPY- said: By the way, what happens if add the XP-compatible code to the BCryptGenRandom function in the empty bcrypt.dll that I built? I'm not sure but It may work. Edited February 22, 2019 by hotnuma
jumper Posted February 23, 2019 Posted February 23, 2019 Sorry for the delay, but here is a new BCrypt.dll I wrote three days ago with a fully functioning BCryptGenRandom: From http://www.geocities.ws/jumper: BCrypt.dll replacement library (with C source) [7z] BCrypt.7z - 4KB (C) BCryptGenRandom calls RtlGenRandom (aka SystemFunction036) as implemented by the KernelEx project. 3
heinoganda Posted February 24, 2019 Posted February 24, 2019 (edited) @jumper I once tested your "BCrypt.dll" on Windows XP with the module "cryptography-2.5" in Python 3.4.4 and HTTPSProxy started with no errors, but crashed on a connection (just closed). But still have HTTPSProxy compiled under Windows XP and tested under Windows 7 where it worked flawlessly. Definitely there is a problem in Windows XP where the system file "BCrypt.dll" does not exist. I assume that here in addition some functions in the "BCrypt.dll" are needed. Thank you for your effort. Update: A check of the files of Crptography 2.5 (_constant_time.pyd, _openssl.pyd and _padding.pyd) with Dependency Walker shows many red functions in the various system files under Windows XP, which is not the case with Crptography 2.4.2. The library "BCrypt.dll" is only part of the many problems. Edited February 24, 2019 by heinoganda
-SnooPY- Posted February 24, 2019 Posted February 24, 2019 (edited) On 2/23/2019 at 6:40 PM, jumper said: BCryptGenRandom calls RtlGenRandom (aka SystemFunction036) as implemented by the KernelEx project. I tested your BCrypt.dll on XP in Python 3.7.1 and it crashed a couple of minutes after launch with the "BEX EventType" error: C:\Temp\ProxHTTPSProxy>python C:\Temp\ProxHTTPSProxy\ProxHTTPSProxy.py ============================================================================ ProxHTTPSProxyMII v1.5 (urllib3/1.24.1) FrontServer : localhost:8079 RearServer : localhost:8081 ParentServer : None Proxomitron : http://localhost:8118 ============================================================================ Thank you so much for the great work. Edited February 24, 2019 by -SnooPY-
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now