The C++ programming language

learn more… | top users | synonyms

124
votes
7answers
18k views

Why are programs written in C and C++ so frequently vulnerable to overflow attacks?

When I look at the exploits from the past few years related to implementations, I see that quite a lot of them are from C or C++, and a lot of them are overflow attacks. Heartbleed was a buffer ...
39
votes
2answers
8k 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 ...
21
votes
2answers
3k views

Is it possible to write shellcode in C++?

Usually I write assembly programs and then dump their contents to get the shellcode. What I was wondering is whether I could write a C++ program instead of assembly, then dump and use that instead of ...
11
votes
4answers
8k views

How is printf() in C/C++ a Buffer overflow vulnerability?

According to an article I just read, the functions printf and strcpy are considered security vulnerabilities due to Buffer overflows. I understand how strcpy is vulnerable, but could someone possibly ...
6
votes
2answers
923 views

buffer overflow attack scripts

I saw various different scripts for a buffer overflow attack. Many of the scripts include lines that look like this: char code[] = "\xdb\xd7\xd9\x74\x24\xf4\xb8\x79\xc4\x64\xb7\x33\xc9\xb1\x38" ...
5
votes
2answers
186 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 ...
5
votes
1answer
5k views

Hiding process from Task Manager [closed]

What technique is used to hide a process from Task Manager? I'm currently researching ways I can do this in C++. Is this process called hooking? ...
4
votes
5answers
219 views

What are attackers trying to achieve when doing attacks on local programs such as buffer overflows?

In attacks on programs, such as stack buffer overflows, what is the objective of the attacker? I’m having trouble learning the technical details of the attack (such as overwriting the function’s ...
4
votes
3answers
172 views

Safely remove original file after encryption

My application encrypts a file, and the result is written to a different one. How do I safely remove the original one (C++)? Update. Wow! The problem is more complicated than I thought of it... 1) ...
3
votes
2answers
82 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 ...
3
votes
1answer
72 views

Will Intel's MPX extension make C/C++ completely safe to use?

This is apparently an extension that will eliminate buffer overflow and format string vulnerabilities in C/C++ programs, I would guess by providing hardware support for, e.g. converting scanf to fgets ...
3
votes
2answers
106 views

How to know the time of compilation

I've read that a malware found by kaspersky was compiled at the moscow time zone. How they know the time of compilation ?
3
votes
0answers
41 views

Are there any C++ STL alternatives which is bulletproof against timing attack?

Just out of curiosity, I wonder if there are any packages of popular algorithm/data structures which are secure against timing attack. I think GNU libstdc++ std::string::compare(), std::unordered_map ...
3
votes
1answer
63 views

Practical security for an inexperienced database developer? (HIPAA)

