Blame tests/regression/misc/30-fuzzyHash.t

Packit Service 384592
### libinjection.
Packit Service 384592
Packit Service 384592
{
Packit Service 384592
	type => "misc",
Packit Service 384592
	comment => "fuzzyHash test",
Packit Service 384592
	conf => qq(
Packit Service 384592
		SecRuleEngine On
Packit Service 384592
		SecDebugLog $ENV{DEBUG_LOG}
Packit Service 384592
		SecDebugLogLevel 9
Packit Service 384592
                SecRequestBodyAccess On
Packit Service 384592
Packit Service 384592
		SecRule REQUEST_BODY "\@fuzzyHash $ENV{CONF_DIR}/ssdeep.txt 1" "id:192372,log,deny"
Packit Service 384592
	),
Packit Service 384592
	match_log => {
Packit Service 384592
		error => [ qr/ModSecurity: Access denied with code 403 \(phase 2\)\. Fuzzy hash of REQUEST_BODY matched with 96:MbQ1L0LDX8GPI8ov3D2D9zd6.*"modsecurity.conf-recommended"|ModSecurity was not compiled with ssdeep support./, 1],
Packit Service 384592
		debug => [ qr/Access denied with code 403 \(phase 2\)\. Fuzzy hash of REQUEST_BODY matched with 96:MbQ1L0LDX8GPI8ov3D2D9zd6.*"modsecurity.conf-recommended"|ModSecurity was not compiled with ssdeep support./, 1],
Packit Service 384592
	},
Packit Service 384592
	match_response => {
Packit Service 384592
		status => qr/^403|200$/,
Packit Service 384592
	},
Packit Service 384592
	request => new HTTP::Request(
Packit Service 384592
		POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/index.html",
Packit Service 384592
		[
Packit Service 384592
			"Content-Type" => "application/x-www-form-urlencoded",
Packit Service 384592
		],
Packit Service 384592
		#  Args
Packit Service 384592
		"
Packit Service 384592
# -- Rule engine initialization ----------------------------------------------
Packit Service 384592
Packit Service 384592
# Enable ModSecurity, attaching it to every transaction. Use detection
Packit Service 384592
# only to start with, because that minimises the chances of post-installation
Packit Service 384592
# disruption.
Packit Service 384592
#
Packit Service 384592
SecRuleEngine DetectionOnly
Packit Service 384592
Packit Service 384592
Packit Service 384592
# -- Request body handling ---------------------------------------------------
Packit Service 384592
Packit Service 384592
# Allow ModSecurity to access request bodies. If you don't, ModSecurity
Packit Service 384592
# won't be able to see any POST parameters, which opens a large security
Packit Service 384592
# hole for attackers to exploit.
Packit Service 384592
#
Packit Service 384592
SecRequestBodyAccess On
Packit Service 384592
Packit Service 384592
Packit Service 384592
# Enable XML request body parser.
Packit Service 384592
# Initiate XML Processor in case of xml content-type
Packit Service 384592
#
Packit Service 384592
SecRule REQUEST_HEADERS:Content-Type \"text/xml\" \
Packit Service 384592
     \"id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML\"
Packit Service 384592
Packit Service 384592
# Enable JSON request body parser.
Packit Service 384592
# Initiate JSON Processor in case of JSON content-type; change accordingly
Packit Service 384592
# if your application does not use 'application/json'
Packit Service 384592
#
Packit Service 384592
SecRule REQUEST_HEADERS:Content-Type \"application/json\" \
Packit Service 384592
     \"id:'200001',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON\"
Packit Service 384592
Packit Service 384592
# Maximum request body size we will accept for buffering. If you support
Packit Service 384592
# file uploads then the value given on the first line has to be as large
Packit Service 384592
# as the largest file you are willing to accept. The second value refers
Packit Service 384592
# to the size of data, with files excluded. You want to keep that value as
Packit Service 384592
# low as practical.
Packit Service 384592
#
Packit Service 384592
SecRequestBodyLimit 13107200
Packit Service 384592
SecRequestBodyNoFilesLimit 131072
Packit Service 384592
Packit Service 384592
# Store up to 128 KB of request body data in memory. When the multipart
Packit Service 384592
# parser reachers this limit, it will start using your hard disk for
Packit Service 384592
# storage. That is slow, but unavoidable.
Packit Service 384592
#
Packit Service 384592
SecRequestBodyInMemoryLimit 131072
Packit Service 384592
Packit Service 384592
# What do do if the request body size is above our configured limit.
Packit Service 384592
# Keep in mind that this setting will automatically be set to ProcessPartial
Packit Service 384592
# when SecRuleEngine is set to DetectionOnly mode in order to minimize
Packit Service 384592
# disruptions when initially deploying ModSecurity.
Packit Service 384592
#
Packit Service 384592
SecRequestBodyLimitAction Reject
Packit Service 384592
Packit Service 384592
# Verify that we've correctly processed the request body.
Packit Service 384592
# As a rule of thumb, when failing to process a request body
Packit Service 384592
# you should reject the request (when deployed in blocking mode)
Packit Service 384592
# or log a high-severity alert (when deployed in detection-only mode).
Packit Service 384592
#
Packit Service 384592
SecRule REQBODY_ERROR \"!\@eq 0\" \
Packit Service 384592
\"id:'200002', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2\"
Packit Service 384592
		"
Packit Service 384592
	),
Packit Service 384592
},
Packit Service 384592
Packit Service 384592
{
Packit Service 384592
	type => "misc",
Packit Service 384592
	comment => "fuzzyHash test",
Packit Service 384592
	conf => qq(
Packit Service 384592
		SecRuleEngine On
Packit Service 384592
		SecDebugLog $ENV{DEBUG_LOG}
Packit Service 384592
		SecDebugLogLevel 9
Packit Service 384592
                SecRequestBodyAccess On
Packit Service 384592
Packit Service 384592
		SecRule REQUEST_BODY "\@fuzzyHash $ENV{CONF_DIR}/ssdeep.txt 1" "id:192372,log,deny"
Packit Service 384592
	),
Packit Service 384592
	match_log => {
Packit Service 384592
		-error => [ qr/Fuzzy hash of REQUEST_BODY matched/, 1],
Packit Service 384592
		-debug => [ qr/Fuzzy hash of REQUEST_BODY matched/, 1],
Packit Service 384592
	},
Packit Service 384592
	match_response => {
Packit Service 384592
		status => qr/^200$/,
Packit Service 384592
	},
Packit Service 384592
	request => new HTTP::Request(
Packit Service 384592
		POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/index.html",
Packit Service 384592
		[
Packit Service 384592
			"Content-Type" => "application/x-www-form-urlencoded",
Packit Service 384592
		],
Packit Service 384592
		#  Args
Packit Service 384592
		"
Packit Service 384592
		wheee
Packit Service 384592
		"
Packit Service 384592
	),
Packit Service 384592
},
Packit Service 384592
Packit Service 384592
{
Packit Service 384592
    type => "misc",
Packit Service 384592
    comment => "fuzzy hash with FILES_TMP_CONTENT",
Packit Service 384592
    conf => qq(
Packit Service 384592
        SecRuleEngine On
Packit Service 384592
        SecDebugLog $ENV{DEBUG_LOG}
Packit Service 384592
        SecDebugLogLevel 9
Packit Service 384592
        SecRequestBodyAccess On
Packit Service 384592
	SecUploadKeepFiles On
Packit Service 384592
Packit Service 384592
	SecRule FILES_TMP_CONTENT "\@fuzzyHash $ENV{CONF_DIR}/ssdeep.txt 1" "id:192372,log,deny"
Packit Service 384592
    ),
Packit Service 384592
    match_log => {
Packit Service 384592
        debug => [ qr/operator \"fuzzyHash\" with param \".*ssdeep.txt 1\" against FILES_TMP_CONTENT:image1/s, 1 ],
Packit Service 384592
    },
Packit Service 384592
    match_response => {
Packit Service 384592
        status => qr/^200$/,
Packit Service 384592
    },
Packit Service 384592
    request => new HTTP::Request(
Packit Service 384592
        POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
Packit Service 384592
        [
Packit Service 384592
            "Content-Type" => q(multipart/form-data; boundary=0000),
Packit Service 384592
        ],
Packit Service 384592
        normalize_raw_request_data(
Packit Service 384592
            q(
Packit Service 384592
                --0000
Packit Service 384592
                Content-Disposition: form-data; name="name"
Packit Service 384592
Packit Service 384592
                Brian Rectanus
Packit Service 384592
                --0000
Packit Service 384592
                Content-Disposition: form-data; name="email"
Packit Service 384592
Packit Service 384592
                brian.rectanus@breach.com
Packit Service 384592
                --0000
Packit Service 384592
                Content-Disposition: form-data; name="image1"; filename="image1.jpg"
Packit Service 384592
                Content-Type: image/jpeg
Packit Service 384592
Packit Service 384592
                BINARYDATA1
Packit Service 384592
                --0000
Packit Service 384592
                Content-Disposition: form-data; name="image2"; filename="image2.jpg"
Packit Service 384592
                Content-Type: image/jpeg
Packit Service 384592
Packit Service 384592
                BINARYDATA2
Packit Service 384592
                --0000
Packit Service 384592
                Content-Disposition: form-data; name="image3"; filename="image3.jpg"
Packit Service 384592
                Content-Type: image/jpeg
Packit Service 384592
Packit Service 384592
                BINARYDATA3
Packit Service 384592
                --0000
Packit Service 384592
                Content-Disposition: form-data; name="test"
Packit Service 384592
Packit Service 384592
                This is test data.
Packit Service 384592
                --0000--
Packit Service 384592
            ),
Packit Service 384592
        ),
Packit Service 384592
    ),
Packit Service 384592
},
Packit Service 384592
Packit Service 384592