Limited characters, process and much more Flashcards

1
Q

From what part of memory DLL’s can be used to choose PPR?

A

Either application DLL, application exe or system DLL’

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

How to find all instances of shellcode?

A

Save the shellcode in bin file and compare with memory using MSF pattern and bin file comparison

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

How can we troubleshoot the final shellcode before egg hunter jumps to it?

A

look into all memory regions where final shell code is and see it is unmodified. Setup breakpoints in egg hunter and diagnose

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

Why do we use NOPS or NOP equivalent instructions?

A

Bcoz the encoded shellcode will get decoded. So it is good have NOPS or NOP like instruction to allow space for decoding

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

How do we know whether an exploit broken or not bcoz of opcodes and how to verify it before?

A

For any code that we write, we need to know it’s opcode and ascii value to speculate the possibility of exploit getting broken

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

What are things that we need to consider before choosing PPR?

A

It should not be compiled with safeSEH and it is subjected to limited charset. So pick an address in allowed ascii charset

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

How will you search PPR address?

A

Either through mona or manually search through immunity

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

How is limited charset different from ascii range?

A

Though ascii characters are printable, only few charters are allowed in certain buffer spaces like username, filename, etc. So we have a limited charset within ascii range

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

What are the problems if shellcode is not executing?

A

It could be due to wrong architecture of shellcode or it could be some missing sys cal functions or it could be due to port numbers or it could be due to ESP alignment corruption

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

Do we have to use alpha3 to encode egg hunter evrey time for limited charset scenario?

A

We should only use alpha3 egghunter only when we have limited nuffer above REt overw rite and final shell code is somewhere is memory, unmodified.

If the final shell code is below the RET overwrite then the final shell code can be encoded. We have plenty of room!!!!!

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

Do we have to write custom code based on stack and memory?

A

No, custom code can be created based on chosen register and its offset with egg hunter starting byte. Just a common addition and subtraction.

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

Why we use sub EAX and why not other registers?

A

Bcoz sub EAX comes under allowed limited charset

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

What are the possible problems if the egg hunter is not executing?

A

It could be due to sys call code or it could be due to executing corrupt code or it could be due to absence of NOPS like instructions before the encoded egg hunter

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

How can we position ESP at bottom to run custom decoded code?

A

By few pop functions

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

How can we troubleshoot egg hunter?

A

We can troubleshoot egg hunter by looking into the starting EDX value and then see from where it begins.etup breakpoints in egg hunter and diagnose

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

How do we find compatible characters?

A

We need to research and find the list of characters possible in the exploit .I.e filenames compatible depending upon the place where exploit is written ‘/‘ is not file compatible but still it will work in file name inside zip folder

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

Alternate scenario to adjust ESP and jumping to final shell code?..”Hitting two birds in one stone”

The custom decoder will push bytecode to the stack. In order to be able to execute that bytecode, we will need to control the location where this code is written to, so we can get it to execute after it was reproduced. That location is esp.

So perhaps we can use the same value as esp and put that in ebx, and use it as base address for doing the math. That way, we may be able to do our math calculation and produce the desired address in ebx, based on that value

A

There are a number of ways to modify esp. We could copy a value from a register, or pop one from the stack. If we have a good start value in esp, we can easily put it in ebx as well.

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

Why should you modify the egg hunter starting position?

A

Bcoz it takes lot of time to search through memory locations. Hence we should modify. Also there might be lot of chances to execute the corrupt code first

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

How to choose the NOPS in limited scenario?

A

It is based on a register which is not a buffer register and also at times we should also look for other things like EDX in egg hunter (e.g. inc edx 42 and ins eax 40)

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

Should we really care about egg - in character limitation scenario?

A

Yes if the egg contains bad character it might break the exploit

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

How can we position ESP above RET overwrite to execute custom code?

A

By using some conditional jump statements

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

How do you choose the buffer register for custom encoder?

A

Buffer can be chosen after we copy the egg hunter and see which registers are close by . The egg hunter can be again recreated using the identified new buffer

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

How can we walk over PPR address?

A

We have to choose PPR in such a way that it aligns and execution pass through the code below

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

If pop esp”/” in ESP alingment breaks the exploit then what would be another way?

A

Is to use POPAD to basically reduce down to ESP or junk fillers. If the number of instrcution in popad is not not enough to be filled in the stack below, then jump above ret overwrite and put them for enough room

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

Wy do we use various junks in exploits?. What is the use of it?

A

[junk1]+[nseh]+[seh]+[code to align ebx & jump ebx]+[junk2]+[encoded shellcode]+[junk3] [297] [4] [4] [100 bytes] [x bytes] [fill]

where junk1 = offset to nseh, junk2 = amount of bytes needed to fill the space between the code to align ebx and the start location of that code + 100 bytes, and junk3 = the amount of bytes needed to fill the buffer up to 4064 bytes.

