nixawk / labs

Vulnerability Labs for security analysis
1.16k stars 440 forks source link

Bug at line number 232 when bindata is finally written into file (Windows Environment) #12

Closed readercrap closed 7 years ago

readercrap commented 7 years ago

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.

Thanks

nixawk commented 7 years ago

Thanks @readercrap . Fix it. - https://github.com/nixawk/labs/commit/96eaad8654f4e425c476889973da6cfd5f9708b7