Repository: secdev/scapy

Issue:
No exception when 'tcpreplay' is not available on the target host
Not getting any error message in case that 'tcpreplay' is not installed on the target host, while running 'sendpfast'.
No exception when 'tcpreplay' is not available on the target host
Not getting any error message in case that 'tcpreplay' is not installed on the target host, while running 'sendpfast'.


Discussion:
I can't reproduce the issue. Here is what I got:
```
>>> sendpfast(rdpcap("test.pcap"))
ERROR: while trying to exec [tcpreplay]: [Errno 2] No such file or directory
```
Can you provide us more details about the OS, and the Scapy version you are using ?
LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Red Hat Enterprise Linux Server release 6.5 (Santiago)

[root@dev-r-vrt-242-008 ~]# which tcpreplay
/usr/bin/which: no tcpreplay in (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/ibutils/bin:/root/bin)

>>> import scapy.all
>>> print (scapy.all.VERSION)
2.3.3
>>> packet = scapy.all.Ether(src='aa:aa:aa:aa:aa:aa', dst='bb:bb:bb:bb:bb:bb')
>>> packet = packet/scapy.all.IP(src='1.1.1.1',dst='2.2.2.2')
>>> sendp(packet, iface='eth1')
>>> scapy.all.sendp(packet, iface='eth1')
.
Sent 1 packets.
>>> scapy.all.sendpfast(packet, iface='eth1')
>>>

Thanks,
Roy Sror

