Skip to content
Snippets Groups Projects
Commit adb84366 authored by Phil's avatar Phil
Browse files

Added IPython support (ticket #329, patch from D. Loss)

Add the following line to ~/.scapy_startup.py :
conf.interactive_shell="ipython
parent 7ccd2fe5
No related branches found
No related tags found
No related merge requests found
...@@ -287,6 +287,7 @@ def _prompt_changer(attr,val): ...@@ -287,6 +287,7 @@ def _prompt_changer(attr,val):
class Conf(ConfClass): class Conf(ConfClass):
"""This object contains the configuration of scapy. """This object contains the configuration of scapy.
session : filename where the session will be saved session : filename where the session will be saved
interactive_shell : If set to "ipython", use IPython as shell. Default: Python
stealth : if 1, prevents any unwanted packet to go out (ARP, DNS, ...) stealth : if 1, prevents any unwanted packet to go out (ARP, DNS, ...)
checkIPID: if 0, doesn't check that IPID matches between IP sent and ICMP IP citation received checkIPID: if 0, doesn't check that IPID matches between IP sent and ICMP IP citation received
if 1, checks that they either are equal or byte swapped equals (bug in some IP stacks) if 1, checks that they either are equal or byte swapped equals (bug in some IP stacks)
...@@ -314,6 +315,7 @@ extensions_paths: path or list of paths where extensions are to be looked for ...@@ -314,6 +315,7 @@ extensions_paths: path or list of paths where extensions are to be looked for
version = "2.1.0-dev" version = "2.1.0-dev"
session = "" session = ""
interactive = False interactive = False
interactive_shell = ""
stealth = "not implemented" stealth = "not implemented"
iface = None iface = None
readfunc = None readfunc = None
......
...@@ -296,8 +296,23 @@ def interact(mydict=None,argv=None,mybanner=None,loglevel=20): ...@@ -296,8 +296,23 @@ def interact(mydict=None,argv=None,mybanner=None,loglevel=20):
atexit.register(scapy_delete_temp_files) atexit.register(scapy_delete_temp_files)
conf.color_theme = DefaultTheme() conf.color_theme = DefaultTheme()
code.interact(banner = the_banner % (conf.version),
local=session, readfunc=conf.readfunc) IPYTHON=False
if conf.interactive_shell.lower() == "ipython":
try:
import IPython
IPYTHON=True
except ImportError, e:
log_loading.warning("IPython not available. Using standard Python shell instead.")
IPYTHON=False
if IPYTHON:
banner = the_banner % (conf.version) + " using IPython %s" % IPython.__version__
ipshell = IPython.Shell.IPShellEmbed(banner = banner)
ipshell(local_ns=session)
else:
code.interact(banner = the_banner % (conf.version),
local=session, readfunc=conf.readfunc)
if conf.session: if conf.session:
save_session(conf.session, session) save_session(conf.session, session)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment