hasherezade / masm_shc

A helper utility for creating shellcodes. Cleans MASM file generated by MSVC, gives refactoring hints.
MIT License
156 stars 30 forks source link

Change "CONST" to "_DATA" to fix string inlining #7

Closed dismantl closed 2 years ago

dismantl commented 2 years ago

I'm not sure if it's because of the version of VS I'm using (VS Community 2022), but the assembly produced by the compiler puts all the string constants in the _DATA segment, rather than a CONST segment as referenced in the code. This caused string inlining not to work using the masm_shc utility. When I switched CONST to _DATA, string inlining worked again.

Thanks for your work on this, the paper was super informative.

hasherezade commented 2 years ago

@dismantl - thanks for your report, and I am glad that you like my paper! it seems in some versions of VS it will use CONST , and in other _DATA - so just changing CONST to _DATA is not a solution, as it will break compatibility with other versions. We should rather have:

            if (seg_name == "CONST"  || seg_name == "_DATA") {
                in_const = true;
            }

in order to cover both cases.

dismantl commented 2 years ago

Good call. I just made the change so it looks for either _DATA or CONST.

hasherezade commented 2 years ago

thanks!