It can be used to calculate fixed locations to jumo for example,

0x0012FC04 + 100 bytes (0x64 bytes).

26
Q

What effect in exploit flow can PPR DLL can create in choosing app, system dll’s?

A

If OS dll are chosen, then it might have slight chances of not working in other machines If application exe is used, then exploit flow has to be taken care above the Ret overwrite If application DLL is used then it can be universal

27
Q

Why do we do a conditional jump in limited scenario?

A

Bcoz pointer to NSEH is a limited character set which will not accept short jumps

28
Q

Why do we use add EAX to make it zero?

A

t is a simple arithmetic. if Number1 AND number 2 is zero then ADD EAX,NUM1 and ADD eax,num2 is zero

29
Q

How do we find the bad characters in limited set?

A

t is very difficult to identify difference between the character conversion and bad character as both are generally called bad characters .The former basically get converted to something else but latter just truncates the flow . So it is always good to encode the shellcode using alpha numeric

30
Q

How can we find offset to conditional jumps in limited scenario?

A

By taking advantage of charset conversion

31
Q

What if, if you don’t have a conditional jump?

A

We can walk over the PPR and NSEH over to shellcode

32
Q

How can we find if PPR address cannot be used for walk through method “Unicode method”?

A

We have take the PPR values

0x6D7E4331

And assemble it as below,

0012FC00 3143 7E XOR DWORD PTR DS:[EBX+7E],EAX 0012FC03 6D INS DWORD PTR ES:[EDI],DX

and look inot eax and ebx registers to see if they cause address violation

33
Q

What is the difference between MSF pattern and bin file comparison?

A

MSF pattern already uses file compatible characters so it is always good to do bin file comparison to see if it that particular memory is also subjected to charset limitation

34
Q

How do we align ESP for executing custom decoded shellcode?

A

It can be aligned based on registers and stack values. The stack can be positioned either at top of Ret overwrite or bottom after SEH overwrite

35
Q

Why the buffer register cannot be eax for alpha code?

A

It is because eax is used in custom encoder and it is not possible to fix the value of eax to egg hunter starting point as it holds the decoded value

36
Q

Why do we use alpha3 over metasploit?

A

Bcoz metasploit getpc routine is not alpha numeric

37
Q

How do we write the custom encoded shellcode?

A

Basically we have to make EAX zero by few add instruction and then take 2’s complement and using sub we have to recreate those bytes

38
Q

What’s the issue of using poppad as opposed to pop?

A

Both can be used but if the buffer register for alpha code is used, it might change the offset that was previously calculated and we have to do the math again. Doing the math again popped is also a good way but custom decoder has to be written again. Instead pop is used which is totally acceptable

39
Q

Do we have to encode final shellcode?

A

Yes and may be. Yes using alpha encoder coz if it part of She overflow and characters should not interrupt the SEH chain May be it can be used as it is if it does not interrupt the SEH overwrite chain If it is below the overwrite we don’t have to normally encode

40
Q

What are the two major ways of overwriting and exploitation?

A

Direct RET and SEH method

41
Q

What should we do before placing custom encoded code in stack ?

A

First we have to align the ESP and then create custom encoder and finally run the decoded code

42
Q

If we cant adjust ESP by poping any values from stack ..how could we achieve it ?

A

By doing some conditional jumps to top and sliding between non equivalent instructions into reproduced custom code

43
Q

How can you get the list of all converted characters?

A

Basically we can take a portion of byte area and prepend a string and include it as part of buffer. Then later it can be searched in immunity to get to that memory location and find the conversions. “Need more research on this”

44
Q

If PPR compiled with safeseh is not found in application DLL.what would be the next approach?

A

To search in OS DLL range

45
Q

How to assemble instructions in mona plugin?

A

!mona assemble -s “pop eax#inc ebx#ret”

46
Q

How to use help function in mona?

A

!mona help

47
Q

Mona has a second configuration parameter, allowing you to always exclude certain modules from search operations. ?

A

!mona config -set excluded_modules “module1.dll,module2.dll” !mona config -add excluded_modules “module3.dll”

48
Q

what is global options in mona?

A

Global options allow you to influence and fine tune the results of any search command that produces a list of pointers.

49
Q

-n global option in mona?

A

If you use option -n, all modules that start with a null byte will be skipped. This will speed up the searches, but it might miss some results because the module might actually contain pointers that don’t start with a null byte. If this behaviour is too broad, and if you only want to exclude pointer with null bytes, then you should either use option -cp nonull or option -cpb ‘\x00’ (see below)

50
Q

-o global option in mona?

A

This option will tell mona to ignore OS module from search operations. As you will see in the documentation of each command, this is often the default behaviour. You will be able to overrule the behaviour using the -cm option (see later)

51
Q

-p global option in mona?

A

This option takes one argument : a numeric value. Option -p allows you to limit the number of results to return. If you only want 5 pointers, you can use option -p 5

