You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+73Lines changed: 73 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -42,3 +42,76 @@ Secure Programming
42
42
-[Fix: Not in a hypervisor partition (HVP=0) (VERR_NEM_NOT_AVAILABLE) or VT-x is disabled in the BIOS for all CPU modes (VERR_VMX_MSR_ALL_VMX_DISABLED)](https://techsupportwhale.com/not-in-a-hypervisor-partition/)
43
43
-[Fix: Cannot install Ubuntu in VirtualBox due to "this kernel requires an x86-64 CPU, but only detects an i686 CPU, unable to boot" error](https://askubuntu.com/questions/308937/cannot-install-ubuntu-in-virtualbox-due-to-this-kernel-requires-an-x86-64-cpu)
44
44
-[Fix: Installation Step Failed (installing the system) - Kali Linux](https://unix.stackexchange.com/questions/208772/installation-step-failed-installing-the-system-kali-linux)
45
+
46
+
---
47
+
48
+
## Lab 1
49
+
50
+
**Lab 1: Format String
51
+
Vulnerabilities and Attacks**
52
+
53
+
-**Aim:** Perform the following using programming
54
+
1) Write a secure program by avoiding vulnerable programming factors
55
+
like Eval and printf.
56
+
2) Demonstrate Format string vulnerabilities with example
- The line printf("%s", argv[1]); in the example is safe, if you compile the program and run it:
85
+
-`./main "%s%s%s%s%s%s"`
86
+
- The printf in the first line will not interpret the “%s%s%s%s%s%s” in
87
+
the input string, and the output will be:
88
+
-`“%s%s%s%s%s%s”`
89
+
90
+
- The Vulnerable Code from the program
91
+
- The line printf(argv[1]); in the example is vulnerable, if you compile the program and run it:
92
+
-`./main "%s%s%s%s%s%s"`
93
+
- The printf in the second line will interpret the %s%s%s%s%s%s in the input string as a reference to string pointers, so it will try to interpret every %s as a pointer to a string, starting from the location of the buffer (probably on the Stack).
94
+
- At some point, it will get to an invalid address, and attempting to access it will cause the program to crash.
95
+
96
+
- Different Payloads
97
+
- An attacker can also use this to get information, not just crash the software.
- The first line is printed from the non-vulnerable version of printf, and the second line from the vulnerable line. The values printed are the values on the stack of my computer at the moment of running this example.
110
+
- Also reading and writing to any memory location is possible in some conditions, and even code execution
111
+
112
+
-**Result:**
113
+
- Format string vulnerabilities and exploits are successfully demonstrated by writing a C program with a secure code and a vulnerable code using printf function and string parameters
0 commit comments