4.2 Rebuild Nop Constraint
For the nop constraint, in order to make the nop area
in the code as large as possible, CRAX uses
dichotomy to gradually determine the nop area step
by step between the start address of the symbolic
memory area and the start address of shellcode.
1. When the constraint is first constructed, try to
arrange all the nop between the symbolic memory
area and the shellcode starting address, that is, the
initial before endpoint and after endpoint used in the
record dichotomy are low= symbolicArea
_startAddr, high= shellcodeaddress-1, and the nop
area starting address is nopAttempt= symbolicArea
_startAddr.
2. Try to construct a constraint that sets all
contents from nopAttempt to high as nop, and add
nop constraint to exploit constraint. After building
exploit constraint, determining the solubility of the
result with the combination of exploit constraint and
path constraint.
3. If the decision result is solvable, it indicates
that under the current condition, all nop areas can be
covered as nop. Try to use dichotomy to expand nop
interval, so determine whether abs(high-low) <= 1.
If not, the nop area still can expand. Make
successPivot = nopAttempt, nopAttempt =
(failedPivot + successPivot)/2, and then go to step 2.
If true, the nop area cannot be expanded, then
nop_constraint is returned.
4. If the decision result is unsolved, in the
current condition, the number of bytes in the nop
area cannot be assigned to the nop, so try to narrow
down the nop interval by using the dichotomy.
Determine whether the condition abs(high - low)<=1
is true. If not, make low=nopAttempt,
nopAttempt=(low+ high)/2, and then go to step 2 to
construct the nop constraint. If the condition is true,
it returns nop_constrait 0.
4.3 Rebuild Eip Constraint
1. For eip constraint, if the nop constraint is not
empty, try to make the value used to cover the ip
register within the nop area, or point directly to the
shellcode starting address, and construct the
corresponding constraint accordingly. If the nop
constraint is empty, try to directly builds constraints
that make the ip register equal to the shellcode start
address.
2. If eip constraint is added to exploit constraint
determine whether there is a solution to the exploit
constraint. If yes, try to determine the maximum
range that nop area can obtain by dichotomy, that is
to advance the start address of nop area by
dichotomy. Make high=nopAttempt,
nopAttempt=(low+high)/2, and determine whether
the end of dichotomy condition abs(high-low) <= 1
is true. If it is true, then the exploit constraint is the
final constraint and constraint building has solution;
then simplifing the constraint and solving the
constraint by the constraint solver, the final
vulnerability exploit constraint code can be obtained.
If the end condition of dichotomy is not true, try
again to construct the nop constraint in 2 according
to the new high, low and nopAttempt values.
3. If the exploit constraint obtained in 2 is
determined to be unsolved after solving, it means
that the eip constraint cannot fall within the nop area
or directly points to the shellcode starting address.
Then, it is considered that whether the nop area
space can be expanded by dichotomy to expand the
feasible range of eip constraint. Then, the start
address of nop area is brought forward to make
high=nopAttempt, nopAttempt=(low+high)/2, and
then judge whether the condition abs(high-low)<= 1
is true. If it is not true, the nop constraint is
reconstructed again according to the new high, low
and nopAttempt values. If true, when reaching end
but there is no feasible solution, go to step 1, move
the shellcode start address one ahead, and rebuild
the shellcode constraint.
5 CONCLUSION
CRAX is an automatic development and generation
framework based on S2E. In order to generate
control flow hijacking attacks, it focuses on
symbolized EIP, registers, and pointers, and propose
a systematic method for searching maximum
contiguous symbolic memory for payload injection.
Experiments on various vulnerable sample codes
show that CRAX can handle different types of
control flow hijacking vulnerabilities. At the same
time, it analyzed and utilized the vulnerability faster
and more efficiently than manual debugging. CRAX
is also a viable and powerful development tool for
real-world environments.
But CRAX has limitations. First of all, it mainly
focuses on the automated analysis of stack overflow
vulnerability, while the automated analysis of heap
overflow vulnerability remains to be studied.
Secondly, it does not consider the influence of
ASLR, DEP and other protection mechanisms on
automatic analysis.