forked from mufeedvh/code2prompt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbinary-exploitation-ctf-solver.hbs
54 lines (42 loc) · 1.72 KB
/
binary-exploitation-ctf-solver.hbs
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
Challenge Name: {{challenge_name}}
Category: Binary Exploitation
Description: {{challenge_description}}
Provided Files:
{{#each files}}
{{#if code}}
`{{path}}`:
{{code}}
{{/if}}
{{/each}}
To solve this binary exploitation challenge:
1. Examine the provided source code (if any):
- Identify vulnerabilities (buffer overflow, use-after-free, integer issues, etc.)
- Understand intended behavior and user input
- Note compiled binary type (ELF 32/64-bit, Windows PE, etc.)
2. Perform static analysis on the binary:
- Enumerate input vectors (local files, network port, stdin, etc.)
- Reverse engineer relevant code paths
- Locate vulnerable functions (unsafe C functions, syscalls, etc.)
- Check for stack canaries, NX, PIE, ASLR, RELRO
3. Proceed to dynamic analysis:
- Attach debugger and send input
- Determine segfault type (IP overwrite, invalid read/write, etc.)
- Inspect registers, stack, heap contents
- Dump process memory
- Set breakpoints and watchpoints as needed
4. Develop your exploit strategy:
- Goal (EIP control, arbitrary read/write, information leak, etc.)
- Payload (spawning a shell, leaking a flag, ret2libc, ROP, etc.)
- Method to reach vulnerable code
- Bypassing any exploit mitigations
5. Construct your exploit payload:
- Determine bad characters and encoding
- Find ROP gadgets, function addresses, etc. as needed
- Use pwntools, Ropper, one_gadget, etc.
- Build payload in debugger, then script it
6. If remote, ensure your exploit is stable and reliable:
- Adapt to remote environment
- Handle network quirks, latency
- Encode payload for transmission
7. Launch the exploit, catch the shell or leaked flag.
Include your process, not just the final payload. Stay within scope (no attacking unintended targets).