Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile Error: b'' #7

Closed
dlimanov opened this issue Mar 1, 2021 · 19 comments
Closed

Compile Error: b'' #7

dlimanov opened this issue Mar 1, 2021 · 19 comments

Comments

@dlimanov
Copy link

dlimanov commented Mar 1, 2021

Getting the below error on Win10 x64 with latest Python 3.9.2:

python builder.py -s c:\temp\shellcode.bin -p {redacted} -o c:\temp\shellcode.exe
�[36m[i] Key, IV Generation:�[32m Successful�[39m
�[36m [+] Key:�[35m 76a4bdc4d17ef05116bd8c122841aef093e75eb701ff68628ceece84ce37e547�[39m
�[36m [+] IV:�[35m 871b56e90419ec41c0e01fd6bd93a589�[39m
�[36m [+] Salt:�[35m b35a686992959641a2668b9d731c567d�[39m
�[36m[i] Encrypt Shellcode:�[32m Successful�[39m
�[36m[i] Variable Swap:�[32m Successful�[39m
Compile Error: b''

@mrothbart
Copy link

mrothbart commented Mar 2, 2021

this is also true of PoshC2 shellcode. See below.

image

It's possible this has to do with the size of the shellcode. Is there a defined upper limit? Can it be overcome?

@joshfaust
Copy link
Owner

I'm very confident this is due to the sizing issue seen here. I will test it on my end. If either of you (@mrothbart @dlimanov ) could send your shellcode that is throwing this exception, I would greatly appreciate it.

@dlimanov
Copy link
Author

dlimanov commented Mar 3, 2021

I'm using a default Covenant shellcode payload. Let me know what's the best way to send it to you.

@mrothbart
Copy link

Same with default PoshC2 shellcode. I linked the repo in my comment so you can generate it yourself and use the excellent framework. I am of course happy to send it to you as well. What's the best way to send it over?

@joshfaust
Copy link
Owner

joshfaust commented Mar 3, 2021

@mrothbart try: https://github.com/cribdragg3r/Alaris/tree/builder_patch

You will have to pip3 install -r requirements.txt again

I'm guessing it's too large. And there seem to be ways to bypass that via a custom data struct which, I will build into Alaris (Hopefully this week) to mitigate this issue.

@mrothbart
Copy link

image

@dlimanov
Copy link
Author

dlimanov commented Mar 3, 2021

Same here:

python.exe builder.py -s c:\temp\GruntHTTP.bin -p pass123 -o c:\temp
�[36m[i] Key, IV Generation:�[32m Successful�[39m
�[36m [+] Key:�[35m f4a76d3b9d980a3db3a6c73367c67941f97a9e6f94ddb4c82ee83c63500cc47e�[39m
�[36m [+] IV:�[35m d893325678310dace7599153baf5cdf2�[39m
�[36m [+] Salt:�[35m 3941242bb17da618b20aff44c4571b8a�[39m
�[36m[i] Encrypt Shellcode:�[32m Successful�[39m
�[31m[!] Shellcode Too Large, a string can't be longer than 16380 single-byte characters.
�[36m[i] https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2026?view=msvc-160&viewFallbackFrom=vs-2019

@joshfaust
Copy link
Owner

Okay, that's expected behavior. I will review the MSDN docs tonight and see if there isn't a easy way around this by breaking up the string.

@joshfaust
Copy link
Owner

@mrothbart @dlimanov This "Should" fix it, mind having a go to test on your system? https://github.com/cribdragg3r/Alaris/tree/builder_patch

@mrothbart
Copy link

image

@joshfaust
Copy link
Owner

You're on the builder_patch branch?

@joshfaust
Copy link
Owner

image
image

@mrothbart
Copy link

image

@mrothbart
Copy link

mrothbart commented Mar 4, 2021

image

Sorry for the screens, its just a much more effective way of getting over the info. I think the posh shellcode is quite a bit larger than 17k...

@joshfaust
Copy link
Owner

I'm not having the same issues on my end which, is odd. I thought for sure when I hit the max string size of 65,535 bytes I would get the same exception but I'm not. Could you check the loader.cpp source to see how big the shellcode string object is?
image
image
image

@mrothbart
Copy link

Mine is 222596 for some reason.
Posh_v4_x64_Shellcode.zip
I've uploaded my posh shellcode here. The password is alaris
You should use 7z to unzip it as it is aes and not zip crypto.

If this shellcode works for you, then there is a local issue that we need to pin down.

@mrothbart
Copy link

If you like I can upload my loader.cpp tomorrow as well.

@dlimanov
Copy link
Author

dlimanov commented Mar 4, 2021

New builder_batch worked for me, was able to generate a binary from a 43kb shellcode.

@mrothbart
Copy link

Yeah that doesn't hit the 65k limit like the posh shellcode does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants