-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_injection_elf.py
52 lines (39 loc) · 1.47 KB
/
send_injection_elf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import argparse
import socket
import struct
import os
MAX_PROC_NAME = 0x100
SERVER_PORT = 9033
# Function to build the struct -> target_name[MAX_PROC_NAME] + data
def build_injector_data(proc_name, data):
proc_name = proc_name.encode()
proc_name = proc_name.ljust(MAX_PROC_NAME, b"\x00");
# print(len(proc_name))
return proc_name + data
def send_data_to_server(data, ip, port):
try:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((ip, port))
s.sendall(data)
print(f"Sent data to {ip}:{port}")
except Exception as e:
print(f"Error while sending data: {e}")
# Main function
def main():
# Parse command-line arguments
parser = argparse.ArgumentParser(description="Send process name and data to a remote server.")
parser.add_argument("name", type=str, help="The name of the process.")
parser.add_argument("path", type=str, help="The path to the data file.")
parser.add_argument("ip", type=str, help="PS5 IP address")
args = parser.parse_args()
if not os.path.exists(args.path):
print(f"Error: File {args.path} does not exist.")
return
with open(args.path, "rb") as file:
data = file.read()
# Build the struct with the process name and data
injector_data = build_injector_data(args.name, data)
# Send the data to the server
send_data_to_server(injector_data, args.ip, SERVER_PORT)
if __name__ == "__main__":
main()