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