calebstewart / pwncat

Fancy reverse and bind shell handler
https://pwncat.readthedocs.io
MIT License
2.58k stars 250 forks source link

Support reloading of custom modules using "reload" #241

Open DanaEpp opened 2 years ago

DanaEpp commented 2 years ago

When doing custom module development it is rather tedious to have to restart pwncat and establish a new session just to reload the changes to the module code. It would be nice to do reload /path/to/modules, or to otherwise auto-reload when a module file has been altered.

Alternatively, having an option during dev to pass a switch to pwncat-cs to have it reload modules from disk on every "run", or offer a new command like run-dev that would always fetch the module code would be useful.

calebstewart commented 2 years ago

This shouldn't be too difficult to implement. I should be able to simply remove the reference from Manager.modules and sys.modules, then reload the Python module. I'll try to get this added soon!

calebstewart commented 2 years ago

I implemented a first-pass on this in the referenced PR. @DanaEpp if you have the time/interest, I'd appreciate you giving that branch a try. You should be able to either use load --reload /path/to/modules or run --reload my.module.name. The former will obviously explicitly reload the module, while the latter will reload the module prior to execution (as mentioned in your original issue above).

Thanks for the suggestion. This is a really good feature to have for debugging, and I don't know why it didn't occur to me before! :+1:

DanaEpp commented 2 years ago

I implemented a first-pass on this in the referenced PR. @DanaEpp if you have the time/interest, I'd appreciate you giving that branch a try. You should be able to either use load --reload /path/to/modules or run --reload my.module.name. The former will obviously explicitly reload the module, while the latter will reload the module prior to execution (as mentioned in your original issue above).

Thanks for the suggestion. This is a really good feature to have for debugging, and I don't know why it didn't occur to me before! 👍

Thanks for such a quick turnaround Caleb! This will be an awesome feature. I am right in the middle of writing a module as we speak, so this is timely.

I'll try to test this branch tonight.