We expect a high standard of professionalism from you at all times while you are taking any of our courses. We expect all students to act in good faith at all times
TLDR: don’t be a dick jerk
ramble about fuzzers
avg | 3/3 | |
---|---|---|
war01 | 2.50 | 18 |
war02 | 2.25 | ?? |
war03 | 1.80 | ?? |
total | 6.55 | ?? |
int flags = 1;
if (flags & FLAG){
printf("TRUE\n");
} else{
printf("FALSE\n");
}
if (flags & FLAG != 0){
printf("TRUE\n");
} else{
printf("FALSE\n");
}
if (flags & (FLAG != 0)){
printf("TRUE\n");
} else{
printf("FALSE\n");
}
flags = flags + 1 % 2;
printf("Flags: %d\n",flags);
flags = flags++ % 2;
printf("Flags: %d\n",flags);
char pt[] = "THISISSOMEDATAOFSOMESORT";
char env_script_name[] = "USER_CONTROLLED_ENV1";
char env_path_info[] = "USER_CONTROLLED_ENV2";
int ptlen = strlen(pt) - strlen(env_script_name);
int path_translated_len = ptlen + env_path_info
? strlen(env_path_info) : 0;
char *path_translated = NULL;
path_translated = (char *) malloc(path_translated_len + 1);
memcpy(path_translated, pt, ptlen);
if (env_path_info) {
memcpy(path_translated + ptlen, env_path_info,
path_translated_len - ptlen);
// vvvvvvvvvvvvvvvvvvvvvvvvvvvv
int path_translated_len = ptlen + env_path_info
? strlen(env_path_info) : 0;
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
path_translated = (char *) malloc(path_translated_len + 1);
memcpy(path_translated, pt, ptlen);
if (env_path_info) {
memcpy(path_translated + ptlen, env_path_info,
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvv
path_translated_len - ptlen);
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ptlen + env_path_info ? strlen(env_path_info) : 0;
// is not the same as
ptlen + (env_path_info ? strlen(env_path_info) : 0);
if(env_path_info) {
path_translated_len = ptlen + strlen(env_path_info);
} else {
path_translated_len = ptlen;
}
if (ptlen + env_path_info){
path_translated_len = strlen(env_path_info);
} else {
path_translated_len = 0;
}
$ man mmap
if (x == 0) {
if (y == 0) error();
else {
z = x + y;
fclose(&z);
}
if (x == 0) {
if (y == 0) error();
} else {
z = x + y;
fclose(&z);
}
if (x == 0) {
if (y == 0)
error();
else {
z = x + y;
fclose(&z);
}
}
which one is calculated first?
a + b * c
> a + (b * c)
> (a + b) * c
if (count != 0 && sum/count < smallaverage)
printf("average < %g\n",smallaverage);
i = 0
while (i < n)
y[i] = x[i++];
but why?
u_int strLen = strlen(userinput);
int buffsize = strLen + 11;
char *mem = malloc(buffsize);
strncpy(mem,"this/path/",10);
strncpy(mem[10],userinput,strLen);
u_int strLen = strlen(userinput);
int buffsize = strLen + 11;
char *mem = malloc(buffsize);
strncpy(mem,"this/path/",10);
strncpy(mem[10],userinput,strLen);
its an integer overflow
u_int strLen = strlen(userinput);
//vvvvvvvvvvvvvvvvvvvvvvvvv
int buffsize = strLen + 11;
//^^^^^^^^^^^^^^^^^^^^^^^^^
char *mem = malloc(buffsize);
strncpy(mem,"this/path/",10);
strncpy(mem[10],userinput,strLen);
what if user input is super long, (e.g. INT_MAX?)
char *var;
printf(var);
fprintf(stderr,var);
vsnprintf(var2, strlen(var2), var);
// etc...
I hope you recognise these lol
char *var malloc(10);
free(var);
printf("%s\n", var);
char *var malloc(10);
free(var);
printf("%s\n", var);
use-after-free
char *var malloc(10);
free(var);
char *var2 malloc(10);
free(var);
char *var malloc(10);
free(var);
char *var2 malloc(10);
free(var);
double-free
char *a;
a = NULL;
char b[] = "string";
strcpy(a, b);
char *a;
a = NULL;
char b[] = "string";
strcpy(a, b);
null pointer dereferences
char *a, b[] = "string";
// vuln_syscall_sets_a_NULL
// Lets map NULL pointer
mem = mmap(NULL, 0x1000, PROT READ | PROT WRITE | PROT EXEC,
MAP FIXED | MAP ANONYMOUS | MAP PRIVATE, 0, 0);
if (mem != NULL)
fatal("[-] UNABLE TO MAP ZERO PAGE!");
exit(1);
fprintf(stdout, "[+] MAPPED ZERO PAGE!\n");
strcpy(a, b);
printf("%s\n",a);
char *var = malloc(10);
if(var == NULL) return;
for(int i = 0; i <= 10; i++) {
var[i] = argv[2][i];
}
// vvvvvvvvvv
char *var = malloc(10);
// ^^^^^^^^^^
if(var == NULL) return;
// vvvvvvv
for(int i = 0; i <= 10; i++) {
// ^^^^^^^
var[i] = argv[2][i];
}
off-by-one
char *var = malloc(10);
// ^^^^^^^^^^^
if(var == NULL) return;
for(int i = 0; i <= 10; i++) {
// ^^^^^^^^
var[i] = argv[2][i];
}
find the vulns here