312-50V10 · Question #301
An engineer is learning to write exploits in C++ and is using the exploit tool Backtrack. The engineer wants to compile the newest C++ exploit and name it calc.exe. Which command would the engineer us
The correct answer is A. g++ hackersExploit.cpp -o calc.exe. The correct g++ command to compile a C++ source file and name the output binary uses the -o flag followed by the desired output filename.
Question
An engineer is learning to write exploits in C++ and is using the exploit tool Backtrack. The engineer wants to compile the newest C++ exploit and name it calc.exe. Which command would the engineer use to accomplish this?
Options
- Ag++ hackersExploit.cpp -o calc.exe
- Bg++ hackersExploit.py -o calc.exe
- Cg++ -i hackersExploit.pl -o calc.exe
- Dg++ --compile hackersExploit.cpp -o calc.exe
How the community answered
(27 responses)- A93% (25)
- B4% (1)
- D4% (1)
Why each option
The correct g++ command to compile a C++ source file and name the output binary uses the -o flag followed by the desired output filename.
The GNU C++ compiler (g++) compiles C++ source files (.cpp) using the syntax 'g++ <source_file> -o <output_file>'. The -o flag specifies the output file name, so 'g++ hackersExploit.cpp -o calc.exe' correctly compiles the C++ source and names the resulting binary calc.exe.
The .py file extension indicates a Python script, not a C++ source file, so g++ cannot compile it.
The .pl extension indicates a Perl script, not C++, and -i is not a valid g++ input flag.
The flag '--compile' does not exist in g++; the correct flag for compile-only (without linking) would be -c, and even then it would not produce a final executable named calc.exe.
Concept tested: GNU g++ compiler command syntax and flags
Source: https://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html
Topics
Community Discussion
No community discussion yet for this question.