Wednesday, August 3, 2011

2 practical scripts for embedded systems

1. Live Wireshark capture for a CPE from your PC

Prerequisites:
- tcpdump installed on the CPE
- CPE accepting SSH connections
- Wireshark and Putty installed on the PC (Windows)

You can use the following command to listen for the packets on the CPE interface and see the output on the Wireshark which is launched on your PC:

C:\Program Files\PuTTY>plink.exe -pw root@ export LD_LIBRARY_PATH=/usr/local/ssl/lib:/usr/sfw/lib ; /tcpdump -s 1500 -l -w- 'port!22' | "c:\Program Files\Wireshark\wireshark.exe" -k -i-

2. Extracting folders from a CPE without following symbolic links

Prerequisites:
- tar installed on the CPE and the Linux PC
- CPE accepting SSH connections

We know that we can use scp -r to extract folders from another Linux device, but scp will follow symbolic links. Here is how you do it without following symbolic links (this example will get the folders under /etc and /usr):

ssh root@ "cd /; tar cf - etc usr" | tar xvf -

Source: