Skip to content

Instantly share code, notes, and snippets.

@thepacketgeek
Created October 23, 2013 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thepacketgeek/7110285 to your computer and use it in GitHub Desktop.
Save thepacketgeek/7110285 to your computer and use it in GitHub Desktop.
Random packet field generators
## Returns a string of a random int between 1 and 254(default)
def randOct(end = 254):
return str(random.randint(1, end))
## Used for random size or TTL
def randTS(max = 256):
return str(random.randint(1, max/8) * 8)
## Returns a string of a hex number 4 digits long, with the preceding '0x' sliced off
def randHex(max = 65535):
return str(hex(random.randint(1, max)))[2:]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment