Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- from sys import argv
- from struct import pack, unpack
- import socket
- import re
- # unhexlify(b'41414141') = b'AAAA'
- # hexlify(b'AAAA') = b'41414141'
- from binascii import hexlify, unhexlify
- ################### Helper methods #####################################################3
- def p64(d):
- """Return d packed as 64-bit unsigned integer (little endian)."""
- return pack('<Q', d)
- # Read exactly n bytes from the socket
- def receive(n):
- buf = bytearray()
- while not len(buf) >= n:
- buf += s.recv(1)
- print(buf.decode())
- return bytes(buf)
- # Read from socket until the character sequence delimiter is read
- def receive_until(delimiter):
- buf = bytearray()
- while not delimiter in buf:
- buf += s.recv(1)
- print(buf.decode())
- return bytes(buf)
- # Send data
- def send(data):
- print(data)
- s.sendall(data)
- # Send data + newline
- def sendline(data):
- send(data + b'\n')
- # Extract all hexadecimal numbers from a string s
- def extract_hexstr(s):
- return re.findall(r'0x[0-9A-F]+',s.decode() , re.I)
- # Convert hexstring (0x1234) to integer
- def hexstr2int(s):
- return int(s, 16)
- ################### Create connection to target ########################################3
- if len(argv) < 3:
- print("Usage:\npython3 filename.py <host> <port>")
- exit()
- host = argv[1]
- port = int(argv[2])
- s = socket.create_connection((host, port))
- ################### Put your exploit code here #########################################3
- receive_until(b'> ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement