This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <stddef.h> | |
typedef ptrdiff_t ssize_t; | |
/******************************************************************************* | |
* getline -- Stores line of text from stream. * | |
* * | |
* Parameters * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
char* | |
fgetLine(FILE *stream) | |
{ | |
const size_t chunk = 128; | |
size_t max = chunk; | |
/* Preliminary check */ | |
if (!stream || feof(stream)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(int argc, char *argv[]) | |
{ | |
char* Array[2][2] = { { "0th Row, 0th Col", "0th Row, 1st Col"}, | |
{ "1st Row, 0th Col", "1st Row, 1st Col"}}; | |
puts (Array[0][0]); | |
puts (Array[0][1]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> // void exit( int exit_code) | |
#include <signal.h> // void (*signal( int sig, void (*handler) (int))) (int) | |
// handler must be of the form "void func (int sig)" | |
// signal_code is useful in-cases where handler is used for more than one signal | |
void handler (int signal_code) | |
{ | |
printf ("\nHello World!\n"); | |
printf ("signal value: %d\n", signal_code); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
struct fn_struct { | |
int number; | |
void (*f) (void *); | |
}; | |
void foo (unsigned int m) | |
{ | |
unsigned int tmp = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> // for fixed width types e.g. uint8_t, etc. | |
#include <inttypes.h> // for PRI{fmt}{type} and SCN{fmt}{type} macros | |
int main() | |
{ | |
uint32_t num; | |
scanf("%"SCNu32, &num); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use warnings; | |
while (read STDIN, my $octets, 3) { | |
# converts the 3 octal numbers to equivalent decimal number and then said | |
# decimal number into its hex equivalent. | |
$hex_fmt = sprintf "%02x", oct($octets); | |
# print out hex in raw hex byte values. | |
print pack("H*", $hex_fmt); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PrintUnicode.c - input ascii utf8 hex value and prints the corresponding unicode | |
// character. | |
// example - try the following! | |
// echo -n '0xf09f9886' | xargs ./PrintUnicode | |
// Or | |
// ./PrintUnicode f09f9886 | |
#include <stdio.h> // sscanf, printf | |
#include <stdint.h> // uint32_t, uint8_t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc --static -m32 -fno-stack-protector bufExploits1.c -g -o ex1 | |
// If using gcc on windows, gcc -static-libgcc -bufExploits1.c -m32 -fno-stack-protector -g -o ex1 | |
/* | |
* NOTE: Windows 10 will trigger windows defender and quarantine the exe before you can run it. | |
* I kept getting the threat warning for "Trojan:win32/Conteban.B!ml" -- not sure why, guess windows doesn't like stack smashing. | |
* You will need to first restore the exe from windows defender to let windows know this behavior is okay for this program. | |
*/ | |
#ifdef _WIN32 | |
#include <windows.h> | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdbool.h> | |
#include <string.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <inttypes.h> | |
// gcc Print_data_in_binary.c -o printBinary | |
// | |
// ./printBinary 27 |
OlderNewer