diff --git a/scapy/config.py b/scapy/config.py index af1b1e0c889bd8eb810d17281acae101edb21599..ad73f68e70296093f4b6ef6911792ebccfc4ecdf 100644 --- a/scapy/config.py +++ b/scapy/config.py @@ -287,6 +287,7 @@ def _prompt_changer(attr,val): class Conf(ConfClass): """This object contains the configuration of scapy. 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, ...) 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) @@ -314,6 +315,7 @@ extensions_paths: path or list of paths where extensions are to be looked for version = "2.1.0-dev" session = "" interactive = False + interactive_shell = "" stealth = "not implemented" iface = None readfunc = None diff --git a/scapy/main.py b/scapy/main.py index 2aa1614628757dc04201bf39beced434bc3c5c70..d50763f2baaf5ce2155c72f01d3b0862c1da0fa2 100644 --- a/scapy/main.py +++ b/scapy/main.py @@ -296,8 +296,23 @@ def interact(mydict=None,argv=None,mybanner=None,loglevel=20): atexit.register(scapy_delete_temp_files) 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: save_session(conf.session, session)