Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a private device from a private web page on a mobile phone #1

Open
minanagehsalalma opened this issue Jun 11, 2019 · 2 comments

Comments

@minanagehsalalma
Copy link

i want to access a local device page from another page (192.168.1.2) on the same network but that device page doesn't have remote access so i can't use your tool. .... and using extensions won't work cause i want to test it on chrome phones app .... and i can't edit that local device page code .
i want to make a login script that works what ever local CORS Anywhere server was available or not !!

any ideas ?
i think this may be the fix but how can i make it available at local and public at the same time ?!
here is the code that i want to use
c0a80101.c0a80102.rbndr.us is 192.168.1.1 and 192.168.1.2 combined .
i want at the first response the answer be 192.168.1.2 and then when the internet connection is back
i want the second response to be 192.168.1.1 and the code get's executed only if it received the second response correctly !!

<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script> 
var http = new XMLHttpRequest();
var params = 'frashnum=&action=login&Frm_Logintoken="+results+"&Username=admin&Password=test';
var url = 'http://c0a80101.c0a80102.rbndr.us/';
http.open('POST', url, true);
//Send the proper header information along with the request
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
 http.onload = function myfunction() {
let str = (http.responseText);
    alert(str)
    let pattern =/\bgetObj\("Frm_Logintoken"\)\.value = "([^"]+)";/;
    let results = console.log(str.match(pattern)[1]);
    return results;
    
 }; 
  var test = myfunction();
 document.write(test);
 http.send(params);
</script>
</body>
</html>
@michaelfig
Copy link
Owner

michaelfig commented Jun 11, 2019

If you can't modify the device's HTTP headers, then the only way to accomplish this is via a proxy. DNS tricks can't possibly work since they can't tell which URL you are trying to access.

Cacao was built especially for this situation, but currently only works if you're using a desktop browser (with https://github.com/michaelfig/cacao-extension), or if you have a desktop or server machine you can run the proxy on (https://github.com/michaelfig/cacao repository).

You can run the latter proxy on Linux, MacOS, or Windows machine that has HTTP access to 192.168.1.1 and 192.168.1.2. There are more OSes that this can run on, so long as there is a Dart interpreter for the platform (see the README.md).

But https://github.com/michaelfig/cacao_app is the solution that would work best. That is an app you can install on your Android/iOS device where you run the browser, and it would do the selective proxying to your web page and the target device.

Unfortunately, I haven't finished cacao_app! If this is the only way you can make it work, please let me know. I might have some time next week where I can get it up-and-running for you.

Hope this helps,
Michael.

@michaelfig michaelfig changed the title do you think this can be solved ? Using a private device from a private web page on a mobile phone Jun 11, 2019
@michaelfig
Copy link
Owner

You could even run Cacao on your 192.168.1.1 machine if it has the right OS. Something like:

$ bin/cacao --host 0.0.0.0 --port=8000 http://192.168.1.1 /mapped=http://192.168.1.2

and then, http://192.168.1.1:8000/some-url.html is the webpage served from http://192.168.1.1/some-url.html and http://192.168.1.1:8000/mapped is the device.

Experiment with the mapping and changing your HTML until it is right for you. Let me know the results of these experiments, please!

Good luck,
Michael.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants