C into shell code - c

I'm trying to get a shellcode using C. I cannot just take .obj file due to the large amount of nulls. I've also tried "Shellcode Compiler", but it hasn't helped me.
Are there any other projects which can help me, or any ways to create a useable shell code from C?
My simple C code:
#include <Windows.h>
int main()
{
WinExec("SomeFile", 0);
}

Seeing that c is a compiled language and not interpreted. I am sure you will get better results from converting the binary to shellcode.
Check out GitHub vulnwarex/bin2sc.

Related

Problem with compilation in VS Code. IncludePath error

I have a big problem with compilation of my program in VS Code. I'm writing a simple program but when I try to compile it and run it shows 2 problems. (I'm trying to translate it as clear as I can).
There is a problem with element #include. Please upgrade element includePath.
Can't open source file "stdio.h"
I'm writing the program in C language. I have to say that I'm a fresh programmer so if you can help me, please write it as simple as it's possible.
I'm adding the program, but I think it's very simple and that's not the issue:
#include <stdio.h>
int main()
{
printf("costam\n");
return 0;
}

Where is the source code for the GNU C library?

How do I go about finding the source code behind standard C functions (under Linux/Ubuntu 13)?
Case in point, chdir(). I know I have to #include <unistd.h> but then I encounter a bug, and I suppose the source code would help me figure out this bug.
Thanks if you point me out to the correct source - but real thanks if you give me a method for finding the correct source file every time I need one.
The project is online at GNU C Library.
Yes, the source code to the GNU libc is available at https://sourceware.org/git/?p=glibc.git;a=tree

OS X lock screen with pure C?

I know this is possible, because I have a binary I wrote a couple years ago to do exactly this. Unfortunately, I didn't save the source code.
I know that it was written in pure C, and I called against an OS X API and was able to lock the screen. Googling for "pure C OS X lock screen" and similar strings isn't getting me much; I saw documentation on how to do it in Objective C but that's not what I'm looking for.
Anyone have any idea how I accomplished this previously?
One way to do this is by using a call to system():
#include <stdlib.h>
int main(void) {
system("/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -suspend");
return 0;
}
You're probably thinking of CGSCreateLoginSession() -- it's a private function and not documented by Apple. See this question for an example of its use.

Get preprocessed C code altogether with library implementation

I use *nix/gcc. I am beginner in C so this may be an easy question. Let's say I have a file main.c with the following content:
#include<stdio.h>
int main(int argc, char *argv[])
{
printf("Hello World.\n");
return 0;
}
Now what I want to get is one file which contains all code after preprocessing and all library implementation code (for inspection purpose). Now, if I run
gcc -E main.c >> full.c
I do get bunch of code, but there are only data types and function prototypes. Is it possible somehow to also get implementation of all functions, so that I can see whole code in one place.
Thanks.
The C Preprocessor just does text manipulation. In this case what it will do is to generate an output file that will contain the contents of the include file stdio.h along with the couple of lines of your main program.
It will not contain the stdio.h function implementations as that source is in some other files which are not provided in source code format with gcc.
So if you want the implementation you will need to find the gcc Standard C library source code which I expect is on the web some place.
However if you want to understand the Standard C library you should start with Plaughers books on the Standard C library or something similar which provides implementation as well as annotations and notes about what is done and why.

how to avoid writing main() too many times in C?

Let say I have 5 small piece of codes in C.
Every time I want to test each piece of code, I have to repeat this process:
#include <stdio.h>
int main()
{
// code piece go into here
return 0;
}
Is there way that I don't have to do this 5 times? I'm using Code::Blocks, that means I have to create 5 different projects, which I believe not necessary because each piece of code is small.
Is this really so hard? Every program you run needs a main function, and the text you've pasted there isn't very long. Also, people expect to see a main function in C/C++ programs. If you template this out somehow, you're just going to make your code confusing.
If the issue is that you have to make a project for every test you want to build, then I would guess you are not using your IDE correctly. Is there not a multi-target project type that lets you have multiple test programs without all the extra project files? If there is not, then perhaps you should be using a different IDE.
Use a good editor with code templates. Most feature-full editors (Emacs, vi, Scite, Textmate, or even MSVC if that's your cup of tea) have some support for them. This way, writing this boring template every time will take only a fraction of the second.
Would template files or copying and pasting be too difficult for some reason?

Resources