summaryrefslogtreecommitdiffstats
path: root/sploit/payload/payload_entry.py (follow)
AgeCommit message (Collapse)AuthorFilesLines
2025-01-04Rename sploit package to nsploitMalfurious1-113/+0
Rename all affected files, references to file paths, and module imports within the code. Since this line of development represents a fork from the original sploit, a name change is seen as necessary to distinguish the projects, as well as allow them to be installed side by side. What does the "n" mean? Great question! You can think of it as meaning "new sploit" if you want, though that's not quite intended. The name is simply distinct and easy to pronounce. I had originally settled on "msploit" (something along the lines of "Malf's sploit"), but this name is too close to "metasploit" for me - and N is right next to it on the keyboard. Signed-off-by: Malfurious <m@lfurio.us>
2025-01-02payload: Rework pointer to directly target another payload fieldMalfurious1-8/+10
PayloadEntry pointer will no longer pre-compute it's offset to target on construction, but instead save a reference to the target field and dynamically compute the pointer value on demand. This has the restriction that pointer targets must now reside in the same Payload object, at the same encapsulation level. However, pointers will now dynamically react to their target's relocation due to padding change or other field alterations. When a pointer is generated, we now simply encode the address of the target field as it currently stands at the time. A new property "math" may be given a lambda function, which will have the chance to massage this final pointer value before use. Signed-off-by: Malfurious <m@lfurio.us>
2025-01-02payload: padalign reference propertyMalfurious1-2/+3
Previously, the auto alignment tool would ensure that the next payload byte address was evenly divisible by the padding size, and nothing more. Users now have the added flexibility to specify a basis or "reference" address. The next payload byte address will then be an even multiple of the padding size away from this reference. Signed-off-by: Malfurious <m@lfurio.us>
2025-01-02payload: Separate length and bytes calculationsMalfurious1-17/+28
Previously, the len(payload) operation required the generation of the full payload binary content, in order to count how many bytes long it was. This is no longer the case, as there are opportunities for optimizations, primarily regarding fixed-length dynamic payload entries where we can simply grab the size parameter without having to generate a buffer. In addition to potential speedups, this fix also allows the user to insert PayloadEntry pointers for fields which are not yet present in the payload being built (ie: whenever the pointer is to exist before the pointed-to data). Whereas previously, the inability to generate the ill-formed pointer would break length calculations necessary to insert additional data. Signed-off-by: Malfurious <m@lfurio.us>
2025-01-01payload: Refactor as a concrete IndexTblMalfurious1-0/+99
Payload is now an index table, wherein each index is a byte string (or compatible type). The retrieval of indices will return a corresponding offset or address of the indexed data (which is sensitive to the payload base). There is no longer a Symtbl member. Due to this new design, the class no longer keeps a running payload buffer that is appended to every time the payload is updated. When the user wants to get the full data, this buffer is constructed from the Lict elements backing the payload. This allows individual elements to be modified or removed easily after they are inserted. The use of a Lict allows data elements to be referred to by either their positional array index, or the key specified when first creating that element (done using the IndexTbl interface). Payload objects may now be directly nested inside eachother, as opposed to simply taking a payload's bytes and inserting those. This allows payloads to be used in a way resembling C structures. The type-specific insertion functions have been removed and we instead now lean on the __setindex__ interface inherited from IndexTbl to directly assign values and append them to the payload. In this case, values are taken as-is from the assignment if they are bytes-like, and automatically converted in some cases. Payload's __call__ overload is now used to perform the quick, chainable, and inline value insertion that was lost by the removal of the type-specific functions. "Calling" a payload with zero arguments will still provide the old behavior of returning the payload bytes, however. The semi-advanced features such as padding, alignment, and inserting placeholder bytes have been removed from the main payload interface and are now provided as compatible types that can be directly inserted into Payload via the means described above. In most cases, these are now implemented to dynamically react to changes in the Payload content. For example, a "padlen" element, which is constructed with a fixed target length parameter, will grow or shrink in length if the data preceding it changes. Automatic "badbytes" detection is removed, simply due to API conflict. In my experience, this feature was little-used and can easily be done manually by scripts if desired. I don't plan to reintroduce this feature. pad_front functionality is also removed by this patch, since at the moment it doesn't fit into the new design very well. We may attempt to reimplement it as a PayloadEntry down the road. However, this feature has also only seen rare use in my experience. Signed-off-by: Malfurious <m@lfurio.us>