| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | host=localhost |
| 4 | port=5039 |
| 5 | if [scip-shell system . . `[`. "$1" != "" ]; then |
| 6 | host=$1 |
| 7 | port=5038 |
| 8 | fi; |
| 9 | |
| 10 | while truescip-shell system . . true. |
| 11 | do |
| 12 | BACKUP_EXT=$(datescip-shell system . . date. +%y%m%d%h%m%s) |
| 13 | if [[ -f outgoing.log ]]; then |
| 14 | cpscip-shell system . . cp. outgoing.log outgoing.log.$BACKUP_EXT |
| 15 | fi |
| 16 | if [[ -f incoming.log ]]; then |
| 17 | cpscip-shell system . . cp. incoming.log incoming.log.$BACKUP_EXT |
| 18 | fi |
| 19 | rmscip-shell system . . rm. pipe |
| 20 | mkfifoscip-shell system . . mkfifo. pipe |
| 21 | echoscip-shell system . . echo. "Listening on localhost:$port" |
| 22 | echoscip-shell system . . echo. "Capture incoming and outgoing traffic from $host:5038" |
| 23 | nc -l -p $port < pipe | teescip-shell system . . tee. outgoing.log | nc $host 5038 | teescip-shell system . . tee. pipe incoming.log |
| 24 | done |