small update
This commit is contained in:
parent
48727a7aa6
commit
bd227f9c4b
@ -5,6 +5,7 @@ import sys
|
||||
import pty
|
||||
import util
|
||||
import time
|
||||
import random
|
||||
import threading
|
||||
import readline
|
||||
import base64
|
||||
@ -137,11 +138,9 @@ if __name__ == "__main__":
|
||||
|
||||
# choose random port
|
||||
if listen_port is None:
|
||||
sock = util.openServer(local_address)
|
||||
if not sock:
|
||||
exit(1)
|
||||
listen_port = sock.getsockname()[1]
|
||||
sock.close()
|
||||
listen_port = random.randint(10000,65535)
|
||||
while util.isPortInUse(listen_port):
|
||||
listen_port = random.randint(10000,65535)
|
||||
|
||||
payload = generatePayload(payload_type, local_address, listen_port)
|
||||
|
||||
|
6
util.py
6
util.py
@ -11,6 +11,12 @@ import io
|
||||
from PIL import Image
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
def isPortInUse(port):
|
||||
import socket
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
return s.connect_ex(('127.0.0.1', port)) == 0
|
||||
|
||||
|
||||
def getAddress(interface="tun0"):
|
||||
if not interface in ni.interfaces():
|
||||
interfaces = ni.interfaces()
|
||||
|
Loading…
Reference in New Issue
Block a user