52
Q

-m global option in mona?

A

This option allows you to specify the modules to perform the search operation on. If you specify -m, it will ignore all other module criteria (set by option -cm or set as default behaviour for a given command). You can specify multiple modules by separating them with comma’s.

Example : suppose you want to include all modules that start with “gtk”, all modules that contains “win” and module “shell32.dll”, then this is what the option should look like :

-m “gtk*,*win*,shell32.dll”

53
Q

-cm option in mona?

A

option -cm

This option allows you to set the criteria (c) a module (m) should comply with to get included in search operations.

The available criteria are :

aslr

rebase

safeseh

nx

os

If you want to include aslr and rebase modules, but exclude safeseh modules, you can use

-cm aslr=true,rebase=true,safeseh=false

(note : this will also include the non aslr and non rebase modules). You can use the “true” value to override defaults used in a given command, you can use “false” to force certain modules from getting excluded).

If you want more granularity, you can use the -m “module1,module1” option (basically tell mona to search in those modules and only those modules)

54
Q

-cp global option in mona?

A

option -cp

The cp option allows you to specify what criteria (c) a pointer (p) should match. pvefindaddr already marked pointers (in the output file) if they were unicode or ascii, or contained a null byte, but mona is a lot more powerful. On top of marking pointers (which mona does as well), you can limit the returning pointers to just the ones that meet the given criteria.

The available criteria are :

unicode (this will include unicode transforms as well)

ascii

asciiprint

upper

lower

uppernum

lowernum

numeric

alphanum

nonull

startswithnull

If you specify multiple criteria, the resulting pointers will meet ALL of the criteria. If you want to apply “OR” to the criteria, you’ll have to run multiple searches.

We believe this is a very strong feature. Especially with ROP exploits (where large parts of the payload consist of pointers and not just shellcode), the ability to finetune the pointer criteria is very important (and an often missing feature from other search tools).

Example : only show pointers that contain ascii printable bytes

-cp asciiprint

55
Q

-cpb global option in mona?

A

This option allows you to specify bad characters for pointers. This feature will basically skip pointers that contain any of the bad chars specified at the command line.

Suppose your exploit can’t contain \x00, \x0a or \x0d, then you can use the following global option to skip pointers that contain those bytes :

-cpb ‘\x00\x0a\x0d’

56
Q

-x option in mona?

A

This option allows you to set the desired access level of the resulting pointers. In most cases, pointers should part of an executable page, but in some cases, you may need to be able to look for pointers (or data) in non-executable area’s as well.

The available values for -x are :

*

R

RW

RX

RWX

W

WX

X

In all cases the default setting will be X (which includes X, RX,WX and RWX)

57
Q

bytearray in mona?

A

The “bytearray” option was implemented to assist exploit developers when finding bad chars. It will produce an array with all bytes between \x00 and \xff (except for the ones that you excluded), and writes the array to 2 files :

a text file containing the array in ascii format (bytearray.txt)

a binary file containing the same array (bytearray.bin)

Optional arguments :

  • b : exclude these bytes from the array
  • r : show the array in reverse (starting at \xff, end at \x00)

!mona bytearray -b ‘\x00\x0a\x0d’

58
Q

compare in mona?

A

-f : points to a binary file containing the bytes to locate and compare in memory

You can use this command to find bad chars (as explained earlier), but you can also use it to see if your shellcode got corrupted in memory.

You could, for example, write tag+tag+shellcode (egghunter egg) to a binary file and use the compare command to find the eggs and show if they got corrupted or not. If some of them do, others don’t, you’ll know if and how you have to tweak the start location of the hunter, or just use a checksum routine.

59
Q

various ways to jump accoriding to mona?

A

jmp reg

call reg

push reg + ret (+ offsets)

push reg + pop r32 + jmp r32

push reg + pop r32 + call r32

push reg + pop r32 + push r32 + ret (+ offset)

xchg reg,r32 + jmp r32

xchg reg,r32 + call r32

xchg reg,r32 + push r32 + ret (+ offset)

xchg r32,reg + jmp r32

xchg r32,reg + call r32

xchg r32,reg + push r32 + ret (+ offset)

mov r32,reg + jmp r32

mov r32,reg + call r32

mov r32,reg + push r32 + ret (+offset)

jmp r32

jmp [esp]

jmp [esp+offset]

jmp [r32]

jmp [r32+offset]

60
Q

List of modules which has no safe seh and aslr in mona?

A

This command is a wrapper around the “modules” command. It will show all modules that don’t have safeseh and aslr enabled by calling the modules function with global option -cm safeseh=false,aslr=false

61
Q

How to find distnace between to registers in mona?

A

This command will show the distance between 2 addresses, and will show the offset in hex which can be used to make a jump forward or backwards.

Mandatory arguments :

  • a1 : the start address or register
  • a2 : the end address or register