Comments (5)
It looks like the only place for us to inject is threading.Thread.__bootstrap
.
# At the end of 'context.py', add
class ContextPreservingThread(threading.Thread):
def __init__(self, *args, **kwargs):
super(ContextPreservingThread, self).__init__(*args, **kwargs)
self.parent_ctx = context._thread_ctx()
self.__old_bootstrap = self._Thread__bootstrap
self._Thread__bootstrap = self.__new_bootstrap
def __new_bootstrap(self):
context._ctxs.setdefault(
threading.current_thread().ident, self.parent_ctx
)
return self.__old_bootstrap()
context.log_level = 'silent'
def bar():
print context.log_level
bar()
# 100
threading.Thread(target=bar).start()
# 20
ContextPreservingThread(target=bar).start()
# 100
The proper way to get it implemented is to replace all calls to threading.Thread
within pwntools. The 'fuck it' way would be to:
threading.Thread = ContextPreservingThread
But this may have unintended side effects, and is probably a Bad Ideaβ’.
from pwntools.
Sorry, posted on the wrong account. @ebeip90 is me.
from pwntools.
Is this an acceptable mechanism for implementation?
from pwntools.
I think we should avoid monkey-patching if possible.
I also think that your model of how to fix the context module is slightly too simple. But otherwise, yes, this is the way to do it.
from pwntools.
I'm merging #124 into my master
and won't pursue any further
from pwntools.
Related Issues (20)
- Inconsistency detected by ld.so HOT 2
- can't find write-what-where gadgets HOT 2
- [docs bug] Beginning of documentation cuts off for some things (due to "}")
- [docs bug] Many "links to the source" in the docs just link to the file (and not the line)
- [Bug?] FileStructure.struntil one byte shorter for no apparent reason?
- [Windows] Using "Process" raises "AttributeError: module 'os' has no attribute 'getuid'" HOT 2
- context.cyclic_size doesn't update when using context.binary = ELF('./prog') HOT 3
- Pwntools setup on Mac OS HOT 1
- ROP.call execve syscall ignores parameter HOT 5
- execve bug HOT 1
- libcdb print redundant information
- Could not find any instructions in ['int 0x80'] HOT 2
- ret2dlresolve segfaulting. HOT 2
- Issue with printing with "\r\n" HOT 4
- Terminal cannot print ANSI color after importing `pwn` HOT 4
- flat() spins the cpu and never returns
- context in gdb event handlers
- remote should not overwrite server_hostname HOT 3
- Undocumented behaviour of sni kwarg of remote() HOT 2
- [bug] kitty debugging window doesn't close when exiting process
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pwntools.