From: Guillaume Valadon [mailto:notifications@github.com]
Sent: Wednesday, August 30, 2017 3:37 PM
To: secdev/scapy <scapy@noreply.github.com>
Cc: Roy Sror <roysr@mellanox.com>; Author <author@noreply.github.com>
Subject: Re: [secdev/scapy] No exception when 'tcpreplay' is not available on the target host (#791)


I can't reproduce the issue. Here is what I got:

>>> sendpfast(rdpcap("test.pcap"))

ERROR: while trying to exec [tcpreplay]: [Errno 2] No such file or directory

Can you provide us more details about the OS, and the Scapy version you are using ?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsecdev%2Fscapy%2Fissues%2F791%23issuecomment-325976989&data=02%7C01%7Croysr%40mellanox.com%7C0d895210ddc84bf4970008d4efa3d59f%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636396934324695880&sdata=rUTvStx24%2FtrLdGxVsmY7Q44CPGPZ7Tvkj266MClbnQ%3D&reserved=0>, or mute the thread<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAVTjW9Ta-mcsWV7LWKKcXWl7u6e0g0DSks5sdVd1gaJpZM4PG85K&data=02%7C01%7Croysr%40mellanox.com%7C0d895210ddc84bf4970008d4efa3d59f%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636396934324695880&sdata=ToIRe7Bda1jHDQ419uR1H7fCRlTA%2Bt%2BUwnSZ661nRec%3D&reserved=0>.

You need to load Scapy with `from scapy.all import *`.

No error message, even with 'from scapy.all import *'

Thanks,
Roy Sror

From: Guillaume Valadon [mailto:notifications@github.com]
Sent: Wednesday, August 30, 2017 6:34 PM
To: secdev/scapy <scapy@noreply.github.com>
Cc: Roy Sror <roysr@mellanox.com>; Author <author@noreply.github.com>
Subject: Re: [secdev/scapy] No exception when 'tcpreplay' is not available on the target host (#791)


You need to load Scapy with from scapy.all import *.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsecdev%2Fscapy%2Fissues%2F791%23issuecomment-326029015&data=02%7C01%7Croysr%40mellanox.com%7C522dd1e6b4c240f6080f08d4efbc8020%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636397040269278974&sdata=PDxekQFnZf98C1DBdLnjTFAQCSwsrb3lLxMhNZM4JGQ%3D&reserved=0>, or mute the thread<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAVTjW1u4SRB62StkqXgp-qTbCwcoV11eks5sdYDUgaJpZM4PG85K&data=02%7C01%7Croysr%40mellanox.com%7C522dd1e6b4c240f6080f08d4efbc8020%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636397040269278974&sdata=%2FpXwPGe0Ja0nsTszoHywvTobU5RBehDilESDiYKzGdE%3D&reserved=0>.

Here is what I did to try to reproduce the issue. Can you use Scapy from github and try again ?
```
$ sudo python
Python 2.7.13 (default, Jan 19 2017, 14:48:08) 
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from scapy.all import *
>>> sendpfast(rdpcap("test.pcap"))
>>> 
```

Do u have 'tcpreplay' on this host?
If not- you are also not getting any error message or exception

Thanks,
Roy Sror

From: Guillaume Valadon [mailto:notifications@github.com]
Sent: Wednesday, August 30, 2017 6:58 PM
To: secdev/scapy <scapy@noreply.github.com>
Cc: Roy Sror <roysr@mellanox.com>; Author <author@noreply.github.com>
Subject: Re: [secdev/scapy] No exception when 'tcpreplay' is not available on the target host (#791)


Here is what I did to try to reproduce the issue. Can you use Scapy from github and try again ?

$ sudo python

Python 2.7.13 (default, Jan 19 2017, 14:48:08)

[GCC 6.3.0 20170118] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> from scapy.all import *

>>> sendpfast(rdpcap("test.pcap"))

>>>

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsecdev%2Fscapy%2Fissues%2F791%23issuecomment-326036950&data=02%7C01%7Croysr%40mellanox.com%7Cf47584a8aeb449819bd108d4efbfeeba%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636397054993623412&sdata=RmcsFIqbLDgWF10%2FgSNCcORPQ%2FOWZZlXqTEaATUGeFw%3D&reserved=0>, or mute the thread<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAVTjW1tkE8kqSFTIdzR-lVO5vmg-2x5Uks5sdYaXgaJpZM4PG85K&data=02%7C01%7Croysr%40mellanox.com%7Cf47584a8aeb449819bd108d4efbfeeba%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636397054993623412&sdata=yN8ZMilXURk7uBnGXGvKk94PVs7GiWZtFsYGP0omhes%3D&reserved=0>.

I will try to investigate that today.
`git bisect` gives that commit 4d31afe7796aa20d0fdc28a5873882ff20059074 introduces this regression.
I can't reproduce the issue. Here is what I got:
```
>>> sendpfast(rdpcap("test.pcap"))
ERROR: while trying to exec [tcpreplay]: [Errno 2] No such file or directory
```
Can you provide us more details about the OS, and the Scapy version you are using ?
LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Red Hat Enterprise Linux Server release 6.5 (Santiago)

[root@dev-r-vrt-242-008 ~]# which tcpreplay
/usr/bin/which: no tcpreplay in (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/ibutils/bin:/root/bin)

>>> import scapy.all
>>> print (scapy.all.VERSION)
2.3.3
>>> packet = scapy.all.Ether(src='aa:aa:aa:aa:aa:aa', dst='bb:bb:bb:bb:bb:bb')
>>> packet = packet/scapy.all.IP(src='1.1.1.1',dst='2.2.2.2')
>>> sendp(packet, iface='eth1')
>>> scapy.all.sendp(packet, iface='eth1')
.
Sent 1 packets.
>>> scapy.all.sendpfast(packet, iface='eth1')
>>>

Thanks,
Roy Sror

From: Guillaume Valadon [mailto:notifications@github.com]
Sent: Wednesday, August 30, 2017 3:37 PM
To: secdev/scapy <scapy@noreply.github.com>
Cc: Roy Sror <roysr@mellanox.com>; Author <author@noreply.github.com>
Subject: Re: [secdev/scapy] No exception when 'tcpreplay' is not available on the target host (#791)


I can't reproduce the issue. Here is what I got:

>>> sendpfast(rdpcap("test.pcap"))

ERROR: while trying to exec [tcpreplay]: [Errno 2] No such file or directory

Can you provide us more details about the OS, and the Scapy version you are using ?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsecdev%2Fscapy%2Fissues%2F791%23issuecomment-325976989&data=02%7C01%7Croysr%40mellanox.com%7C0d895210ddc84bf4970008d4efa3d59f%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636396934324695880&sdata=rUTvStx24%2FtrLdGxVsmY7Q44CPGPZ7Tvkj266MClbnQ%3D&reserved=0>, or mute the thread<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAVTjW9Ta-mcsWV7LWKKcXWl7u6e0g0DSks5sdVd1gaJpZM4PG85K&data=02%7C01%7Croysr%40mellanox.com%7C0d895210ddc84bf4970008d4efa3d59f%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636396934324695880&sdata=ToIRe7Bda1jHDQ419uR1H7fCRlTA%2Bt%2BUwnSZ661nRec%3D&reserved=0>.

You need to load Scapy with `from scapy.all import *`.

No error message, even with 'from scapy.all import *'

Thanks,
Roy Sror

From: Guillaume Valadon [mailto:notifications@github.com]
Sent: Wednesday, August 30, 2017 6:34 PM
To: secdev/scapy <scapy@noreply.github.com>
Cc: Roy Sror <roysr@mellanox.com>; Author <author@noreply.github.com>
Subject: Re: [secdev/scapy] No exception when 'tcpreplay' is not available on the target host (#791)


You need to load Scapy with from scapy.all import *.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsecdev%2Fscapy%2Fissues%2F791%23issuecomment-326029015&data=02%7C01%7Croysr%40mellanox.com%7C522dd1e6b4c240f6080f08d4efbc8020%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636397040269278974&sdata=PDxekQFnZf98C1DBdLnjTFAQCSwsrb3lLxMhNZM4JGQ%3D&reserved=0>, or mute the thread<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAVTjW1u4SRB62StkqXgp-qTbCwcoV11eks5sdYDUgaJpZM4PG85K&data=02%7C01%7Croysr%40mellanox.com%7C522dd1e6b4c240f6080f08d4efbc8020%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636397040269278974&sdata=%2FpXwPGe0Ja0nsTszoHywvTobU5RBehDilESDiYKzGdE%3D&reserved=0>.

Here is what I did to try to reproduce the issue. Can you use Scapy from github and try again ?
```
$ sudo python
Python 2.7.13 (default, Jan 19 2017, 14:48:08) 
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from scapy.all import *
>>> sendpfast(rdpcap("test.pcap"))
>>> 
```

Do u have 'tcpreplay' on this host?
If not- you are also not getting any error message or exception

Thanks,
Roy Sror

From: Guillaume Valadon [mailto:notifications@github.com]
Sent: Wednesday, August 30, 2017 6:58 PM
To: secdev/scapy <scapy@noreply.github.com>
Cc: Roy Sror <roysr@mellanox.com>; Author <author@noreply.github.com>
Subject: Re: [secdev/scapy] No exception when 'tcpreplay' is not available on the target host (#791)


Here is what I did to try to reproduce the issue. Can you use Scapy from github and try again ?

$ sudo python

Python 2.7.13 (default, Jan 19 2017, 14:48:08)

[GCC 6.3.0 20170118] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> from scapy.all import *

>>> sendpfast(rdpcap("test.pcap"))

>>>

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsecdev%2Fscapy%2Fissues%2F791%23issuecomment-326036950&data=02%7C01%7Croysr%40mellanox.com%7Cf47584a8aeb449819bd108d4efbfeeba%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636397054993623412&sdata=RmcsFIqbLDgWF10%2FgSNCcORPQ%2FOWZZlXqTEaATUGeFw%3D&reserved=0>, or mute the thread<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAVTjW1tkE8kqSFTIdzR-lVO5vmg-2x5Uks5sdYaXgaJpZM4PG85K&data=02%7C01%7Croysr%40mellanox.com%7Cf47584a8aeb449819bd108d4efbfeeba%7Ca652971c7d2e4d9ba6a4d149256f461b%7C0%7C0%7C636397054993623412&sdata=yN8ZMilXURk7uBnGXGvKk94PVs7GiWZtFsYGP0omhes%3D&reserved=0>.

I will try to investigate that today.
`git bisect` gives that commit 4d31afe7796aa20d0fdc28a5873882ff20059074 introduces this regression.

Resolving patch:
diff --git a/scapy/sendrecv.py b/scapy/sendrecv.py
--- a/scapy/sendrecv.py
+++ b/scapy/sendrecv.py
@@ -338,7 +338,10 @@ def sendpfast(x, pps=None, mbps=None, realtime=None, loop=0, file_cache=False, i
     except KeyboardInterrupt:
         log_interactive.info("Interrupted by user")
     except Exception as e:
-        log_interactive.error("while trying to exec [%s]: %s", argv[0], e)
+        if conf.interactive:
+            log_interactive.error("Cannot execute [%s]", argv[0], exc_info=True)
+        else:
+            raise
     finally:
         os.unlink(f)
 


Test patch:
diff --git a/test/regression.uts b/test/regression.uts
--- a/test/regression.uts
+++ b/test/regression.uts
@@ -995,6 +995,18 @@ for i in six.moves.range(5):
 assert (len(ret) == 2)
 assert all(x[1] == 15169 for x in ret)
 
+= sendpfast
+
+old_interactive = conf.interactive
+conf.interactive = False
+try:
+    sendpfast([])
+    assert False
+except Exception:
+    assert True
+
+conf.interactive = old_interactive
+assert True
 
 ############
 ############