Comments (8)
It does work on my machine. Can you try to do the same in foreground and see if it somehow quits?
from pwncat.
Hmm. In foreground it works. I tried it with Python versions 2.7.18, 3.9.2, and 3.10.8, and it does not work in background.
More info: I tried on Debian Stable (bullseye) and with Debian Unstable.
Running it with nohup (nohup ./bin/pwncat -u -l 127.0.0.1 9999) it shows these exceptions:
------------------------------------>8------------------------------------
Exception in thread STDIN:
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/git/waiting/pwncat/pwncat/./bin/pwncat", line 4015, in run_action
for data in producer.function(*producer.args, **producer.kwargs):
File "/git/waiting/pwncat/pwncat/./bin/pwncat", line 3423, in producer
data = self.__read_stdin()
File "/git/waiting/pwncat/pwncat/./bin/pwncat", line 3539, in __read_stdin
return sys.stdin.buffer.readline()
OSError: [Errno 9] Bad file descriptor
/git/waiting/pwncat/pwncat/./bin/pwncat:4210: DeprecationWarning: getName() is deprecated, get the name attribute instead
self.__threads[key].getName(),
/git/waiting/pwncat/pwncat/./bin/pwncat:4216: DeprecationWarning: getName() is deprecated, get the name attribute instead
"Joining %s", self.__threads[key].getName()
/git/waiting/pwncat/pwncat/./bin/pwncat:4222: DeprecationWarning: getName() is deprecated, get the name attribute instead
"Joined %s", self.__threads[key].getName()
Exception in thread RECV:
Traceback (most recent call last):
File "/git/waiting/pwncat/pwncat/./bin/pwncat", line 2841, in producer
yield self.__net.receive()
File "/git/waiting/pwncat/pwncat/./bin/pwncat", line 1967, in receive
raise socket.timeout("timed out") # type: ignore
TimeoutError: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/git/waiting/pwncat/pwncat/./bin/pwncat", line 4015, in run_action
for data in producer.function(*producer.args, **producer.kwargs):
File "/git/waiting/pwncat/pwncat/./bin/pwncat", line 2849, in producer
self.__net.send_eof()
File "/git/waiting/pwncat/pwncat/./bin/pwncat", line 1860, in send_eof
self.__sock.shutdown_send(self.__active["conn"], "conn")
KeyError: 'conn'
------------------------------------8<------------------------------------
Just to let you know, I'm working on Debian packaging [1] of pwncat, and I
discovered this issue during the creation of CI tests.
[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1015173
from pwncat.
Thanks for the details 👍, I will look into this
from pwncat.
The issue seems to be the stdin file descriptor, when it is not attached to a terminal anymore:
File "/git/waiting/pwncat/pwncat/./bin/pwncat", line 3539, in __read_stdin
return sys.stdin.buffer.readline()
OSError: [Errno 9] Bad file descriptor
This happens both in TCP and also UDP mode as it is not connected to any mode. It is trying to read from stdin, but stdin does not exist.
It can therefore (atm) not put into background mode. I will need to do a little digging if this is possible somehow.
from pwncat.
I can reproduce it with a very simple script:
test.py
:
import sys
print(sys.stdin.readline())
And then run it with nohup:
$ nohup python test.py
$ cat nohup.out
Traceback (most recent call last):
File "test.py", line 3, in <module>
print(sys.stdin.readline())
IOError: [Errno 9] Bad file descriptor
from pwncat.
What you can do for now is the following command for a server:
TCP
nohup ./pwncat -l --no-shutdown 127.0.0.1 9998 > log.log 2>&1
UDP
nohup ./pwncat -l --no-shutdown -u 127.0.0.1 9998 > log.log 2>&1
from pwncat.
The issue seems to be the stdin file descriptor, when it is not attached to a terminal anymore:
File "/git/waiting/pwncat/pwncat/./bin/pwncat", line 3539, in __read_stdin return sys.stdin.buffer.readline() OSError: [Errno 9] Bad file descriptor
This happens both in TCP and also UDP mode as it is not connected to any mode. It is trying to read from stdin, but stdin does not exist.
It can therefore (atm) not put into background mode. I will need to do a little digging if this is possible somehow.
@cytopia For me, the problem occurs only in UDP mode, TCP runs OK in background mode.
i.e: python3 ./bin/pwncat -l 127.0.0.1 9999 &
(works fine)
from pwncat.
@cytopia Hi there! Any news about this issue?
from pwncat.
Related Issues (20)
- windows question HOT 1
- when pasting in term I donot get full line echo HOT 9
- Link to grab netcat no longer works HOT 4
- setup.py: Multiple top-level packages discovered in a flat-layout HOT 3
- Similar to #83, --self-inject does not detect python because client does not send server output of remote_command HOT 3
- TCP UDP relay
- DeprecationWarning in threading
- connection failed: channel unexpectedly closed
- Netcat Compatibility HOT 2
- Pwncat Scripting Engine (PSE)
- Be able to specify source address and port for clients
- Implement feature: Stateless UDP connect
- When upgrading TTY to interactive its crashes after performing the fg HOT 12
- Self-inject command does not find python version HOT 26
- IPv6 self injection / port forwarding HOT 2
- IPv6 link-local address causes "Invalid argument" / "Bind Error" HOT 3
- Add SSL WRAPPER
- Add Keyboard Interrupt Exception
- Please implement ability to port forward after catching reverse shell HOT 5
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 pwncat.