1

I'm using this code to practice BOF but can't get it to work. Any help is appreciated.

#!/usr/bin/python3

import socket, sys
from time import sleep

buffer = b'A' * 100

while True:
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect(('192.168.71.141, 9999'))
        s.close()
        sleep(2)

        buffer = buffer + b'A' * 100

    except:
        print(f"Fuzzing crashed at {str(len(buffer))} bytes.")
        sys.exit()

The error message:

File "/root/home_lab/py3fuzz", line 18
    print(f"Fuzzing crashed at {str(len(buffer))} bytes.")
                                                        ^
SyntaxError: invalid syntax
Ted Klein Bergman
  • 9,146
  • 4
  • 29
  • 50

1 Answers1

1

This sounds like you're using an old version of python, specifically a version 3.5 or earlier.

What does python3 --version say?

If possible, you should upgrade to a version of python 3.6 or higher, as python 3.5 is no longer supported.

If that isn't possible, don't use f-string syntax. Instead, you could do something like this:

    print("Fuzzing crashed at %s bytes." % (len(buffer),) )
Daniel Martin
  • 23,083
  • 6
  • 50
  • 70
  • I'm using version 3.9.1. I couldn't get it to work with that line either.. Starting to think I'm rerarted. – Hellcatwarrior Feb 03 '21 at 22:57
  • @Hellcatwarrior Maybe you think you are running Python 3.9.1, but really using a lower-version. The full error in the Traceback should show the current Python version you are running. – Gino Mempin Feb 03 '21 at 23:07