I am having problem compiling the followed exploit code:
http://downloads.securityfocus.com/vulnerabilities/exploits/59846-1.c
I am using: \"gcc file.c\" and
With me this error ocurred when I copied and pasted a code in text format to my editor (gedit). The code was in a text document (.odt) and I copied it and pasted it into gedit. If you did the same, you have manually rewrite the code.
Whenever compiler found special character .. it gives these king of compile error .... what error i found is as following
error: stray '\302' in program and error: stray '\240' in program
....
Some piece of code i copied from chatting messanger. In messanger it was special character only.. after copiying into vim editor it changed to correct character only. But compiler was giving above error .. then .. that stamenet i wrote mannualy after .. it got resolve.. :)
You have invalid chars in your source. If you don't have any valid non ascii chars in your source, maybe in a double quoted string literal, you can simply convert your file back to ascii with:
tr -cd '\11\12\15\40-\176' < old.c > new.c
Edit: method with iconv will stop at wrong chars which makes no sense. The above command line is working with the example file. Good luck :-)
Sure, convert the file to ascii and blast all unicode characters away. It will probably work.... BUT...
Two more sugrical approaches to fixing the problem:
Regex search all unicode characters not part non-extended ascii. In notepad++ I can search up to FFFF, which hasn't failed me yet.
[\x{80}-\x{FFFF}]
80 is hex for 128, the first extended ascii character.
After hitting "find next" and highlighting what appears to be empty space, you can close your search dialog and press CTRL+C to copy to clipboard.
Then paste the character into a unicode search tool. I usually use an online one. http://unicode.scarfboy.com/
Example: I had a bullet point (•) in my code somehow. The unicode value is 2022 (hex), but when read as ascii by the compiler you get \342 \200 \242 (3 octal values). It's not as simple as converting each octal values to hex and smashing them together. So "E2 80 A2" is NOT the hex unicode point in your code.
I got the same with a character that visibly appeared as an asterisk, but was a UTF-8 sequence instead.
Encoder * st;
When compiled returned:
g.c:2:1: error: stray ‘\342’ in program
g.c:2:1: error: stray ‘\210’ in program
g.c:2:1: error: stray ‘\227’ in program
342 210 227 turns out to be UTF-8 for ASTERISK OPERATOR.
Deleting the '*' and typing it again fixed the problem.
You have an invalid character on that line. This is what I saw: