Xamarin WebView request desktop site - mobile

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;

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!

PhpPhantom request returns '405 Not Allowed'. Any way to still scrape the data?

I am trying to scrape data from site which returns 405 not allowed and also load content using AJAX. Is there a way I can still scrape data using any method?
I solved this by using following:
$chrome_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36';
$firefox_agent = 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0';
$ie_agent = 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko';
$edge_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063';
$agents = array($chrome_agent, $firefox_agent, $edge_agent, $ie_agent);
$user_agent = array_rand(array_flip($agents));
Ref: https://github.com/jonnnnyw/php-phantomjs/issues/208

Why does my code uncomment this part of the code out

So I've been making a simple HTTP flooder with a Wget and a user agent but when flooding i realize this happens
125.27.78.172 - - [26/Apr/2016:12:38:45 -0500] "GET / HTTP/1.1" 403 4961 "-" "Wget"
And if you are confused about this error i asked my friend to flood my VPS and this happend
208.67.1.176 - - [26/Apr/2016:12:48:32 -0500] "GET / HTTP/1.0" 403 4961 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.85 Safari/537.36"
Why is is it not working with me code:
sprintf(command, "wget -O /tmp/fff --header="Accept: text/html" --user-agent="Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.85 Safari/537.36" http://208.67.1.176/ ");
if you're wondering how this is a flooder the main code loops it
Escape the string?
sprintf(command, "wget -O /tmp/fff --header=\"Accept: text/html\" --user-agent=\"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.85 Safari/537.36\" http://208.67.1.176/ ");

Error 404 on uploading blob to production server on google app engine

I'm building a system where the users will upload articles to my app and I need to store them. I've read the tutorial about blobhandlers on Google's documentation and it worked, but only local.
When I test the app on development server, everything is fine, but on production server, I get Error 404 and the following logs:
2014-02-17 08:59:28.490 /http://ciro-app-id.appspot.com/_ah/upload/AMmfu6ah2vpKNsIDSzlpYPqAgnQ_zznnUwDweG571CgMMnGlluXc1GJS0i42UYYOKVZNQMBhzyY3grQFeCgD4hf4usx_YeMwy4n_93qM-QFegsMIFHDkNovRcJ9Rnl9li91bo4bdClfV/ALBNUaYAAAAAUwJCQ_kw2ANG1Tnvs9OIU6cAyOUDscqL/ 404 19ms 0kb Mozilla/5.0 (X11; Linux i686 (x86_64)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36 module=default version=1
186.226.15.242 - - [17/Feb/2014:08:59:28 -0800] "POST /http://ciro-app-id.appspot.com/_ah/upload/AMmfu6ah2vpKNsIDSzlpYPqAgnQ_zznnUwDweG571CgMMnGlluXc1GJS0i42UYYOKVZNQMBhzyY3grQFeCgD4hf4usx_YeMwy4n_93qM-QFegsMIFHDkNovRcJ9Rnl9li91bo4bdClfV/ALBNUaYAAAAAUwJCQ_kw2ANG1Tnvs9OIU6cAyOUDscqL/ HTTP/1.1" 404 188 "http://ciro-app-id.appspot.com/enviar" "Mozilla/5.0 (X11; Linux i686 (x86_64)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36" "ciro-app-id.appspot.com" ms=20 cpu_ms=0 cpm_usd=0.000021 app_engine_release=1.9.0 instance=00c61b117c6c9b0c25f5b86e2eadac83e2908691
Here is my code: https://drive.google.com/file/d/0B1-lpPH97tV2dzN6aURYVENCMzQ/edit?usp=sharing
Here is my app: ciro-app-id.appspot.com
Try it yourself
Login credentials:
Email: ciromoraismedeiros#gmail.com
Password: 123
Access ciro-app-id.appspot.com/enviar fill the form and submit it.
Obs.: I'm Brazillian, so everything is in portuguese language.
Notice the leading "/" in your request log? In /templates/enviar_artigo.html, change
<form action='/{{upload_url}}' ...>
to
<form action='{{upload_url}}' ...>

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

Resources