Skip to content

Commit

Permalink
let python script take command line arguments for automation
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmichaelsmith committed Nov 19, 2014
1 parent d5e4432 commit de1f2d2
Showing 1 changed file with 37 additions and 16 deletions.
53 changes: 37 additions & 16 deletions scripts/iface-choice.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#apt-get install python-pip
#pip install netifaces
import netifaces
import os
import os
import sys

def select_iface(iface):
try:
iface = int(iface)
if(iface < 0):
raise IndexError

return netifaces.interfaces()[iface]

except IndexError:
print("Number provided was too big or small")
return []
Expand All @@ -17,21 +18,41 @@ def select_iface(iface):
return []


print("Please choose a network interface to run the honeypot on:\r\n")
def get_args():
if len(sys.argv) > 1:
return netifaces.interfaces()[int(sys.argv[1])]

for i, ifaces in enumerate(netifaces.interfaces()):
try:
iface_text = "\t[%d] %s (%s)" % (i,ifaces,netifaces.ifaddresses(ifaces)[netifaces.AF_INET])
print(iface_text)
except Exception:
pass
def get_user_input():

print("Please choose a network interface to run the honeypot on:\r\n")

for i, ifaces in enumerate(netifaces.interfaces()):
try:
iface_text = "\t[%d] %s (%s)" % (i,ifaces,netifaces.ifaddresses(ifaces)[netifaces.AF_INET])
print(iface_text)
except Exception:
pass

print("\r\n")

found = []
while(not found):
found=select_iface(raw_input('Chosen interface: '))
return found

def run():


args = get_args()

found = get_args() if get_args() else get_user_input()

print found

print("\r\n")
f = open(os.path.expanduser('~/.honey_iface'), 'w')
f.write(found)

found = []
while(not found):
found=select_iface(raw_input('Chosen interface: '))
if __name__ == "__main__":
run()

f = open(os.path.expanduser('~/.honey_iface'), 'w')
f.write(found)

0 comments on commit de1f2d2

Please sign in to comment.