dutzi / tamper

Devtools extension, lets you locally edit files served from the web (based on mitmproxy).
http://dutzi.github.io/tamper
MIT License
394 stars 36 forks source link

Could not connect to proxy #23

Open BrandesEric opened 9 years ago

BrandesEric commented 9 years ago

I've seen the steps @saalmaan came up with to get things working on OSX. I have tried that, but am still not able to connect to the mitmproxy.

I have confirmed that mitmproxy itself is working fine (it can capture traffic without issue). Further, I installed it via pip, not from binaries, so hopefully that is not the issue.

I'm not sure what else I can try?

saalmaan commented 9 years ago

Hi @BrandesEric are you trying to install this on MacOSX? After installing the tamper, did you see the success message? saying something like

Successfully installed tamper mitmproxy pyOpenSSL Pillow netlib lxml Werkzeug Jinja2 itsdangerous certifi backports.ssl-match-hostname cryptography markupsafe cffi pycparser

also did you restart the proxy in tamper's chrome extension? and enabled the plugin?

if all of the above is working and you tried all that, then can you post a screen shot of tamper chrome plugin?

Thanks

BrandesEric commented 9 years ago

Yep, I did see the success message. Here are some screenshots :)
screen shot 2014-12-21 at 4 53 00 pm screen shot 2014-12-21 at 4 53 49 pm

This behaves the same whether I have mitmproxy running or not.

saalmaan commented 9 years ago

Thank you for the screenshots, did you try to restart proxy in the chrome plugin, from the wheel icon in left hand side of tamper plugin?

BrandesEric commented 9 years ago

Yep yep, I have tried that with both mitmproxy running in a terminal window and with it NOT running in a terminal window. Honestly, whenever I click the restart button nothing seems to happen. It's like it's not really doing anything?

On Sun, Dec 21, 2014 at 5:31 PM, saalmaan notifications@github.com wrote:

Thank you for the screenshots, did you try to restart proxy in the chrome plugin, from the wheel icon in left hand side of tamper plugin?

— Reply to this email directly or view it on GitHub https://github.com/dutzi/tamper/issues/23#issuecomment-67789891.

gaborbernat commented 9 years ago

Got the same issue, how does this tries to start the proxy?

dutzi commented 9 years ago

By runing a python script through chrome's native application API. Did you install both the extension and the tamper Python package through pip? On Sat, Feb 28, 2015 at 15:31 Gábor Bernát notifications@github.com wrote:

Got the same issue, how does this tries to start the proxy?

Reply to this email directly or view it on GitHub https://github.com/dutzi/tamper/issues/23#issuecomment-76526175.

gaborbernat commented 9 years ago

Yes of course, I should not I'm on Linux(Arch). Not sure into which python should I install, how does you call it from Chrome?

saalmaan commented 9 years ago

please see the troubleshooting guide below, this should help some installation/configuration questions. https://github.com/dutzi/tamper/wiki/Troubleshooting

gaborbernat commented 9 years ago

Any other ideas? So if I open up a console and run mitmproxy it starts. If I configure a proxy plugin to route traffic via it, it works. However from Chrome I can only see a Could not connect to proxy message, even though I change the port and such :)

gaborbernat commented 9 years ago

I think this has something to do that altough tamper installs fine, it does throw a warning:

copying build/scripts-2.7/tamper.py -> /usr/local/bin

changing mode of /usr/local/bin/tamper.py to 755

writing list of installed files to '/tmp/pip-klsxZt-record/install-record.txt'

error: [Errno 2] No such file or directory: '/home/bernat/Library/Application Support/Google/Chrome/NativeMessagingHosts/'

This folder is OS specific, as this does seem to be MacOS path, do your resolve this path OS angosticly?

saalmaan commented 9 years ago

@gaborbernat seems like troubleshotting guide didn't help, you need @dutzi he the man for advance debugging :)

gaborbernat commented 9 years ago

Okay, @dutzi let me know if I can assist with anything :)

saalmaan commented 9 years ago

