summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2023-01-15shellcode: Move example code to a new directoryMalfurious2-0/+0
This is mainly done to keep the top working directory (where the Makefile lives) cleaner. Signed-off-by: Malfurious <m@lfurio.us>
2023-01-15shellcode: Drop SYS_EXIT samplesMalfurious2-16/+0
Signed-off-by: Malfurious <m@lfurio.us>
2022-09-12Merge branch 'sploit/symtbl-base'Malfurious2-8/+15
This branch brings some conveniences to the semantics behind Symtbl base values. * sploit/symtbl-base: sploit: rev: Properly base Symtbls for non-PIC binaries sploit: Fix bugs involving Symtbl base value sploit: mem: Allow Symtbl base to be modified
2022-09-12Merge branch 'sploit/payload-rop-prep'Malfurious1-32/+32
This branch provides some payload-specific upgrades that have come out of the development so far on the automated ROP chain builder. * sploit/payload-rop-prep: sploit: payload: Promote private methods to "protected" access sploit: payload: Clean up automatic symbol naming sploit: payload: Class no longer extends Symtbl sploit: payload: Allow variadic insertions
2022-09-12sploit: rev: Properly base Symtbls for non-PIC binariesMalfurious1-1/+6
The baddr property identified by r2 is now used as the base address for ELF symbol tables. This should not change the addresses retrieved via the table normally, however should fix the internal offsets of the table so that rebasing makes sense. Note that for PIC/PIE binaries we would already get a Symtbl with 'correct' offsets, as r2 is unable to absolutely resolve them for us. In these cases, the Symtbl base value remains at zero. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-09-12sploit: Fix bugs involving Symtbl base valueMalfurious2-3/+3
Some code previously assumed a Symtbl's base value to always be zero. This was often the case, however the assumption would break (for example) when attempting to rebase() a mapped Symtbl. As of the previous patch enabling freer modification of base, the potentiality of these bugs will be higher. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-09-12sploit: mem: Allow Symtbl base to be modifiedMalfurious1-6/+8
Allow a Symtbl's base to be modified in-place, without mapping into a new object. This is useful when working with the Symtbl aspect of a Payload. This includes setting a non-zero base on construction. As usual, when defining base on construction, any additional kwargs symbols are interpreted relative to the given base. The order of arguments does not matter. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-09-12sploit: payload: Promote private methods to "protected" accessMalfurious1-15/+15
Lift restriction (name mangling) to Payload helper functions, as their use will be useful in Payload subclasses. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-09-12sploit: payload: Clean up automatic symbol namingMalfurious1-10/+11
This is just a slight code reduction, but will make any future code simpler as well. Explicit comparision to None is more correct as well; centralizing this for reuse better justifies the wordier if statement. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-09-12sploit: payload: Class no longer extends SymtblMalfurious1-11/+8
Given the current design of Symtbl, creating subclasses of it gets more tedious the further one goes down a potential class hierarchy. As I am planning to introduce new features in the future that explicitly extend Payload, make this change now to minimize the impact. Additionally, switching Payload's relationship with Symtbl from "is-a" to "has-a" makes it more consistent with rev.ELF, the other major user of Symtbl. (And in both cases, the member is named 'sym') Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-09-12sploit: payload: Allow variadic insertionsMalfurious1-13/+15
Often times, users of the Payload module wish to push a list of integers to a payload buffer. Currently, the best (and intended) way to do this is to make several calls to .int(). However, as part of the ROP effort, I am planning to add function 'gadget(addr, *params)' to the Payload class. Per the design of this function, calling it with an expanded list of values would be equivalent to passing each to .int() individually. In order to discourage the use of .gadget(), as a shortcut to a series of .int()s, .int(), and most other insertion functions, now accept arbitrarily many value arguments. Functions that support additional options (such as .int()'s 'signed' parameter) will apply such options to all values. If a symbol name is defined, it will reference the beginning of the block of values. Keep in mind, this will also allow inserting zero values. For example, obj.bin(sym='end') will tag the end of the payload without extending its content. This use-case is not intended to be particularly useful, but exists as a consequence of the change. Payload.rep() and the pad functions are not affected by this commit, as I don't think changing their semantics in this way makes sense. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-08-21Merge branch 'malf-angstrom-2022'Malfurious5-0/+370
* malf-angstrom-2022: Writeup angstromCTF 2022 / whatsmyname Writeup angstromCTF 2022 / uninspired Writeup angstromCTF 2022 / baby3 Writeup angstromCTF 2022 / Auth Skip angstromCTF 2022 results
2022-05-07Writeup angstromCTF 2022 / whatsmynameMalfurious1-0/+115
Signed-off-by: Malfurious <m@lfurio.us>
2022-05-07Writeup angstromCTF 2022 / uninspiredMalfurious1-0/+150
Signed-off-by: Malfurious <m@lfurio.us>
2022-05-07Writeup angstromCTF 2022 / baby3Malfurious1-0/+43
Signed-off-by: Malfurious <m@lfurio.us>
2022-05-07Writeup angstromCTF 2022 / Auth SkipMalfurious1-0/+61
Signed-off-by: Malfurious <m@lfurio.us>
2022-05-05angstromCTF 2022 resultsMalfurious1-0/+1
Signed-off-by: Malfurious <m@lfurio.us>
2022-04-08Merge branch 'sploit/interactive-fixes'Malfurious1-3/+7
These patches correct some issues I've run into using the interactive workflow in Sploit during picoCTF. * sploit/interactive-fixes: sploit: Allow multiple reads in Comm.readall_nonblock() sploit: Fix units for Comm.timeout
2022-04-08sploit: Allow multiple reads in Comm.readall_nonblock()Malfurious1-2/+6
Due to line buffering, we may often trigger a burst of data to be sent by the target, but resolve the non-blocking read only after the first line is received. We would like to wait just a little longer to receive the entire burst instead. readall_nonblock() will now reset its timeout period whenever any data becomes readable and will not return until we go an entire period of silence. Under normal conditions, the full duration of readall_nonblock should barely be any longer than the defined period itself. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-04-08sploit: Fix units for Comm.timeoutMalfurious1-1/+1
select's poll.poll() function expects its timeout argument to be in milliseconds. This is an artifact from earlier developent where we were using the higher-level 'selectors' API, which never got merged. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-30Merge tag 'pull-sploit-arch-fix' of https://github.com/Dusoleil/lib-des-gnuxMalfurious1-1/+7
Add indirection to arch access * tag 'pull-sploit-arch-fix' of https://github.com/Dusoleil/lib-des-gnux: Add indirection to arch access
2022-03-30Merge branch 'malf-pico-2022'Malfurious5-0/+409
* malf-pico-2022: picoCTF 2022 results Add signal and coredump tips to gdb document Add writeup for picoCTF 2022 / unpackme Add writeup for picoCTF 2022 / Eavesdrop Add writeup for picoCTF 2022 / Wizardlike
2022-03-30picoCTF 2022 resultsMalfurious1-0/+2
Signed-off-by: Malfurious <m@lfurio.us>
2022-03-27Add signal and coredump tips to gdb documentMalfurious1-0/+26
Signed-off-by: Malfurious <m@lfurio.us>
2022-03-26Add writeup for picoCTF 2022 / unpackmeMalfurious1-0/+67
Signed-off-by: Malfurious <m@lfurio.us>
2022-03-26Add writeup for picoCTF 2022 / EavesdropMalfurious1-0/+48
Signed-off-by: Malfurious <m@lfurio.us>
2022-03-23Add writeup for picoCTF 2022 / WizardlikeMalfurious1-0/+266
Signed-off-by: Malfurious <m@lfurio.us>
2022-03-19Add indirection to arch accessdusoleil1-1/+7
Add a layer of indirection to access the active arch config. Currently when importing sploit.arch.arch, the name will be bound to whatever the current reference is and won't follow if another module (user script) updates the reference in sploit.arch. A layer of indirection seemlessly solves that issue and also provides a cleaner interface for setting the active arch from the user script. Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-17sploit: Rework payload builderMalfurious1-57/+68
The design/implementation of class Payload is updated for better compatibility with Symtbl, and to address some usability issues that have come up so far: No more automatically fixed-up stack alignment by default: In fact, alignment as a concept is fully removed from the tool, in preparation for another upcoming ROP-centric addon to Payload. Therefore, insertion of return addresses (via .ret()) are now equivalent to any other integer value. No instance size value: Each call to .pad() uses an independent size passed as a parameter, but functions in the same manor as before. Padding can also now be inserted at the beginning of the payload: .pad_front() prepends the necessary amount of data, and updates the tracked offsets of values that were already inserted to the payload. Payload now directly extends Symtbl: Instead of possessing a Symtbl member, payload objects can directly be treated as symbol tables for things like mounting them as subtables, or mapping them to access absolute addresses. New call syntax to access binary data: As a shorthand, users may now use the call syntax to get the bytes string built by the tool. If an argument is passed, it is another byte string containing illegal bytes that we check the built payload for. Unfortunately, the __str__ magic func doesn't like returning bytes string; plus, that overload is already in use for formatting the symbol table content (worth not hiding). New semantic insertion functions: .bin(), .str() [C-style strings], .int(), .ret(), and more. Some of these functions are direct synonyms, however their use can provide more clarity in Sploit scripts. Smarter default element symbol names: Instead of just using '_' as a placeholder if no symbol name is ever given, we now uniquely name each inserted element according to the API function that was used, then slap on an incrementing number. An explicit name still bypasses this scheme. Insertion functions can now be chained together: Functions previously returned the offset/address of the inserted value. However, this feature was seldom used, and there is now the possibility of .pad_front() invalidating previously-returned offsets. Instead, functional-style chaining is enabled to reduce boilerplate, and help with quick oneliners. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-17Merge branch 'sploit/symtbl-retcon'Malfurious3-94/+46
Fixes some problems found in the Sploit Symtbl module, and includes some additional cleanup suggested by dusoleil. * sploit/symtbl-retcon: sploit: Clean up use of __getattribute__ sploit: Fix bugs and simplify Symtbl
2022-03-17sploit: Clean up use of __getattribute__Malfurious2-12/+1
__getattribute__ is the low-level magic func and will intercept every attribute lookup, whereas __getattr__ is high-level, and is only invoked in specific conditions (such as __getattribute__'s failure). As such, any overload of __getattribute__ which preferentially falls back to object.__getattribute__() before serving a request, can more simply be replaced by a __getattr__ overload without the fallback. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-17sploit: Fix bugs and simplify SymtblMalfurious1-82/+45
The recent implementation of the new design for Symtbl contained a few bugs: - Attempting to access .base on a Symtbl or intermediate __InnerTable__ caused an exception. - Symtbl objects all used the same static collection of nested subtables, rather than an instanced one. If two table objects contained the same named key, they would refer to the same nested table from both locations. - Printing the contents of a table accessed via an absolute nesting (aka: via an __InnerTable__ object) would not show the offsets adjusted for the curent context. In addition to these fixes, the class implementation is largely simplified as well. This is in part due to the removal of unnecessary logic, such as the way our __getattribute__ overloads were implemented. Mainly, this came down to merging the redundant abstractions in our original design. Over time, the differences between these interfaces became blurred to the point where simply reusing one is not at all problematic. It is very much the intent of this patch to preserve the semantics of the tool's design (that being: flexable, nestable tables, to which a separate, but linked, mapped view may be obtained), but to state it as cleanly as possible. Note that all of the working state of a Symtbl is kept in its new _namesp member. This is primarily done to enable subclassing the Symtbl class. Ordinarily, setattr() on self would force the incoming value into the actual symbol table, making it impossible for subclasses to store separate instance data. Furthermore, the consolidation of properties into this object creates fewer potential collisions with user-defined symbols. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-14Merge tag 'pull-sploit-rev' of https://github.com/Dusoleil/lib-des-gnuxMalfurious8-5/+201
Add rev for basic reverse engineering * tag 'pull-sploit-rev' of https://github.com/Dusoleil/lib-des-gnux: sploit: Move __attr_filter__ to a general place in util sploit: Filter all magic python members by default in mem module sploit: add stack base pointer to locals symtbl sploit: print hex of addresses in rev logs sploit: add status logging to rev module sploit: lazy load libs for ELF sploit: cache results of external commands sploit: add the rest of r2 functions through elf sploit: typo fix in rev.r2 sploit: cache ELF loads sploit: add ELF helper class to rev sploit: consolidate r2 symbol search calls sploit: fix r2 module syntax error sploit: reverse direction of r2 get_locals offsets sploit: add r2 funcionality to rev module sploit: add ldd ability to rev module sploit: add rev module to sploit
2022-03-14Merge branch 'sploit/repl-qol'Malfurious1-32/+45
This branch addresses some user experience issues when attempting to use Sploit interactively, in the Python REPL (or iPython). In particular: - Target output is more responsive - Setting up io plumbing is simplified * sploit/repl-qol: sploit: Clean up function Comm.interact() sploit: Add function popen() sploit: Add Comm property 'readonwrite' sploit: Add function Comm.readall_nonblock()
2022-03-14sploit: Clean up function Comm.interact()Malfurious1-32/+26
The previous patches in this series have needed to utilize similar logic as Comm.interact() throughout other parts of the Comm class. This patch just revisits .interact() to clean up redundant code. Co-authored-by: dusoleil <howcansocksbereal@gmail.com> Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-14sploit: Add function popen()Malfurious1-0/+6
This is a free-function in the comm module, intended to help setup Sploit plumbing when working in the Python interactive interpreter. At the moment, the intended user experience in the interpreter is to err on the side of being interactive/responsive. As such, the Comm object returned from popen() is initialized with overridden IO settings to prefer 'readonwrite' by default. Addtionally, any early output from the target is also read, so that it may be immediately visible. A consequence of this configuration is that, until readonwrite is set False, most target output will be consumed before any .read* function has a chance to return it. While that would be a hard showstopper for any Sploit script, an interactive user can simply copy/paste any important data that is produced. Given that the interpreter workflow is likely going to be most useful for quick prototyping and recon with the proposed rev module, I consider this tradeoff appropriate at the moment, but will consider revisiting this if its usage is problematic. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-14sploit: Add Comm property 'readonwrite'Malfurious1-0/+2
If readonwrite is set to True (default False), Sploit will catch up and read all available stdin data from the target in a non-blocking fashion. If logonread is also set to True, this data will immediately be presented to the user whenever data is sent, but is otherwise lost (not returned). This mode is primarily intended for use in the interactive Python interpreter, where it can be cumbersome to keep alternating read and write calls when one does not care to actually record the read values. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-14sploit: Add function Comm.readall_nonblock()Malfurious1-0/+11
Function should consume all available incoming data from target and return it, however will return 'immediately' (according to a configurable timeout) if the pipe is empty. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: Move __attr_filter__ to a general place in utildusoleil3-3/+11
Found a spot to use __attr_filter__ in the rev module, so moving it out of mem and into a shared place (util). Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: Filter all magic python members by default in mem moduledusoleil1-3/+6
In the various __getattribute__() overloads in the mem module, we should filter all of the built-in magic members to do the default object.__getattribute__() behavior. This is opposed to the earlier stance of just caring about the ones that I saw as realistically being called. Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: add stack base pointer to locals symtbldusoleil1-1/+3
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: print hex of addresses in rev logsdusoleil1-2/+2
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: add status logging to rev moduledusoleil2-0/+13
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: lazy load libs for ELFdusoleil2-6/+16
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: cache results of external commandsdusoleil5-15/+25
rather than cacheing ELF instantiations, just cache the results of external commands Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: add the rest of r2 functions through elfdusoleil1-0/+20
expose the rest of the rev.r2 capabilities through rev.elf Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: typo fix in rev.r2dusoleil1-1/+1
accidentally left the argument as "elf" instead of "binary" and had the arguments in the wrong order Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: cache ELF loadsdusoleil1-1/+11
With recursive ELF loads, there is the possibility of loading in a heavy ELF (like libc) multiple times. Hiding instantiation of the class behind a factory method and caching instances should eliminate this problem. Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: add ELF helper class to revdusoleil2-0/+23
Create a class which encapsulates some basic information about an ELF file and provides a convenient interface for basic reverse engineering. In particular, ELF automatically loads the symbol table of the given elf file and recursively creates ELF objects for any linked libraries. Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: consolidate r2 symbol search callsdusoleil1-16/+5
Consolidate some of the r2 calls that get combined to create the symbol list. Instead of doing multiple calls with different greps within radare2, just do a single call and search it in the python side. This gives us a slight, but noticeable performance increase. Signed-off-by: dusoleil <howcansocksbereal@gmail.com>