Create a gist now

Instantly share code, notes, and snippets.

@hasherezade /test.py Secret
Created Nov 23, 2017

Embed
What would you like to do?
import socket
import sys
import argparse
def main():
parser = argparse.ArgumentParser(description="Send to the Crackme")
parser.add_argument('--key', dest="key", default="0xa2", help="The value to be sent")
args = parser.parse_args()
my_key = int(args.key, 16) % 255
print '[+] Checking the key: ' + hex(my_key)
key = chr(my_key) + '012'
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', 2222))
s.send(key)
result = s.recv(512)
if result is not None:
print "[+] Response: " + result
s.close()
except socket.error:
print "Could not connect to the socket. Is the crackme running?"
if __name__ == "__main__":
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment