summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
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>
2022-03-13sploit: fix r2 module syntax errordusoleil1-12/+12
forgot to remove the r2 namespace from the calls from back when it was implemented differently Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: reverse direction of r2 get_locals offsetsdusoleil1-1/+1
rev.r2's get_locals() function returns a Symtbl of offsets representing the local variables on in a stack frame of a particular function. The offsets returned by r2 are based around the base of the stack, but they are increasing in value as they grow from the stack. To properly model memory, they should decrease in value as they grow from the stack. Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: add r2 funcionality to rev moduledusoleil2-1/+94
Add an r2 module with several helper functions that do a number of simple reverse engineering tasks to aid in writing simple sploit scripts. The functions in this module invoke radare2 to accomplish their tasks. Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: add ldd ability to rev moduledusoleil2-0/+14
add helper function to invoke ldd to get a list of libraries that will be linked to a given ELF Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: add rev module to sploitdusoleil3-2/+3
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13Merge tag 'pull-sploit-symtbl-redesign' of ↵Malfurious1-10/+80
https://github.com/Dusoleil/lib-des-gnux Redesign mem module * tag 'pull-sploit-symtbl-redesign' of https://github.com/Dusoleil/lib-des-gnux: sploit: Add support for nested Symtbls sploit: Instantiate Memmap with integer offset sploit: remove length calculation from Symtbl sploit: code reuse for mem string methods sploit: add len func to mem sploit: move adjust and rebase into member funcs Add adjust and rebase functions to mem module sploit: Add string cast for Symtbl and Memmap sploit: Split Symtbl funcionality with Memmap
2022-03-13sploit: Add support for nested Symtblsdusoleil1-3/+45
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: Instantiate Memmap with integer offsetdusoleil1-6/+6
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-13sploit: remove length calculation from Symtbldusoleil1-13/+1
length() fails on local stack frames (where it was originally intended to be useful) when register based locals (like arguments) are present. Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-12sploit: code reuse for mem string methodsdusoleil1-12/+14
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-12sploit: add len func to memdusoleil1-0/+11
len() will calculate the length of the symtbl in bytes rather than the number of symbols Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-12sploit: move adjust and rebase into member funcsdusoleil1-7/+6
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-10Add adjust and rebase functions to mem moduledusoleil1-0/+8
Add the ability to shift all Symtbl offsets by a fixed amount with adjust(). Add the ability to shift all Symtbl offsets so that a designated symbol is now at offset 0 and all other symbols maintain their relative offsets to that symbol with rebase(). Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-10sploit: Add string cast for Symtbl and Memmapdusoleil1-0/+16
Add string cast to mem module types so that they can be printed out in a human readable format. Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-10sploit: Split Symtbl funcionality with Memmapdusoleil1-11/+15
Symtbl now only deals with offets. A read-only view of a symtbl can be created via the Memmap class. This view also takes an absolute address for a symbol and will return adjusted addresses based on this. This replaces the addr() method. Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2022-03-06sploit: Add ARM/THUMB architecture detailsMalfurious1-21/+8
This _should_ be accurate for ARMv7-a at least (including thumb mode). We might want to later include ARMv8 details, which would primarily include a 64-bit profile - I just don't have the details at the moment. A namedtuple is now used as the implementation of type 'Arch', which allows the definitions to be much more compact and table-like, aiding readability. Signed-off-by: Malfurious <m@lfurio.us>
2022-03-06Merge tag 'pull-duso-tool-docs' of https://github.com/Dusoleil/lib-des-gnuxMalfurious10-1/+572
Pulling an assortment of tools documentation from Dusoleil. I did fix 1 minor conflict in the readme file. * tag 'pull-duso-tool-docs' of https://github.com/Dusoleil/lib-des-gnux: (21 commits) Remove 'sudo' from install command. Fix typo in for loop in asm rep prefix doc Add install/uninstall instructions to radare doc Add radare2 command cheatsheet Add doc about fixing a ptrace error in debugger. Add doc about the rep prefix on an x86 instruction Add short doc on the one_gadget tool Remove curl example line from README Add cheatsheet of common flags for curl Add a short doc with links to reqbin and hookbin Add Short Doc About proxychains Add Example that Uses Custom Charset Update Incremental Examples to Use Short Flag Add Info About Issues with Small Workload Add More Mask/Hybrid Attacks to Examples Add Examples for Showing Cracks/Identifying Type Add --status Flag to Examples Fix Paths in Examples Remove "LIGHT"/"HEAVY" Descriptors from Examples Add hashcat doc ...
2022-02-27shellcode: Initialize envp to NULLMalfurious2-0/+2
This issue was discovered a while back, during one of the CTFs, and was particularly a problem with the 32-bit shellcode. Because the third kernel argument register was not being set by the payload, we would essentially pass garbage. I'm only committing this now, as I've recently been able to reproduce the related failure and demonstrate this patch working. I never actually observed the 64-bit shellcode fail for this reason on a target, but it is also patched for correctness. Argument 3 to execve() is the environment pointer, a pointer to array of strings to define the process's environment variables. Although this argument should point to an empty array (ptr to NULL) if empty, Linux allows the pointer itself to be NULL in this case - thus the xor of the register. Signed-off-by: Malfurious <m@lfurio.us>
2022-02-26Commit notes from Metasploit CTF 2021Malfurious2-0/+36
Signed-off-by: Malfurious <m@lfurio.us>
2021-12-25Remove 'sudo' from install command.dusoleil1-1/+1
Apparently, install.sh will automatically elevate privileges as it needs. Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2021-12-25Fix typo in for loop in asm rep prefix docdusoleil1-1/+1
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2021-12-20Add install/uninstall instructions to radare docdusoleil1-0/+8
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2021-12-20Add radare2 command cheatsheetdusoleil1-0/+80
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2021-12-20Add doc about fixing a ptrace error in debugger.dusoleil1-0/+22
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2021-12-20Add doc about the rep prefix on an x86 instructiondusoleil1-0/+18
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2021-12-17Merge branch 'sploit-io'Malfurious3-57/+93
This branch features changes to Sploit's 'user-interface' and some QoL fixes pertaining to target communications. Sploit's logging module is rewritten to make the normal text output more readable, and all console output is now globally filtered through it. Explicit daemon mode is removed (now implicit) to support a new Sploit invocation method: shebangs! Some logging inconsistencies are addressed in the comms front-end, and Sploit now shuts down the output stream after user-supplied scripts finish. * sploit-io: sploit: Automatically shutdown outgoing comms after script execution sploit: Catch KeyboardInterrupt in Comm.readall() sploit: Ensure the logonread option is restored by Comm.readuntil() sploit: Add logonwrite option to comms sploit: Check logonread in function Comm.readall() sploit: Add startup banner sploit: Rework logger sploit: Remove -d/--daemon option
2021-12-17sploit: Automatically shutdown outgoing comms after script executionMalfurious2-0/+4
A new function, Comm.shutdown(), is added. It will close only the stdout stream of the communications backend, potentially making the termination of the target program more fluid. The name 'shutdown' is chosen to emulate shutdown(2) from the low-level socket api, which is used to close just part of a full-duplex file descriptor. This is in contrast to 'close', which I would expect to completely terminate the given object IO. comm.shutdown() is now called by main.py, after the user script returns, to ensure that the subsequent readall() doesn't get stuck because our target is blocked reading its stdin. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2021-12-17sploit: Catch KeyboardInterrupt in Comm.readall()Malfurious1-3/+6
If execution is stuck inside readall() (for example, due to blocked IO), handling KeyboardInterrupt allows the user a way to get out, without exiting the active script early or losing the data read so far. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2021-12-17sploit: Ensure the logonread option is restored by Comm.readuntil()Malfurious1-5/+7
This function has a momentary side-effect of switching self.logonread to False. This patch ensures its original value is always restored, even if an exception is raised. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2021-12-17sploit: Add logonwrite option to commsMalfurious1-0/+2
If enabled, data sent to the target will be printed/logged as alt text, similar to data directly printed by the user. Feature is off by default. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2021-12-17sploit: Check logonread in function Comm.readall()Malfurious1-1/+1
This function will no longer mistakenly log data when logonread is set to False. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2021-12-17sploit: Add startup bannerMalfurious1-2/+12
This just adds a fancy 'SPLOIT' header to the beginning of Sploit's startup preamble data. It has the ability to display a few lines of text beside itself, but most of the things we've planned to put here are not available yet, so just the operating mode is printed for now. The SPLOIT text has a colored stripe which, at the moment, also indicates the operating mode. This stripe was originally chosen to balance out the amount of color present in the preamble text, but I've grown to like it. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2021-12-17sploit: Rework loggerMalfurious3-28/+56
The log module is updated to support binary encodings, colors, and for improved compatibility with Python's print() builtin. Encoding semantics are switched up, since it seems like some of the more interesting encoding modes (from a CTF perspective) actually use bytes-like objects as their high-level form (that is, bytes are encoded to another form, such as hex, then decoded back to the original form). So the logged value is now passed to encode instead of decode, and only if the object is of type 'bytes', as unicode strings are now considered out-of-scope for this operation. Additionally, the bytes wrapper (b'') is no longer visible in the logged content. For readability, several standard colors have been defined for use within Sploit: - RED: Errors - YELLOW: Warnings - GREEN: Status messages / Startup messages - WHITE: Target output - GRAY: User output / Alt text Logging functions now support an optional color option to select the desired color, and have specific defaults based on who is invoking the log (see below...) Logging functions are now also fully compatible with the builtin print() function. This is because Sploit now replaces the standard print() with a logging function within the user's script (which is done to maintain additional consistency of messages displayed in the console). Function ilog (internal log) has default values tuned for the library's convenience: Text goes to stderr, and is presented as status messages (green). Function elog (external log) has default values tuned for the user: Text goes to stdout, and is presented as alt text to distinguish it from data read from the target. Within the user context, 'print' refers to this function. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2021-12-17sploit: Remove -d/--daemon optionMalfurious1-23/+10
A couple of facts have influenced the decision to remove this option: - If a sploit script uses a shebang to launch sploit, it is tricky to specify this option. Specifically, one must add it to their shebang line, which couples more information to the script than was originally intended. - Single-pass pipe mode wasn't all that useful. One can accomplish the same thing by running pipe-daemon, and it is easy to exit after one iteration. Electing to run normal pipe mode requires you to know you only want to run once, which is much more common when running via direct subprocess. As a result of this change, running in pipe mode will now be equivalent to the previous pipe-daemon mode, and subprocess target mode remains single pass. Signed-off-by: Malfurious <m@lfurio.us> Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
2021-12-17Add short doc on the one_gadget tooldusoleil1-0/+57
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>