Skip to content

Commit db5b87e

Browse files
committed
Add Py2 alert, catch socket error, changer payload sender timeout
1 parent 48ca454 commit db5b87e

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

start.py

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
Source: https://github.com/Al-Azif/ps4-exploit-host
55
"""
66

7+
from __future__ import print_function
8+
9+
10+
import sys
11+
if sys.version_info.major < 3:
12+
print('This cannot be run under Python 2')
13+
try:
14+
input('Press [ENTER] to exit')
15+
finally:
16+
sys.exit()
17+
718
import argparse
819
import hashlib
920
from http.server import BaseHTTPRequestHandler
@@ -13,7 +24,6 @@
1324
import os
1425
import re
1526
import socket
16-
import sys
1727
import threading
1828
import time
1929

@@ -307,25 +317,28 @@ def payload_menu(payloads):
307317
def send_payload(hostname, port, content):
308318
"""Netcat implementation"""
309319
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
310-
timeout = time.time() + 60
320+
timeout = time.time() + 15
311321
while True:
312322
result = soc.connect_ex((hostname, port))
313323
if result == 0:
314324
print('>> Connected to PS4')
315325
timed_out = False
316326
break
317327
if time.time() >= timeout:
318-
print('>> Netcat service timed out')
328+
print('ERROR: Payload sender timed out')
319329
timed_out = True
320330
break
321331
if not timed_out:
322-
soc.sendall(content)
323-
soc.shutdown(socket.SHUT_WR)
324-
while True:
325-
data = soc.recv(1024)
326-
if not data:
327-
break
328-
print('>> Payload Sent!')
332+
try:
333+
soc.sendall(content)
334+
soc.shutdown(socket.SHUT_WR)
335+
while True:
336+
data = soc.recv(1024)
337+
if not data:
338+
break
339+
print('>> Payload Sent!')
340+
except socket.error:
341+
print('ERROR: Broken Pipe (Out of Memory Error?)')
329342
soc.close()
330343

331344

@@ -418,7 +431,8 @@ def main():
418431
if not args.e_type:
419432
args.e_type = exploit_menu()
420433

421-
if os.path.isdir(os.path.join(EXPLOIT_LOC, args.e_type)) and args.e_type:
434+
if os.path.isdir(os.path.join(EXPLOIT_LOC, args.e_type)) \
435+
and args.e_type:
422436
EXPLOIT_LOC = os.path.join(EXPLOIT_LOC, args.e_type)
423437
else:
424438
closer('ERROR: Could not find exploit specified')

0 commit comments

Comments
 (0)