Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pyrasite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
pyrasite
Commits
3242a44e
Commit
3242a44e
authored
Mar 22, 2012
by
Luke Macken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More robust socket handling
parent
7ccde020
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
16 deletions
+20
-16
pyrasite/ipc.py
pyrasite/ipc.py
+12
-9
pyrasite/reverse.py
pyrasite/reverse.py
+8
-7
No files found.
pyrasite/ipc.py
View file @
3242a44e
...
@@ -83,20 +83,23 @@ class PyrasiteIPC(object):
...
@@ -83,20 +83,23 @@ class PyrasiteIPC(object):
af
,
socktype
,
proto
,
canonname
,
sa
=
res
af
,
socktype
,
proto
,
canonname
,
sa
=
res
try
:
try
:
self
.
server_sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
self
.
server_sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
try
:
self
.
server_sock
.
bind
(
sa
)
self
.
server_sock
.
listen
(
1
)
except
socket
.
error
:
self
.
server_sock
.
close
()
self
.
server_sock
=
None
continue
except
socket
.
error
:
except
socket
.
error
:
self
.
server_sock
=
None
self
.
server_sock
=
None
continue
continue
try
:
self
.
server_sock
.
bind
(
sa
)
self
.
server_sock
.
listen
(
1
)
except
socket
.
error
:
self
.
server_sock
.
close
()
self
.
server_sock
=
None
continue
break
break
self
.
hostname
,
self
.
port
=
self
.
server_sock
.
getsockname
()[
0
:
2
]
if
not
self
.
server_sock
:
self
.
running
=
True
raise
Exception
(
'pyrasite was unable to setup a '
+
'local server socket'
)
else
:
self
.
hostname
,
self
.
port
=
self
.
server_sock
.
getsockname
()[
0
:
2
]
def
create_payload
(
self
):
def
create_payload
(
self
):
"""Write out a reverse python connection payload with a custom port"""
"""Write out a reverse python connection payload with a custom port"""
...
...
pyrasite/reverse.py
View file @
3242a44e
...
@@ -61,19 +61,20 @@ class ReverseConnection(threading.Thread, pyrasite.PyrasiteIPC):
...
@@ -61,19 +61,20 @@ class ReverseConnection(threading.Thread, pyrasite.PyrasiteIPC):
af
,
socktype
,
proto
,
canonname
,
sa
=
res
af
,
socktype
,
proto
,
canonname
,
sa
=
res
try
:
try
:
self
.
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
self
.
sock
=
socket
.
socket
(
af
,
socktype
,
proto
)
try
:
self
.
sock
.
connect
(
sa
)
except
socket
.
error
:
self
.
sock
.
close
()
self
.
sock
=
None
continue
except
socket
.
error
:
except
socket
.
error
:
self
.
sock
=
None
self
.
sock
=
None
continue
continue
try
:
self
.
sock
.
connect
(
sa
)
except
socket
.
error
:
self
.
sock
.
close
()
self
.
sock
=
None
continue
break
break
if
not
self
.
sock
:
if
not
self
.
sock
:
raise
Exception
(
'pyrasite cannot establish reverse connection to %s:%d'
%
(
self
.
host
,
self
.
port
))
raise
Exception
(
'pyrasite cannot establish reverse '
+
'connection to %s:%d'
%
(
self
.
host
,
self
.
port
))
self
.
on_connect
()
self
.
on_connect
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment