PCREPlugin.html 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <h3>3proxy Perl Compatible Regular Expressions (PCRE) plugin</h3>
  2. This filtering plugin can be used to create matching and replace
  3. rules with regular expressions for client's request, client and
  4. servers header and client and server data. It adds 3 additional
  5. configuration commands:
  6. <pre>
  7. pcre TYPE FILTER_ACTION REGEXP [ACE]
  8. pcre_rewrite TYPE FILTER_ACTION REGEXP REWRITE_EXPRESSION [ACE]
  9. pcre_extend FILTER_ACTION [ACE]
  10. pcre_options OPTION1 [...]
  11. </pre>
  12. pcre - allows to apply some rule for matching
  13. <br>pcre_rewrite - in addition to 'pcre' allows to substitute substrings
  14. <br>pcre_extend - extends ACL of the last pcre or pcre_rewrite comand by
  15. adding additional ACE (like with allow/deny configuration commands).
  16. <br>pcre_options - allows to set matching options. Awailable options are:
  17. PCRE_CASELESS,
  18. PCRE_MULTILINE,
  19. PCRE_DOTALL,
  20. PCRE_EXTENDED,
  21. PCRE_ANCHORED,
  22. PCRE_DOLLAR_ENDONLY,
  23. PCRE_EXTRA,
  24. PCRE_NOTBOL,
  25. PCRE_NOTEOL,
  26. PCRE_UNGREEDY,
  27. PCRE_NOTEMPTY,
  28. PCRE_UTF8,
  29. PCRE_NO_AUTO_CAPTURE,
  30. PCRE_NO_UTF8_CHECK,
  31. PCRE_AUTO_CALLOUT,
  32. PCRE_PARTIAL,
  33. PCRE_DFA_SHORTEST,
  34. PCRE_DFA_RESTART,
  35. PCRE_FIRSTLINE,
  36. PCRE_DUPNAMES,
  37. PCRE_NEWLINE_CR,
  38. PCRE_NEWLINE_LF,
  39. PCRE_NEWLINE_CRLF,
  40. PCRE_NEWLINE_ANY,
  41. PCRE_NEWLINE_ANYCRLF,
  42. PCRE_BSR_ANYCRLF,
  43. PCRE_BSR_UNICODE
  44. <ul>
  45. <li>TYPE - type of filtered data. May contain one or more
  46. (comma delimited list) values:
  47. <ul>
  48. <li>request - content of client's request e.g. HTTP GET request string.
  49. (known problem: changing request string doesn't change IP of the host to connect)
  50. <li>cliheader - content of client request headers, e.g. HTTP request header.
  51. <li>srvheader - content of server's reply headers, e.g. HTTP status and headers.
  52. <li>clidata - data received from client, e.g. HTTP POST request data
  53. <li>srvdata - data received from server, e.g. HTML page
  54. </ul>
  55. <li>FILTER_ACTION - action on match
  56. <ul>allow - allow this request without checking rest of the given type
  57. of the rules
  58. <li>deny - deny this request without checking rest of the rules
  59. <li>dunno - continue with the rest of rules (useful with pcre_rewrite)
  60. </ul>
  61. <li>REGEXP - PCRE (perl) regular expression. Use * if no regexp matching
  62. required.
  63. <li>REWRITE_EXPRESSION - substitution string. May contain perl-style
  64. substrings
  65. (not tested) $1, $2. $0 - means whole matched string. \r and \n may be used
  66. to insert new strings, string may be empty ("").
  67. <li>ACE - access control entry (user names, source IPs, destination IPs,
  68. ports, etc), absolutely identical to allow/deny/bandlimin commands.
  69. Regular expression is only matched if ACL matches connection data.
  70. Warning:
  71. reqular expression doesn't require authentication and can not replace
  72. authentication and/or allow/deny ACLs.
  73. </ul>
  74. <h4>Example:</h4>
  75. <pre>
  76. plugin PCREPlugin.dll pcre_plugin
  77. pcre request deny "porn|sex" user1,user2,user3 192.168.0.0/16
  78. pcre srvheader deny "Content-type: application"
  79. pcre_rewrite clidata,srvdata dunno "porn|sex|pussy" "***" baduser
  80. pcre_extend deny * 192.168.0.1/16
  81. </pre>
  82. <h4>Download:</h4>
  83. <ul>
  84. <li>Plugin is included into 3proxy 0.6 binary and source distribution
  85. <li>Example configuration (by Dennis Garber): <A HREF="NoPornLitest.cfg.txt">NoPornLitest.cfg</A>
  86. </ul>