Skip to content

Instantly share code, notes, and snippets.

@ffr4nz
Created May 24, 2013 11:04
Show Gist options
  • Save ffr4nz/5642744 to your computer and use it in GitHub Desktop.
Save ffr4nz/5642744 to your computer and use it in GitHub Desktop.
List all Martian IPs, included the current broadcast address.
#!/usr/bin/env python
from commands import *
import iptools
#Get broadcast IP (must choose the correct interface)
com="ifconfig eth0 | grep 'inet '| grep -v '127.0.0.1' | cut -d: -f3 | awk '{ print $1}'"
Bcast = getoutput(com)
#Declare IPTools objects
SRC_MARTIAN_IPS = iptools.IpRangeList(
'127. 0.0. 0/8',
'0. 0.0. 0',
'255. 255.255. 255',
('224. 0.0. 0','239. 255.255. 255'),
Bcast,
)
DST_MARTIAN_IPS = iptools.IpRangeList(
'127. 0.0 .0/8',
'0. 0.0. 0',
('224 .0.0. 0','239. 255.255. 255'),
)
for ip in SRC_MARTIAN_IPS: # Use each IP in scapy functions
print ip
for ip in DST_MARTIAN_IPS: # Use each IP in scapy functions
print ip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment