Skip to content

Commit

Permalink
Refactor 'Success' -> 'Good Job'
Browse files Browse the repository at this point in the history
  • Loading branch information
jakespringer committed Jul 24, 2017
1 parent 2fe6317 commit 4fcecf6
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions 00_angr_find/00_angr_find.c.templite
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int main(int argc, char* argv[]) {
for (int i=0; i < 20; ++i) {
password[i] = 0;
}

strncpy(password, USERDEF, LEN_USERDEF);

password[0] ^= password[1];
Expand All @@ -50,6 +50,6 @@ int main(int argc, char* argv[]) {
if (strcmp(buffer, password)) {
printf("Try again.\n");
} else {
printf("Success.\n");
printf("Good Job.\n");
}
}
4 changes: 2 additions & 2 deletions 01_angr_avoid/01_angr_avoid.c.templite
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int main(int argc, char* argv[]) {
for (int i=0; i < 20; ++i) {
password[i] = 0;
}

strncpy(password, USERDEF, LEN_USERDEF);

password[0] ^= password[1];
Expand All @@ -50,7 +50,7 @@ int main(int argc, char* argv[]) {
}

if (!strcmp(buffer, password)) {
printf("Success.\n");
printf("Good Job.\n");
} else {
asm("mov $64, %eax\n\t"
"int $0x80");
Expand Down
4 changes: 2 additions & 2 deletions 02_angr_find_condition/02_angr_find_condition.c.templite
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def generate_true_statement(variable, value):

def recursive_if_else(variable, value, depth):
if depth == 0:
write('if (strcmp(buffer, password)) { printf(\"Try again.\\n\"); } else { printf(\"Success.\\n\"); }')
write('if (strcmp(buffer, password)) { printf(\"Try again.\\n\"); } else { printf(\"Good Job.\\n\"); }')
else:
if_true = random.choice([True, False])
if (if_true):
Expand Down Expand Up @@ -62,6 +62,6 @@ int main(int argc, char* argv[]) {

printf("Enter the password: ");
scanf("%8s", buffer);

${ recursive_if_else('x', 0xDEADBEEF, 8) }$
}
2 changes: 1 addition & 1 deletion 02_angr_find_condition/scaffold02.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def is_successful(path):
# Dump whatever has been printed out by the binary so far into a string.
stdout_output = path.state.posix.dumps(sys.stdout.fileno())

# Return whether 'Success.' has been printed yet.
# Return whether 'Good Job.' has been printed yet.
# (!)
return ???

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ int main(int argc, char* argv[]) {
if (non_eax || non_ebx || non_edx) {
printf("Try again.\n");
} else {
printf("Success.\n");
printf("Good Job.\n");
}

return 0;
}
4 changes: 2 additions & 2 deletions 04_angr_symbolic_stack/04_angr_symbolic_stack.c.templite
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ void handle_user() {
if ((user_int0 ^ USERDEF0) || (user_int1 ^ USERDEF1) || (user_int2 ^ USERDEF2) || (user_int3 ^ USERDEF3)) {
printf("Try again.\n");
} else {
printf("Success.\n");
printf("Good Job.\n");
}
}

int main(int argc, char* argv[]) {
print_msg();
printf("Enter the password: ");
handle_user();
}
}
6 changes: 3 additions & 3 deletions 05_angr_symbolic_memory/05_angr_symbolic_memory.c.templite
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
${
${
import random, os
random.seed(os.urandom(8))

Expand Down Expand Up @@ -34,12 +34,12 @@ int main(int argc, char* argv[]) {
scanf("%8s %8s %8s %8s", user_input, &user_input[8], &user_input[16], &user_input[24]);

for (int i=0; i<32; ++i) {
user_input[i] = (char) complex_function(user_input[i], i);
user_input[i] = (char) complex_function(user_input[i], i);
}

if (strncmp(user_input, USERDEF, 32)) {
printf("Try again.\n");
} else {
printf("Success.\n");
printf("Good Job.\n");
}
}
4 changes: 2 additions & 2 deletions 06_angr_symbolic_heap/06_angr_symbolic_heap.c.templite
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ int main(int argc, char* argv[]) {
scanf("%8s %8s %8s %8s", buffer, &buffer[8], &buffer[16], &buffer[24]);

for (int i=0; i<32; ++i) {
buffer[i] = complex_function(buffer[i], i);
buffer[i] = complex_function(buffer[i], i);
}

if (strncmp(buffer, USERDEF, 32)) {
printf("Try again.\n");
} else {
printf("Success.\n");
printf("Good Job.\n");
}

free(padding1);
Expand Down
6 changes: 3 additions & 3 deletions 07_angr_symbolic_file/07_angr_symbolic_file.c.templite
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ int complex_function(int value, int i) {
void write_string_to_file(char* buffer, int length) {
char buffer_break_angr[length];
int i;

memset(buffer_break_angr, 0, length);
unlink(USERDEF1);
FILE* file = fopen(USERDEF1, "a+b");
FILE* file = fopen(USERDEF1, "a+b");
fwrite(buffer, 1, length, file);
fseek(file, 0, SEEK_SET);
fscanf(file, "%64s", buffer_break_angr);
Expand Down Expand Up @@ -63,7 +63,7 @@ int main(int argc, char* argv[]) {
printf("Try again.\n");
exit(1);
} else {
printf("Success.\n");
printf("Good Job.\n");
exit(0);
}
}
8 changes: 4 additions & 4 deletions 08_angr_constraints/08_angr_constraints.c.templite
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int octcmp(uint32_t input, const char *buffer) {
if (oct_string[i] < '0' || oct_string[i] > '9') {
oct_string[i] = '0';
}
}
}

printf("%s\n", oct_string);

Expand All @@ -51,15 +51,15 @@ int main(int argc, char* argv[]) {
e0 = e + ${ write(str(random.randint(0, 2**32 - 1)) + 'U') }$;
d0 = d + ${ write(str(random.randint(0, 2**32 - 1)) + 'U') }$;
c0 = c + ${ write(str(random.randint(0, 2**32 - 1)) + 'U') }$;
b0 = b + ${ write(str(random.randint(0, 2**32 - 1)) + 'U') }$;
b0 = b + ${ write(str(random.randint(0, 2**32 - 1)) + 'U') }$;
a0 = a + ${ write(str(random.randint(0, 2**32 - 1)) + 'U') }$;

int result = octcmp(a0, USERDEF0) | octcmp(b0, USERDEF1) | octcmp(c0, USERDEF2) |
int result = octcmp(a0, USERDEF0) | octcmp(b0, USERDEF1) | octcmp(c0, USERDEF2) |
octcmp(d0, USERDEF3) | octcmp(e0, USERDEF4) | octcmp(f0, USERDEF5);

if (result) {
printf("Try again.\n");
} else {
printf("Success.\n");
printf("Good Job.\n");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(int argc, char* argv[]) {

print_msg();

memset(password, 0, 20*4);
memset(password, 0, 20*4);
strncpy(&password[0], USERDEF0, LEN_USERDEF);
strncpy(&password[20], USERDEF1, LEN_USERDEF);
strncpy(&password[40], USERDEF2, LEN_USERDEF);
Expand All @@ -59,6 +59,6 @@ int main(int argc, char* argv[]) {
if (!keep_going) {
printf("Try again.\n");
} else {
printf("Success.\n");
printf("Good Job.\n");
}
}
6 changes: 3 additions & 3 deletions 10_angr_sim_procedures/10_angr_sim_procedures.c.templite
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ${
import random, os
random.seed(os.urandom(16))
userdef_charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
userdef = [''.join(random.choice(userdef_charset) for _ in range(8)) for _ in range(4)]
userdef = [''.join(random.choice(userdef_charset) for _ in range(8)) for _ in range(4)]
def generate_true_statement(variable, value):
random_int = random.randint(0, 0xFFFFFFFF)
value_xor_int = value ^ random_int
Expand Down Expand Up @@ -62,7 +62,7 @@ int main(int argc, char* argv[]) {

print_msg();

memset(password, 0, 20*4);
memset(password, 0, 20*4);
strncpy(&password[0], USERDEF0, LEN_USERDEF);
strncpy(&password[20], USERDEF1, LEN_USERDEF);
strncpy(&password[40], USERDEF2, LEN_USERDEF);
Expand All @@ -89,6 +89,6 @@ int main(int argc, char* argv[]) {
if (!keep_going) {
printf("Try again.\n");
} else {
printf("Success.\n");
printf("Good Job.\n");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void print_msg() {
}

void segv_handler(int sig) {
printf("Success.\n");
printf("Good Job.\n");
exit(0);
}

Expand All @@ -56,7 +56,7 @@ int main(int argc, char* argv[]) {

printf("Enter the password: ");
scanf("%u %32s", &key, user_buffer);

${
hit_statement = """
strcpy(strcpy_buffer, user_buffer);
Expand Down
8 changes: 4 additions & 4 deletions 12_angr_unconstrained/12_angr_unconstrained.c.templite
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ void print_msg() {
printf("%s", msg);
}

void print_success() {
printf("Success.\n");
void print_good() {
printf("Good Job.\n");
}

void read_input() {
char padding0[${ write(random.randint(0, 32)) }$];
char buffer[8];
char padding1[${ write(random.randint(0, 32)) }$];

scanf("%s", buffer);
}

int main(int argc, char* argv[]) {
uint32_t key = 0;

print_msg();

printf("Enter the password: ");
read_input();

Expand Down
4 changes: 2 additions & 2 deletions 13_angr_veritesting/13_angr_veritesting.c.templite
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ int main(int argc, char* argv[]) {
}

if (counter == ${ write(random.randint(8, 56)) }$) {
printf("Success.\n");
printf("Good Job.\n");
} else {
printf("Try again.\n");
}

return 0;
}
4 changes: 2 additions & 2 deletions 14_angr_static_binary/14_angr_static_binary.c.templite
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int main(int argc, char* argv[]) {
for (int i=0; i < 20; ++i) {
password[i] = 0;
}

strncpy(password, USERDEF, LEN_USERDEF);

for (int i=0; i<8; ++i) {
Expand All @@ -50,6 +50,6 @@ int main(int argc, char* argv[]) {
if (strcmp(buffer, password)) {
printf("Try again.\n");
} else {
printf("Success.\n");
printf("Good Job.\n");
}
}
2 changes: 1 addition & 1 deletion 15_angr_shared_library/15_angr_shared_library.c.templite
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int main(int argc, char* argv[]) {
printf("Enter the password: ");
scanf("%8s", buffer);
if (validate(buffer, 8)) {
printf("Success.\n");
printf("Good Job.\n");
} else {
printf("Try again.\n");
}
Expand Down

0 comments on commit 4fcecf6

Please sign in to comment.