HurricaneLabs / machinae

Machinae Security Intelligence Collector
MIT License
502 stars 99 forks source link

Connecting via proxy #12

Closed lewanpaw closed 8 years ago

lewanpaw commented 8 years ago

Hi, is there a way to use it with http proxy? I have my env variables http_proxy and https_proxy set up, but machinae seems not to be using that.

mcm commented 8 years ago

Hmm. Machinae uses requests underneath, which I thought respected those variables. I'll have to dig into this a little bit.

lewanpaw commented 8 years ago

I did a temporary workaround: In file base.py added proxy configuration, right after imports:

proxies = {
        "http":"http://login_here:password_here@address_here:port_here",
        "https":"http://login_here:password_here@address_here:port_here",
}

and then, in def session(self) added this:

def session(self):
    if self._session is None:
        self._session = requests.Session()
        self._session.headers.update({"User-Agent": "Vor/1.0 (Like CIF/2.0)"})
        self._session.proxies = proxies
    return self._session

Not the most elegant solution, but... works!

mcm commented 8 years ago

@lewanpaw do you have the environment variables as http_proxy or HTTP_PROXY? Requests is looking for it to be capitalized...

http://docs.python-requests.org/en/master/user/advanced/#proxies

I've been meaning to add some additional configuration aside from the sites - proxy settings included - but haven't yet decided the best way to do that. Perhaps adding a command line flag for now is the best option. I don't need the proxy settings, though, so I'm not sure what would be easiest. Any thoughts?