Повелитель двух полудесятков полусотен ([info]asd) wrote,

Рабочее про дублирование трафика (tech, shell)

Я уже говорил, что tcpflow — друг индейца. Сегодня Апель подтвердил это прекрасным шелл-однострочником.
sudo tcpflow -cp -i eth0 dst port 9900 | grep param | while read line; do curl -s -- "http://duplicate.host:9900/ask?"$line; done

Скрипт запускается на основной машине и дублирует POST-запросы вида "param=1&other=2&..." на вторую машину, для бесчеловечных опытов.
Tags: shell, tech, work

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    Your reply will be screened

    Your IP address will be recorded 

  • 2 comments

[info]silverity

December 9 2008, 13:17:26 UTC 3 years ago Edited:  December 9 2008, 13:17:45 UTC

Аха, а вот проброс HTTP GET с куками:
sudo tcpflow -cpi eth1 dst port 80 | while read line; do if I=`echo $line | grep "GET /url/"`; then REQ=`echo $line | cut -b 50- | sed s@HTTP/1.1@@`; fi; if J=`echo $line | grep "Cookie: "`; then COOKIE=$line; curl -s -H "$COOKIE" -- http://server:port$REQ; fi; done

[info]Yuriy Vasiyarov

October 6 2011, 18:59:07 UTC 7 months ago

shell-извращенцы, в хорошем смысле этого слова =)
Create an Account
Forgot your login or password?
Facebook Twitter More login options
English • Español • Deutsch • Русский…