| Current Path : /opt/cpanel/ |
| Current File : //opt/cpanel/test3.py |
import socket
import ssl
import os
import uuid
import struct
# Path to your XML
xml_path = "info.xml"
# EPP server details
EPP_HOST = "epp.zarc.net.za"
EPP_PORT = 700
EPP_USER = "enetworks"
EPP_PASS = "36ancerg9a2"
# Load and prepare XML
def load_and_prepare_xml(path):
with open(path, "r", encoding="utf-8") as f:
xml = f.read()
return xml.replace("__CLTRID__", str(uuid.uuid4()))
# Frame EPP (add 4-byte length prefix)
def frame_xml(xml_string):
data = xml_string.encode("utf-8")
length = len(data) + 4
return struct.pack("!I", length) + data
# Read full EPP response
def recv_response(sock):
header = sock.recv(4)
if not header:
return None
length = struct.unpack("!I", header)[0]
return sock.recv(length - 4).decode("utf-8")
# Main connection
def main():
context = ssl.create_default_context()
with socket.create_connection((EPP_HOST, EPP_PORT)) as sock:
with context.wrap_socket(sock, server_hostname=EPP_HOST) as ssock:
print("[+] Connected via TLS")
# 1. Get greeting
greeting = recv_response(ssock)
print("[i] Server Greeting:\n", greeting)
# 2. Send login
login_xml = f"""<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<login>
<clID>{EPP_USER}</clID>
<pw>{EPP_PASS}</pw>
<options>
<version>1.0</version>
<lang>en</lang>
</options>
<services>
<objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>
<objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
</services>
</login>
<clTRID>{uuid.uuid4()}</clTRID>
</command>
</epp>"""
ssock.sendall(frame_xml(login_xml))
print("[*] Sent login.")
print("[i] Login Response:\n", recv_response(ssock))
# 3. Send your XML
user_xml = load_and_prepare_xml(xml_path)
ssock.sendall(frame_xml(user_xml))
print(f"[*] Sent {xml_path}")
print("[i] Command Response:\n", recv_response(ssock))
# 4. Send logout
logout_xml = f"""<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<logout/>
<clTRID>{uuid.uuid4()}</clTRID>
</command>
</epp>"""
ssock.sendall(frame_xml(logout_xml))
print("[*] Sent logout.")
print("[i] Logout Response:\n", recv_response(ssock))
if __name__ == "__main__":
main()