Hopefully my question isn't too unique to be asked here, but I didn't find anything similar after some searching. As a relatively inexperienced developer (only one large project excluding this one ...
2
votes
4answers
3k views

Writing file shredder

I want to write a simple file shredder in c++, i.e. a program that deletes a file so that it is not recoverable. Would the following be a secure and correct way to do that? (1) Open the file with ...
2
votes
2answers
355 views

Can unencrypted keys & logins be kept out of program memory?

No matter what technique is used to store encryption keys & logins, it seems that all roads lead back to program memory (as far as I know), as an unencrypted version of the keys & logins will ...
2
votes
2answers
796 views

How do I make a working example of a “Dangling Pointers” exploit? (or where do I find it online)

I was recently reading about buffer overflows and dangling pointers. I read "Smashing the stack for fun and Profit " by Aleph1 and that paper was really clear and concise in explaination. On the ...
2
votes
2answers
97 views

Is it secure to create a Bitcoin address from a private key generated by Rand() instead of cryptographic elliptic curve

I am writing a C++ application that creates a Bitcoin address. I am having a hard time installing openssl for windows and making it work for visual studio. So, I am asking myself, if I create a ...
2
votes
3answers
1k views

C++ memset() memory overflow

I am new to C++. Can any C++ expert tell me would this causing buffer overflow? Sample Code: MyObject op; memset(&op, 0, sizeof(MyObject)); On my view it is ok to be this since the limit is ...
2
votes
2answers
93 views

when defining constants, is #define more secure than static const?

I want to have some constant values in my program, for example, I have a constant value TimeLimit in a header which is commonly used in other classes, but I don't know if #define TimeLimit 30 is ...
2
votes
1answer
139 views

Testing Poodle TLS vulnerability with OpenSSL in C++

I'm writing a command-line tool for SSL/TLS vulnerability testing and so far I was able to implement testing for all vulnerabilities that I need, except Poodle TLS. Is there any way I could utilize ...
2
votes
0answers
46 views

Creating a dynamic malware analysis environment

I don't know much about malware analysis so why this question here. I have analysed Short cut virus statistically and its impact on USB drives and wrote a code to repair its damage. My static ...
1
vote
1answer
135 views

Encrypting password string in C++

I have a client server based application where user is presented with login screen in the client. It then passes the credentials to the server which does the authentication. Client-server ...
1
vote
2answers
108 views

What cryptographic protocol is appropriate for the case where user needs access to a binary and encrypted configuration files?

This is a very newbie IT security question... I have to quickly implement a solution for our application that works like this... We have a binary executable that is given a configuration file. I need ...
1
vote
1answer
132 views

How to encrypt or store data so that only a pool of processes can share it on Windows?

I am writing an application T1 which is using SQLite database to store some sensitive data and i am trying to encrypt it securely. The issue i am facing is that i don't want my symmetric key to be ...
1
vote
1answer
60 views

Verify external data files for an application

I have a C++ application with an algorithm, whose usage I want to protect. The application needs several input data files to work (those may change for each client). My goal is to allow only ...
1
vote
1answer
44 views

Is reseeding OpenSSL CSPRNG necessary if using RAND_bytes?

I read that cryprographic secure PRNG (CSPRNG) need a random seed to provide random output. Looking at OpenSSL that seems to be archived by RAND_poll() and random data is fetched with RAND_bytes(buf, ...
1
vote
0answers
76 views

Connect to a wifi through code [closed]

Is there any way a person could write a software using for example C++ to connect to a wifi completely by using code?
0
votes
2answers
279 views

Is this hash function safe?

Below is the hash function implementation of the roguewave library. It returns a 32 bit hash. The core operation is A = B ^ ((C << 5) | (C >> 27)). Is this hash safe to use as a password check ...
0
votes
1answer
2k views

Why aren't sophisticated Malware written with .NET [closed]

I've been trying to research malware techniques lately, as malware analysis intrigues me. I've got a pretty heavy background in .NET, and based on my 7+ years in .NET, I feel that I could write a ...
0
votes
1answer
51 views

Is there a solution for runing processes in encrypted mode on runtime?

Is there any solution for securely running encrypted processes on an untrusted machine over the WAN? In public clouding, you can split your processes and send process request over the WAN, but you ...
0
votes
2answers
369 views

Programming languages for security? [duplicate]

I am a computer science student interested in the field of security and just had a few questions. What are the pros and cons for using C# for security purposes, I had assumed applications programmed ...
0
votes
2answers
781 views

Anti Virus Intergration

we have found an issue with some production systems that the Anti-Virus causes the program to become slow a lot of the times and generally interferes with the activity of our software. Now as far as I ...
0
votes
0answers
26 views

Make a program execute only from verified drive [closed]

I want to make simple exe file, which should check if it is executing from verified drive or not (for example, from verified flash drive). If not, to halt execution. Could you please tell how I can ...
0
votes
0answers
28 views

Few questions about verifying a DLL signature?

i have few questions about verifying a file's certificate. The use case is as follows: i have a DLL file that contains a resource i need. I'm signing the file with a code-signing certificate, and ...
0
votes
0answers
20 views

Why SMIME decryption works with sender and recipient private key?

Im developing an application, that needs to use SMIME encryption and authentication. I've implemented a decryption system, and am currently testing it. I send the emails with another fully working ...
0
votes
0answers
31 views

Rootkit driver to change executed instructions

Say I have a process that has a bunch of functions I want to NOP out. From userland, I want anyone viewing the virtual memory to see the normal instructions. However physical memory, and in the end ...
-1
votes
2answers
77 views

Do you know a harmless exe file that copies itself into a file?

I'm doing a simple project where I read an exe file and if I find a virus that I already know, I erase it from the file. I have to test it with a virus (I'm looking for something harmless) that insert ...
-2
votes
1answer
737 views

How to store a hexadecimal string representation in C++ for use in cryptography

Homework question The full question is the following: Suppose you are told that the one time pad encryption of the message "attack at dawn" is 09e1c5f70a65ac519458e7e53f36 (the plaintext letters are ...