Hi @gaborbernat @BrandesEric can you please both run chrome in full verbose debug mode, here is the command for mac osx (close chrome before running this command) /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --enable-logging --v=1

and let me know what error you see in the console.

Many thanks

gaborbernat commented 9 years ago

Abandoned this, instead using nginx + mitmproxy + a chrome proxy extension.

saalmaan commented 9 years ago

make sure you have "com.dutzi.tamper.json" at folder below /Users/USER-NAME/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.dutzi.tamper.json

ghost commented 9 years ago

I'm having the same problem... On mac (latest everything), both installed via pip, mitmproxy runs, restarted proxy via chrome/tamper plugin panel. No NativeMessagingHosts folder so I added one and also added "com.dutzi.tamper.json", makes no difference.

Any solution to this yet?

@gaborbernat any Tuts on how to set that up?

Thanks

ghost commented 9 years ago

Ok, I uninstalled tamper via pip and then installed again (in the same way as before), now it works ?!? Maybe this will work for others.

juneeighteen commented 9 years ago

Uninstalling and reinstalling tamper via pip worked for me as well.

a904guy commented 9 years ago

Sorry, Mac OS X Thread. Moved https://github.com/dutzi/tamper/issues/28

saalmaan commented 9 years ago

made an observation, installing tamper with pip while chrome browser is open doesn't work, but if chrome is closed it always works, so for future reference, close any instances of chrome and then install tamper. this should do the trick

saalmaan commented 9 years ago

@BrandesEric have you managed to install tamper? can we close this issue now?

chrisjaure commented 9 years ago

I'm having the same issue. Reinstalling tamper via pip while Chrome was closed did not work. I ran Chrome in debug mode and saw a bunch of these errors:

[48531:36099:1009/113054:ERROR:native_process_launcher.cc(140)] Failed to load manifest for native messaging host com.dutzi.tamper: Invalid value for path.

I've verified that com.dutzi.tamper.json exists in the correct location.

ryanbaer commented 9 years ago

@chrisjaure, this issue has been driving me insane and I have a quick fix for you and anyone else running into this issue. First of all, we may be running into this issue because of #31. When I looked at my com.dutzi.tamper.json file, I saw:

{
    "allowed_origins": [
        "chrome-extension://mabhojhgigkmnkppkncbkblecnnanfmd/",
        "chrome-extension://ecgndobpbcogellijibmcnjflahddidl/"
    ],
    "description": "Extends the Developer Tools, lets you locally edit files served from the web using Mitmproxy.",
    "name": "com.dutzi.tamper",
    "path": null,
    "type": "stdio"
}

if the path is null, Chrome can't find the executable. This JSON file gets generated and written into ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.dutzi.tamper.json in setup.py when you pip install tamper.

Chrome wants a full path in that field, so I grabbed it via which tamper.py, which returned /usr/local/bin/tamper.py and replaced null with "/usr/local/bin/tamper.py".

I restarted Chrome (and also probably uninstalled and reinstalled the tamper Chrome extension) and it worked!

It may link to #31 because if find_executable is failing for non win32 builds, then the path can never be populated which may the reason I had a null value for that.

ryanbaer commented 9 years ago

So I've done some more digging and want to highlight what I've discovered. First, my system:

Whenever I first blindly tried installing this package and ran into "Cannot connect to proxy", I noticed at one point that I did have a com.dutzi.tamper.json file and the path was null. However, after several later attempts, I actually can't reproduce getting that file placed in there with a null path to figure out what's going on behind #31.

It's notable that all of this time I've been using sudo pip install to get around that annoying permissions error instead of chmoding the site-packages directory. After uninstalling and reinstalling a few times, I noticed that setup would run just fine, but the com.dutzi.tamper.json file was never getting added to Chrome in ~/Library/Application Support.

Some debugging of the post install script revealed that this line is the problem for my particular method of sudo pip install. The file still gets created, but in the wrong place. Since I was executing as root, it thought my home directory was /var/root, and so expanduser actually resolves to: /var/root/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.dutzi.tamper.json instead of the expected ~/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.dutzi.tamper.json.

