-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
910 lines (822 loc) · 32.3 KB
/
Makefile
File metadata and controls
910 lines (822 loc) · 32.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
CC = gcc
EXECSTACK = -z execstack
NOSTACKPROTECT = -fno-stack-protector
32BIT= -m32
OMITFRAMEPOINTER = -fomit-frame-pointer
SRC := src/stack_vuln.c
CLEAN_TARGETS = *_level*
SOURCES := $(wildcard $(SRC)/*.c)
OBJECTS := $(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SOURCES))
# $RANDOM -- TODO RANDOM BUFFER SIZES
all: $(SOURCES)
$(CC) $< -o $@
$(OBJ)/%.o: $(SRC)/%.c
$(CC) -I$(SRC) -c $< -o $@
aslr_off :
echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
aslr_on :
echo 2 | sudo tee /proc/sys/kernel/randomize_va_space
###########################################
# Intro to Manipulating the Stack #
###########################################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Part A : Modifying a variable within the same stack frame
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Modify a simple variable
stack_level1 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=10' \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) \
-D PRINT_BUFFER_SIZE \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=10' \
-D 'PRINT_STACK_RANGE_LOW=-10' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'PRINT_DESCRIPTION="\tTry to modify the value of i on the stack. See if you can make it the number 65.\nThe byte you want to edit should have the hex value of `aa`\n\n\n"' \
-D ECHO_RETURN_ENABLED \
-D 'ECHO_RETURN_TYPE=BYTE' \
-D 'ECHO_RETURN_ARG=ret_arg' \
-D 'ECHO_RETURN_ARG_DECL=BYTE ret_arg' \
-D 'ECHO_RETURN_ARG_INITIAL_VALUE=170' \
-D 'ECHO_RETURN_ARG_FINAL_VALUE=65' \
-D ECHO_RETURN_CORRECTION_PRINT_OUTPUT \
-D ECHO_RETURN_CORRECTION_PRINT_CORRECT
# Same as before, this time the buffer is bigger
stack_level2 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=30' \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D PRINT_BUFFER_SIZE \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_LOW=-10' \
-D 'PRINT_STACK_RANGE_HIGH=10' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'PRINT_DESCRIPTION="\tTry to modify the value of i on the stack. See if you can make it the number 42.\nThe byte you want to edit should have the hex value of `aa`\n\n\n"' \
-D ECHO_RETURN_ENABLED \
-D 'ECHO_RETURN_TYPE=BYTE' \
-D 'ECHO_RETURN_ARG=ret_arg' \
-D 'ECHO_RETURN_ARG_DECL=BYTE ret_arg' \
-D 'ECHO_RETURN_ARG_INITIAL_VALUE=170' \
-D 'ECHO_RETURN_ARG_FINAL_VALUE=42' \
-D ECHO_RETURN_CORRECTION_PRINT_OUTPUT \
-D ECHO_RETURN_CORRECTION_PRINT_CORRECT
# Try it for an integer this time
stack_level3 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=10' \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D PRINT_BUFFER_SIZE \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_LOW=-10' \
-D 'PRINT_STACK_RANGE_HIGH=10' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'PRINT_DESCRIPTION="\tTry to modify the value of i on the stack. See if you can make it the number 9001.\n\n\n"' \
-D ECHO_RETURN_ENABLED \
-D 'ECHO_RETURN_TYPE=int' \
-D 'ECHO_RETURN_ARG=ret_arg' \
-D 'ECHO_RETURN_ARG_DECL=int ret_arg' \
-D 'ECHO_RETURN_ARG_INITIAL_VALUE=2863311530' \
-D 'ECHO_RETURN_ARG_FINAL_VALUE=9001' \
-D ECHO_RETURN_CORRECTION_PRINT_OUTPUT
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Part B : Jumping the return address
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Overflow the return address and jump to the hidden function
stack_level4 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=20' \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D PRINT_SECRET_LOCATION \
-D PRINT_BUFFER_SIZE \
-D 'PRINT_STACK_RANGE_LOW=-8' \
-D 'PRINT_STACK_RANGE_HIGH=40' \
-D PRINT_INITIAL_STACK \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D FUNCTION_JUMP \
-D 'PRINT_DESCRIPTION="\tTry to jump to the hidden function, most of the data you need has been provided.\n\n\n"'
# Again to the hidden function, different buffer size
stack_level5 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=43' \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D PRINT_SECRET_LOCATION \
-D PRINT_BUFFER_SIZE \
-D PRINT_INITIAL_STACK \
-D PRINT_FINAL_STACK \
-D 'PRINT_STACK_RANGE_LOW=-8' \
-D 'PRINT_STACK_RANGE_HIGH=40' \
-D CLEAR_INITIAL_BUFFER \
-D FUNCTION_JUMP \
-D 'PRINT_DESCRIPTION="\tTry to jump to the hidden function, you may find that the buffer has changed.\n\n\n"'
# Again to the hidden function, different buffer size
stack_level6 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=67' \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D PRINT_SECRET_LOCATION \
-D PRINT_BUFFER_SIZE \
-D PRINT_INITIAL_STACK \
-D PRINT_FINAL_STACK \
-D PRINT_STACK_RANGE_LOW=-8 \
-D PRINT_STACK_RANGE_HIGH=40 \
-D CLEAR_INITIAL_BUFFER \
-D FUNCTION_JUMP \
-D 'PRINT_DESCRIPTION="\tTry to jump to the hidden function, different buffer now.\n\n\n"'
# Let's try to pass arguments to the secret function now, start with something easy
stack_level7 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=12' \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D PRINT_SECRET_LOCATION \
-D PRINT_BUFFER_SIZE \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_LOW=-8' \
-D 'PRINT_STACK_RANGE_HIGH=60' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D FUNCTION_VARIABLE_ENABLED \
-D 'N_FUNCTION_VARIABLES=1' \
-D 'FUNCTION_ARGS_DECL= BYTE arg' \
-D 'FUNCTION_VARIABLE_FINAL_VALUE = {3}' \
-D 'FUNCTION_ARGS_PTR = &arg' \
-D 'N_FUNCTION_BYTES=1' \
-D FUNCTION_JUMP \
-D 'PRINT_DESCRIPTION="\tThe hidden function again, this time you need to set an argument, the secret value is 3.\n\n"'
# Two arguments
stack_level8 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=80' \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D PRINT_SECRET_LOCATION \
-D PRINT_BUFFER_SIZE \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_LOW=20' \
-D 'PRINT_STACK_RANGE_HIGH=60' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'STRUCT_DEF= typedef struct {BYTE a; BYTE b;} arg_t' \
-D FUNCTION_VARIABLE_ENABLED \
-D 'N_FUNCTION_VARIABLES=2' \
-D 'N_FUNCTION_BYTES = 8' \
-D 'FUNCTION_ARGS_DECL= arg_t arg' \
-D "FUNCTION_VARIABLE_FINAL_VALUE = {'\x07', '\x00', '\x00', '\x00', '\x06', '\x00', '\x00', '\x00'}" \
-D 'FUNCTION_ARGS_PTR= &arg' \
-D FUNCTION_JUMP \
-D 'PRINT_DESCRIPTION="\tTwo arguments this time, a 6 and a 7 with the arguments passed in that order.\n\tOf course, just because you pass them in that order, doesn`t mean they get stored on the stack that way...\n\n\n"'
# Multiple arguments
stack_level9 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=15' \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D PRINT_SECRET_LOCATION \
-D PRINT_BUFFER_SIZE \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_LOW=20' \
-D 'PRINT_STACK_RANGE_HIGH=60' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'STRUCT_DEF= typedef struct {BYTE a; BYTE b; BYTE c; BYTE d; BYTE e;} arg_t' \
-D FUNCTION_VARIABLE_ENABLED \
-D 'N_FUNCTION_VARIABLES=5' \
-D 'N_FUNCTION_BYTES = 20' \
-D 'FUNCTION_ARGS_DECL= arg_t arg' \
-D "FUNCTION_VARIABLE_FINAL_VALUE = {'\x04', '\x00', '\x00', '\x00', '\x11', '\x00', '\x00', '\x00', '\x08', '\x00', '\x00', '\x00', '\x07', '\x00', '\x00', '\x00', '\x06', '\x00', '\x00', '\x00'}" \
-D 'FUNCTION_ARGS_PTR= &arg' \
-D FUNCTION_JUMP \
-D 'PRINT_DESCRIPTION="\tFive arguments now, 6, 7, 8, 17 and 4\n\n\n"'
# Changing types
stack_level10 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=80' \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D PRINT_SECRET_LOCATION \
-D PRINT_BUFFER_SIZE \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_LOW=20' \
-D 'PRINT_STACK_RANGE_HIGH=60' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'STRUCT_DEF= typedef struct {int a; int b;} arg_t' \
-D FUNCTION_VARIABLE_ENABLED \
-D 'N_FUNCTION_VARIABLES=2' \
-D 'N_FUNCTION_BYTES = 8' \
-D 'FUNCTION_ARGS_DECL= arg_t arg' \
-D "FUNCTION_VARIABLE_FINAL_VALUE = {'\xaa', '\xaa', '\xaa', '\xaa', '\x00', '\x01', '\x00', '\x00'}" \
-D 'FUNCTION_ARGS_PTR=&arg' \
-D FUNCTION_JUMP \
-D 'PRINT_DESCRIPTION="\tLet`s try some different types: (int a, int b), and the values are 256 and 2863311530\n\n\n"'
# A pointer
stack_level11 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=80' \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D PRINT_SECRET_LOCATION \
-D PRINT_BUFFER_SIZE \
-D PRINT_BUFFER_ADDRESS \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_LOW=20' \
-D 'PRINT_STACK_RANGE_HIGH=60' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'STRUCT_DEF= typedef struct {int* a;} arg_t' \
-D FUNCTION_VARIABLE_ENABLED \
-D 'HELP_STRING_FUNCT = printf("Your pointer is currently looking at %p\n", arg.a);' \
-D 'N_FUNCTION_VARIABLES = 1' \
-D 'N_FUNCTION_BYTES = 4' \
-D 'FUNCTION_ARGS_DECL= arg_t arg' \
-D "FUNCTION_VARIABLE_FINAL_VALUE = {'\x39', '\x05', '\x00', '\x00'}" \
-D 'FUNCTION_ARGS_PTR=arg.a' \
-D FUNCTION_JUMP \
-D 'PRINT_DESCRIPTION="\tThis time we`re passing an int* pointer.\n\tThe pointer should point to some address in memory storing the integer value 1337. \n You should have a good long think about what happens to the stack when RET is called.\n\n\n"'
# An array
stack_level12 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=120' \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D PRINT_SECRET_LOCATION \
-D PRINT_BUFFER_SIZE \
-D PRINT_BUFFER_ADDRESS \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_LOW=-120' \
-D 'PRINT_STACK_RANGE_HIGH=60' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'STRUCT_DEF= typedef struct {int* a;} arg_t' \
-D FUNCTION_VARIABLE_ENABLED \
-D 'HELP_STRING_FUNCT = printf("Your pointer is currently looking at %p\n", arg.a);' \
-D 'N_FUNCTION_VARIABLES = 1' \
-D 'N_FUNCTION_BYTES = 12' \
-D 'FUNCTION_ARGS_DECL= arg_t arg' \
-D "FUNCTION_VARIABLE_FINAL_VALUE = {'\x69', '\x7a', '\x00', '\x00', '\x39', '\x05', '\x00', '\x00', '\x00', '\x00', '\xa0', '\x00'}" \
-D 'FUNCTION_ARGS_PTR=arg.a' \
-D FUNCTION_JUMP \
-D 'PRINT_DESCRIPTION="\tThis time we`re passing an array of integers.\n\tThe pointer should point to some address in memory storing the integer values [31337, 1337, 10485760].\n\n\n"'
# A larger array
stack_level13 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=20' \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D PRINT_SECRET_LOCATION \
-D PRINT_BUFFER_SIZE \
-D PRINT_BUFFER_ADDRESS \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_LOW=0' \
-D 'PRINT_STACK_RANGE_HIGH=200' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'STRUCT_DEF= typedef struct {int* a;} arg_t' \
-D FUNCTION_VARIABLE_ENABLED \
-D 'HELP_STRING_FUNCT = printf("Your pointer is currently looking at %p\n", arg.a);' \
-D 'N_FUNCTION_VARIABLES = 1' \
-D 'N_FUNCTION_BYTES = 40' \
-D 'FUNCTION_ARGS_DECL= arg_t arg' \
-D "FUNCTION_VARIABLE_FINAL_VALUE = {'\x01', '\x01', '\x01', '\x01', '\x02', '\x02', '\x02', '\x02', '\x03', '\x03', '\x03', '\x03', '\x04', '\x04', '\x04', '\x04', '\x05', '\x05', '\x05', '\x05', '\x06', '\x06', '\x06', '\x06', '\x07', '\x07', '\x07', '\x07', '\x08', '\x08', '\x08', '\x08', '\x10', '\x10', '\x10', '\x10', '\x11', '\x11', '\x11', '\x11'}" \
-D 'FUNCTION_ARGS_PTR=arg.a' \
-D FUNCTION_JUMP \
-D 'PRINT_DESCRIPTION="\tAlright, you may have found some ways to keep secrets before, but this time it`s a bit bigger; we want an array of 10 integers.\n The first integer should contains \\x01\\x01\\x01\\x01, the second \\x02\\x02\\x02\\x02 and so on up to \\x11 and skipping \\x09.\n\t The buffer is only 20 bytes in total. Good luck. \n\n\n"'
# # A Struct Packing
# level14 : $(SRC)
# $(CC) $(SRC) -o $@ \
# -D 'BUFFER_SIZE=20' \
# $(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) \
# -D PRINT_SECRET_LOCATION \
# -D PRINT_BUFFER_SIZE \
# -D PRINT_BUFFER_ADDRESS \
# -D PRINT_INITIAL_STACK \
# -D 'PRINT_STACK_RANGE_LOW=-120' \
# -D 'PRINT_STACK_RANGE_HIGH=60' \
# -D PRINT_FINAL_STACK \
# -D CLEAR_INITIAL_BUFFER \
# -D 'STRUCT_DEF= typedef struct {int* a;} arg_t' \
# -D FUNCTION_VARIABLE_ENABLED \
# -D 'HELP_STRING_FUNCT = printf("Your pointer is currently looking at %p\n", arg.a);' \
# -D 'N_FUNCTION_VARIABLES = 1' \
# -D 'N_FUNCTION_BYTES = 40' \
# -D 'FUNCTION_ARGS_DECL= arg_t arg' \
# -D "FUNCTION_VARIABLE_FINAL_VALUE = {'\x01', '\x01', '\x01', '\x01', '\x02', '\x02', '\x02', '\x02', '\x03', '\x03', '\x03', '\x03', '\x04', '\x04', '\x04', '\x04', '\x05', '\x05', '\x05', '\x05', '\x06', '\x06', '\x06', '\x06', '\x07', '\x07', '\x07', '\x07', '\x08', '\x08', '\x08', '\x08', '\x10', '\x10', '\x10', '\x10', '\x10' '\x10', '\x11', '\x11', '\x11', '\x11'} \
# -D 'FUNCTION_ARGS_PTR=arg.a' \
# -D FUNCTION_JUMP \
# -D 'PRINT_DESCRIPTION="\tThe last one of these sorts of problems. This time we want an array of structs. \n\n\n"'
# Struct containing a function pointer?
# Memcpy as the secret
###########################################
# Smashing the Stack for Fun and Profit #
# Aleph One, Phrack 49, 66k #
###########################################
# Shellcode to /bin/bash and return to main
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Part A : Execed stack
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Calling Code
shellcode_level1: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=256' \
-D PRINT_BUFFER_ADDRESS \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=256' \
-D 'PRINT_STACK_RANGE_LOW=-10' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D RETURN_TO_BUFFER \
-D 'RETURN_TO_BUFFER_OFFSET=0' \
-D 'PRINT_DESCRIPTION="\t Something a bit different this time; you don`t need to overflow the buffer, you`ve been given 256 bytes of buffer space to write whatever you want, and the function will call the buffer automatically."'
# Calling Code
shellcode_level2: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=256' \
-D PRINT_BUFFER_ADDRESS \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=256' \
-D 'PRINT_STACK_RANGE_LOW=-10' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D RETURN_TO_BUFFER \
-D 'RETURN_TO_BUFFER_OFFSET=0' \
-D 'PRINT_DESCRIPTION="\t Let`s make this a bit harder, rather than returning from the buffer can you print your own level completion message?."'
# Calling Code
shellcode_level3: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=256' \
-D PRINT_BUFFER_ADDRESS \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=256' \
-D 'PRINT_STACK_RANGE_LOW=-10' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D RETURN_TO_BUFFER \
-D 'RETURN_TO_BUFFER_OFFSET=0' \
-D 'PRINT_DESCRIPTION="\t Let`s skip to the end shall we. We`ll return to the start of the buffer again, and you need to provide some working shell code."'
# Calling Code Sledding
shellcode_level4: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=256' \
-D PRINT_BUFFER_ADDRESS \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=256' \
-D 'PRINT_STACK_RANGE_LOW=-10' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D RETURN_TO_BUFFER \
-D 'RETURN_TO_BUFFER_OFFSET=72' \
-D 'PRINT_DESCRIPTION="\t This is like the last one, except we`re not returning to the start of the buffer, we`re going to a random address within the buffer. \n\t You`re going to want to put your shell code at the end of the buffer and have a NOP sled take you there"'
# Danger Zone
shellcode_level5: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=128' \
-D PRINT_BUFFER_ADDRESS \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=196' \
-D 'PRINT_STACK_RANGE_LOW=-10' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'PRINT_DESCRIPTION="\t We`ve decided not to return you to the buffer anymore, that`s your job now. Get a shell."'
# Red Zone I
shellcode_level6: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=32' \
-D PRINT_BUFFER_ADDRESS \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=96' \
-D 'PRINT_STACK_RANGE_LOW=-10' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'PRINT_DESCRIPTION="\t We`ve decided to reduce your buffer size, you need to find your own memory to play with now. \n\t Look into what the red zone is if you`re stuck"'
# Red Zone II
shellcode_level7: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=8' \
-D PRINT_BUFFER_ADDRESS \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=96' \
-D 'PRINT_STACK_RANGE_LOW=-10' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'PRINT_DESCRIPTION="\t If the last one didn`t squeeze you, this one will \n\t Look into what the red zone is if you`re stuck"'
###########################################
# Format String #
###########################################
# Format String
fstring_level1: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=256' \
-D FSTRING_ENABLED \
-D 'FSTRING_FIXED_ITERATIONS=10' \
-D FUNCTION_JUMP \
-D PRINT_BUFFER_LITERAL
-D 'PRINT_DESCRIPTION="\t Lets make life a little harder, we`ve decided to stop telling you where the buffer starts.\n\t Or indeed give you any pointer addresses at all. \n\t If you need help, look up what a format string vulnerability is. Try to jump to the secret function."'
# Format String II
fstring_level2: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=64' \
-D FSTRING_ENABLED \
-D 'FSTRING_FIXED_ITERATIONS=10' \
-D FUNCTION_JUMP \
-D 'PRINT_DESCRIPTION="\t As before, but with fewer iterations."'
# Format String III
fstring_level3: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=8' \
-D FSTRING_ENABLED \
-D FSTRING_ARB_ITERATIONS \
-D NO_SCANF \
-D 'PRINT_DESCRIPTION="\t Now you get as many iterations as you want, but no final buffer overflow."'
fstring_level4: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=8' \
-D PRINT_BUFFER_LITERAL \
-D FSTRING_ENABLED \
-D NO_SCANF \
-D 'PRINT_DESCRIPTION="\t A single shot. Pop a shell."' \
fstring_level5: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(EXECSTACK) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=64' \
-D PRINT_BUFFER_LITERAL \
-D SANITISED_BUFFER \
-D 'PRINT_DESCRIPTION="\t One shot, and the buffer is actually limited."'
###########################################
# Return to Lib C
###########################################
# Return to Lib C 3
rlibc_level1: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=8' \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=256' \
-D 'PRINT_STACK_RANGE_LOW=0' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'PRINT_FUNCTION_POINTER=memcpy' \
-D GLOBAL_VARIABLE_ENABLED \
-D 'N_GLOBAL_VARIABLES = 1' \
-D 'GLOBAL_VARIABLE_INITIAL_VALUE={0}' \
-D 'GLOBAL_VARIABLE_FINAL_VALUE = {42}' \
-D 'PRINT_DESCRIPTION="\t It seems that we need to modify a global variable now. Let`s try to set it to 42. Thankfully somebody has given us the address of memcpy."'
# Return to Lib C 3
rlibc_level2: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=8' \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=256' \
-D 'PRINT_STACK_RANGE_LOW=0' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'PRINT_FUNCTION_POINTER=printf' \
-D GLOBAL_VARIABLE_ENABLED \
-D 'N_GLOBAL_VARIABLES = 1' \
-D 'GLOBAL_VARIABLE_INITIAL_VALUE={0}' \
-D 'GLOBAL_VARIABLE_FINAL_VALUE = {97}' \
-D 'PRINT_DESCRIPTION="\t Let`s try that a second time, this time you`ve got the address of printf"'
# Return to Lib C 3
rlibc_level3: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=8' \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=256' \
-D 'PRINT_STACK_RANGE_LOW=0' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'PRINT_FUNCTION_POINTER=execl' \
-D 'PRINT_DESCRIPTION="\t Oh dear, it seems that somebody has disabled stack execution. We won`t be dropping easy shellcodes anymore.\n\t Let`s give you those addresses back through, and we`ll give you the address of execl"'
# Return to Lib C 4
rlibc_level4: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=16' \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=256' \
-D 'PRINT_STACK_RANGE_LOW=0' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'PRINT_DESCRIPTION="\t No more execl addressing, you`ll need to figure it out."'
# Return to Lib C 5
rlibc_level5: $(SRC)
$(CC) $(SRC) -o $@ \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=8' \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=256' \
-D 'PRINT_STACK_RANGE_LOW=0' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D 'PRINT_FUNCTION_POINTER=mmap' \
-D 'PRINT_DESCRIPTION="\t I wonder what you could do with a pointer to mmap and a non executable stack... Maybe do the ROP problems then come back to this"'
###########################################
# GOT
###########################################
# GOT Part 1
got_level1: $(SRC)
$(CC) $(SRC) -o $@ \
$(32BIT) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=9' \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=12' \
-D 'PRINT_STACK_RANGE_LOW=0' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D GOT_LEAK \
-D 'GOT_CPY=4' \
-D GOT_SRC_BUF \
-D GLOBAL_VARIABLE_ENABLED \
-D GLOBAL_VARIABLE_CMP \
-D 'N_GLOBAL_VARIABLES=128' \
-D 'GLOBAL_VARIABLE_INITIAL_VALUE={0}' \
-D 'GLOBAL_VARIABLE_TARGET_INDEX=67' \
-D 'GLOBAL_VARIABLE_TARGET=0xFF' \
-D 'GLOBAL_VARIABLE_TARGET_FINAL_VALUE=0xAA' \
-D SANITISED_BUFFER \
-D 'PRINT_DESCRIPTION="\t Something different here, your buffer really contains two pointers, the first pointer is going to be copied to the address of the second pointer, you have a few bytes of space in your buffer to play with. Set the target value in the GOT to 0xAA."'
# GOT Part 2
got_level2: $(SRC)
$(CC) $(SRC) -o $@ \
$(32BIT) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=9' \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=12' \
-D 'PRINT_STACK_RANGE_LOW=0' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D GLOBAL_VARIABLE_ENABLED \
-D 'N_GLOBAL_VARIABLES=12' \
-D 'GLOBAL_VARIABLE_INITIAL_VALUE={0}' \
-D GOT_LEAK \
-D 'GOT_CPY=4' \
-D GOT_SRC_BUF \
-D FUNCTION_JUMP \
-D 'PRINT_DESCRIPTION="\t Same deal as before, this time try to get to the secret function"'
# GOT Part 3
got_level3: $(SRC)
$(CC) $(SRC) -o $@ \
$(32BIT) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=9' \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=12' \
-D 'PRINT_STACK_RANGE_LOW=0' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D GLOBAL_VARIABLE_ENABLED \
-D 'N_GLOBAL_VARIABLES=18' \
-D 'GLOBAL_VARIABLE_INITIAL_VALUE={0}' \
-D GOT_LEAK \
-D 'GOT_CPY=4' \
-D FUNCTION_JUMP \
-D 'PRINT_DESCRIPTION="\t Slight modification, we`re now setting dst to be the first four bytes and src to be the second four"'
# GOT Part 4
got_level4: $(SRC)
$(CC) $(SRC) -o $@ \
$(32BIT) $(OMITFRAMEPOINTER) \
-D 'BUFFER_SIZE=9' \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=256' \
-D 'PRINT_STACK_RANGE_LOW=0' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D GLOBAL_VARIABLE_ENABLED \
-D 'N_GLOBAL_VARIABLES=1024' \
-D 'GLOBAL_VARIABLE_INITIAL_VALUE={0}' \
-D GOT_LEAK \
-D 'GOT_CPY=4' \
-D 'PRINT_DESCRIPTION="\t Finally, let`s see if you can pop a shell"'
###########################################
# ROP Chaining
# Need to add gadget functions, better with 64 bit
###########################################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~s
# Part A : Starting to ROP
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Get the function to return from the secret function to main
rop_level1 : $(SRC)
$(CC) $(SRC) -o $@ \
-g \
-D 'BUFFER_SIZE=20' \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D PRINT_SECRET_LOCATION \
-D PRINT_BUFFER_SIZE \
-D 'PRINT_STACK_RANGE_LOW=-16' \
-D 'PRINT_STACK_RANGE_HIGH=64' \
-D PRINT_INITIAL_STACK \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D PRINT_ECHO_FRAME \
-D "PRINT_ECHO_FRAME_INITIAL = -20" \
-D "PRINT_ECHO_FRAME_FINAL = 80" \
-D PRINT_REG \
-D PRINT_ESP_INITIAL \
-D PRINT_EBP_INITIAL \
-D PRINT_ESP_FINAL \
-D PRINT_EBP_FINAL \
-D PRINT_ESP_ECHO \
-D PRINT_EBP_ECHO \
-D PRINT_ESP_MAIN \
-D PRINT_EBP_MAIN \
-D PRINT_MAIN_LOCATION \
-D FUNCTION_JUMP \
-D GLOBAL_VARIABLE_ENABLED \
-D GLOBAL_VARIABLE_CMP \
-D "N_GLOBAL_VARIABLES = 1" \
-D "GLOBAL_VARIABLE_INITIAL_VALUE = {'\x01'}" \
-D "GLOBAL_VARIABLE_FINAL_VALUE = {'\x02'}" \
-D "HELP_STRING_FUNCT = global_variables[0]++" \
-D GLOBAL_CORRECTION_PRINT_OUTPUT \
-D 'PRINT_DESCRIPTION="\tThis time, you need to jump to the secret function, then convince it to return to main.\n\tRunning the entire main function again is not good enough, you should return to exactly where you left off.\n\n\n"'
# Now we care about doing this cleanly
rop_level2 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=124' \
-g \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D PRINT_SECRET_LOCATION \
-D PRINT_BUFFER_SIZE \
-D 'PRINT_STACK_RANGE_LOW=-16' \
-D 'PRINT_STACK_RANGE_HIGH=64' \
-D PRINT_INITIAL_STACK \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D PRINT_EXIT \
-D PRINT_ECHO_FRAME \
-D "PRINT_ECHO_FRAME_INITIAL = -20" \
-D "PRINT_ECHO_FRAME_FINAL = 80" \
-D PRINT_REG \
-D PRINT_ESP_INITIAL \
-D PRINT_EBP_INITIAL \
-D PRINT_ESP_FINAL \
-D PRINT_EBP_FINAL \
-D PRINT_ESP_ECHO \
-D PRINT_EBP_ECHO \
-D PRINT_ESP_MAIN \
-D PRINT_EBP_MAIN \
-D PRINT_MAIN_LOCATION \
-D FUNCTION_JUMP \
-D GLOBAL_VARIABLE_ENABLED \
-D GLOBAL_VARIABLE_CMP \
-D "N_GLOBAL_VARIABLES = 1" \
-D "GLOBAL_VARIABLE_INITIAL_VALUE = {'\x01'}" \
-D "GLOBAL_VARIABLE_FINAL_VALUE = {'\x02'}" \
-D "HELP_STRING_FUNCT = global_variables[0]++" \
-D GLOBAL_CORRECTION_PRINT_OUTPUT \
-D 'PRINT_DESCRIPTION="\tSimilar to last time, you need to jump to the secret function, then convince it to return to main.\n\tThis time you should ensure that the program does not segfault when it exits.\n\n\n"'
# Now we start chaining properly
rop_level3 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=256' \
-g \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D PRINT_SECRET_LOCATION \
-D PRINT_BUFFER_SIZE \
-D 'PRINT_STACK_RANGE_LOW=-16' \
-D 'PRINT_STACK_RANGE_HIGH=64' \
-D PRINT_INITIAL_STACK \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D PRINT_EXIT \
-D PRINT_ECHO_FRAME \
-D "PRINT_ECHO_FRAME_INITIAL = -20" \
-D "PRINT_ECHO_FRAME_FINAL = 80" \
-D PRINT_REG \
-D PRINT_ESP_INITIAL \
-D PRINT_EBP_INITIAL \
-D PRINT_ESP_FINAL \
-D PRINT_EBP_FINAL \
-D PRINT_ESP_ECHO \
-D PRINT_EBP_ECHO \
-D PRINT_ESP_MAIN \
-D PRINT_EBP_MAIN \
-D PRINT_MAIN_LOCATION \
-D FUNCTION_JUMP \
-D GLOBAL_VARIABLE_ENABLED \
-D GLOBAL_VARIABLE_CMP \
-D "N_GLOBAL_VARIABLES = 1" \
-D "GLOBAL_VARIABLE_INITIAL_VALUE = {'\x01'}" \
-D "GLOBAL_VARIABLE_FINAL_VALUE = {'\x05'}" \
-D "HELP_STRING_FUNCT = global_variables[0]++" \
-D GLOBAL_CORRECTION_PRINT_OUTPUT \
-D 'PRINT_DESCRIPTION="\tYou may have noticed that entering the secret function increments the global value.\n\t This time you need to get the global value to `\\x05`, it starts at `\\x01`.\n\t Good luck!\n\n\n"'
# Passing arguments through the chain
rop_level4 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=69' \
-g \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D PRINT_SECRET_LOCATION \
-D PRINT_BUFFER_SIZE \
-D 'PRINT_STACK_RANGE_LOW=-16' \
-D 'PRINT_STACK_RANGE_HIGH=64' \
-D PRINT_INITIAL_STACK \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D PRINT_EXIT \
-D PRINT_ECHO_FRAME \
-D "PRINT_ECHO_FRAME_INITIAL = -20" \
-D "PRINT_ECHO_FRAME_FINAL = 80" \
-D PRINT_REG \
-D PRINT_ESP_INITIAL \
-D PRINT_EBP_INITIAL \
-D PRINT_ESP_FINAL \
-D PRINT_EBP_FINAL \
-D PRINT_ESP_ECHO \
-D PRINT_EBP_ECHO \
-D PRINT_ESP_MAIN \
-D PRINT_EBP_MAIN \
-D PRINT_MAIN_LOCATION \
-D FUNCTION_JUMP \
-D FUNCTION_VARIABLE_ENABLED \
-D FUNCION_ARGS_PTR \
-D FUNCTION_VARIABLE_SKIP_CHECK \
-D 'FUNCTION_ARGS_DECL = char arg' \
-D GLOBAL_VARIABLE_ENABLED \
-D GLOBAL_VARIABLE_CMP \
-D "N_GLOBAL_VARIABLES = 1" \
-D "GLOBAL_VARIABLE_INITIAL_VALUE = {'\x01'}" \
-D "GLOBAL_VARIABLE_FINAL_VALUE = {'\x05'}" \
-D "HELP_STRING_FUNCT = if (arg='\x42') { global_variables[0]++;}" \
-D GLOBAL_CORRECTION_PRINT_OUTPUT \
-D 'PRINT_DESCRIPTION="\tThis time our hidden function takes a one byte input.\n\t It will need to be equal to `\\x42` for the global value to increment.\n\n\n"'
# Just calling our own functions, nobody mind us
rop_level5 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=420' \
-g \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D PRINT_SECRET_LOCATION \
-D PRINT_BUFFER_SIZE \
-D 'PRINT_STACK_RANGE_LOW=-16' \
-D 'PRINT_STACK_RANGE_HIGH=64' \
-D PRINT_INITIAL_STACK \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D PRINT_EXIT \
-D PRINT_ECHO_FRAME \
-D "PRINT_ECHO_FRAME_INITIAL = -20" \
-D "PRINT_ECHO_FRAME_FINAL = 80" \
-D PRINT_REG \
-D PRINT_ESP_INITIAL \
-D PRINT_EBP_INITIAL \
-D PRINT_ESP_FINAL \
-D PRINT_EBP_FINAL \
-D PRINT_ESP_ECHO \
-D PRINT_EBP_ECHO \
-D PRINT_ESP_MAIN \
-D PRINT_EBP_MAIN \
-D PRINT_MAIN_LOCATION \
-D FUNCTION_JUMP \
-D GLOBAL_VARIABLE_ENABLED \
-D GLOBAL_VARIABLE_CMP \
-D "N_GLOBAL_VARIABLES = 1" \
-D "GLOBAL_VARIABLE_INITIAL_VALUE = {'\x01'}" \
-D "GLOBAL_VARIABLE_FINAL_VALUE = {'\xff'}" \
-D "HELP_STRING_FUNCT = global_variables[0]--" \
-D GLOBAL_CORRECTION_PRINT_OUTPUT \
-D 'PRINT_DESCRIPTION="Calling functions is an incredibly useful skill for ROP chaining.\n\t However, there are more functions than just those in the code.\n\t Get the global counter to have a value of `\\xff`.\n\n\n"'
# Passing bad values
rop_level6 : $(SRC)
$(CC) $(SRC) -o $@ \
-D 'BUFFER_SIZE=10' \
$(NOSTACKPROTECT) $(32BIT) $(OMITFRAMEPOINTER) \
-D PRINT_BUFFER_SIZE \
-D PRINT_INITIAL_STACK \
-D 'PRINT_STACK_RANGE_HIGH=10' \
-D 'PRINT_STACK_RANGE_LOW=-10' \
-D PRINT_FINAL_STACK \
-D CLEAR_INITIAL_BUFFER \
-D ECHO_RETURN_ENABLED \
-D 'ECHO_RETURN_TYPE=BYTE' \
-D 'ECHO_RETURN_ARG=ret_arg' \
-D 'ECHO_RETURN_ARG_DECL=BYTE ret_arg' \
-D 'ECHO_RETURN_ARG_INITIAL_VALUE=170' \
-D 'ECHO_RETURN_ARG_FINAL_VALUE=9' \
-D ECHO_RETURN_CORRECTION_PRINT_OUTPUT \
-D ECHO_RETURN_CORRECTION_PRINT_CORRECT \
-D 'PRINT_DESCRIPTION="\tLet`s wind back a little bit. all you need to do this time is get the value x09 onto the stack and return it.\n The byte you`re trying to target should be pre-filled with xAA. This likely won`t help you at all.\n\n\n"' \
###########################################
# Exec on the Heap #
###########################################
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Part A : Canary Evasion
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~
###########################################
# 64 Bits #
###########################################
###########################################
# ASLR #
###########################################
.PHONY: clean
clean:
rm -f $(CLEAN_TARGETS)