Code represented in hex for executing shell operations with int 0x80</code>andspecificregistersmanipulationasdetailed.</p></li></ul></li></ul><h3id="712194e5−2689−4070−b56c−591d8bde11a3"data−toc−id="712194e5−2689−4070−b56c−591d8bde11a3"collapsed="false"seolevelmigrated="true">Page20</h3><ul><li><p><strong>RetrievingObjectCode</strong></p><ul><li><p>Useof<code>objdump</code>fordisassemblyandverificationofinjectedshellcodestructure.</p></li></ul></li></ul><h3id="f2feeecb−4c91−4917−83c4−3594bc8128a3"data−toc−id="f2feeecb−4c91−4917−83c4−3594bc8128a3"collapsed="false"seolevelmigrated="true">Page21</h3><ul><li><p><strong>CraftingExploitMethodology</strong></p><ul><li><p>Strategiesinvolvingsettingtherightreturnaddressandpositioningofshellcodeeffectivelyinthebuffer.</p></li></ul></li></ul><h3id="02a30cb5−8d47−4780−8f94−9f16cf73aa53"data−toc−id="02a30cb5−8d47−4780−8f94−9f16cf73aa53"collapsed="false"seolevelmigrated="true">Page22</h3><ul><li><p><strong>OtherAttackVectors</strong></p><ul><li><p>Includereturn−orientedprogramming,heapoverflow,stringoverflow,integeroverflow.</p></li></ul></li></ul><h3id="16532ddb−d4e0−42a7−bfa4−f8f835cccc94"data−toc−id="16532ddb−d4e0−42a7−bfa4−f8f835cccc94"collapsed="false"seolevelmigrated="true">Page23</h3><ul><li><p><strong>ReturnOrientedProgramming(ROP)</strong></p><ul><li><p>Techniquesinvolvingstackbufferoverflowswithouttheneedtoinjectcodedirectly,usingalreadyloadedcodetoexecuteactions.</p></li><li><p><strong>Stackbufferoverflow</strong></p><ul><li><p>Changereturnaddress</p></li><li><p>Injectcodetostack</p></li><li><p>Executestack</p></li><li><p>Doesnotworkwhenstackisnotexecutable</p></li></ul></li></ul></li><li><p>TraditionalStackBufferOverflowvs.ROP</p><pclass="whitespace−pre−wrapbreak−words">Traditionalstackbufferoverflowsworkedby:</p><ol><li><p>Overflowingabufferonthestack</p></li><li><p>Injectingmaliciouscodeintothestack</p></li><li><p>Overwritingthereturnaddresstopointtothisinjectedcode</p></li><li><p>Whenthefunctionreturns,themaliciouscodeexecutes</p></li></ol><pclass="whitespace−pre−wrapbreak−words">Thisapproachwasmitigatedby<strong>non−executablestack</strong>protections(NX/DEP),whichpreventcodeonthestackfromexecuting.</p><h3id="2b154989−8373−48dc−9094−4854f77b3b0b"data−toc−id="2b154989−8373−48dc−9094−4854f77b3b0b"collapsed="false"seolevelmigrated="true">ROPTechnique</h3><pclass="whitespace−pre−wrapbreak−words">Sincecodeinjectionnolongerworkswiththeseprotections,ROPtakesadifferentapproach:</p><ol><li><p>Insteadofinjectingnewcode,ROPreusesexistingcodealreadyloadedinmemory</p></li><li><p>Itidentifiessmallcodesequencesinexistinglibrariesthatendwithareturninstruction(called"gadgets")</p></li><li><p>Itchainsthesegadgetstogetherbycarefullyconstructingafakestack</p></li><li><p>Eachgadgetperformsasmalloperationandthen"returns"tothenextgadgetinthesequence,enablingtheattackertoexecutearbitrarycodewhilebypassingthesecuritymechanismsdesignedtopreventsuchattacks.</p></li></ol></li></ul><h3id="4dbb74b8−4161−40a8−88c3−ea0579d86a6f"data−toc−id="4dbb74b8−4161−40a8−88c3−ea0579d86a6f"collapsed="false"seolevelmigrated="true">Page24</h3><ul><li><p><strong>FindingCodetoExploit</strong></p><ul><li><p>Usingfunctionsorcodesnippetsalreadypresentinthememorytodirectcontroltodesiredexecutionpathsthroughmanipulations.</p></li></ul></li></ul><h3id="deb86f4a−5460−4969−b8fd−786be9f83bb9"data−toc−id="deb86f4a−5460−4969−b8fd−786be9f83bb9"collapsed="false"seolevelmigrated="true">Page25</h3><ul><li><p><strong>ExecutingShellfromlibc</strong></p><imgsrc="https://knowt−user−attachments.s3.amazonaws.com/c1c3aaeb−34c9−4923−b208−e895b573e94a.png"data−width="100esp: Points to the top of the stack, marking the most recent point in use.