How to detect mobile safari without chrome? - mobile

I'm trying to understand how can i detect when user opens my site in mobile safari. Chrome and safari have absolutely the same parameters:
Chrome "Mozilla/5.0 (iPad; CPU OS 8_1_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B440 Safari/600.1.4"
Safari "Mozilla/5.0 (iPad; CPU OS 8_1_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B440 Safari/600.1.4"
Is there any way to detect only mobile safari?

Chrome for developers website states:
The UA in Chrome for iOS is the same as the Mobile Safari user agent, with CriOS/ instead of Version/< VersionNum>.
So the right useragent check will be:
var ua = navigator.userAgent;
if (ua.match(/(iPod|iPhone|iPad)/) !== null && ua.match(/AppleWebKit/) !== null && ua.search('CriOS') < 0) {
alert("You are using Mobile Safari!");
} else {
alert("Whatever this is, it's not Mobile Safari...");
}
Here's the fiddle - https://jsfiddle.net/h8j9n2m5/1/. Checked myself on iPad iOS 7.0.4, Mobile Safari 7.0, works like a charm :)

Related

HIGH_RISK_COUNTRY_CODES ignored for HTTP/2 requests in CRS 3.3.0

I am using mod_security with CRS 3.3.0 on top of Apache 2.4. During a recent L7 DDoS attack, I recognized that certain attacks using HTTP/1.* were correctly block with HTTP 403 based on geolookup and having the country code listed in tx.high_risk_country_codes of the CRS config. However, a request from the identical IP was not blocked when using HTTP/2 as protocol. Any idea of a configuration setting specific for REQUEST-910-IP-REPUTATION.conf only enabled for protocols HTTP/1.* in the default rule set? For the time being, I restricted allowed protocols to HTTP 1.1 for affected site make mod_security working.
Some examples from access log:
<HOST>:443 XXX.XXX.XXX.XXX - - [03/Aug/2022:00:37:49 +0200] "GET /?s HTTP/1.1" 403 5636 "https://<HOST>/?s" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36"
<HOST>:443 XXX.XXX.XXX.XXX - - [03/Aug/2022:00:43:12 +0200] "GET /?s HTTP/2.0" 301 392 "https:///?s" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36"
Thanks in advance!
SCHAPPY
CRS dev-on-duty here. There is no configuration setting specific for REQUEST-910-IP-REPUTATION.conf that is only enabled for protocols HTTP/1.*.
I have no idea why the rule 910100 does not work for HTTP/2.
But do you have the possibility to enable debug logs (better not in production) with SecDebugLog and SecDebugLogLevel? Maybe you'll get more insights this way?
If you can't see and solve the problem with the modsec_debug.log, you can open an issue in the Core Rule Set GitHub project. We're happy to help!

Google Recaptcha not shown for automation test in headless chrome

I have an Angular page which makes use of google recaptcha. I have written the automation test using Protractor for the same(And have used testing site/secret key for recaptcha) and it works fine for chrome browser.
But I have a requirement to use Xvfb to run virtualized Chrome as part of the testing process in ubuntu/jenkins. And I have the Chrome drivers installed. When I run the test with this setup and following capability setting for protractor,
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [ "--headless", "--disable-gpu", "--window-size=1800,1800" ]
}
}
The Captcha just doesn't show up and it displays as below,
Chrome driver version is chromedriver_2.31
What am I doing wrong??
I ran into this same issue, attempting to get a screenshot with a reCaptcha in the page. The technologies were different but the underlying use of google-chrome headless is the same (am using Puppeteer). The fix is to set the userAgent to something compatible, like the browser you regularly use.
In my case (with puppeteer):
await page.setUserAgent('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/60.0.3112.113 Chrome/60.0.3112.113 Safari/537.36')
For some other agent strings: see Chrome userAgents.
For Protractor, you can set the user agent like so:
capabilities: {
'browserName': 'chrome',
'chrome-switches' : ["--user-agent ='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/60.0.3112.113 Chrome/60.0.3112.113 Safari/537.36'"]
},
Hope that works for you.

Xamarin WebView request desktop site

