shellcode Flashcards

1
Q

initialize data with

A

db, dw,dq

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

$

A

evaluates to current line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

$$

A

evaluates to current section

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

times

A

used to execute one expression multiple times, eg. times 100 movsb runs it 100 times

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

CALL

A

FF Dx. This could be anything from D0 to D7 based on the register that it’s referencing. Again you’re just trying to recall what a command does when you see it, so you don’t have to memorize the number for each register.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

JMP

A

EB. You’re going to be seeing this one alot!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

INC

A

4x. Again this goes from 40 to 47 depending on the register. When you fuzz a program you’re going to be using a lot of A’s, B’s and C’s which translate to 41, 42, 43 respectively. That means that sending A (or 41 in hex) to a program, will be interpreted as a INC ECX command. This is useful to know not just for quickly identifying where your offset lands, but also as a reminder that they can be interpreted as commands.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

DEC

A

4x. This carries on where INC stopped and goes from 48 to 4F depending on the register.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

XOR

A

33

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

jump (or call)

A

a register that points to the shellcode. With this technique, you basically use a register that contains the address where the shellcode resides and put that address in EIP. You try to find the opcode of a “jump” or “call” to that register in one of the dll’s that is loaded when the application runs. When crafting your payload, instead of overwriting EIP with an address in memory, you need to overwrite EIP with the address of the “jump to the register”.� Of course, this only works if one of the available registers contains an address that points to the shellcode. This is how we managed to get our exploit to work in part 1, so I’m not going to discuss this technique in this post anymore.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

pop return

A

If none of the registers point directly to the shellcode, but you can see an address on the stack (first, second, … address on the stack) that points to the shellcode, then you can load that value into EIP by first putting a pointer to pop ret, or pop pop ret, or pop pop pop ret (all depending on the location of where the address is found on the stack) into EIP.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

push return

A

this method is only slightly different than the “call register” technique.� If you cannot find a or opcode anywhere, you could simply put the address on the stack and then do a ret.� So you basically try to find a push , followed by a ret.� Find the opcode for this sequence, find an address that performs this sequence, and overwrite EIP with this address.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

jmp [reg + offset]

A

If there is a� register that points to the buffer containing the shellcode, but it does not point at the beginning of the shellcode, you can also try to find an instruction in one of the OS or application dll’s, which will add the required bytes to the register and then jumps to the register. I’ll refer to this method as jmp [reg]+[offset]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

blind return

A

in my previous post I have explained that ESP points to the current stack position (by definition).� A RET instruction will ‘pop’ the last value (4bytes) from the stack and will put that address in ESP. So if you overwrite EIP with the address that will perform a RET instruction, you will load the value stored at ESP into EIP.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

limited space

A

If you are faced with the fact that the available space in the buffer (after the EIP overwrite) is limited, but you have plenty of space before overwriting EIP, then you could use jump code in the smaller buffer to jump to the main shellcode in the first part of the buffer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

SEH

A

Every application has a default exception handler which is provided for by the OS. So even if the application itself does not use exception handling, you can try to overwrite the SEH handler with your own address and make it jump to your shellcode. Using SEH can make an exploit more reliable on various windows platforms, but it requires some more explanation before you can start abusing the SEH to write exploits.� The idea behind this is that if you build an exploit that does not work on a given OS, then the payload might just crash the application (and trigger an exception). So if you can combine a “regular” exploit with a seh based exploit, then you have build a more reliable exploit. Anyways, the next part of the exploit writing tutorial series (part 3) will deal with SEH.�� Just remember that a typical stack based overflow, where you overwrite EIP, could potentionally be subject to a SEH based exploit technique as well, giving you more stability, a larger buffer size (and overwriting EIP would trigger SEH… so it’s a win win)