Hi,
First thanks for sharing this PoC.
When we run this code in windows OS to generate the the lnk file it introduces the character '\x0D' before the langth of the name (length will be 10 '\x0A' after including null char at end of name )i.e. "Microsoft" in this case. As name Microsoft is hard coded there it will always do this thing, but if you change the name to any other name whose length is 10 (including null byte) than this problem will persist there.
Reason: As we are writing the final data to the file in simple "write mode" rather than "write in binary mode" so it will write '\x0D\x0A" instead of '\x0A' beacause '\x0A' represents LF which will be replaced by CRLF (i.e. '\x0D\x0A') in windows.
Solution: need to change write mode to binary mode at line number 232. i.e.
with open(lnkpath, 'w') as lnkf:
change to
with open(lnkpath, 'wb') as lnkf:
and problem will be solved.
In Linux there is no problem.
Hi, First thanks for sharing this PoC. When we run this code in windows OS to generate the the lnk file it introduces the character '\x0D' before the langth of the name (length will be 10 '\x0A' after including null char at end of name )i.e. "Microsoft" in this case. As name Microsoft is hard coded there it will always do this thing, but if you change the name to any other name whose length is 10 (including null byte) than this problem will persist there. Reason: As we are writing the final data to the file in simple "write mode" rather than "write in binary mode" so it will write '\x0D\x0A" instead of '\x0A' beacause '\x0A' represents LF which will be replaced by CRLF (i.e. '\x0D\x0A') in windows. Solution: need to change write mode to binary mode at line number 232. i.e.
with open(lnkpath, 'w') as lnkf:
change towith open(lnkpath, 'wb') as lnkf:
and problem will be solved. In Linux there is no problem.
Thanks