Is there a way to ask, via C#, the iOS and Android WebView components to request the desktop sites?
You need to do this per platform
Android
In Android you have to implement a custom renderer. Add this into your Android code:
// this line directly ubleow usings, before namespace declaration
[assembly:ExportRenderer(typeof(WebView), typeof(DesktopWebViewRenderer))]
// this in your namespace
public class DesktopWebViewRenderer : WebViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<WebView> e)
{
base.OnElementChanged(e);
Control.Settings.UserAgentString = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
}
}
iOS
Xamarin Forms is using UIWebView, so you have to call
NSUserDefaults.StandardUserDefaults.RegisterDefaults(new NSDictionary("UserAgent",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A"));
some where in your startup code. E.g. in FinishedLaunching of your AppDelegate.
Set the user agent string appropriately. There is no way to do this directly in Xamarin Forms, you would need to write a custom renderer to do that.
iOS UIWebView
NSUserDefaults.StandardUserDefaults.RegisterDefaults(["UserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A"]);
iOS9+ WKWebView
web.CustomUserAgent = #"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36";
Android
string agent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
web.Settings.UserAgentString = agent;

Failed to load module from user agent at localhost

When I tried to run GWT quick start tutorial I got this error message!
How can I fix this issue?
P.S.
I already installed GWT Developer plugin for Firefox 1.23
I installed eclipse from ubuntu 13.04 repository (version 3.8.1)
I already GWT from ubuntu 13.04 repository (version 2.4.0)
00:27:29.230 [ERROR] [hellostupid] Failed to load module 'hellostupid' from user agent 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:23.0) Gecko/20100101 Firefox/23.0' at localhost:40544
java.lang.NullPointerException: null
at com.google.gwt.dev.javac.JsniChecker.getSuppressedWarnings(JsniChecker.java:565)
at com.google.gwt.dev.javac.JsniChecker$JsniDeclChecker.visit(JsniChecker.java:135)
at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1233)
at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:679)
at com.google.gwt.dev.javac.JsniChecker.check(JsniChecker.java:615)
at com.google.gwt.dev.javac.JsniChecker.check(JsniChecker.java:559)
at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater$UnitProcessorImpl.process(CompilationStateBuilder.java:83)
at com.google.gwt.dev.javac.JdtCompiler$CompilerImpl.process(JdtCompiler.java:251)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:464)
at com.google.gwt.dev.javac.JdtCompiler.doCompile(JdtCompiler.java:710)
at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater.compile(CompilationStateBuilder.java:235)
at com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:447)
at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:370)
at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:360)
at com.google.gwt.dev.DevModeBase$UiBrowserWidgetHostImpl.createModuleSpaceHost(DevModeBase.java:110)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:197)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:724)
I was facing the same issue , you can try this if you are getting this problem -
1.[ERROR] [mysecondproj] - Unable to initialize static dispatcher
2.[ERROR] [mysecondproj] - Failed to load module 'mysecondproj' from user agent 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1712.2 Safari/537.36' at 127.0.0.1:63405
http://stackoverflow.com/questions/29411048/gwt-starting-sample-project

Glassware Starter Project(Java) works fine on localhost, but not in app engine

I have build it from eclipse and ran on development server, it works, when I deploy it on app engine from eclipse, I got this following error, any idea why?
Very first time it went up to oauth2 dance, but it did not succeed, I have fixed redirect-url on api console, then, localhost worked, I did deployed again onto app engine, but it did not work, I got this error:
Error: 500 Server Error
The server encountered an error and could not complete your request.
If the problem persists, please report your problem and mention this error message and the query that caused it.
Error log in App engine console:
2013-06-07 01:59:36.619 /oauth2callback?code={removed now} 500 2416ms 0kb Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36
68.5.238.205 - - [07/Jun/2013:01:59:36 -0700] "GET /oauth2callback?code={removed now} HTTP/1.1" 500 0 - "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36" "{my appid }.appspot.com" ms=2416 cpu_ms=1581 cpm_usd=0.000087 app_engine_release=1.8.0 instance=00c61b117c2c977fac245e8480eff747e75eb6
I 2013-06-07 01:59:34.228
com.google.glassware.AuthFilter doFilter: Skipping auth check during auth flow
I 2013-06-07 01:59:34.230
com.google.glassware.AuthServlet doGet: Got a code. Attempting to exchange for access token.
I 2013-06-07 01:59:35.427
com.google.glassware.AuthServlet doGet: Code exchange worked. User 115370471277937689999 logged in.
W 2013-06-07 01:59:36.614
Error for /oauth2callback
java.lang.NoClassDefFoundError: com/google/common/collect/Lists
at com.google.glassware.NewUserBootstrapper.bootstrapNewUser(NewUserBootstrapper.java:54)
at com.google.glassware.AuthServlet.doGet(AuthServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
This looks like a bug in App Engine and the Google OAuth endpoints. It's being tracked in the Glass issue tracker. You can star that issue to receive updates as the investigation proceeds.
In the mean time, check out the .NET and PHP quick starts. They're working great.

Resources