尊龙凯时人生就是搏

mitmproxy ¾ç±¾±à³Ì½Ì³Ì

mitmproxy ÊÇÒ»¸ö http/https ÊðÀí£¬¿Éͨ¹ý¾ç±¾À©Õ¹Æ书Ч¡£Ê¹Óà mitmproxy ¾ç±¾£¬Óû§¿ÉÒÔ×èµ²¡¢Ð޸ĺÍÖØ·ÅÍøÂçÇëÇóºÍÏìÓ¦£¬ÓÃÓÚµ÷ÊÔ¡¢²âÊÔºÍÇå¾²ÆÊÎö¡£mitmproxy ¾ç±¾¿ÉÒÔͨ¹ý±àд×Ô½ç˵ python ¾ç±¾ÊµÏÖ£¬ÕâЩ¾ç±¾¿ÉÒÔ´¦ÀíÒÔÏÂÊÂÎñ£ºrequest_headers£º·¢ËÍÇëÇóͷʱ´¥·¢response_headers£ºÎüÊÕµ½ÏìӦͷʱ´¥·¢request_body£º·¢ËÍÇëÇóÖ÷Ìåʱ´¥·¢response_body£ºÎüÊÕµ½ÏìÓ¦Ö÷Ìåʱ´¥·¢Óû§¿Éͨ¹ý flow ¹¤¾ß»á¼ûÕýÔÚ´¦Àí

mitmproxy ¾ç±¾±à³Ì½Ì³Ì

ʲôÊÇ mitmproxy£¿

mitmproxy ÊÇÒ»¸ö¹¦Ð§Ç¿Ê¢µÄ¿ªÔ´ HTTP/HTTPS ÊðÀí£¬ÔÊÐíÓû§×èµ²¡¢Ð޸ĺÍÖØ·ÅÍøÂçÇëÇóºÍÏìÓ¦¡£ËüÆÕ±éÓÃÓÚµ÷ÊÔ¡¢²âÊÔºÍÇå¾²ÆÊÎö¡£

ΪʲôҪʹÓà mitmproxy ¾ç±¾£¿

mitmproxy ¾ç±¾ÔÊÐíÓû§Í¨¹ý±àд×Ô½ç˵ Python ¾ç±¾À©Õ¹ÊðÀíµÄ¹¦Ð§¡£ÕâЩ¾ç±¾¿ÉÒÔÖ´ÐФµ¤Þ¤¶¤Þ¤ÊʹÃü£¬ÀýÈ磺

  • ÐÞ¸ÄÇëÇó»òÏìÓ¦ÒÔ¾ÙÐвâÊÔ
  • ×èµ²²¢ÉúÑÄÌض¨ÇëÇó»òÏìÓ¦¾ÙÐÐÆÊÎö
  • ÔÚÇëÇó»òÏìÓ¦ÖÐ×¢Èë»ò¸ü¸Ä±êÍ·

½¨Éè mitmproxy ¾ç±¾

  1. ×°Öà mitmproxy£º pip install mitmproxy
  2. ½¨Éè¾ç±¾Îļþ£º ʹÓÃÄúϲ»¶µÄÎı¾±à¼­Æ÷½¨ÉèÒ»¸öÐ嵀 Python Îļþ¡£
  3. µ¼Èë mitmproxy API£º Ôھ籾ÎļþµÄ¶¥²¿µ¼Èë mitmproxy.http Ä£¿é£¬Ëü°üÀ¨ÓÃÓÚ´¦Àí HTTP ÇëÇóºÍÏìÓ¦µÄÀàºÍº¯Êý¡£
  4. ±àдÄúµÄ¾ç±¾£º ƾ֤ÄúµÄÐèÒª±àд Python ´úÂëÀ´´¦ÀíÇëÇó»òÏìÓ¦¡£

´¦ÀíÊÂÎñ

mitmproxy ¾ç±¾Í¨¹ý´¦ÀíÒÔÏÂÊÂÎñÓëÊðÀí¾ÙÐн»»¥£º

  • request_headers£º ÔÚ·¢ËÍÇëÇóͷʱ´¥·¢¡£
  • response_headers£º ÔÚÎüÊÕµ½ÏìӦͷʱ´¥·¢¡£
  • request_body£º ÔÚ·¢ËÍÇëÇóÖ÷Ìåʱ´¥·¢¡£
  • response_body£º ÔÚÎüÊÕµ½ÏìÓ¦Ö÷Ìåʱ´¥·¢¡£

ʾÀý¾ç±¾

ÒÔÏÂʾÀý¾ç±¾×èµ²ËùÓаüÀ¨Ìض¨±êÍ·µÄÇëÇó²¢´òÓ¡ÇëÇóºÍÏìÓ¦ÐÅÏ¢£º

from mitmproxy.http import HTTPFlow

def request(flow: HTTPFlow):
    if "My-Custom-Header" in flow.request.headers:
        print(f"Request: {flow.request.method} {flow.request.url}")

def response(flow: HTTPFlow):
    if "My-Custom-Header" in flow.request.headers:
        print(f"Response: {flow.response.status_code} {flow.response.reason}")

µÇ¼ºó¸´ÖÆ

ʹÓþ籾

½«ÄúµÄ¾ç±¾ÎļþÉúÑÄΪ .py Îļþ£¬È»ºóʹÓÃÒÔÏÂÏÂÁîÔËÐÐ mitmproxy£º

mitmproxy -s /path/to/your_script.py

mitmproxy ½«¼ÓÔØÄúµÄ¾ç±¾²¢×èµ²ËùÓд«ÈëµÄÁ÷Á¿¡£

ÌáÐÑ

  • ¾ç±¾¿ÉÒÔ»á¼û flow ¹¤¾ß£¬Ëü°üÀ¨ÓйØÕýÔÚ´¦ÀíµÄÇëÇóºÍÏìÓ¦µÄÏêϸÐÅÏ¢¡£
  • ʹÓà flow.kill() ¿ÉÒÔÑïÆúÇëÇó»òÏìÓ¦£¬´Ó¶ø×èÖ¹ËüÃDZ»·¢ËÍ»òÎüÊÕ¡£
  • Óйظü¶àÐÅÏ¢£¬Çë²ÎÔÄ mitmproxy Îĵµ¡£

ÒÔÉϾÍÊÇmitmproxy ¾ç±¾±à³Ì½Ì³ÌµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