However I did find that running sudo pip install --no-cache-dir tamper actually resolves this issue. My theory on why this works is that, when pip caches the wheel of the package, it does not include the post install script. Running sudo pip install -v tamper showed me the path to the cached wheel being used. Installing directly from the wheel, even with --no-cache-dir, like so: sudo pip install tamper-0.24.5-py2-none-any.whl --no-cache-dir does not result in com.dutzi.tamper.json getting created in either places (/var/root/Library/... or ~/Library/...). Decompressing the wheel and viewing the contents also seems to support this theory as well - no mention of any post-install script, just the assets and the tamper.py script.

So when you sudo pip install tamper --no-cache-dir, I'm guessing it is fetching it in some other form that causes the post install script to actually run, perhaps as an egg.

A few solutions to fix the missing com.dutzi.tamper.json file:

sirwolfgang commented 8 years ago

I ran into this issue, with the missing path. A good way to check if this is true for you is to test start your editor for the settings menu. If nothing happens, then its not talking to the tamper.py.

jcrben commented 8 years ago

@sirwolfgang what editor and settings menu are you referring to?

ryanbaer commented 8 years ago

@jcrben he may just be referring Developer Tools to bring up the Console

Settings > More Tools > Developer Tools Shortcut: Alt + Cmd + i

Are you having an issue getting it running? You may want to look at ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com.dutzi.tamper.json and see if path is null or not.

Synchro commented 8 years ago

This is broken for me too. python 2.7 and 3 are freshly reinstalled from homebrew. pip, setuptools, and tamper & mitmproxy all installed fine - all are shown in pip list (though I note that it installs an old version of mitmproxy), the path to tamper.py is in the plist file and points at the correct file. I uninstalled and reinstalled with --no-cache-dir but that didn't help. Everything is installed as me, not root, permissions are OK. I've reinstalled tamper extension, restarted chrome, but it still says "Could not connect to proxy". Notably I can't launch editors from the tamper panel either, and trying to start mitmproxy from a shell fails to find it, so I suspect path issues, but I've not found anywhere to tell me where python installs utilities.

ryanbaer commented 8 years ago

@Synchro hop on the repo's Gitter channel and I'll help you debug it: https://gitter.im/dutzi/tamper

saalmaan commented 8 years ago

@Synchro did you try https://github.com/dutzi/tamper/wiki/Troubleshooting guide its been updated, that might help

Synchro commented 8 years ago

Just reposting what I said in Gitter:

If I pip install mitmproxy, it installs with no errors, but tamper has a hard dependency on an older version, so it does this when I install it:

Installing collected packages: mitmproxy, tamper
Found existing installation: mitmproxy 0.17
Uninstalling mitmproxy-0.17:
Successfully uninstalled mitmproxy-0.17
Successfully installed mitmproxy-0.11.1 tamper-0.24.5

After this, I can simply tun tamper.py, but I can't run mitmproxy. Sounds like a path problem.

sodacrackers commented 7 years ago

Any progress on this? Chrome debugger still shows "Could not connect to proxy" for me. I'm eager to use this.

I can confirm mitmproxy manually: 1) running mitmdump from a Mac terminal 2) Setting a proxy under System Preferences > Network > WIFI Ethernet > Advanced > HTTP Proxy 127.0.0.1:8080 3) Then visiting http://mitm.it/

I wonder if the extension triggers Python because no editor opens. E.g. Google Chrome > Developer Tools > Tamper > Settings (cog) > Test Command does not fire app.

I don't see errors in the Mac console for Chrome when using the extension. Ideas?

ryanbaer commented 7 years ago

@sodacrackers double-check my earlier messages in this thread, particularly about that JSON file - i.e. if it's in the right location (where the extension expects it to be), if it has the correct path to the python script in it, etc.

sodacrackers commented 7 years ago

@ryanbaer I've checked json path above and tried testing the python script $ python /usr/local/bin/tamper.py

There's no output, so I added a console dump after the imports statements. That worked. I'd expect I could visit http://mitm.it/ afterword though?

gaborbernat commented 7 years ago

I think we can close this issue for now.