tcpdump01: fix the way to identify network interface
PATCH 1/1 tcpdump01: fix the way to identify network interface
The script tries to identify network interface that can communicate with RHOST by searching for the IP of RHOST in ifconfig output on localhost, which doesn't make any sense when RHOST is not localhost. This patch changes the script to indetify the network interface by ping RHOST.
Signed-off-by Simon Xu <[email protected]>
--- testcases/network/tcp_cmds/tcpdump/tcpdump01 | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)
testcases/network/tcp_cmds/tcpdump/tcpdump01 +5 -15
@@ -48,22 +48,12 @@ do_setup() exists awk grep host hostname ifconfig netstat ping tail tcpdump RHOST=${RHOST:-`hostname`} - IP=`host ${RHOST} 2>/dev/null | awk '{print $4}'` - IFNUMS=`netstat -i|wc -l` - IFNUMS=$(( $IFNUMS - 2 )) - IFNAME=${IFNAME:-$(netstat -i | awk '{print $1}' | tail -n ${IFNUMS})} - - for i in ${IFNAME}; do - if ifconfig ${i} | grep $IP; then - IF=$i - break - fi + # Find the first interface that can ping RHOST + IF="" + for i in $(netstat -i | tail -n+3 | sed '/^lo/d' | cut -f1 -d' '); do + ping -I $i -c 3 $RHOST && { IF="$i"; break; } done - # Default to empty string if unset, to avoid errors caused by set -u, which we use (see cmdlib.sh) - if [ -z "${IF:-}" ]; then - end_testcase "Could not identify interface" - exit 1 - fi + test -z $IF && end_testcase "Could not find an interface that can ping remote host $RHOST" IFNAME=${IF} NUMLOOPS=${NUMLOOPS:-20} OUTFILE=$TCtmp/tcpdump_out
Signature · 13 lines
1.8.4.2 ------------------------------------------------------------------------------ Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure. http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Quoted 6 lines
The script tries to identify network interface that can communicate with RHOST by searching for the IP of RHOST in ifconfig output on localhost, which doesn't make any sense when RHOST is not localhost. This patch changes the script to indetify the network interface by ping RHOST.
Signed-off-by Simon Xu <[email protected]>
Pushed thanks.
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list