Fiddler regex to match a file - regex

I am trying to intercept a http request(which is requesting for a .js file) and return a file from the local disk.
Here are the sample http requests :
> http://rupall.mmk.test.com/%7B636242121790000792%7D/WebResources/main_system_library.js?ver=1854333973
> http://rupall.mmk.test.com/%7B636242121790000792%7D/WebResources/main_system_library.js?ver=1854333973
> http://rupall.mmk.test.com/%7B636242121790000792%7D/WebResources/main_system_library.js?ver=-1518765574
Here is my regex :
REGEX:http://rupall\.mmk\.test\.com/.*/WebResources/main_system_library.js?ver=.*$
But this regex is not matching any of the http requests that I listed above. When I use the test feature of fiddler, it is failing. Is this regex correct or what am I missing here ?

Try this
https?:\/{2}\w*\.\w*\.\w*\.\w*\/{1}\%\d\w*\%{1}\d+\w\/{1}\w*\/{1}\w*\.js\?ver\=
https://regex101.com/r/4zoky6/1

Related

Need regular expression for Spring controller GetMapping with path variable that excludes URLs with a certain prefix

I am trying to create a regular expression for my Spring controller method that matches all of the paths in my web application, except It also needs to exclude any traffic with the prefix “/websock” that comes in for my websocket server. Here is the method:
#GetMapping(value = "/{path:[^\\.]*}")
public String redirect(#PathVariable(value="path") String path) {
LOGGER.debug("In redirect path:" + path);
return "forward:/";
}
I have tried a lot of examples from the web I have not been able to find one that does what I need. My examples have either accepted all traffic (including the websocket prefix), or that have excluded some of the http traffic.
The first reg-ex was
"/{path:[^\\.]*}"
which matches URLs such “http://localhost:8080/abc”. But, it was failing to match http://localhost:8080/abc/def.
My second attempt using
"/**/{path:[^\\.]*}"
corrected that issue but then matched everything including my websocket traffic.
I tried the following, which I saw from other questions, was supposed to exclude traffic starting with "/websock". But instead it failed to match anything including the “abc” URLs above:
"/{path:[^\\.]*}", "/**/{path:^(?!websock).*}/{path:[^\\.]*}".
What am I doing wrong with my reg-ex?

Apache 2.4: Require expr: match %{var} with strings loaded from a file

I have apache 2.4 with SSL validating client certificates. I'm trying to filter some users by the CN provided in the client cert. For that, I wrote a file with a list of permitted CN, with one CN per line.
The expression need to be like: true if %{SSL_CLIENT_S_DN_CN} is inside {file("/etc/httpd/users.txt")}.
So, I want to use the "file" function to "Read contents from a file (including line endings, when present)" to validate the %{SSL_CLIENT_S_DN} from client certificate.
I tested it with: %{} in {file()} and %{} =~ {file()}, but it doesn't work.
I don't find any example on apache docs or googling. Does anyone knows how I can do this?

IIS Request Filtering Allow URL

I am using IIS7 request Filtering (WebSite level) with 'Allow unlisted file name extensions' set to un-checked. After this setting when I access my web application say, _http:/machine_name/app1 then it fails. After adding correct file extensions under 'file name extensions' it starts functioning but it later fails when I surf other links inside my application. I found that I need to add URL's under 'Allow URL' but I do have huge number of URL list which need to be added for e.g.:
'/app1/prop1', '/app1/prop1/services/', '/app1/prop2/repository'..... and more
So, I see a pattern like /app1/* but 'allow URL don't allow any pattern matching. Is there any way to add Regular expression somewhere in IIS so that the matching URL's can be allowed.
Thanks in advance.
I think URLs like '/app1/prop1', '/app1/prop1/services/', '/app1/prop2/repository' don't work with 'Allow unlisted file name extensions' set to false because you didn't allow extensionless requests.
To allow extensionless requests, add <add fileExtension="." allowed="true" /> to your web.config as below:
<system.webServer>
<security>
<requestFiltering>
<fileExtensions allowUnlisted="false">
<add fileExtension="." allowed="true" />
</fileExtensions>
</requestFiltering>
</security>
</system.webServer>
Please let me know if this helped or the issue still occurs.
OK, at last I got the solution. The trick was not using 'requestfiltering' but 'URL rewrite'. It has the option to allow or deny URL based on the regular expression or Wildcard with the option 'Does not match the pattern'. I created rule for the URL/file which does not matches my application's pattern and deny those by redirecting a 404 type of error.
#alexander-abakumov is correct. When allowUnlisted=false, one must include the provided xml (<add fileExtension="." allowed="true" />) to allow extension-less requests (e.g. /App/ or /Folder/).
Request Filtering Limitations
You're correct to use URL Rewrite for achieving RegEx pattern matching. Below are the limitations of Request Filtering.
Stateless - Request Filtering has no knowledge of application or session state. Each request is processed individually regardless of whether a session has or has not been established.
Request Header Only - Request Filtering can only inspect the request header. It has no visibility into the request body or any part of the response.
Basic Logic - Regular expressions and wildcard matches are not available. Most settings consist of establishing size constraints while others perform simple string matching.
Still use Request Filtering
I would still recommend using Request Filtering since it operates so early in the IIS request pipeline; even before URL Rewrite. This gives you the opportunity to immediately discard bad requests. URL Rewrite can then be a second layer of request filtering.
IISRFBaseline
The information above is based on my PowerShell module IISRFBaseline. It helps establish an IIS Request Filtering baseline by leveraging Microsoft Logparser to scan a website's content directory and IIS logs.
For the fileExtensions setting there are two methods for establishing a baseline:
IIS Logs - by parsing prior successful requests and determining the extension of the request.
Content Directory - scanning the file system of the website content directory to see what file extensions are in use.
There are caveats to these two approaches which are described in more detail here. With two techniques, a markdown file is provided describing the methodology of each as denoted by the suffix IIS or FS.
fileExtensions_FS
fileExtensions_IIS
The result of these two techniques are combined, after removing bad requests, to create a baseline for this Request Filtering setting.

Match URL Scheme with Port

I'm trying to match the the URI / URL scheme (e.x. ftp, http, https) using this regex ^(.*:) . The problem is that my url has a port number so the : to connote server connection in the scheme isn't the only one in the URL there is also :80. How do I just match the scheme using regex?
Given this example:
http://video.google.co.uk/videoplay?docid=-7246927612831078230&hl=en#00h02m30s
I would like regex to just match:
http
I'm not interested in something like
^((http[s]?|ftp):\/)
I know this would work it, it is limiting however. It wouldn't give me mailto, tel, ssh, etc.
I just found that ^[^:]+ works.

Web service using Lotus notes

when am trying to WSDL using lotus script i got following error, any one help me
"Error: client:WSDLreader:Loading of the wsdl file failed HRESULT=0x80070057-WSDLReader:xml Parser failed at linenumber 1, lineposition 63, reason is required white space was missing.HRESULT=0x1Line:7"
It sounds like an error with the WSDL file. See if you can verify it with an online WSDL checker.
Also, make sure you have specified the correct endpoint URL.
That error normally means that the structure of the WSDL is broken. For example if you got a 404 page back instead of WSDL from the server.
First try opening the WSDL File via a browser and check it to make sure you only get the WSDL back.
Your URL above has at the end:
?WSDL%22
The %22 looks wrong.
Second you can test your WSDL using a tool like SOAPUI. http://www.soapui.org
There is a tutorial on the Wiki at this location:
http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Testing_your_Domino_web_service_provider_and_consumer_using_SoapUI._