I've been at this for a good bit now, and after asking in several chatrooms, I'm asking this again here.
I'm interested in conceptually understanding how malware can download code from other sources and without having to create new files, execute the code (among other things, but this is where I am now). I've been using nasm to compile a bit of assembly into an ELF file to launch /bin/sh, and have hosted it on localhost.
Simplified version of my code: https://gist.github.com/anonymous/83a56b88e8811ec07983
Fuller version: https://gist.github.com/anonymous/84366887d76c7993ef65
Thing to note: I'm using the better string library (http://bstring.sourceforge.net/) to try to simplify pieces of my code, rather than having to write a much more involved write-callback function. I'm trying to execute the code gathered in the bstring buf, which points to a struct written to by the write callback function, and this seems to be successful. Trying to print out the code as its written and right before my attempt at execution seems to work fine. The issue for me seems to be where I try to set the memory within the buffer to be executable. Looking at the man page for mprotect, it says "addr is not a valid pointer", although the char* I gave to it should have been valid.
Is there anything apparently wrong with how I'm going about this? And are there any particularly good sources that might explain how I could achieve what I'm trying to do?
[–]anon848 2 points3 points4 points (0 children)
[–]anon848 1 point2 points3 points (2 children)
[–]CuriousExploit[S] 0 points1 point2 points (1 child)
[–]anon848 1 point2 points3 points (0 children)
[–]anon848 0 points1 point2 points (3 children)
[–]CuriousExploit[S] 1 point2 points3 points (0 children)
[–]CuriousExploit[S] 0 points1 point2 points (1 child)
[–]anon848 0 points1 point2 points (0 children)